osman hömek / not defteri

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;
        }

Add the user-specified resource to the CompositeControl’s MapResourceManager and initialize the Map extent

Filed under: arcobjects — osman @ 6:39 pm

        // Executes before the control is rendered
        protected override void OnPreRender(System.EventArgs e)
        {
            base.OnPreRender(e);

            ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem =
                AddResourceToMapResourceManager();
            if (m_mapResourceManager != null && mapResourceItem != null)
            {
                ESRI.ArcGIS.ADF.Web.DataSources.IMapResource commonMapResource =
                    mapResourceItem.Resource as ESRI.ArcGIS.ADF.Web.DataSources.IMapResource;
                m_adfMap.Extent = commonMapResource.MapInformation.DefaultExtent;
            }
        }

February 19, 2009

proje yönetimi ve bedavaları

Filed under: development, programlama — osman @ 2:18 pm

http://www.tigris.org/

adresini bir kenara yazalım. kendi ağızları ile “Open Source Software Engineering Tools” işi ile meşguller.

Birçok aracı kendi bünyelerinde barındırıyorlar. kesinlikle takip edilmeli.

 visual source safe tarzı bir yazılım olarak msdn in bloglarından birinde yapılan ankette subversion birinci sırada idi.

burada onu da anmadan geçmeyelim. http://subversion.tigris.org/

 Öte yandan server ı için visual svn yi öneririm. http://www.visualsvn.com/server/

client olaraksa iki tercihim var visual studio için paralı visualvsn veya http://ankhsvn.open.collab.net/servlets/ProjectProcess?pageID=3797 adresindeki ankhSVN

mutlaka atlanmadan geçilmemesi gereken SVN client ı ise : http://tortoisesvn.net/

komple proje yönetimi falan işleri için incelenmesi gereken bir ürün : http://www.open.collab.net/

 öte yandan kullandığım http://www.16bugs.com/ sitesini müşteri ilişkileri açısından çok yalın ve işgörür bulduğumu belirtmeden geçemeyeceğim. kendileri bug tracink olarak geçerler.

February 18, 2009

Custom callback events

Filed under: arcobjects — osman @ 3:43 pm
Event Argument Description
 ”content” Used to set the outerHTML property of an html element. The html element on the client defined by the CallbackResults controlType and controlID is completely replaced by the html content provided as a parameter in the object array (object[]).
 ”innercontent” Used to set the innerHTML property of an html element. The content inside the html element on the client defined by the CallbackResults controlType and controlID is completely replaced by the html content provided as a parameter in the object array (object[]).
 ”image” Used to set the src property of an image element. The source of the image element on the client defined by the CallbackResults controlType and controlID is changed to the url string provided as a parameter in the object array (object[]).
 ”javascript” Used to execute JavaScript on the client. The CallbackResults controlType and controlID and set to null. The JavaScript code is provided as a parameter in the object array (object[]).

iş yaptın, bitti, geriye veri döndürmen gerekli o sırada

Map1′e eklediğimiz CallbackResult nesnelerini javascript ten türetirken tip olarak sağdakileri

yazabiliyoruz. Zaten js, innercontent i sıklıkla kullanıyoruz. diğer ikisini de öğrenmiş olduk.

hangi client event ine hangi server event karşılık gelir

Filed under: arcobjects — osman @ 3:41 pm
ClientAction Cast ToolEventArgs to:
 Point  PointEventArgs
 Line  LineEventArgs
 Polyline  VectorEventArgs, PolylineEventArgs
 Polygon  VectorEventArgs, PolygonEventArgs
 DragRectangle  RectangleEventArgs
 Circle  CircleEventArgs
 Oval  OvalEventArgs

İçerideki class

CircleEventArgs pCircle = (CircleEventArgs)args;

 yazmak yeterli.

February 16, 2009

en ucuz cinsinden harita component i asp.net için

Filed under: development — osman @ 4:10 pm

http://www.vdstech.com/index.htm

 birçok belediye tarafından kullanıldığı kulağıma geldi.

aklımızda olsun…

February 6, 2009

arcgis 9.2 Lejant (legend) bmp olarak export ediliyor

Filed under: arcobjects — osman @ 5:52 pm

http://codekeep.net/snippets/673ed2c6-1d23-4cc0-8fe1-fec35322035e.aspx

adresinden alıp, bir miktar kendi güncellemelerimi yaptıktan sonraki hali ile 

