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); }
// <?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 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 }); } }