コード例 #1
0
        public override void GetQueryLayers(GISService service, ref List<GISLayerInfo> layers)
        {
            var activeQuery = from x in service.ActiveLayers where x.IsQueryable select x;

            if (activeQuery.Count() > 0)
            {
                layers = activeQuery.ToList();
                return;
            }

            activeQuery = from x in service.ActiveLayers where ((EsriLayerInfo)x).FeatureCount > 0 select x;

            if (activeQuery.Count() > 0)
            {
                layers = activeQuery.ToList();
                return;
            }

            if (service.HasLayers || GetServiceDetails(service).Result)
            {
                foreach (EsriLayerInfo info in service.BaseLayers)
                {
                    if (!layers.Contains(info) && info.IsQueryable) layers.Add(info);
                }
            }
        }
コード例 #2
0
        public override string GetMapImage(GISService activeService, List<GISLayerInfo> mapLayers, GISEnvelope mapEnvelope, double zoomLevel, int width, int height)
        {
            List<OGCLayer> ogcmapLayers = new List<OGCLayer>();

            if (!mapLayers.Any())
            {
                List<OGCLayer> ogcLayers = new List<OGCLayer>();
                var layerList = activeService.BaseLayers.ToList();

                foreach (GISLayerInfo layer in layerList)
                {
                    ogcLayers.Add(layer as OGCLayer);
                }

                ogcmapLayers = ogcLayers;
            }
            else
            {
                foreach (var l in mapLayers)
                {
                    if (l is OGCLayer)
                    {
                        ogcmapLayers.Add(l as OGCLayer);
                    }
                    else
                    {
                        ogcmapLayers.Add(new OGCLayer(l.Name, l.Id));
                    }
                }
            }

            return GetUrl(OGC_OPERATION.GetMap, OGC_SERVICE_TYPE.WMS, activeService as OGCService, ogcmapLayers, new OGCEnvelope(mapEnvelope), width, height);
        }
コード例 #3
0
 public override void GetQueryLayers(GISService service, ref List<GISLayerInfo> layers)
 {
     if (service.HasLayers || GetServiceDetails(service).Result)
     {
         layers.AddRange(service.BaseLayers);
     }
 }
コード例 #4
0
 public override void GetImageLayers(GISService service, List<GISLayerInfo> layers)
 {
     if (service.HasLayers || GetServiceDetails(service).Result)
     {
         foreach (GISLayerInfo info in service.BaseLayers)
         {
             if (!layers.Contains(info)) layers.Add(info);
         }
     }
 }
コード例 #5
0
        public override string GetMapImage(GISService activeService, List<GISLayerInfo> mapLayers, GISEnvelope mapEnvelope, double zoomLevel, int height, int width)
        {
            //http://basemap.nationalmap.gov/ArcGIS/rest/services/USGSTopo/MapServer/export?bbox=-15809463.2958818%2C2409214.11633487%2C-7845336.4447948%2C7007665.73796985&bboxSR=&layers=&layerdefs=&size=250%2C250&imageSR=&format=png&transparent=false&dpi=&time=&layerTimeOptions=&f=image

            EsriEnvelope imageEnvelope = new EsriEnvelope(mapEnvelope);
            string activeServiceName = activeService.Id.IndexOf("__") > 0 ? activeService.Id.Substring(0, activeService.Id.IndexOf("__")) : activeService.Id;
            string requestUrl = activeService.ServiceType == ServiceType.MapServer ? String.Format(IMAGE_URL, Server.Host, activeServiceName, activeService.ServiceType, imageEnvelope.ToJSON(), height, width, Server.ServletPath, BuildLayers(mapLayers), "image")
                : String.Format(EXPORT_IMAGE_URL, Server.Host, activeServiceName, activeService.ServiceType, imageEnvelope.ToJSON(), height, width, Server.ServletPath, BuildLayers(mapLayers), "image");

            return requestUrl;
        }