public Bitmap GetLegendImage(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map, int width, int height, int printResolution, string legendTitle, int resourceIndex){

Bitmap legendImage = null;

#region “Trying to get the legend information”Dictionary<string, KeyValuePair<string, CartoImage>> legendInfo = new Dictionary<string, KeyValuePair<string, CartoImage>>();

int layerCounter = 0;IMapResource itemMP = map.MapResourceManagerInstance.GetResource(resourceIndex);

IMapTocFunctionality mtoc = itemMP.CreateFunctionality(typeof(IMapTocFunctionality), Guid.NewGuid().ToString()) as IMapTocFunctionality;IMapFunctionality mf = map.GetFunctionality(resourceIndex);

TocDataFrame[] tocDataFrames = mtoc.GetMapContents(mf.Name, WebImageFormat.PNG24, true, false);foreach (TocDataFrame tocDataFrame in tocDataFrames){

foreach (TocLayer tocLayer in tocDataFrame){

if (tocLayer.Visible){

List<KeyValuePair<string, CartoImage>> legends = GetLegendImages(tocLayer);

if (legends != null && legends.Count > 0){

foreach (KeyValuePair<string, CartoImage> entry in legends){

legendInfo.Add(layerCounter.ToString(), new KeyValuePair<string, CartoImage>(entry.Key, entry.Value));layerCounter++;

}

}

}

}

}

#endregion

#region “Create the legend dynamically”if (legendInfo != null && legendInfo.Count > 0){

int legendWidth = width;

int legendHeight = height;int marginPadding = 10;

int legendEntryPadding = 5;legendImage = new Bitmap(legendWidth, legendHeight);legendImage.SetResolution(printResolution, printResolution);

Graphics graphics = Graphics.FromImage(legendImage);

Font stringFont = new Font(“Verdana”, 8, System.Drawing.FontStyle.Bold);SolidBrush drawBrush = new SolidBrush(Color.Black);

List<Bitmap> legendEntries = new List<Bitmap>();foreach (KeyValuePair<string, KeyValuePair<string, CartoImage>> item in legendInfo){

if (item.Value.Value != null){

Bitmap swatch = new Bitmap(new System.IO.MemoryStream(item.Value.Value.MimeData.Bytes));

float swatchColumnWidth = (swatch.Width * (printResolution / swatch.HorizontalResolution)) > 100 ? 100 : (swatch.Width * (printResolution / swatch.HorizontalResolution));SizeF textSize = graphics.MeasureString(item.Value.Key, stringFont, (int)(legendWidth - swatchColumnWidth - (marginPadding * 2)));

float inidividualHeight = (swatch.Height * (printResolution / swatch.VerticalResolution)) > textSize.Height ? (swatch.Height * (printResolution / swatch.VerticalResolution)) : textSize.Height;Bitmap individuallegend = new Bitmap(legendWidth, (int)inidividualHeight);individuallegend.SetResolution(printResolution, printResolution);

Graphics g = Graphics.FromImage(individuallegend);g.DrawImage(swatch, marginPadding, 0);

RectangleF textArea = new RectangleF(swatchColumnWidth + marginPadding, 0, legendWidth - swatchColumnWidth - (marginPadding * 2), inidividualHeight);g.DrawString(item.Value.Key, stringFont, drawBrush, textArea);

g.Dispose();

legendEntries.Add(individuallegend);

}

else

{

if (item.Value.Key != “”){

SizeF textSize = graphics.MeasureString(item.Value.Key, stringFont, (int)(legendWidth - (marginPadding * 2)));float inidividualHeight = textSize.Height;

Bitmap individuallegend = new Bitmap(legendWidth, (int)inidividualHeight);individuallegend.SetResolution(printResolution, printResolution);

Graphics g = Graphics.FromImage(individuallegend);RectangleF textArea = new RectangleF(marginPadding, 0, legendWidth - (marginPadding * 2), inidividualHeight);g.DrawString(item.Value.Key, stringFont, drawBrush, textArea);

g.Dispose();

legendEntries.Add(individuallegend);

}

}

}

Font legendTitleFont = new Font(“Verdana”, 10, System.Drawing.FontStyle.Bold);SizeF legendTitleArea = graphics.MeasureString(legendTitle, legendTitleFont);

float currentY = 0;graphics.DrawString(legendTitle, legendTitleFont, drawBrush, marginPadding, legendEntryPadding);

currentY += legendTitleArea.Height + marginPadding;

foreach (Bitmap entry in legendEntries){

if ((currentY + entry.Height) < legendHeight){

graphics.DrawImage(entry, 0, currentY);

currentY += entry.Height + legendEntryPadding;

}

}

graphics.Dispose();

}

