Exemplo n.º 1
0
        /// <summary>
        /// Draws a single feature based on world space coordinates
        /// </summary>
        /// <param name="position"> Vector3 position</param>
        /// <param name="gisId">string Id</param>
        /// <param name="properties">Dictionary properties</param>
        protected VirgisFeature _drawFeature(Vector3 position, string gisId = null, Dictionary <string, object> properties = null)
        {
            //instantiate the prefab with coordinates defined above
            GameObject dataPoint = Instantiate(PointPrefab, transform, false);

            dataPoint.transform.position = position;

            // add the gis data from geoJSON
            Datapoint com = dataPoint.GetComponent <Datapoint>();

            com.gisId         = gisId;
            com.gisProperties = properties ?? new Dictionary <string, object>();
            com.SetMaterial(mainMat, selectedMat);

            //Set the symbology
            if (symbology.ContainsKey("point"))
            {
                dataPoint.transform.localScale    = symbology["point"].Transform.Scale;
                dataPoint.transform.localRotation = symbology["point"].Transform.Rotate;
                dataPoint.transform.Translate(symbology["point"].Transform.Position, Space.Self);
            }


            //Set the label
            if (symbology.ContainsKey("point") && symbology["point"].ContainsKey("Label") && symbology["point"].Label != null && (properties?.ContainsKey(symbology["point"].Label) ?? false))
            {
                GameObject labelObject = Instantiate(LabelPrefab, dataPoint.transform, false);
                labelObject.transform.localScale    = labelObject.transform.localScale * Vector3.one.magnitude / dataPoint.transform.localScale.magnitude;
                labelObject.transform.localPosition = Vector3.up * displacement;
                Text labelText = labelObject.GetComponentInChildren <Text>();
                labelText.text = (string)properties[symbology["point"].Label];
            }

            return(com);
        }
Exemplo n.º 2
0
        public override GameObject GetFeatureShape()
        {
            GameObject fs  = Instantiate(PointPrefab);
            Datapoint  com = fs.GetComponent <Datapoint>();

            com.SetMaterial(mainMat, selectedMat);
            return(fs);
        }
Exemplo n.º 3
0
        private Datapoint _createVertex(Vector3 vertex, int i)
        {
            GameObject handle = Instantiate(HandlePrefab, vertex, Quaternion.identity, transform);
            Datapoint  com    = handle.GetComponent <Datapoint>();

            VertexTable.Add(new VertexLookup()
            {
                Id = com.GetId(), Vertex = i, isVertex = true, Com = com
            });
            com.SetMaterial(mainMat, selectedMat);
            handle.transform.localScale = symbology["point"].Transform.Scale;
            return(com);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws a single feature based on world space coordinates
        /// </summary>
        /// <param name="position"> Vector3 position</param>
        /// <param name="feature">Feature (optional)</param>

        protected VirgisFeature _drawFeature(Vector3 position, Feature feature = null)
        {
            //instantiate the prefab with coordinates defined above
            GameObject dataPoint = Instantiate(PointPrefab, transform, false);

            dataPoint.transform.position = position;

            // add the gis data from source
            Datapoint com = dataPoint.GetComponent <Datapoint>();

            if (feature != null)
            {
                com.feature = feature;
            }
            com.SetMaterial(mainMat, selectedMat);



            //Set the symbology
            if (symbology.ContainsKey("point"))
            {
                dataPoint.transform.localScale    = symbology["point"].Transform.Scale;
                dataPoint.transform.localRotation = symbology["point"].Transform.Rotate;
                dataPoint.transform.Translate(symbology["point"].Transform.Position, Space.Self);
            }


            //Set the label
            if (symbology.ContainsKey("point") && symbology["point"].ContainsKey("Label") && symbology["point"].Label != null && (feature?.ContainsKey(symbology["point"].Label) ?? false))
            {
                GameObject labelObject = Instantiate(LabelPrefab, dataPoint.transform, false);
                labelObject.transform.localScale    = labelObject.transform.localScale * Vector3.one.magnitude / dataPoint.transform.localScale.magnitude;
                labelObject.transform.localPosition = Vector3.up * displacement;
                Text labelText = labelObject.GetComponentInChildren <Text>();
                labelText.text = (string)feature.Get(symbology["point"].Label);
            }

            return(com);
        }