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); }
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); }