public OGCLineString(com.epl.geometry.MultiPath mp, int pathIndex, com.epl.geometry.SpatialReference sr, bool reversed) { multiPath = new com.epl.geometry.Polyline(); if (!mp.IsEmpty()) { multiPath.AddPath(mp, pathIndex, !reversed); } esriSR = sr; }
private static void ExportPolypathToJson(com.epl.geometry.MultiPath pp, string name, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties) { bool bExportZs = pp.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z); bool bExportMs = pp.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M); bool bPositionAsF = false; int decimals = 17; if (exportProperties != null) { object numberOfDecimalsXY = exportProperties["numberOfDecimalsXY"]; if (numberOfDecimalsXY != null && numberOfDecimalsXY is java.lang.Number) { bPositionAsF = true; decimals = ((java.lang.Number)numberOfDecimalsXY); } } jsonWriter.StartObject(); if (bExportZs) { jsonWriter.AddPairBoolean("hasZ", true); } if (bExportMs) { jsonWriter.AddPairBoolean("hasM", true); } jsonWriter.AddPairArray(name); if (!pp.IsEmpty()) { int n = pp.GetPathCount(); // rings or paths com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)pp._getImpl(); // get impl for // faster // access com.epl.geometry.AttributeStreamOfDbl zs = null; com.epl.geometry.AttributeStreamOfDbl ms = null; if (bExportZs) { zs = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z); } if (bExportMs) { ms = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M); } bool bPolygon = pp is com.epl.geometry.Polygon; com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D(); for (int i = 0; i < n; i++) { jsonWriter.AddValueArray(); int startindex = pp.GetPathStart(i); int numVertices = pp.GetPathSize(i); double startx = 0.0; double starty = 0.0; double startz = com.epl.geometry.NumberUtils.NaN(); double startm = com.epl.geometry.NumberUtils.NaN(); double z = com.epl.geometry.NumberUtils.NaN(); double m = com.epl.geometry.NumberUtils.NaN(); bool bClosed = pp.IsClosedPath(i); for (int j = startindex; j < startindex + numVertices; j++) { pp.GetXY(j, pt); jsonWriter.AddValueArray(); if (bPositionAsF) { jsonWriter.AddValueDouble(pt.x, decimals, true); jsonWriter.AddValueDouble(pt.y, decimals, true); } else { jsonWriter.AddValueDouble(pt.x); jsonWriter.AddValueDouble(pt.y); } if (bExportZs) { z = zs.Get(j); jsonWriter.AddValueDouble(z); } if (bExportMs) { m = ms.Get(j); jsonWriter.AddValueDouble(m); } if (j == startindex && bClosed) { startx = pt.x; starty = pt.y; startz = z; startm = m; } jsonWriter.EndArray(); } // Close the Path/Ring by writing the Point at the start index if (bClosed && (startx != pt.x || starty != pt.y || (bExportZs && !(com.epl.geometry.NumberUtils.IsNaN(startz) && com.epl.geometry.NumberUtils.IsNaN(z)) && startz != z) || (bExportMs && !(com.epl.geometry.NumberUtils.IsNaN(startm) && com.epl.geometry.NumberUtils.IsNaN(m)) && startm != m))) { pp.GetXY(startindex, pt); // getPoint(startindex); jsonWriter.AddValueArray(); if (bPositionAsF) { jsonWriter.AddValueDouble(pt.x, decimals, true); jsonWriter.AddValueDouble(pt.y, decimals, true); } else { jsonWriter.AddValueDouble(pt.x); jsonWriter.AddValueDouble(pt.y); } if (bExportZs) { z = zs.Get(startindex); jsonWriter.AddValueDouble(z); } if (bExportMs) { m = ms.Get(startindex); jsonWriter.AddValueDouble(m); } jsonWriter.EndArray(); } jsonWriter.EndArray(); } } jsonWriter.EndArray(); if (spatialReference != null) { WriteSR(spatialReference, jsonWriter); } jsonWriter.EndObject(); }