예제 #1
0
        ///
        /// This is the initialisation script.
        ///
        /// It loads the Project file, reads it for the layers and calls Draw to render each layer
        /// </summary>
        async void Start()
        {
            // Fetch Project definition - return if the file cannot be read - this will lead to an empty world
            geoJsonReader = new GeoJsonReader();
            await geoJsonReader.Load(inputfile);

            if (geoJsonReader.payload is null)
            {
                return;
            }
            appState.project = geoJsonReader.GetProject();

            //initialize space
            Vector2d    origin = appState.project.Origin.Coordinates.Vector2d();
            GameObject  Map    = gameObject;
            AbstractMap _map   = Map.GetComponent <AbstractMap>();

            _map.UseWorldScale();
            _map.Initialize(origin, appState.project.MapScale);


            //set globals
            appState.abstractMap = _map;
            appState.map         = Map;
            appState.ZoomChange(appState.project.Scale);
            appState.mainCamera              = MainCamera;
            appState.trackingSpace           = TrackingSpace;
            TrackingSpace.transform.position = appState.project.Camera.Coordinates.Vector3();

            await Init(null);

            Draw();
        }
예제 #2
0
        protected override async Task _init(GeographyCollection layer)
        {
            geoJsonReader = new GeoJsonReader();
            await geoJsonReader.Load(layer.Source);

            features     = geoJsonReader.getFeatureCollection();
            symbology    = layer.Properties.Units;
            displacement = 1.0f;
            if (symbology.ContainsKey("point") && symbology["point"].ContainsKey("Shape"))
            {
                Shapes shape = symbology["point"].Shape;
                switch (shape)
                {
                case Shapes.Spheroid:
                    PointPrefab = SpherePrefab;
                    break;

                case Shapes.Cuboid:
                    PointPrefab = CubePrefab;
                    break;

                case Shapes.Cylinder:
                    PointPrefab  = CylinderPrefab;
                    displacement = 1.5f;
                    break;

                default:
                    PointPrefab = SpherePrefab;
                    break;
                }
            }
            else
            {
                PointPrefab = SpherePrefab;
            }

            Color col = symbology.ContainsKey("point") ? (Color)symbology["point"].Color : Color.white;
            Color sel = symbology.ContainsKey("point") ? new Color(1 - col.r, 1 - col.g, 1 - col.b, col.a) : Color.red;

            mainMat = Instantiate(BaseMaterial);
            mainMat.SetColor("_BaseColor", col);
            selectedMat = Instantiate(BaseMaterial);
            selectedMat.SetColor("_BaseColor", sel);
        }
예제 #3
0
        protected override async Task _init(GeographyCollection layer)
        {
            geoJsonReader = new GeoJsonReader();
            await geoJsonReader.Load(layer.Source);

            features  = geoJsonReader.getFeatureCollection();
            symbology = layer.Properties.Units;

            if (symbology.ContainsKey("point") && symbology["point"].ContainsKey("Shape"))
            {
                Shapes shape = symbology["point"].Shape;
                switch (shape)
                {
                case Shapes.Spheroid:
                    HandlePrefab = SpherePrefab;
                    break;

                case Shapes.Cuboid:
                    HandlePrefab = CubePrefab;
                    break;

                case Shapes.Cylinder:
                    HandlePrefab = CylinderPrefab;
                    break;

                default:
                    HandlePrefab = SpherePrefab;
                    break;
                }
            }
            else
            {
                HandlePrefab = SpherePrefab;
            }

            if (symbology.ContainsKey("line") && symbology["line"].ContainsKey("Shape"))
            {
                Shapes shape = symbology["line"].Shape;
                switch (shape)
                {
                case Shapes.Cuboid:
                    LinePrefab = CuboidLinePrefab;
                    break;

                case Shapes.Cylinder:
                    LinePrefab = CylinderLinePrefab;
                    break;

                default:
                    LinePrefab = CylinderLinePrefab;
                    break;
                }
            }
            else
            {
                LinePrefab = CylinderLinePrefab;
            }

            Color col     = symbology.ContainsKey("point") ? (Color)symbology["point"].Color : Color.white;
            Color sel     = symbology.ContainsKey("point") ? new Color(1 - col.r, 1 - col.g, 1 - col.b, col.a) : Color.red;
            Color line    = symbology.ContainsKey("line") ? (Color)symbology["line"].Color : Color.white;
            Color lineSel = symbology.ContainsKey("line") ? new Color(1 - line.r, 1 - line.g, 1 - line.b, line.a) : Color.red;
            Color body    = symbology.ContainsKey("body") ? (Color)symbology["body"].Color : Color.white;
            Color bodySel = symbology.ContainsKey("body") ? new Color(1 - body.r, 1 - body.g, 1 - body.b, body.a) : Color.red;

            mainMat = Instantiate(PointBaseMaterial);
            mainMat.SetColor("_BaseColor", col);
            selectedMat = Instantiate(PointBaseMaterial);
            selectedMat.SetColor("_BaseColor", sel);
            lineMain = Instantiate(LineBaseMaterial);
            lineMain.SetColor("_BaseColor", line);
            lineSelected = Instantiate(LineBaseMaterial);
            lineSelected.SetColor("_BaseColor", lineSel);
            bodyMain = Instantiate(BodyBaseMaterial);
            bodyMain.SetColor("_BaseColor", body);
        }