osman hömek / not defteri

June 12, 2009

9.2 de servis konfigurasyon değerini değiştirmek

Filed under: arcobjects — osman @ 9:39 am

C:\Program Files\ArcGIS\server\user\cfg

 dizinin altında her servise ait cfg uzantılı XML dosyaları mevcut.

(idari_sinirlar.MapServer.cfg   gibi)

<MaxRecordCount>500</MaxRecordCount>
<MaxBufferCount>100</MaxBufferCount>
<MaxImageWidth>2048</MaxImageWidth>
<MaxImageHeight>2048</MaxImageHeight>
<OutputDir>c:\arcgisserver\arcgisoutput</OutputDir>
<SupportedImageReturnTypes>URL</SupportedImageReturnTypes>
<FilePath>\\my_prj_files\temp\idari.mxd</FilePath>
<VirtualOutputDir>http://mymach/arcgisoutput</VirtualOutputDir>
<SOMCacheDir>c:\arcgisserver\arcgiscache</SOMCacheDir>
<CacheDir>c:\arcgisserver\arcgiscache\idari_sinirlar</CacheDir>

 gibi değerler değiştirilebilir.

May 14, 2009

arcgis 9.2 join - view temaşası

Filed under: arcobjects — osman @ 1:52 pm

diyelimki elimizde bir dataframe imiz var,
semboloji için haricen bir view kullanmamız gerekli
view ımızı oracle da hazırlayıp, mxd üzerinden istediğimiz geo table ile view ımızı istediğimiz kolon üzerinden join ettikten sonra
sembolojimizi güzelce oluşturuyoruz.
buraya kadar bir sorun yok.

ancak web.adf ye geçip, bu tablo üzerinde Spatial Query çalıştırdığımızda kucağımıza aldığımız datable ın null olduğunu görüyoruz.
fakat ters görünen birşey de yok
o sırada view ı oluşturan kolon isimlerinin bir veya birkaçının ana tablodaki ile aynı olduğunu görüp
yahu buna kızıyor olmasın diye içimizden geçirirken
denemeye karar veriyoruz. oda ne!!

öngörümüzde haklıyız.

çıkartılacak sonuç
1. view ların kolon isimleri asla bağlanacakları ana tablodaki kolon isimlerinden olmamalı
2. veritabanı işini veritabancı, harita işini haritacı yapsın, kimse kimsenin işine karışmasın

May 7, 2009

getscale & setscale esri arcgis server 9.2

Filed under: arcobjects — osman @ 10:03 am

HTML 
<input type=”text” name=”txtScale” style=”border:1px solid gray; width:55px;font-family:Tahoma; font-size:11px;” maxlength=”7″>
<a href=”javascript:setScale()”>olceği Ayarla</a><input type=”hidden” name=”scaleRegex” value=”^\d{1,7}$” />

function setScale()
{
var FrmTxs = document.getElementById(“txtScale”);
var FrmTxsVal = FrmTxs.value;
var checkReg = document.getElementById(“scaleRegex”);
var re = new RegExp(checkReg.value);
var m = re.exec(FrmTxsVal);
if (m == null)
{
alert(
“Olcek bolumune lutfen sadece rakam giriniz.”);
}
else
{
context =
“UpdateScale”;
ChangeClientADF(FrmTxsVal);
}
}

function UpdateScaleDdl(scaleVal)
{
var txs = document.getElementById(“txtScale”);
txs.value = scaleVal;
}

ChangeClientADF bildiğimiz gibi ESRI nin CallBack leri için kullandığı fonksyion. Birçok yerde aynı isimle geçiyor.)

page_load içerisine

MapViewer.ScaleChanged += new MapScaleChangeEventHandler(mMap_ScaleChanged);