#endregion

return legendImage;}

private List<KeyValuePair<string, CartoImage>> GetLegendImages(TocLayer tocLayer){

List<KeyValuePair<string, CartoImage>> legends = new List<KeyValuePair<string, CartoImage>>();if (tocLayer != null && tocLayer.Visible){

if (tocLayer.TocSymbolGroupCount > 0){

if (tocLayer.TocSymbolGroupCount == 1){

TocSymbolGroup symbolGroupSingle = tocLayer.GetTocSymbolGroup(0);

if (symbolGroupSingle.Count == 1){

TocSymbol tocSymbol = symbolGroupSingle[0];legends.Add(new KeyValuePair<string, CartoImage>(tocLayer.LayerName, tocSymbol.Image));}

else

{

System.Collections.IEnumerator e = tocLayer.GetTocSymbolGroups();//add the layer name

if (e.MoveNext() && e.Current != null)legends.Add(new KeyValuePair<string, CartoImage>(tocLayer.LayerName, null));e.Reset();

while (e.MoveNext()){

//Add the group name

TocSymbolGroup symbolGroup = e.Current as TocSymbolGroup;legends.Add(new KeyValuePair<string, CartoImage>(symbolGroup.Heading, null));

foreach (TocSymbol tocSymbol in symbolGroup){

//add group entries

legends.Add(new KeyValuePair<string, CartoImage>(tocSymbol.Label, tocSymbol.Image));}

}

}

}

else

{

System.Collections.IEnumerator e = tocLayer.GetTocSymbolGroups();if (e.MoveNext() && e.Current != null)legends.Add(

new KeyValuePair<string, CartoImage>(tocLayer.LayerName, null));e.Reset();

while (e.MoveNext()){

TocSymbolGroup symbolGroup = e.Current as TocSymbolGroup;legends.Add(new KeyValuePair<string, CartoImage>(symbolGroup.Heading, null));

foreach (TocSymbol tocSymbol in symbolGroup){

legends.Add(new KeyValuePair<string, CartoImage>(tocSymbol.Label, tocSymbol.Image));}

}

}

}

if (tocLayer.TocLayerCount > 0){

System.Collections.IEnumerator subLayers = tocLayer.GetTocLayers();while (subLayers.MoveNext()){

List<KeyValuePair<string, CartoImage>> subLayerLegends = GetLegendImages(subLayers.Current as TocLayer);

if (subLayerLegends != null)legends.AddRange(subLayerLegends);

}

}

}

return legends;}

callback sonrası harita harici nesne geri döndürme taktiği

Filed under: arcobjects — osman @ 5:49 pm

Bitmap cmb = GetLegendImage(Map1, 200, 900, 96, “lejant basligi”, 0);string internalAdr = “lejant/legend.bmp”;

string uril = Server.MapPath(internalAdr);cmb.Save(uril);

Image1.ImageUrl = “/progis/” + internalAdr;string returnstring = “”;

using (System.IO.StringWriter sw = new System.IO.StringWriter()){

HtmlTextWriter htw = new HtmlTextWriter(sw);Image1.RenderControl(htw);

htw.Flush();

returnstring = sw.ToString();

}

CallbackResult cr = new CallbackResult(“div”, “lejant”, “innercontent”, returnstring);Map1.CallbackResults.Add(cr);

return Map1.CallbackResults.ToString();

February 5, 2009

alias gönderip, layer in index ini alma methodu

Filed under: arcobjects — osman @ 6:11 pm

public static int GetLayerIndexByLayerAliasName(string serviceName, string layerAliasName, string dataFrameName, string hostName, string serverType, string userName, string password, string domain){

ESRI.ArcGIS.Server.IServerContext ctx = null;IMapServer mapsrv = null;

AGSServerConnection connection = null;int layerIndex = -1;try

{

connection = GetAGSConnection(userName, password, domain, hostName);

ctx = GetServerContext(connection, serverType, serviceName);

mapsrv = ctx.ServerObject as IMapServer;IMapServerObjects mapo = mapsrv as IMapServerObjects;

IMap pFeatureMap = mapo.get_Map(dataFrameName);for (int k = 0; k < pFeatureMap.LayerCount; k++){

if (pFeatureMap.get_Layer(k).Name.ToString() == layerAliasName){

layerIndex = k;

break;}

}

}

catch (Exception ex){

throw ex;}

finally

{

ctx.ReleaseContext();

connection.Dispose();

}

return layerIndex;}