コード例 #6
0
        public override bool GetMap(GISService activeService, double centerX, double centerY, double zoomLevel)
        {
            //double logZoom = Math.Log10(zoomLevel);

            //if (zoomLevel > 0 && logZoom < .1)
            //{
            //    zoomLevel = Math.Pow(10, .5 * 1.1);
            //}
            //else if (zoomLevel > 0)
            //{
            //    //GISEnvelope mapEnvelope = GetTileEnvelope(centerX, centerY, (int)zoomLevel);
            //    zoomLevel = Math.Pow(10, logZoom * 1.1);
            //}

            GISEnvelope mapEnvelope = BuildEnvelope(centerX, centerY, SelectEnvelope(activeService), zoomLevel);
            TransformEnvelope(ref mapEnvelope);

            if (activeService._activeLayers.Count == 0) activeService.ActiveLayers.AddRange(activeService.BaseLayers);

            //string currentlayerId = activeService.ActiveLayers.Count > 0 ? activeService.ActiveLayers[0]._id : string.Empty;
            //string styleId = activeService.ActiveLayers.Count > 0 ? (activeService.ActiveLayers[0] as OGCLayer).Style : string.Empty;

            //for (int i = 1; i < activeService.ActiveLayers.Count; i++)
            //{
            //    currentlayerId = string.Format("{0},{1}", currentlayerId, activeService.ActiveLayers[i]._id);
            //}

            //for (int i = 1; i < activeService.ActiveLayers.Count; i++)
            //{
            //    if (!string.IsNullOrEmpty((activeService.ActiveLayers[i] as OGCLayer).Style))
            //    {
            //        styleId = string.Format("{0},{1}", styleId, (activeService.ActiveLayers[i] as OGCLayer).Style);
            //    }
            //}

            string mapUrl = GetUrl(OGC_OPERATION.GetMap, OGC_SERVICE_TYPE.WMS, activeService as OGCService, activeService.ActiveLayers.Cast<OGCLayer>(), new OGCEnvelope(mapEnvelope), _imageWidth, _imageHeight);
            return GetMap(activeService, activeService.ActiveLayers, mapEnvelope, zoomLevel, mapUrl);
        }
コード例 #7
0
        public override bool GetMap(GISService activeService, double centerX, double centerY, double zoomLevel)
        {
            zoomLevel = Math.Min(MaxZoom, Math.Max(MinZoom, zoomLevel));
            if (activeService.ActiveLayers.Count == 0 && activeService._baseLayers.Count > 0) activeService.ActiveLayers.Add(activeService._baseLayers[0]);

            GISEnvelope mapEnvelope = BuildEnvelope(centerX, centerY, SelectEnvelope(activeService), zoomLevel);

            EsriEnvelope env = new EsriEnvelope(mapEnvelope.minX, mapEnvelope.maxX, mapEnvelope.minY, mapEnvelope.maxY);
            string activeServiceName = activeService.Id.IndexOf("__") > 0 ? activeService.Id.Substring(0, activeService.Id.IndexOf("__")) : activeService.Id;
            string requestUrl = activeService.ServiceType == ServiceType.MapServer ? String.Format(IMAGE_URL, Server.Host, activeServiceName, activeService.ServiceType, env.ToJSON(), _imageWidth, _imageHeight, Server.ServletPath, BuildLayers(activeService.ActiveLayers), "json")
                : String.Format(EXPORT_IMAGE_URL, Server.Host, activeServiceName, activeService.ServiceType, env.ToJSON(), _imageWidth, _imageHeight, Server.ServletPath, BuildLayers(activeService.ActiveLayers), "json");

            return GetMap(activeService, activeService.ActiveLayers, mapEnvelope, zoomLevel, requestUrl);
        }
