protected override async Task _save() { Dataline[] dataFeatures = gameObject.GetComponentsInChildren <Dataline>(); List <Feature> thisFeatures = new List <Feature>(); foreach (Dataline dataFeature in dataFeatures) { Vector3[] vertices = dataFeature.GetVertexPositions(); List <Position> positions = new List <Position>(); foreach (Vector3 vertex in vertices) { positions.Add(vertex.ToPosition() as Position); } List <LineString> lines = new List <LineString>(); lines.Add(new LineString(positions)); thisFeatures.Add(new Feature(new MultiLineString(lines), dataFeature.gisProperties, dataFeature.gisId)); } ; FeatureCollection FC = new FeatureCollection(thisFeatures); geoJsonReader.SetFeatureCollection(FC); await geoJsonReader.Save(); features = FC; }
protected override async Task _save() { Datapoint[] pointFuncs = gameObject.GetComponentsInChildren <Datapoint>(); List <Feature> thisFeatures = new List <Feature>(); foreach (Datapoint pointFunc in pointFuncs) { thisFeatures.Add(new Feature(pointFunc.gameObject.transform.position.ToPoint(), pointFunc.gisProperties, pointFunc.gisId)); } FeatureCollection FC = new FeatureCollection(thisFeatures); geoJsonReader.SetFeatureCollection(FC); await geoJsonReader.Save(); features = FC; }
protected override async Task _save() { Datapolygon[] dataFeatures = gameObject.GetComponentsInChildren <Datapolygon>(); List <Feature> thisFeatures = new List <Feature>(); foreach (Datapolygon dataFeature in dataFeatures) { Dataline[] polygon = dataFeature.GetComponentsInChildren <Dataline>(); List <LineString> LinearRings = new List <LineString>(); foreach (Dataline perimeter in polygon) { Vector3[] vertices = perimeter.GetVertexPositions(); List <Position> positions = new List <Position>(); foreach (Vector3 vertex in vertices) { positions.Add(vertex.ToPosition() as Position); } LineString line = new LineString(positions); if (!line.IsLinearRing()) { Debug.LogError("This Polygon is not a Linear Ring"); return; } LinearRings.Add(line); } Dictionary <string, object> properties = dataFeature.gisProperties as Dictionary <string, object> ?? new Dictionary <string, object>(); thisFeatures.Add(new Feature(new Polygon(LinearRings), properties, dataFeature.gisId)); } ; FeatureCollection FC = new FeatureCollection(thisFeatures); geoJsonReader.SetFeatureCollection(FC); await geoJsonReader.Save(); features = FC; }