// <?xml version="1.0" encoding="UTF-8"?> public override bool Identify(int xpoint, int ypoint, double centerY, double centerX, GISEnvelope envelope, GISLayerInfo featureLayer) { int maxFeaturesReturned = 20; string requestUrl = String.Format(QUERY_URL, Server.Host, Server.ServletPath, Server.ActiveService.Id, false, Server.Version); GISEnvelope mapEnvelope = BuildEnvelope(centerX, centerY, SelectEnvelope(Server.ActiveService), 99); string requestXml = BuildQuery(featureLayer, maxFeaturesReturned, mapEnvelope); EsriFeatureResponse response = new EsriFeatureResponse(); response._envelope = mapEnvelope; response._layers = new List<GISLayerInfo>() { featureLayer }; response.HasError = false; response.LastRequest = requestXml; webClient.PostRequest(requestUrl, Server.UseForm ? ApplyFormEncoding(requestXml) : requestXml, ProcessServiceReturn, response); return true; }
public override IGISLegend GetLegend(GISLayerInfo selectedLayer) { try { System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient(); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0"); System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> response = httpClient.GetAsync(string.Empty); System.Threading.Tasks.Task<string> responseBody = response.Result.Content.ReadAsStringAsync(); MemoryStream stream1 = new MemoryStream(); StreamWriter sw = new StreamWriter(stream1); sw.Write(responseBody); System.Runtime.Serialization.Json.DataContractJsonSerializer ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(EsriLegend)); StreamReader sr = new StreamReader(stream1); EsriLegend p2 = (EsriLegend)ser.ReadObject(stream1); return p2; } catch (System.Net.WebException e) { throw e; } catch (Exception ex) { throw ex; } }
public override void ExecuteSearch(string searchTerm, SEARCH_TYPE searchType, GISEnvelope searchArea, GISLayerInfo featureLayer) { int maxFeaturesReturned = 20; string requestUrl = String.Format(QUERY_URL, Server.Host, Server.ServletPath, Server.ActiveService.Id, false, Server.Version); string requestXml = BuildQuery(featureLayer, maxFeaturesReturned, searchArea); EsriFeatureResponse response = new EsriFeatureResponse() { SearchTerm = searchTerm }; response._envelope = searchArea; response._layers = new List<GISLayerInfo>() { featureLayer }; response.HasError = false; response.LastRequest = requestXml; webClient.PostRequest(requestUrl, Server.UseForm ? ApplyFormEncoding(requestXml) : requestXml, ProcessSearchReturn, response); }
private string BuildQuery(GISLayerInfo queryLayer, int maxFeaturesReturned, GISEnvelope spatialQuery) { StringBuilder queryString = new StringBuilder(); StringWriter messageString = new StringWriter(queryString); XmlWriter queryWriter = XmlWriter.Create(messageString); queryWriter.WriteStartElement("ARCXML"); queryWriter.WriteAttributeString("", "VERSION", "", "1.1"); queryWriter.WriteStartElement("REQUEST"); queryWriter.WriteStartElement("GET_FEATURES"); queryWriter.WriteAttributeString("", "outputmode", "", "xml"); queryWriter.WriteAttributeString("", "geometry", "", "false"); queryWriter.WriteAttributeString("", "envelope", "", "true"); queryWriter.WriteAttributeString("", "beginrecord", "", "0"); queryWriter.WriteAttributeString("", "checkesc", "", "true"); queryWriter.WriteAttributeString("", "compact", "", "true"); queryWriter.WriteStartElement("LAYER"); queryWriter.WriteAttributeString("", "id", "", queryLayer.Id); queryWriter.WriteAttributeString("", "name", "", queryLayer.Name); queryWriter.WriteEndElement(); queryWriter.WriteStartElement("SPATIALQUERY"); queryWriter.WriteAttributeString("", "subfields", "", "#ALL#"); queryWriter.WriteStartElement("SPATIALFILTER"); queryWriter.WriteAttributeString("", "relation", "", "area_intersection"); EsriEnvelope.AsXml(queryWriter, spatialQuery); queryWriter.WriteEndElement(); // SPATIALFILTER queryWriter.WriteEndElement(); // SPATIALQUERY //queryWriter.WriteEndElement(); // PROPERTIES queryWriter.WriteEndElement(); // GET_FEATURES queryWriter.WriteEndElement(); // REQUEST queryWriter.WriteEndElement(); // ARCXML queryWriter.Flush(); return queryString.ToString(); }
public override IGISLegend GetLegend(GISLayerInfo selectedLayer) { string legendUrl = GetUrl(OGC_OPERATION.GetLegendGraphic, OGC_SERVICE_TYPE.WMS, Server.ActiveService as OGCService, new List<OGCLayer>(){selectedLayer as OGCLayer}, new OGCEnvelope(), _imageWidth, _imageHeight); return new GISLegend() { LegendUrl = legendUrl }; }
public override bool Identify(int xpoint, int ypoint, double latitude, double longitude, GISEnvelope envelope, GISLayerInfo featureLayer) { // http://maps.google.com/maps/api/geocode/xml?latlng=40.714224,-73.961452&sensor=true try { if (featureLayer == null) return false; envelope = new OGCEnvelope(envelope); //string layerString = featureLayer.Id; string requestUrl = GetUrl(OGC_OPERATION.GetFeatureInfo, OGC_SERVICE_TYPE.WMS, Server.ActiveService as OGCService, new List<OGCLayer>() { featureLayer as OGCLayer }, envelope as OGCEnvelope, _imageWidth, _imageHeight, xpoint, ypoint); GISFeatureResponse response = new GISFeatureResponse(); response._envelope = BuildEnvelope(longitude, latitude, envelope, Server.MaxZoom * .9); response._layers = new List<GISLayerInfo>() { featureLayer }; response.HasError = false; response.LastRequest = requestUrl; webClient.GetRequest(requestUrl, ProcessQueryResponse, response); return true; } catch (Exception ex) { return false; } }
public override void ExecuteSearch(string searchTerm, SEARCH_TYPE searchType, GISEnvelope searchArea, GISLayerInfo featureLayer) { if (searchType == SEARCH_TYPE.Geocode) { // http://{0}/{1}?SERVICE={2}&VERSION={3}&REQUEST=GetFeatureInfo&LAYERS={4}&QUERY_LAYERS={4}&STYLES=&BBOX={5}&FEATURE_COUNT=10&HEIGHT={6}&WIDTH={7}&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fxml&SRS={8}&X={9}&Y={10} OGCEnvelope envelope = new OGCEnvelope(searchArea); string requestUrl = string.Format(FEATURE_INFO_URL, Server.Host, Server.ServletPath, OGC_SERVICE_TYPE.WMS, Server.Version, (featureLayer as OGCLayer).Id, (envelope as OGCEnvelope).ToBBoxString(), _imageHeight, _imageWidth, searchArea.CoordinateSystem, _imageWidth / 2, _imageHeight / 2); GISFeatureResponse response = new GISFeatureResponse(); response._envelope = searchArea; response._layers = new List<GISLayerInfo>() { featureLayer }; response.HasError = false; response.LastRequest = requestUrl; webClient.GetRequest(requestUrl, ProcessQueryResponse, response); } else { List<GISLayerInfo> layers = new List<GISLayerInfo>(); GetQueryLayers(Server.ActiveService, ref layers); string queryLayers = string.Empty; foreach (GISLayerInfo layer in layers) { queryLayers += layer.Id; } string requestUrl = GetUrl(OGC_OPERATION.GetFeatureInfo, OGC_SERVICE_TYPE.WMS, Server.ActiveService as OGCService, queryLayers.Cast<OGCLayer>(), new OGCEnvelope(searchArea), _imageWidth, _imageHeight); //http://<hostname>/<deploy_name>/com.esri.wms.Esrimap?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&SRS=EPSG:4326&BBOX=-117,38,-90,49&WIDTH=600&HEIGHT=400&QUERY_LAYERS=States&X=200&Y=150& GISFeatureResponse response = new GISFeatureResponse() { SearchTerm = searchTerm }; response._envelope = new GISEnvelope(); response._layers = new List<GISLayerInfo>() { new OGCLayer("Search", "Search") }; response.HasError = false; response.LastRequest = requestUrl; webClient.GetRequest(requestUrl, ProcessSearchResponse, response); } }
public override IGISLegend GetLegend(GISLayerInfo selectedLayer) { EsriLegend response = new EsriLegend(); try { string legendUrl = String.Format(LEGEND_URL, Server.Host, Server.ServletPath, Server.ActiveService.Id, Server.ActiveService.ServiceType); Task<WebResponseResult> resp = webClient.GetRequestAsync(legendUrl); System.Runtime.Serialization.Json.DataContractJsonSerializer ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(EsriLegend)); MemoryStream mem = new MemoryStream(Encoding.UTF8.GetBytes(resp.Result.output)); response = (EsriLegend)ser.ReadObject(mem); } catch (System.Exception ex) { //throw ex; } return response; }
public override bool Identify(int xpoint, int ypoint, double latitude, double longitude, GISEnvelope envelope, GISLayerInfo featureLayer) { try { // http://{0}/ArcGIS/rest/services/{1}/{2}/identify?geometryType=esriGeometryPoint&geometry={{x:{3}, y:{4} }}&wkid={5}&layers=all:{6}&tolerance=10&mapExtent={7}&imageDisplay={8},{9},96&returnGeometry=true string layerid = featureLayer.Id; string requestUrl = string.Format(IDENTIFY_URL, _Server.Host, _Server.ActiveService.Id, _Server.ActiveService.ServiceType, longitude, latitude, envelope.CoordinateSystem, layerid, envelope.ToString(), _imageHeight, _imageWidth, Server.ServletPath); GISFeatureResponse response = new GISFeatureResponse(); response._envelope = BuildEnvelope(longitude, latitude, SelectEnvelope(Server.ActiveService), MaxZoom - 2); response._layers = new List<GISLayerInfo>() { featureLayer }; response.HasError = false; response.LastRequest = requestUrl; webClient.GetRequest(requestUrl, ProcessIdentifyResponse, response); return true; } catch (Exception ex) { Server.RaiseErrorResponse(new GISResponse() { _envelope = null, _layers = new List<GISLayerInfo>() { new EsriLayerInfo() { _name = "Search", _type = "Search" } }, ErrorMessage = ex.Message }); return false; } }
private JSONObject BuildQuery(GISLayerInfo queryLayer, int maxFeaturesReturned, GISEnvelope queryEnvelope) { return new JSONObject(); }
public override void ExecuteSearch(string searchTerm, SEARCH_TYPE searchType, GISEnvelope searchArea, GISLayerInfo featureLayer) { string activeServiceName = Server.ActiveService.Name.IndexOf("__") > 0 ? Server.ActiveService.Name.Substring(0, Server.ActiveService.Name.IndexOf("__")) : Server.ActiveService.Name; EsriEnvelope queryEnvelope = new EsriEnvelope(searchArea); string requestUrl = string.Empty; if (searchType == SEARCH_TYPE.Geocode) { //http://planthardiness.ars.usda.gov/ArcGIS/rest/services/uspz/MapServer/identify?geometryType=esriGeometryPoint&geometry=-120%2C40&tolerance=10&mapExtent=-119%2C38%2C-121%2C41&imageDisplay=400%2C300%2C96 //http://services.arcgisonline.com/ArcGIS/rest/services/Specialty/Soil_Survey_Map/MapServer/identify?geometryType=esriGeometryPoint&geometry=19.23865%2C48.23152&sr=102100&layers=0&time=&layerTimeOptions=&layerdefs=&tolerance=100&mapExtent=19.23865%2C48.23152%2C19.23865%2C48.23152&imageDisplay=600%2C550%2C96&returnGeometry=true&maxAllowableOffset=&f=json requestUrl = String.Format(GEOCODE_URL, Server.Host, Server.ServletPath, activeServiceName, searchArea.CenterX, searchArea.CenterY); } else if (searchType == SEARCH_TYPE.Identify) { //http://planthardiness.ars.usda.gov/ArcGIS/rest/services/uspz/MapServer/identify?geometryType=esriGeometryPoint&geometry=-120%2C40&tolerance=10&mapExtent=-119%2C38%2C-121%2C41&imageDisplay=400%2C300%2C96 //http://services.arcgisonline.com/ArcGIS/rest/services/Specialty/Soil_Survey_Map/MapServer/identify?geometryType=esriGeometryPoint&geometry=19.23865%2C48.23152&sr=102100&layers=0&time=&layerTimeOptions=&layerdefs=&tolerance=100&mapExtent=19.23865%2C48.23152%2C19.23865%2C48.23152&imageDisplay=600%2C550%2C96&returnGeometry=true&maxAllowableOffset=&f=json requestUrl = String.Format(GEOCODE_URL, Server.Host, Server.ServletPath, activeServiceName, searchArea.CenterX, searchArea.CenterY); } else { requestUrl = String.Format(QUERY_URL, Server.Host, activeServiceName, Server.ActiveService.ServiceType, Server.ActiveService.BaseLayers[0].Id, queryEnvelope.ToJSON(), Server.ServletPath); } EsriFeatureResponse response = new EsriFeatureResponse(); response._envelope = searchArea; response._layers = new List<GISLayerInfo>() { featureLayer }; response.HasError = false; response.LastRequest = requestUrl; try { webClient.GetRequest(requestUrl, new EventHandler<WebEventArgs>(ProcessQueryReturn), response); //wc.DownloadStringAsync(new Uri(requestUrl), new AsyncState() { Response = response, CurrentState = Server.ActiveService }); } catch (Exception ex) { Server.RaiseSearchResponse(new GISResponse() { HasError = true, ErrorMessage = string.Format("{0}: {1}", ex.Message), LastRequest = requestUrl, LastResponse = string.Empty, _layers = new List<GISLayerInfo>() { Server.ActiveService.BaseLayers[0] }, _envelope = queryEnvelope }); } }