//scale değiştiğinde textbox taki değeri güncelleyen method
void
mMap_ScaleChanged(object sender, ScaleEventArgs args)
{
ESRI.ArcGIS.ADF.Web.DataSources.
IMapFunctionality mf = (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality)MapViewer.GetFunctionality(1);
int mWid = Convert.ToInt32(MapViewer.Width.Value);
int mHeg = Convert.ToInt32(MapViewer.Height.Value);
double Scale = mf.GetScale(MapViewer.Extent, mWid, mHeg);
int iScale = Convert.ToInt32(Scale);
string UpdateDdl = “UpdateScaleDdl(’” + String.Format(“{0:n}”,iScale.ToString()) + “‘);”;
MapViewer.CallbackResults.Add(
new CallbackResult(MapViewer, “JavaScript”, UpdateDdl));
}

//scale i textbox a yazan değere çeken method
private
string SetScaleValue(string newScaleValue)
{
ESRI.ArcGIS.ADF.Web.DataSources.
IMapFunctionality mf = (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality)MapViewer.GetFunctionality(1);
int mWid = Convert.ToInt32(MapViewer.Width.Value);
int mHeg = Convert.ToInt32(MapViewer.Height.Value);
double Scale = mf.GetScale(MapViewer.Extent, mWid, mHeg);
double dNewScaleValue = double.Parse(newScaleValue);
double ZoomFactor = Scale / dNewScaleValue;
MapViewer.Zoom(ZoomFactor);
MapViewer.Refresh();
return MapViewer.CallbackResults.ToString();
}

April 10, 2009

bir veya birden çok alana zoom etme / enveloplarını bulma

Filed under: arcobjects — osman @ 11:53 am

if (tableGeometryType == “esriGeometryPolygon”){

ESRI.ArcGIS.ADF.Web.Geometry.Polygon alan;ESRI.ArcGIS.ADF.Web.Geometry.Envelope pEnvA = null;

double minX = 9999999999999999;double minY = 9999999999999999;

double maxX = 0;double maxY = 0;

double curValx = 0;double curValy = 0;

for (int g = 0; g < datatable.Rows.Count; g++){

alan = (ESRI.ArcGIS.ADF.Web.Geometry.Polygon)datatable.Rows[g][shapeFieldIndex];for(int k=0;k<alan.Rings.Count;k++){

for(int t=0;t<alan.Rings[k].Points.Count;t++){

curValx = alan.Rings[k].Points[t].X;

curValy = alan.Rings[k].Points[t].Y;

if (curValx > maxX){

maxX = curValx;

}

if (curValx < minX){

minX = curValx;

}

if (curValy > maxY){

maxY = curValy;

}

if (curValy < minY){

minY = curValy;

}

}

}

}

ESRI.ArcGIS.ADF.Web.Geometry.Envelope manualEnv = new ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minX, minY, maxX, maxY);pEnv = manualEnv;

}

March 13, 2009

tasks 9.3

Filed under: arcobjects — osman @ 4:18 pm

Editing versioned and nonversioned data

The Editor task supports editing versioned and nonversioned data. To edit versioned data with the Editor task, you must be using a nonpooled service.

You can edit nonversioned data with either pooled or nonpooled services. When editing nonversioned data, you cannot undo or redo edits or adjust the autoreconciliation options. The last edit to be saved always overwrites any previous edits to the same feature.

Print task

When setting the page size and quality, keep in mind that the GIS server imposes limits on the maximum image size it can return. For example, ArcGIS Server map services, by default, restrict the image size to a maximum of 2048 x 2048 pixels. This means that a 10 inch square map with a quality of 200 dpi is 2000 x 2000 pixels. If the print task map request exceeds the limits of the GIS server, the particular service will not print

March 6, 2009

getDataFrame Name to Toolbar DropDownBox

Filed under: arcobjects — osman @ 4:39 pm

ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl = Map1;ESRI.ArcGIS.ADF.Web.UI.WebControls.Toolbar toolbar = Toolbar1;

int iResourceItemIndex = 1;string comboDataFrameName = “SelectActiveDataFrame”;//————

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)mapctrl.GetFunctionality(iResourceItemIndex);ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)ags_mapfunctionality.Resource;ESRI.ArcGIS.Server.

