Exemple #1
0
        public async Task <RecordSet> Save(bool all = true)
        {
            Debug.Log("MapInitialize.Save starts");
            try {
                if (all)
                {
                    foreach (IVirgisLayer com in appState.layers)
                    {
                        RecordSet alayer = await com.Save();

                        int index = appState.project.RecordSets.FindIndex(x => x.Id == alayer.Id);
                        appState.project.RecordSets[index] = alayer;
                    }
                }
                appState.project.Scale   = appState.GetScale();
                appState.project.Cameras = new List <Point>()
                {
                    MainCamera.transform.position.ToPoint()
                };
                geoJsonReader.SetProject(appState.project);
                await geoJsonReader.Save();

                Debug.Log("MapInitialize.Save ends");
                // TODO: should return the root layer in v2
                return(null);
            } catch (Exception e) {
                Debug.Log($"MapInitialize.Save exception: {e.Message}");
                return(null);
            }
        }
Exemple #2
0
        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;
        }
Exemple #3
0
        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;
        }
Exemple #4
0
        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;
        }