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); }
public IQueryOver <TEntity, TEntity> FilterForBoundingBox(IQueryOver <TEntity, TEntity> queryOver, TReportParameter parameter) { var filterGeom = GISService.GetGeometryFromBoundingBox(parameter.BoundingBox); queryOver.UnderlyingCriteria.Add(SpatialRestrictions.Filter(ExpressionHelper.GetPropertyName <StrassenabschnittGIS, IGeometry>(e => e.Shape), filterGeom)); return(queryOver); }
public override void GetQueryLayers(GISService service, ref List<GISLayerInfo> layers) { if (service.HasLayers || GetServiceDetails(service).Result) { layers.AddRange(service.BaseLayers); } }
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); } } }
public IList <MassnahmenvorschlagTeilsystemeGIS> GetAllKoordinierteMassnahmenAt(double x, double y, double tolerance) { IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0)); var buffer = clickedPoint.Buffer(tolerance); IList <MassnahmenvorschlagTeilsystemeGIS> koordinierteMassnahmenliste = GetBySpatialFilter(buffer).Where(mts => mts.Status != EMSG.Common.Enums.StatusTyp.Abgeschlossen).ToList(); return(koordinierteMassnahmenliste); }
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); } } }
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; }
public void SplitStrassenabschnittGISAtXY(Guid strassenabschnittId, string x, string y) { StrassenabschnittGIS strassenabschnittToSplit = GetEntityById(strassenabschnittId); //check whether the strassenabschnitt (inspektionsroute) is checked out (=locked) if (strassenabschnittToSplit.IsLocked) { return; } //1. find achsenref. to split IGeometry splitPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate(double.Parse(x, System.Globalization.NumberFormatInfo.InvariantInfo), double.Parse(y, System.Globalization.NumberFormatInfo.InvariantInfo), 0)); AchsenReferenz achsenreferenceToSplit = gisService.GetNearestGeometry(splitPoint, strassenabschnittToSplit.ReferenzGruppe.AchsenReferenzen); //2. split achsenref LengthIndexedLine line = new LengthIndexedLine(achsenreferenceToSplit.Shape); IGeometry split1 = line.ExtractLine(0, line.IndexOf(splitPoint.Coordinate)); IGeometry split2 = line.ExtractLine(line.IndexOf(splitPoint.Coordinate), line.EndIndex); //create new strassenabschnitte StrassenabschnittGIS copiedStrassenabschnittGIS1 = PrepareNewStrassenabschnitt(strassenabschnittToSplit, achsenreferenceToSplit, split1); StrassenabschnittGIS copiedStrassenabschnittGIS2 = PrepareNewStrassenabschnitt(strassenabschnittToSplit, achsenreferenceToSplit, split2); //3. relate other achsenrefs to the new two references foreach (AchsenReferenz achsref in strassenabschnittToSplit.ReferenzGruppe.AchsenReferenzen.Where(ac => !ac.Equals(achsenreferenceToSplit))) { if (achsref.Shape.Distance(split1) <= achsref.Shape.Distance(split2)) { copiedStrassenabschnittGIS1.ReferenzGruppe.AddAchsenReferenz(PrepareAchsenreferenz(achsref)); copiedStrassenabschnittGIS1.Shape = copiedStrassenabschnittGIS1.Shape.Union(achsref.Shape); } else { copiedStrassenabschnittGIS2.ReferenzGruppe.AddAchsenReferenz(PrepareAchsenreferenz(achsref)); copiedStrassenabschnittGIS2.Shape = copiedStrassenabschnittGIS2.Shape.Union(achsref.Shape); } } copiedStrassenabschnittGIS1.Laenge = getLength(copiedStrassenabschnittGIS1); copiedStrassenabschnittGIS2.Laenge = getLength(copiedStrassenabschnittGIS2); //update inspektionsroute strassenabschnittToSplit.InspektionsRtStrAbschnitte.ForEach(s => s.InspektionsRouteGIS.AddStrassenabschnittGIS(copiedStrassenabschnittGIS1)); strassenabschnittToSplit.InspektionsRtStrAbschnitte.ForEach(s => s.InspektionsRouteGIS.AddStrassenabschnittGIS(copiedStrassenabschnittGIS2)); strassenabschnittToSplit.InspektionsRtStrAbschnitte.ForEach(s => s.InspektionsRouteGIS.RemoveStrassenabschnittGIS(strassenabschnittToSplit)); //5. save/delete splitted strassenabschnitte Delete(strassenabschnittToSplit); CreateEntity(copiedStrassenabschnittGIS1); CreateEntity(copiedStrassenabschnittGIS2); }
public ZustandsabschnittGISModel GetZustandsabschnittAt(double x, double y, double tolerance) { IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate(x, y, 0)); var buffer = clickedPoint.Buffer(tolerance); //ZustandsabschnittGIS zustandsabschnitt = gisService.GetNearestGeometry(buffer, GetEntityListBySpatialFilter(buffer).Where(e=> e.ErfassungsPeriod==CurrentErfassungsPeriod).ToList()); ZustandsabschnittGIS zustandsabschnitt = gisService.GetNearestGeometry(clickedPoint, GetCurrentZustandsAbschnitteBySpatialFilter(buffer, CurrentErfassungsPeriod)); var zustandsabschnittmodel = new ZustandsabschnittGISModel();//base.GetById(zustandsabschnitt.Id); zustandsabschnittmodel.FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(zustandsabschnitt); return(zustandsabschnittmodel); }
public MassnahmenvorschlagTeilsystemeGISModel GetKoordinierteMassnahmeAt(double x, double y, double tolerance) { IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0)); var buffer = clickedPoint.Buffer(tolerance); IList <MassnahmenvorschlagTeilsystemeGIS> koordinierteMassnahmenliste = GetBySpatialFilter(buffer).Where(mts => mts.Status != EMSG.Common.Enums.StatusTyp.Abgeschlossen).ToList(); MassnahmenvorschlagTeilsystemeGIS koordinierteMassnahme = gisService.GetNearestGeometry(buffer, koordinierteMassnahmenliste); return(new MassnahmenvorschlagTeilsystemeGISModel { FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(koordinierteMassnahme) }); }
public RealisierteMassnahmeGISModel GetRealisierteMassnahmeAt(double x, double y, double tolerance) { IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate(x, y, 0)); var buffer = clickedPoint.Buffer(tolerance); IList <RealisierteMassnahmeGIS> realisierteMassnahmenliste = GetCurrentBySpatialFilter(buffer).ToList(); RealisierteMassnahmeGIS realisierteMassnahme = gisService.GetNearestGeometry(buffer, realisierteMassnahmenliste); return(new RealisierteMassnahmeGISModel { FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(realisierteMassnahme) }); }
public StrassenabschnittGISModel GetCurrentStrassenabschnittAt(double x, double y, double tolerance) { IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0)); var buffer = clickedPoint.Buffer(tolerance); //only strassenabschnitte from current erfassungsperiode ErfassungsPeriod currentErfassungsperiod = historizationService.GetCurrentErfassungsperiod(); IList <StrassenabschnittGIS> strabsliste = GetCurrentBySpatialFilter(buffer); StrassenabschnittGIS strabs = gisService.GetNearestGeometry(clickedPoint, strabsliste); return(new StrassenabschnittGISModel { FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(strabs) }); }
private object ConvertMLineStringTo2D(object source, PropertyInfo sourceProperty, PropertyInfo destinationProperty) { IGeometryFactory gf = GISService.CreateGeometryFactory(); var sourceEntityPropertyValue = sourceProperty.GetValue(source, new object[0]); if (sourceEntityPropertyValue == null) { return(null); } var mlineString = sourceEntityPropertyValue as MLineString; if (mlineString != null) { return(GeometryUtils.ConvertMLineStringTo2D(gf, mlineString)); } else { return(sourceEntityPropertyValue); } }
public InspektionsRouteGISModel GetInspektionsRouteGISAt(double x, double y, double tolerance) { IGeometry clickedPoint = GISService.CreateGeometryFactory().CreatePoint(new Coordinate((double)x, (double)y, 0)); IGeometry buffer = clickedPoint.Buffer(tolerance); IList <InspektionsRouteGIS> inspektionsRouteGISListe = GetCurrentEntityListBySpatialFilter(buffer); InspektionsRouteGIS inspektionsRoute = gisService.GetNearestGeometry(buffer, inspektionsRouteGISListe); if (inspektionsRoute != null) { return(new InspektionsRouteGISModel { FeatureGeoJSONString = geoJSONParseService.GenerateGeoJsonStringFromEntity(inspektionsRoute) }); } else { return(new InspektionsRouteGISModel { FeatureGeoJSONString = "{ \"type\": \"FeatureCollection\", \"features\": []}" }); } }
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)); }
public override bool GetMap(GISService activeService) { GISEnvelope imageEnvelope = SelectEnvelope(activeService); return GetMap(activeService, imageEnvelope); }
// 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(); } }
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); } }
public ActionResult GetStrassenabschnittByBbox(double minX, double minY, double maxX, double maxY) { try { Coordinate bottomLeft = new Coordinate(minX, minY); Coordinate topRight = new Coordinate(maxX, maxY); Coordinate bottomRight = new Coordinate(maxX, minY); Coordinate topLeft = new Coordinate(minX, maxY); ILinearRing linearRing = new LinearRing(new Coordinate[] { topLeft, topRight, bottomRight, bottomLeft, topLeft }); IGeometry filterGeom = new NetTopologySuite.Geometries.Polygon(linearRing, GISService.CreateGeometryFactory()); IList <StrassenabschnittGIS> strassenabschnitte = strassenabschnittGISService.GetCurrentBySpatialFilter(filterGeom); strassenabschnitte = strassenabschnitte.Where(s => s.Shape.Intersects(filterGeom)).ToList(); return(Content(geoJSONParseService.GenereateGeoJsonStringfromEntities(strassenabschnitte), "application/json")); } catch (Exception exc) { return(Content(GeoJSONStrings.GeoJSONFailure(exc.Message), "application/json")); } }
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(); } }
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; }
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); }
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; } }
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; } }
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); }
public override async Task<bool> GetServiceDetails(GISService activeService) { return ((activeService == null && GetClientServices().Result) || activeService.HasLayers); }
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); } }
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)); }
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; }
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; }
public Stream WriteShape(IList <Feature> featureCollection, string name, DbaseFileHeader header = null) { if (featureCollection.IsEmpty()) { return(null); } ShapeMemoryStreamDataWriter shapeWriter = new ShapeMemoryStreamDataWriter(GISService.CreateGeometryFactory()); shapeWriter.Header = header == null?ShapefileDataWriter.GetHeader(featureCollection.First(), featureCollection.Count) : header; shapeWriter.Write(featureCollection as IList); MemoryStream shpMemStream = shapeWriter.GetShpStream(); MemoryStream shxMemStream = shapeWriter.GetShxStream(); MemoryStream dbfMemStream = shapeWriter.GetDbfStream(); MemoryStream prjMemStream = new MemoryStream(Encoding.UTF8.GetBytes(GisConstants.EsriWkt21781)); MemoryStream cpgMemStream = new MemoryStream(Encoding.UTF8.GetBytes(GisConstants.EsriUTF8CodePage)); ZipFile zipfile = new ZipFile(); shpMemStream.Seek(0, 0); shxMemStream.Seek(0, 0); dbfMemStream.Seek(0, 0); prjMemStream.Seek(0, 0); zipfile.AddEntry(name + ".shp", shpMemStream); zipfile.AddEntry(name + ".shx", shxMemStream); zipfile.AddEntry(name + ".dbf", dbfMemStream); zipfile.AddEntry(name + ".prj", prjMemStream); zipfile.AddEntry(name + ".cpg", cpgMemStream); MemoryStream stream = new MemoryStream(); zipfile.Save(stream); stream.Seek(0, 0); shpMemStream.Close(); shxMemStream.Close(); dbfMemStream.Close(); prjMemStream.Close(); return(stream); }
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); }
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; } }
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); }
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); }
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; } }
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; } }