示例#1
0
        protected VirgisFeature _drawFeature(Geometry poly, Feature feature = null)
        {
            Geometry center = poly.Centroid();

            center.AssignSpatialReference(poly.GetSpatialReference());


            //Create the GameObjects
            GameObject dataPoly = Instantiate(PolygonPrefab, center.TransformWorld()[0], Quaternion.identity, transform);



            // add the gis data from geoJSON
            Datapolygon p = dataPoly.GetComponent <Datapolygon>();

            if (feature != null)
            {
                p.feature = feature;
            }

            if (symbology.ContainsKey("body") && symbology["body"].ContainsKey("Label") && symbology["body"].Label != null && (feature?.ContainsKey(symbology["body"].Label) ?? false))
            {
                //Set the label
                GameObject labelObject = Instantiate(LabelPrefab, dataPoly.transform, false);
                labelObject.transform.Translate(dataPoly.transform.TransformVector(Vector3.up) * symbology["point"].Transform.Scale.magnitude, Space.Self);
                Text labelText = labelObject.GetComponentInChildren <Text>();
                labelText.text = (string)feature.Get(symbology["body"].Label);
            }


            List <Dataline> polygon     = new List <Dataline>();
            List <Geometry> LinearRings = new List <Geometry>();

            for (int i = 0; i < poly.GetGeometryCount(); i++)
            {
                LinearRings.Add(poly.GetGeometryRef(i));
            }
            // Darw the LinearRing
            foreach (Geometry LinearRing in LinearRings)
            {
                wkbGeometryType type = LinearRing.GetGeometryType();
                if (type == wkbGeometryType.wkbLinearRing || type == wkbGeometryType.wkbLineString25D || type == wkbGeometryType.wkbLineString)
                {
                    GameObject dataLine = Instantiate(LinePrefab, dataPoly.transform, false);
                    Dataline   com      = dataLine.GetComponent <Dataline>();
                    LinearRing.CloseRings();
                    com.Draw(LinearRing, symbology, LinePrefab, HandlePrefab, null, mainMat, selectedMat, lineMain, lineSelected, true);
                    polygon.Add(com);
                }
            }

            //Draw the Polygon
            p.Draw(polygon, bodyMain);

            return(p);
        }
示例#2
0
        /// <summary>
        /// Draws a single feature based on world scale coordinates
        /// </summary>
        /// <param name="line"> Vector3[] coordinates</param>
        /// <param name="Lr"> boolean Is the line a linear ring , deafult false</param>
        /// <param name="gisId">string Id</param>
        /// <param name="properties">Dictionary properties</param>
        protected VirgisFeature _drawFeature(Vector3[] line, bool Lr = false, string gisId = null, Dictionary <string, object> properties = null)
        {
            GameObject dataLine = Instantiate(LinePrefab, transform, false);

            //set the gisProject properties
            Dataline com = dataLine.GetComponent <Dataline>();

            com.gisId         = gisId;
            com.gisProperties = properties ?? new Dictionary <string, object>();
            //Draw the line
            com.Draw(line, Lr, symbology, LinePrefab, HandlePrefab, LabelPrefab, mainMat, selectedMat, lineMain, lineSelected);

            return(com);
        }
示例#3
0
        protected VirgisFeature _drawFeature(IEnumerable <LineString> LinearRings, string gisId = null, Dictionary <string, object> properties = null)
        {
            LineString perimeter = (LinearRings as ReadOnlyCollection <LineString>)[0];

            Vector3[] poly  = perimeter.Vector3();
            DCurve3   curve = new DCurve3();

            curve.Vector3(poly, true);
            Vector3 center = (Vector3)curve.Center();
            //Create the GameObjects
            GameObject dataPoly = Instantiate(PolygonPrefab, center, Quaternion.identity, transform);



            // add the gis data from geoJSON
            Datapolygon p = dataPoly.GetComponent <Datapolygon>();

            p.gisId         = gisId;
            p.gisProperties = properties ?? new Dictionary <string, object>();

            if (symbology["body"].ContainsKey("Label") && symbology["body"].Label != null && (properties?.ContainsKey(symbology["body"].Label) ?? false))
            {
                //Set the label
                GameObject labelObject = Instantiate(LabelPrefab, dataPoly.transform, false);
                labelObject.transform.Translate(dataPoly.transform.TransformVector(Vector3.up) * symbology["point"].Transform.Scale.magnitude, Space.Self);
                Text labelText = labelObject.GetComponentInChildren <Text>();
                labelText.text = (string)properties[symbology["body"].Label];
            }


            List <Dataline> polygon = new List <Dataline>();

            // Darw the LinearRing
            foreach (LineString LinearRing in LinearRings)
            {
                Vector3[]  lr       = LinearRing.Vector3();
                GameObject dataLine = Instantiate(LinePrefab, dataPoly.transform, false);
                Dataline   com      = dataLine.GetComponent <Dataline>();
                com.Draw(lr, true, symbology, LinePrefab, HandlePrefab, null, mainMat, selectedMat, lineMain, lineSelected);
                polygon.Add(com);
            }

            //Draw the Polygon
            p.Draw(polygon, bodyMain);

            return(p);
        }
示例#4
0
        /// <summary>
        /// Draws a single feature based on world scale coordinates
        /// </summary>
        /// <param name="line"> Vector3[] coordinates</param>
        /// <param name="feature">Featire (optinal)</param>
        protected VirgisFeature _drawFeature(Geometry line, Feature feature = null)
        {
            GameObject dataLine = Instantiate(LinePrefab, transform, false);

            //set the gisProject properties
            Dataline com = dataLine.GetComponent <Dataline>();

            if (feature != null)
            {
                com.feature = feature;
            }

            //Draw the line
            com.Draw(line, symbology, LinePrefab, HandlePrefab, LabelPrefab, mainMat, selectedMat, lineMain, lineSelected);

            return(com);
        }