Exemplo n.º 1
0
 public static void Initialize()
 {
     MapServiceFidTests._mapservice     = new MapServerProxy();
     MapServiceFidTests._mapservice.Url = "http://mashup/ArcGIS/services/MapServices/Austin/MapServer";
     MapServiceFidTests.name            = MapServiceFidTests._mapservice.GetDefaultMapName();
     MapServiceFidTests._mapinfo        = MapServiceFidTests._mapservice.GetServerInfo(MapServiceFidTests.name);
 }
Exemplo n.º 2
0
 public UpdateMapImageTask()
 {
     this.Mapservice             = null;
     this.Imagedescription       = null;
     this.Mapdesc                = null;
     this.UpdateForm             = null;
     this.OutputSpatialReference = null;
     this.GeometryService        = null;
 }
Exemplo n.º 3
0
 public TiledRaster(Document doc)
 {
     this.ParentDoc       = doc;
     this.RasterIds       = new List <ObjectId>();
     this._mapservice     = new MapServerProxy();
     this._mapservice.Url = "http://mashup/ArcGIS/services/MapServices/CorvallisCompact/MapServer";
     this._mapinfo        = this._mapservice.GetServerInfo(this._mapservice.GetDefaultMapName());
     this.SampleGetTileInfo();
 }
Exemplo n.º 4
0
 public MapFrame( MapDescription mapDescription, MapServerProxy mapServerProxy, ImageDescription imageDescription)
 {
     m_mapDescription = mapDescription;
     m_mapServerProxy = mapServerProxy;
     m_imageDescription = imageDescription;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the map query data.
 /// </summary>
 /// <param name="mapServer">The map server.</param>
 /// <param name="layerName">Name of the layer.</param>
 /// <param name="whereClause">The where clause.</param>
 /// <param name="maxRecords">The max records.</param>
 /// <param name="assetType">Type of the asset.</param>
 /// <returns></returns>
 private MapCustomDataTable GetMapQueryData(MapServerProxy mapServer, string layerName, 
     string whereClause,int maxRecords, string assetType)
 {
     #region "Local Variables"
     DataTable dtQSrch = null;
     MapCustomDataTable dtCustomQSrch = null;
     int intLayerID = -1;
     QueryFilter objQSFilter = new QueryFilter();
     MapProcessManager objMapController = null;
     ESRI.ArcGIS.ADF.StringCollection objFieldsColl = null;
     string strFields = string.Empty;
     ESRI.ArcGIS.ADF.ArcGISServer.RecordSet objRS = null;
     #endregion
     try
     {
         if (!string.IsNullOrEmpty(layerName))
         {
             intLayerID = GetLayerID(mapServer, layerName);
             if (intLayerID != -1)
             {
                 //assigning Query Functionality
                 //Declaring Query Filter and assigning properties
                 objMapController = new MapProcessManager();
                 objFieldsColl = new ESRI.ArcGIS.ADF.StringCollection();
                 objQSFilter.WhereClause = whereClause;
                 objFieldsColl = objMapController.GetSubFields(layerName);
                 foreach (string strColumnName in objFieldsColl)
                 {
                     if (!string.IsNullOrEmpty(strFields))
                         strFields = strFields + "," + strColumnName;
                     else
                         strFields = strColumnName;
                 }
                 if (objFieldsColl != null && objFieldsColl.Count > 0) objQSFilter.SubFields = strFields;
                 //Querying for data Table.
                 objRS = mapServer.QueryFeatureData(mapServer.GetMapName(0), intLayerID, objQSFilter);
                 dtQSrch = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToDataTable(objRS);
                 if (dtQSrch != null && dtQSrch.Rows.Count > 0)
                 {
                     dtCustomQSrch = FormatDataTable(dtQSrch,layerName,maxRecords, assetType);
                 }
             }
         }
     }
     catch
     {
         throw;
     }
     finally
     {
         if (dtQSrch != null) dtQSrch.Dispose();
         if (dtCustomQSrch != null) dtCustomQSrch.Dispose();
     }
     return dtCustomQSrch;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the layer ID.
 /// </summary>
 /// <param name="mapServer">The map server.</param>
 /// <param name="layerName">Name of the layer.</param>
 /// <returns></returns>
 private int GetLayerID(MapServerProxy mapServer, string layerName)
 {
     #region Local Variables
     int intLayerID = -1;
     MapServerInfo objMapServerInfo = null;
     MapLayerInfo[] objLayerInfoArray = null;
     MapLayerInfo objLayerInfo = null;
     #endregion
     try
     {
         objMapServerInfo = mapServer.GetServerInfo(mapServer.GetMapName(0));
         objLayerInfoArray = objMapServerInfo.MapLayerInfos;
         for (int intLayers = 1; intLayers < objLayerInfoArray.Length; intLayers++)
         {
             objLayerInfo = objLayerInfoArray[intLayers];
             if (objLayerInfo.Name == layerName)
             {
                 intLayerID = objLayerInfo.LayerID;
                 break;
             }
         }
     }
     catch
     {
         throw;
     }
     return intLayerID;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gats the map spatial query data.
 /// </summary>
 /// <param name="mapServer">The map server.</param>
 /// <param name="inputGeometry">The input geometry.</param>
 /// <param name="layerName">Name of the layer.</param>
 /// <param name="maxRecords">The max records.</param>
 /// <param name="returnGeometry">if set to <c>true</c> [return geometry].</param>
 /// <param name="assetType">Type of the asset.</param>
 /// <returns></returns>
 private MapCustomDataTable GatMapSpatialQueryData(MapServerProxy mapServer, 
 ESRI.ArcGIS.ADF.Web.Geometry.Geometry inputGeometry,
 string layerName, int maxRecords, bool returnGeometry, string assetType)
 {
     #region "Local Variables"
     DataTable objDataTable = null;
     MapCustomDataTable objCustomDataTable = null;
     int intLayerID = -1;
     SpatialFilter objSpatailFil;
     MapProcessManager objMapController = null;
     ESRI.ArcGIS.ADF.StringCollection objStrColl = null;
     string strFields = string.Empty;
     ESRI.ArcGIS.ADF.ArcGISServer.RecordSet objRS = null;
     #endregion
     try
     {
         if (!string.IsNullOrEmpty(layerName))
         {
             intLayerID = GetLayerID(mapServer, layerName);
             if (intLayerID != -1)
             {
                 objMapController = new MapProcessManager();
                 objStrColl = new ESRI.ArcGIS.ADF.StringCollection();
                 //creating spatial filter
                 objSpatailFil = new SpatialFilter();
                 //setting geometry to spatial filter
                 objSpatailFil.FilterGeometry = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfGeometry(inputGeometry);
                 objSpatailFil.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                 objStrColl = objMapController.GetSubFields(layerName);
                 foreach (string strColumnName in objStrColl)
                 {
                     if (!string.IsNullOrEmpty(strFields))
                         strFields = strFields + "," + strColumnName;
                     else
                         strFields = strColumnName;
                 }
                 if (objStrColl != null && objStrColl.Count > 0) objSpatailFil.SubFields = strFields;
                 //obtaining queried data table
                 objRS = mapServer.QueryFeatureData(mapServer.GetMapName(0), intLayerID, objSpatailFil);
                 objDataTable = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToDataTable(objRS);
                 //formatting data table
                 if (objDataTable != null && objDataTable.Rows.Count > 0 && returnGeometry == false)
                 {
                     objCustomDataTable = FormatDataTable(objDataTable, layerName,
                          maxRecords, assetType);
                 }
             }
         }
     }
     catch
     {
         throw;
     }
     finally
     {
         if (objDataTable != null) objDataTable.Dispose();
         if (objCustomDataTable != null) objCustomDataTable.Dispose();
     }
     return objCustomDataTable;
 }
Exemplo n.º 8
0
        public static StringBuilder GetLegendJson(string serviceUri)
        {
            StringBuilder result = new StringBuilder();
            result.Append("[");
            MapServerProxy proxy = new MapServerProxy(serviceUri);
            string mapName = proxy.GetDefaultMapName();
            ImageType imageType = new ImageType();
            imageType.ImageFormat = esriImageFormat.esriImageBMP;
            imageType.ImageReturnType = esriImageReturnType.esriImageReturnMimeData;

            MapServerLegendInfo[] legends = proxy.GetLegendInfo(mapName, null, null, imageType);
            if (legends != null && legends.Length > 0) {
                bool firstLegend = true;
                foreach (MapServerLegendInfo legend in legends) {
                    if (firstLegend) {
                        firstLegend = false;
                    } else {
                        result.Append(",");
                    }
                    result.Append("{");
                    if (legend.Name.Length > 0) {
                        result.Append("\"Name\":\"");
                        result.Append(legend.Name);
                        result.Append("\",");
                    }
                    result.Append("\"Groups\":[");
                    bool firstGroup = true;
                    foreach (MapServerLegendGroup group in legend.LegendGroups) {
                        if (firstGroup) {
                            firstGroup = false;
                        } else {
                            result.Append(",");
                        }
                        result.Append("{");
                        if (group.Heading.Length > 0) {
                            result.Append("\"Heading\":\"");
                            result.Append(group.Heading);
                            result.Append("\",");
                        }
                        result.Append("\"Entries\":[");
                        bool firstEntry = true;
                        for (int i = 0; i < group.LegendClasses.Length; i += 1) {
                            MapServerLegendClass legendClass = group.LegendClasses[i];
                            if (firstEntry) {
                                firstEntry = false;
                            } else {
                                result.Append(",");
                            }
                            result.Append("{\"Label\":\"");
                            result.Append(legendClass.Label);
                            result.Append("\",");
                            Bitmap colors = new Bitmap(new System.IO.MemoryStream(legendClass.SymbolImage.ImageData));
                            //colors.Save(@"E:\arcgisserver\arcgisoutput\Class" + (i++).ToString() + ".jpg");
                            System.Drawing.Color lc = colors.GetPixel(2, 2);
                            result.Append("\"LineColor\":{\"r\":");
                            result.Append(lc.R);
                            result.Append(",\"g\":");
                            result.Append(lc.G);
                            result.Append(",\"b\":");
                            result.Append(lc.B);
                            result.Append("},");
                            int sampleX = colors.Width / 2;
                            int sampleY;
                            if (group.LegendClasses.Length == 1) {
                                sampleY = colors.Height / 2;
                            } else {
                                sampleY = (int)(3 + ((colors.Height - 6) * (i / (group.LegendClasses.Length - 1.0))));
                            }
                            System.Drawing.Color fc = colors.GetPixel(sampleX, sampleY);
                            result.Append("\"FillColor\":{\"r\":");
                            result.Append(fc.R);
                            result.Append(",\"g\":");
                            result.Append(fc.G);
                            result.Append(",\"b\":");
                            result.Append(fc.B);
                            result.Append("}}");
                        }
                        result.Append("]}");
                    }
                    result.Append("]}");
                }
                result.Append("]");
            }
            return result;
        }
Exemplo n.º 9
0
 public static Bitmap GetLegendImage(string serviceUri,
     int width,
     int height,
     int resolution,
     Font font,
     bool antialias)
 {
     MapServerProxy proxy = new MapServerProxy(serviceUri);
     string mapName = proxy.GetDefaultMapName();
     ImageType imageType = new ImageType();
     imageType.ImageFormat = esriImageFormat.esriImageBMP;
     imageType.ImageReturnType = esriImageReturnType.esriImageReturnMimeData;
     MapServerLegendInfo[] legends = proxy.GetLegendInfo(mapName, null, null, imageType);
     List<Bitmap> legendEntries = new List<Bitmap>();
     Bitmap result = null;
     if (height > 0) {
         result = new Bitmap(width, height);
         result.SetResolution(resolution, resolution);
     }
     if (legends != null && legends.Length > 0) {
         Bitmap scratchBitmap = result;
         if (scratchBitmap == null) {
             scratchBitmap = new Bitmap(width, 500);
             scratchBitmap.SetResolution(resolution, resolution);
         }
         LegendBitmapGenerator gen = new LegendBitmapGenerator(scratchBitmap);
         gen.Margin = 10;
         gen.IndentLevel = 0;
         gen.Font = font;
         gen.Brush = new SolidBrush(System.Drawing.Color.Black);
         gen.Antialias = antialias;
         foreach (MapServerLegendInfo legend in legends) {
             if (legend.Name.Length > 0) {
                 legendEntries.Add(gen.Generate(legend.Name));
             }
             gen.IndentLevel += 1;
             foreach (MapServerLegendGroup group in legend.LegendGroups) {
                 if (group.Heading.Length > 0) {
                     legendEntries.Add(gen.Generate(group.Heading));
                 }
                 gen.IndentLevel += 1;
                 foreach (MapServerLegendClass legendClass in group.LegendClasses) {
                     legendEntries.Add(gen.Generate(new Bitmap(new System.IO.MemoryStream(legendClass.SymbolImage.ImageData)),
                                                    legendClass.Label));
                 }
                 gen.IndentLevel -= 1;
             }
             gen.IndentLevel -= 1;
         }
         gen.Dispose();
     }
     int legendEntryPadding = 2;
     if (result == null) {
         height = legendEntryPadding;
         foreach (Bitmap entry in legendEntries) {
             height += legendEntryPadding + entry.Height;
         }
         result = new Bitmap(width, height);
         result.SetResolution(resolution, resolution);
     }
     int currentY = legendEntryPadding;
     Graphics graphics = Graphics.FromImage(result);
     graphics.Clear(System.Drawing.Color.White);
     foreach (Bitmap entry in legendEntries) {
         if ((currentY + entry.Height) <= height) {
             graphics.DrawImage(entry, 0, currentY);
             currentY += legendEntryPadding + entry.Height;
         }
     }
     graphics.Dispose();
     //result.MakeTransparent(result.GetPixel(0, 0));
     return result;
 }