コード例 #8
0
        public override bool GetMap(GISService activeService, List<GISLayerInfo> mapLayers, GISEnvelope mapEnvelope, double zoomLevel, string requestXml)
        {
            string requestUrl = String.Format(SERVICE_URL, Server.Host, Server.ServletPath, activeService.Id, Server.UseForm, Server.Version);
            XmlReader responseString = null;
            EsriImageResponse response = new EsriImageResponse();

            try
            {
                response.Envelope = mapEnvelope;
                response._layers.AddRange(mapLayers);
                response.LastRequest = requestXml;
                response._mapImageUrl = requestUrl;
                response.ZoomLevel = zoomLevel;

                // http://websig.hidrografico.pt/servlet/com.esri.esrimap.Esrimap?ServiceName=ICENCUK&ClientVersion=4.0&Form=True&Encode=False
                webClient.PostRequest(requestUrl, Server.UseForm ? ApplyFormEncoding(requestXml) : requestXml, ProcessImageReturn, response);
                return true;
            }
            catch (Exception ex)
            {
                return false; // new GISResponse() { _envelope = mapEnvelope, _layers = mapLayers, ErrorMessage = ex.Message, HasError = true, LastRequest = requestXml, LastResponse = Return };
                //return GISResponse.ProcessErrorResponse("The last map request failed: " + ex.Message, Request, Return);
            }
            finally
            {
                //if (responseString != null) responseString.Close();
            }
        }
コード例 #9
0
        public override bool GetMap(GISService activeService, GISEnvelope mapEnvelope, List<GISLayerInfo> mapLayers)
        {
            List<GISLayerInfo> totalLayers = GetTotalLayers(activeService);

            return GetMap(activeService, totalLayers, mapEnvelope, SetZoomLevel(mapEnvelope, activeService._baseExtent), BuildRequest(ImageHeight, ImageWidth, mapEnvelope, totalLayers));
        }
コード例 #10
0
        public override bool GetMap(GISService activeService)
        {
            GISEnvelope imageEnvelope = SelectEnvelope(activeService);

            return GetMap(activeService, imageEnvelope);
        }
