public string GenerateGeoJsonStringFromEntity(InspektionsRouteGIS inspektionsroute) { if (inspektionsroute == null) { return("{ \"type\": \"FeatureCollection\", \"features\": []}"); } FeatureWithID feature = new FeatureWithID(); IAttributesTable attributes = new AttributesTable(); IList <FeatureWithID> strassenabschnitte = new List <FeatureWithID>(); feature.Id = inspektionsroute.Id.ToString(); feature.Geometry = inspektionsroute.Shape; attributes.AddAttribute(geoJSONAttribute_InspektionsrouteID, inspektionsroute.Id); attributes.AddAttribute(geoJSONAttribute_InspektionsrouteBezeichnung, inspektionsroute.Bezeichnung); attributes.AddAttribute(geoJSONAttribute_IsLocked, inspektionsroute.IsLocked); //GEOJSON PROPERTIES: Strassenabschnitte foreach (InspektionsRtStrAbschnitte inspektionsrouteStrassenabschnitt in inspektionsroute.InspektionsRtStrAbschnitteList) { FeatureWithID featureIrs = new FeatureWithID(); IAttributesTable attributeIrs = new AttributesTable(); IList <AchsenReferenz> achsenreferenzenIrs = achsenReferenzService.GetAchsenReferenzGruppe(inspektionsrouteStrassenabschnitt.StrassenabschnittGIS.ReferenzGruppe.Id); IList <FeatureWithID> achsenreferenzen = new List <FeatureWithID>(); featureIrs.Id = inspektionsrouteStrassenabschnitt.StrassenabschnittGIS.Id.ToString(); featureIrs.Geometry = inspektionsrouteStrassenabschnitt.StrassenabschnittGIS.Shape; foreach (AchsenReferenz achsenreferenz in achsenreferenzenIrs) { FeatureWithID featAr = new FeatureWithID(); IAttributesTable attAr = new AttributesTable(); featAr.Id = achsenreferenz.Id.ToString(); featAr.Geometry = achsenreferenz.Shape; attAr.AddAttribute(geoJSONAttribute_AchsenSegmentId, achsenreferenz.AchsenSegment.Id); featAr.Attributes = attAr; achsenreferenzen.Add(featAr); } attributeIrs.AddAttribute(geoJSONAttribute_childs, achsenreferenzen); featureIrs.Attributes = attributeIrs; strassenabschnitte.Add(featureIrs); } attributes.AddAttribute(geoJSONAttribute_Strassenabschnitte, strassenabschnitte); feature.Attributes = attributes; TextWriter sw = new StringWriter(); GeoJSONWriter.WriteWithID(feature, sw); string geoJSONstring = sw.ToString(); return(geoJSONstring); }
public string GenerateGeoJsonStringFromEntity(IDTOGeometryHolder entity) { if (entity == null) { return(geoJSON_EmptyFeatureCollection); } FeatureWithID feature = getFeatureWithId(entity); TextWriter sw = new StringWriter(); GeoJSONWriter.WriteWithID(feature, sw); string geoJSONstring = sw.ToString(); return(geoJSONstring); }
public string GenerateGeoJsonStringFromEntity(IAbschnittGISBase entity) { if (entity == null) { return("{ \"type\": \"FeatureCollection\", \"features\": []}"); } FeatureWithID feature = getFeatureWithId(entity); TextWriter sw = new StringWriter(); GeoJSONWriter.WriteWithID(feature, sw); string geoJSONstring = sw.ToString(); return(geoJSONstring); }