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); }
/// <summary> /// Estimates the nearest point on a DCurve to the centroid of that DCurve /// </summary> /// <param name="curve">g3.DCurve</param> /// <returns>g3.Vector3d Centroid</returns> public static Vector3d CenterMark(this DCurve3 curve) { Vector3d center = curve.Center(); return(curve.GetSegment(curve.NearestSegment(center)).NearestPoint(center)); }
/// <summary> /// Calculates the 3D Centroid as a World space Vector3 of the DCurve3 that is in local map space. /// </summary> /// <param name="curve">DCurve3 in local map space coordinates</param> /// <returns>Vcetor3 in world space coordinates</returns> public static Vector3 WorldCenter(this DCurve3 curve) { return(AppState.instance.map.transform.TransformVector((Vector3)curve.Center())); }