9.2 service->dataframe->layername ile erişip DataTable almak

Filed under: arcobjects — osman @ 6:08 pm

böylelikle  index ini bildiğimiz katmanın attribute table değerini datatable olarak alabiliyoruz
tüm veriler string e dönüştürelerek datatable haline getiriliyor

arcgis geodb ile yaptığımız bu deneme sonucu itibari ile yavaş
git oracle a native çek daha iyi ;)

ana method içerisinde yönlenilen metodları aşağıya yazdım
aranma!

kullanım örneğini de not defterimize ekleyelim
bu neydi yahu demeyelim

DataTable itb = GetDataTable(“arcgis_service_adi”, “data_framein_adi”, “mxd_icerisindekiKatmaninLayerIndex”, “MapServer”, “kullaniciadi”, “12345″, “computer_name”, “localhost”); serverType değişkeninin karşılığı olan MapServer değişmeyecek.

public static DataTable GetDataTable(string serviceName, string dataFrameName, int layerIndex, string serverType, string userName, string password, string domain, string hostName){

ESRI.ArcGIS.Server.IServerContext ctx = null;IMapServer mapsrv = null;

AGSServerConnection connection = null;DataTable dt = null;try

{

connection = GetAGSConnection(userName, password, domain, hostName);

ctx = GetServerContext(connection, serverType, serviceName);

mapsrv = ctx.ServerObject as IMapServer;IMapServerObjects mapo = mapsrv as IMapServerObjects;

IMap pFeatureMap = mapo.get_Map(dataFrameName);IFeatureLayer pFeatureLayer = (IFeatureLayer)mapo.get_Layer(dataFrameName, layerIndex);

IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;ITable pDataTable = (ITable)pFeatureClass;string alanlar = “”;

for (int m = 0; m < pDataTable.Fields.FieldCount; m++){

alanlar = alanlar + “|” + pDataTable.Fields.get_Field(m).Name.ToString();}

alanlar = alanlar.Trim();

if (alanlar.StartsWith(“|”))alanlar = alanlar.Substring(1, alanlar.Length - 1);

if (alanlar.EndsWith(“|”))alanlar = alanlar.Substring(0, alanlar.Length - 1);

string[] aryAlanlar = alanlar.Split(“|”.ToCharArray());dt = Utility.CreateBlankDataTable(aryAlanlar);

for (int k = 0; k < pDataTable.RowCount(null); k++){

IRow pRow = pDataTable.GetRow(k+1);DataRow dr = dt.NewRow();

for (int j = 0; j < pDataTable.Fields.FieldCount; j++){

dr[j] = pRow.get_Value(j).ToString();

}

dt.Rows.Add(dr);

}

dt.AcceptChanges();

}

catch (Exception ex){

throw ex;}

finally

{

ctx.ReleaseContext();

connection.Dispose();

}

return dt;}

 //*************************************************************************************************************************************************

public static ESRI.ArcGIS.Server.IServerContext GetServerContext(AGSServerConnection agsServerConnection, string serverType, string serviceName){

ESRI.ArcGIS.Server.IServerContext serverContext = null;try

{

ESRI.ArcGIS.Server.IServerObjectManager serverObjectManager = agsServerConnection.ServerObjectManager;serverContext = serverObjectManager.CreateServerContext(serviceName, serverType);

}

catch (Exception ex){

throw ex;}

return serverContext;}

 //*************************************************************************************************************************************************

public static ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection GetAGSConnection(string userName, string password, string domain, string hostName){

ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection = null;try

{

ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(userName, password, domain);agsServerConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(hostName, identity);agsServerConnection.Connect();

}

catch (Exception ex){

throw ex;}

return agsServerConnection;}

 //*************************************************************************************************************************************************

public static DataTable CreateBlankDataTable(string[] fields){

DataTable dt = new DataTable();for(int k=0;k<fields.Length;k++){

DataColumn dc = new DataColumn();dc.ColumnName = fields[k].ToString();

dt.Columns.Add(dc);

}

dt.AcceptChanges();

return dt;}

Next Page »

Powered by WordPress