コード例 #11
0
        public override async Task<bool> GetServiceDetails(GISService activeService)
        {
            if (activeService.HasLayers) return true;

            // http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_1990-2000_Population_Change/MapServer?f=json
            string requestUrl = String.Format(SERVICE_LAYER_URL, Server.Host, activeService._serviceName, activeService._type, Server.ServletPath);

            try
            {
                var result = await webClient.GetRequestAsync(requestUrl);
                ProcessServiceDetailReturn(activeService, result.output);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
コード例 #12
0
        private void ProcessServiceDetailReturn(GISService svc, string responseString)
        {
            GISResponse response = new GISResponse();
            response.LastResponse = responseString;

            try
            {
                Nii.JSON.JSONObject responseReader = new Nii.JSON.JSONObject(responseString);

                Server._lastUpdated = DateTime.Now;

                EsriService.AddServiceInfo(svc, responseReader);
                Server.RaiseServiceDetailResponse(svc);
            }
            catch (Exception ex)
            {
                response.HasError = true;
                response.ErrorMessage = ex.Message;
                response = GISResponse.ProcessErrorResponse(ex.Message, response.LastRequest, responseString);
                Server.RaiseErrorResponse(response);
            }
        }
コード例 #13
0
        public override bool GetMap(GISService activeService, List<GISLayerInfo> mapLayers, GISEnvelope mapEnvelope, double zoomLevel, string requestString)
        {
            EsriImageResponse response = new EsriImageResponse();

            try
            {
                response.Envelope = mapEnvelope;
                response._layers.AddRange(mapLayers);
                response.LastRequest = requestString;
                response._mapImageUrl = requestString;
                response.ZoomLevel = zoomLevel;

                webClient.GetRequest(requestString, ProcessImageReturn, response);
                return true;
            }
            catch (System.Exception ex)
            {
                Server.RaiseErrorResponse(new GISResponse() { LastResponse = ex.Message, ErrorMessage = ex.Message, HasError = true, LastRequest = requestString, _envelope = response.Envelope, _layers = mapLayers });
                return false;
            }
        }
コード例 #14
0
        private List<GISLayerInfo> GetTotalLayers(GISService activeService)
        {
            List<GISLayerInfo> totalLayers = new List<GISLayerInfo>();
            totalLayers.AddRange(activeService.ActiveLayers);

            foreach (GISLayerInfo info in activeService._baseLayers)
            {
                if (!totalLayers.Contains(info) && info._isVisible == true)
                {
                    totalLayers.Add(CreateLayer(info._name, info._id, false));
                }
            }

            return totalLayers;
        }
コード例 #15
0
        public override bool GetMap(GISService activeService, GISEnvelope imageEnvelope, List<GISLayerInfo> mapLayers)
        {
            string requestUrl = string.Empty;

            try
            {
                List<GISLayerInfo> totalLayers = GetTotalLayers(activeService);

                EsriEnvelope mapEnvelope = new EsriEnvelope(imageEnvelope);
                requestUrl = activeService.ServiceType == ServiceType.MapServer ? String.Format(IMAGE_URL, Server.Host, activeService.Name, activeService.ServiceType, mapEnvelope.ToJSON(), _imageWidth, _imageHeight, Server.ServletPath, BuildLayers(mapLayers), "json")
                    : String.Format(EXPORT_IMAGE_URL, Server.Host, activeService.Name, activeService.ServiceType, mapEnvelope.ToJSON(), _imageWidth, _imageHeight, Server.ServletPath, BuildLayers(mapLayers), "json");

                return GetMap(activeService, totalLayers, mapEnvelope, SetZoomLevel(mapEnvelope, activeService._baseExtent), requestUrl);
            }
            catch (System.Exception ex)
            {
                Server.RaiseErrorResponse(new GISResponse() { LastResponse = ex.Message, ErrorMessage = ex.Message, HasError = true, LastRequest = requestUrl, _envelope = imageEnvelope, _layers = mapLayers });
                return false;
            }
        }
コード例 #16
0
        public override bool GetMap(GISService activeService, List<GISLayerInfo> mapLayers, GISEnvelope mapEnvelope, double zoomLevel, string requestString)
        {
            OGCImageResponse response = new OGCImageResponse();

            try
            {
                response.Envelope = mapEnvelope;
                response.Layers = mapLayers;
                OGCEnvelope ogcEnvelope = new OGCEnvelope(mapEnvelope);

                //string currentlayerId = mapLayers[0]._id;
                //string styleId = (mapLayers[0] as OGCLayer).Style;

                //for (int i = 1; i < mapLayers.Count; i++)
                //{
                //    currentlayerId = string.Format("{0},{1}", currentlayerId, mapLayers[i]._id);
                //}

                //for (int i = 1; i < mapLayers.Count; i++)
                //{
                //    if (!string.IsNullOrEmpty((mapLayers[i] as OGCLayer).Style))
                //    {
                //        styleId = string.Format("{0},{1}", styleId, (mapLayers[i] as OGCLayer).Style);
                //    }
                //}

                response.LastRequest = requestString;

                response.LastResponse = "Complete";
                response._mapImageUrl = requestString;
                response.ZoomLevel = zoomLevel;
                Server.RaiseMapResponse(response);
                return true;
            }
            catch (System.Exception ex)
            {
                Server.RaiseErrorResponse(new GISResponse() { LastResponse = ex.Message, ErrorMessage = ex.Message, HasError = true, LastRequest = requestString, _envelope = response.Envelope, _layers = mapLayers });
            }

            return false;
        }
コード例 #17
0
        //        private static XmlSerializer _info = new XmlSerializer(typeof(SERVICEINFO));

        public override async Task<bool> GetServiceDetails(GISService activeService)
        {
            string requestUrl = String.Format(SERVICE_URL, Server.Host, Server.ServletPath, activeService.Name, false, Server.Version);

            try
            {
                webClient.PostRequest(requestUrl, Server.UseForm ? ApplyFormEncoding(GET_SERVICE_INFO) : GET_SERVICE_INFO, ProcessServiceDetailReturn, activeService);
                return true;
            }
            catch (Exception ex)
            {
                //_returnString = string.Format("{0}: {1}", ex.Message, _returnString);
                return false;
            }
            finally
            {
                //if (responseString != null) responseString.Close();
            }
        }
コード例 #18
0
        public override void GetQueryLayers(GISService service, ref List<GISLayerInfo> layers)
        {
            foreach (GISLayerInfo info in (service as OGCService).ActiveLayers)
            {
                if (!layers.Contains(info) && info.IsQueryable) layers.Add(info);
            }

            foreach (GISLayerInfo info in (service as OGCService).BaseLayers)
            {
                if (!layers.Contains(info) && info.IsQueryable) layers.Add(info);
            }
        }
コード例 #19
0
        public override bool GetMap(GISService activeService, double centerX, double centerY, double zoomLevel)
        {
            GISEnvelope mapEnvelope = BuildEnvelope(centerX, centerY, SelectEnvelope(activeService), zoomLevel);
            List<GISLayerInfo> totalLayers = new List<GISLayerInfo>();// GetTotalLayers(activeService);

            return GetMap(activeService, totalLayers, mapEnvelope, zoomLevel, BuildRequest(ImageHeight, ImageWidth, mapEnvelope, totalLayers));
        }
コード例 #20
0
 public override async Task<bool> GetServiceDetails(GISService activeService)
 {
     return ((activeService == null && GetClientServices().Result) || activeService.HasLayers);
 }
コード例 #21
0
        private List<GISLayerInfo> GetTotalLayers(GISService activeService)
        {
            List<GISLayerInfo> totalLayers = new List<GISLayerInfo>();

            var visibleLayers = from x in activeService._baseLayers where x._isVisible select x;
            int count = visibleLayers.Count();

            if (activeService.ActiveLayers.Count > 0)
            {
                totalLayers.AddRange(activeService.ActiveLayers);

                if (count > 0)
                {
                    foreach (GISLayerInfo info in visibleLayers)
                    {
                        if (!totalLayers.Contains(info))
                        {
                            totalLayers.Add(CreateLayer(info._name, info._id, false));
                        }
                    }
                }
            }
            else
            {
                foreach (GISLayerInfo info in activeService._baseLayers)
                {
                    if (!totalLayers.Contains(info))
                    {
                        totalLayers.Add(info);
                    }
                }
            }

            return totalLayers;
        }
コード例 #22
0
        public override bool GetMap(GISService activeService)
        {
            GISEnvelope imageEnvelope = SelectEnvelope(activeService);

            TransformEnvelope(ref imageEnvelope);

            //if (activeService.ActiveLayers.Count == 0 && activeService.BaseLayers.Count > 0) activeService.ActiveLayers.Add(activeService.BaseLayers[0]);
            return GetMap(activeService, imageEnvelope);
        }
コード例 #23
0
        public override bool GetMap(GISService activeService, GISEnvelope imageEnvelope)
        {
            OGCImageResponse response = new OGCImageResponse();

            if (activeService.HasLayers || GetServiceDetails(activeService).Result)
            {
                if (activeService._activeLayers.Count == 0)
                {
                    for (int i = 0; i < activeService._baseLayers.Count; i++)
                    {
                        if (activeService._baseLayers[i].IsVisible && activeService._baseLayers[i]._baseExtent != null)
                        {
                            activeService._activeLayers.Add(activeService._baseLayers[i]);
                        }
                    }
                }

                return GetMap(activeService, imageEnvelope, activeService._activeLayers.ToList());
            }
            else
            {
                Server.RaiseErrorResponse(GISResponse.ProcessErrorResponse("Services could not be located for this server at this time.", "", ""));
                return false;
            }
        }
コード例 #24
0
        public override bool GetMap(GISService activeService, GISEnvelope mapEnvelope, List<GISLayerInfo> mapLayers)
        {
            if (mapEnvelope == null) SelectEnvelope(activeService);

            OGCEnvelope ogcEnvelope = new OGCEnvelope(mapEnvelope);

            if (activeService.HasLayers || GetServiceDetails(activeService).Result)
            {
                if (mapLayers.Count == 0)
                {
                    mapLayers.Add(activeService.BaseLayers[0]);
                }

                //string currentlayerId = mapLayers[0]._id;
                //string styleId = (mapLayers[0] as OGCLayer).Style;
                GISEnvelope maxEnvelope = activeService._baseExtent;
                if (mapLayers.Count > 0) maxEnvelope = mapLayers[0]._baseExtent;

                //for (int i = 1; i < mapLayers.Count; i++)
                //{
                //    currentlayerId = string.Format("{0},{1}", currentlayerId, mapLayers[i]._id);
                //    if (mapLayers[i]._baseExtent != null) maxEnvelope = mapLayers[i]._baseExtent;
                //}

                //for (int i = 1; i < mapLayers.Count; i++)
                //{
                //    styleId = string.Format("{0},{1}", styleId, (mapLayers[i] as OGCLayer).Style);
                //}

                string mapUrl = GetUrl(OGC_OPERATION.GetMap, OGC_SERVICE_TYPE.WMS, activeService as OGCService, mapLayers.Cast<OGCLayer>(), ogcEnvelope, _imageWidth, _imageHeight);
                return GetMap(activeService, mapLayers, mapEnvelope, SetZoomLevel(mapEnvelope, maxEnvelope), mapUrl);
            }
            else
            {
                Server.RaiseErrorResponse(new GISResponse() { Envelope = mapEnvelope, ErrorMessage = "Service details could not be found for this service.", Layers = mapLayers, HasError = true });
                return false;
            }
        }
コード例 #25
0
        public override string GetMapImage(GISService activeService, List<GISLayerInfo> mapLayers, GISEnvelope mapEnvelope, double zoomLevel, int height, int width)
        {
            // http://toposervices.cr.usgs.gov/wmsconnector/com.esri.wms.Esrimap/USGS_EDNA_geo?TRANSPARENT=true&LAYERS=NED_2003_SHADEDRELIEF&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG%3A4326&BBOX=-128.6875,31.425,-111.8125,42.675&WIDTH=768&HEIGHT=512

            StringBuilder layerstring = new StringBuilder();

            if (!mapLayers.Any())
            {
                var layerList = activeService.BaseLayers.Take(Math.Min(activeService.BaseLayers.Count, 5)).ToList();

                foreach (GISLayerInfo layer in layerList)
                {
                    layerstring.AppendFormat("{0},", layer.Id);
                }
            }
            else
            {
                foreach (var l in mapLayers)
                {
                    layerstring.AppendFormat("{0},", l.Id);
                }
            }

            return string.Format("http://{0}/wmsconnector/com.esri.wms.Esrimap/{1}?TRANSPARENT=true&LAYERS={2}&SERVICE=WMS&VERSION={3}&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS={4}&BBOX={5}&WIDTH={6}&HEIGHT={7}", Server.Host, activeService.Name, layerstring, Server.Version, mapEnvelope.CoordinateSystem, mapEnvelope.ToBBoxString(), width, height);
        }
コード例 #26
0
        public override bool GetMap(GISService activeService, GISEnvelope imageEnvelope)
        {
            EsriEnvelope mapEnvelope = new EsriEnvelope(imageEnvelope);
            string activeServiceName = activeService.Id.IndexOf("__") > 0 ? activeService.Id.Substring(0, activeService.Id.IndexOf("__")) : activeService.Id;
            string requestUrl = activeService.ServiceType == ServiceType.MapServer ? String.Format(IMAGE_URL, Server.Host, activeServiceName, activeService.ServiceType, mapEnvelope.ToJSON(), _imageWidth, _imageHeight, Server.ServletPath, BuildLayers(activeService.ActiveLayers), "json")
                : String.Format(EXPORT_IMAGE_URL, Server.Host, activeServiceName, activeService.ServiceType, mapEnvelope.ToJSON(), _imageWidth, _imageHeight, Server.ServletPath, BuildLayers(activeService.ActiveLayers), "json");

            return GetMap(activeService, activeService.ActiveLayers, mapEnvelope, SetZoomLevel(mapEnvelope, SelectEnvelope(activeService)), requestUrl);
        }