IServerContext ServerContext = ags_mapresourcelocal.ServerContextInfo.ServerContext;IMapServer mapsrv = ServerContext.ServerObject as IMapServer;ESRI.ArcGIS.ADF.Web.UI.WebControls.

DropDownBox activeLayer = (ESRI.ArcGIS.ADF.Web.UI.WebControls.DropDownBox)toolbar.ToolbarItems.Find(comboDataFrameName);activeLayer.Items.Clear();

activeLayer.Items.Add(new ListItem(“Seciniz : Aktif Data Frame”,“”));for (int k = 0; k < mapsrv.MapCount; k++){

activeLayer.Items.Add(new ListItem (mapsrv.get_MapName(k).ToString().Trim(),mapsrv.get_MapName(k).ToString().Trim()));}

System.Runtime.InteropServices.COMException: Exception from HRESULT: 0×80040228.

Filed under: arcobjects — osman @ 2:53 pm

Your developing your application using ArcGIS Engine runtime 9.2 and you get the error System.Runtime.InteropServices.COMException: Exception from HRESULT: 0×80040228, One of the most popular and prodigal cause would be you forgot to initialize the license. Please add the following two lines of code at the beginning of your application (eg: Main()) and that should take care of it.

ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeEngine);
If you dont have ArcGIS Engine 9.2 runtime installed and want to use desktop ArcView license for the development then the code would be

ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();

ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcView);
If you dont have ArcGIS Engine 9.2 runtime installed and want to use desktop ArcEditor license for the development then the code would be

ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcEditor);

If you dont have ArcGIS Engine 9.2 runtime installed and want to use desktop ArcInfo license for the development then the code would be

ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcInfo);

March 2, 2009

arcgis server 9.2 run command with server-side

Filed under: arcobjects — osman @ 6:37 pm

<esri:Command ClientAction=”"  Name=”mapref” ServerActionAssembly=”App_Code” ServerActionClass=”util.refreshMap” Text=”Ref Map” />

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;

namespace util
{
    public class refreshMap: IMapServerCommandAction
    {
        public refreshMap()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region IServerAction Members
        public void ServerAction(ToolbarItemInfo info)
        {
            ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)info.BuddyControls[0];
            mapctrl.Refresh();
        }
        #endregion
    }
}

9.2 ArcGis Server utility function CreateGraphicLayerData / GetGeometryColInfo

Filed under: arcobjects — osman @ 10:43 am

    public static void GetGeometryColInfo(out string colName, out int colIndex, DataTable geoResultTable)
    {
        string coln = “”;
        int coli = -1;
        try
        {
            for (int k = 0; k < geoResultTable.Columns.Count; k++)
            {
                if (object.ReferenceEquals(geoResultTable.Columns[k].DataType, typeof(ESRI.ArcGIS.ADF.Web.Geometry.Geometry)))
                {
                    coln = geoResultTable.Columns[k].ColumnName;
                    coli = k;
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            colName = coln;
            colIndex = coli;
        }
    }

    public static void CreateGraphicLayerData(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map, DataTable resultDt, string graphicLayerName, System.Drawing.Color renk1, System.Drawing.Color renk2)
    {
        try
        {
            ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicslayer = ESRI.ArcGIS.ADF.Web.UI.WebControls.Converter.ToGraphicsLayer(resultDt, renk1, renk2);
            ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gResource = null;
            foreach (IGISFunctionality gfunc in map.GetFunctionalities())
            {
                if ((gfunc.Resource is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource) && (gfunc.Resource.Name == graphicLayerName))
                {
                    gResource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)gfunc.Resource;
                    gResource.Graphics.Tables.Clear();
                }
            }

            if (gResource != null)
            {
                gResource.Graphics.Tables.Add(graphicslayer);
            }
            else
            {
                //hata donmeli
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

February 27, 2009

Adds the user-specified resource to the CompositeControl’s MapResourceManager

Filed under: arcobjects — osman @ 6:40 pm

        // Adds the user-specified resource to the CompositeControl’s MapResourceManager
        private ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem AddResourceToMapResourceManager()
        {
            if (string.IsNullOrEmpty(m_dataSource))
            {
                // Define default resource item properties if ToolTocControl properties are empty
                m_mapResourceType = “ArcGIS Server Internet”;
                m_dataSource = “http://localhost/arcgis/services”;
                m_mapResourceDefinition = “(default)@MapService”;
            }

            // Create a GISResourceItemDefinition with user-specified parameters
            ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition gisResourceItemDefinition =
                CreateGISResourceItemDefinition(m_dataSource, m_mapResourceType, string.Empty,
                m_mapResourceDefinition, true);

            // Create a mapResourceItem from the resource item definition
            ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem =
                CreateResourceItem(“AGSMapResource<!–” + this.UniqueID + “–>”,
                gisResourceItemDefinition);

            // Assign the parent of the map resource item and initialize the underlying resource
            mapResourceItem.Parent = m_mapResourceManager;
            mapResourceItem.InitializeResource();

            // Make sure the map resource manager exists and that it does not contain any resource
            // items before adding the resource item to it
            if (m_mapResourceManager != null && m_mapResourceManager.ResourceItems.Count == 0)
            {
                AddMapResourceItemToResourceManager(m_mapResourceManager, false, mapResourceItem);
            }

            return mapResourceItem;
        }

        // Adds the passed-in resource to the passed-in map resource manager
        private void AddMapResourceItemToResourceManager(
            ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceManager mapResourceManager,
            bool insertIntoBeginning, ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem)
        {
            if (insertIntoBeginning)
            {
                mapResourceManager.ResourceItems.Insert(0, mapResourceItem);
            }
            else
            {
                mapResourceManager.ResourceItems.Add(mapResourceItem);
            }
        }

        // Creates a resource item with the passed-in name, the passed-in resource definition string,
        // and default settings
        private ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem
            CreateResourceItem(string resourceName,
            ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition gisResourceItemDefinition)
        {
            ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem =
                new ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem();
            mapResourceItem.Definition = gisResourceItemDefinition;
            mapResourceItem.Name = resourceName;
            mapResourceItem.DisplaySettings = new ESRI.ArcGIS.ADF.Web.DisplaySettings();
            mapResourceItem.DisplaySettings.Visible = true;
            ESRI.ArcGIS.ADF.Web.ImageDescriptor imageDescriptor =
                new ESRI.ArcGIS.ADF.Web.ImageDescriptor();
            imageDescriptor.ImageFormat = ESRI.ArcGIS.ADF.Web.ImageFormat.PNG8;
            imageDescriptor.TransparentBackground = true;
            imageDescriptor.TransparentColor = System.Drawing.Color.White;
            imageDescriptor.ReturnMimeData = true;
            mapResourceItem.DisplaySettings.ImageDescriptor = imageDescriptor;
            mapResourceItem.DisplaySettings.Transparency = 0;
            return mapResourceItem;
        }

        // Creates a GISResourceItemDefinition with the passed-in parameters
        private ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition
            CreateGISResourceItemDefinition(string dataSourceDefinition, string dataSourceType,
            string identity, string resourceDefinition, bool dataSourceShared)
        {
            ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition gisResourceItemDefinition =
                new ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition();
            gisResourceItemDefinition.DataSourceDefinition = dataSourceDefinition;
            gisResourceItemDefinition.Identity = (identity == null) ? string.Empty : identity;
            gisResourceItemDefinition.ResourceDefinition = resourceDefinition;
            gisResourceItemDefinition.DataSourceShared = dataSourceShared;
            gisResourceItemDefinition.DataSourceType = dataSourceType;
            return gisResourceItemDefinition;
        }

Next Page »

Powered by WordPress