internal static void ExportPointToWkt(int export_flags, com.epl.geometry.Point point, System.Text.StringBuilder @string) { int precision = 17 - (7 & (export_flags >> 13)); bool b_export_zs = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.WktExportFlags.wktExportStripZs) == 0; bool b_export_ms = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (export_flags & com.epl.geometry.WktExportFlags.wktExportStripMs) == 0; double x = com.epl.geometry.NumberUtils.TheNaN; double y = com.epl.geometry.NumberUtils.TheNaN; double z = com.epl.geometry.NumberUtils.TheNaN; double m = com.epl.geometry.NumberUtils.TheNaN; if (!point.IsEmpty()) { x = point.GetX(); y = point.GetY(); if (b_export_zs) { z = point.GetZ(); } if (b_export_ms) { m = point.GetM(); } } if ((export_flags & com.epl.geometry.WktExportFlags.wktExportMultiPoint) != 0) { MultiPointTaggedTextFromPoint_(precision, b_export_zs, b_export_ms, x, y, z, m, @string); } else { PointTaggedText_(precision, b_export_zs, b_export_ms, x, y, z, m, @string); } }
private static void ExportPointToJson(com.epl.geometry.Point pt, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties) { bool bExportZs = pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z); bool bExportMs = pt.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 (pt.IsEmpty()) { jsonWriter.AddPairNull("x"); jsonWriter.AddPairNull("y"); if (bExportZs) { jsonWriter.AddPairNull("z"); } if (bExportMs) { jsonWriter.AddPairNull("m"); } } else { if (bPositionAsF) { jsonWriter.AddPairDouble("x", pt.GetX(), decimals, true); jsonWriter.AddPairDouble("y", pt.GetY(), decimals, true); } else { jsonWriter.AddPairDouble("x", pt.GetX()); jsonWriter.AddPairDouble("y", pt.GetY()); } if (bExportZs) { jsonWriter.AddPairDouble("z", pt.GetZ()); } if (bExportMs) { jsonWriter.AddPairDouble("m", pt.GetM()); } } if (spatialReference != null) { WriteSR(spatialReference, jsonWriter); } jsonWriter.EndObject(); }
public void InsertPoint(int beforePointIndex, com.epl.geometry.Point pt) { if (beforePointIndex > GetPointCount()) { throw new com.epl.geometry.GeometryException("index out of bounds"); } if (beforePointIndex < 0) { beforePointIndex = GetPointCount(); } MergeVertexDescription(pt.GetDescription()); int oldPointCount = m_pointCount; _resizeImpl(m_pointCount + 1); _verifyAllStreams(); for (int iattr = 0, nattr = m_description.GetAttributeCount(); iattr < nattr; iattr++) { int semantics = m_description._getSemanticsImpl(iattr); int comp = com.epl.geometry.VertexDescription.GetComponentCount(semantics); com.epl.geometry.AttributeStreamBase stream = com.epl.geometry.AttributeStreamBase.CreateAttributeStreamWithSemantics(semantics, 1); if (pt.HasAttribute(semantics)) { m_vertexAttributes[iattr].InsertAttributes(comp * beforePointIndex, pt, semantics, comp * oldPointCount); } else { // Need to make room for the attribute, so we copy a default // value in double v = com.epl.geometry.VertexDescription.GetDefaultValue(semantics); m_vertexAttributes[iattr].InsertRange(comp * beforePointIndex, v, comp, comp * oldPointCount); } } NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyCoordinates); }
// Mirrors wkt private static void ExportPointToGeoJson_(int export_flags, com.epl.geometry.Point point, com.epl.geometry.JsonWriter json_writer) { int precision = 17 - (31 & (export_flags >> 13)); bool bFixedPoint = (com.epl.geometry.GeoJsonExportFlags.geoJsonExportPrecisionFixedPoint & export_flags) != 0; bool b_export_zs = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0; bool b_export_ms = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripMs) == 0; if (!b_export_zs && b_export_ms) { throw new System.ArgumentException("invalid argument"); } double x = com.epl.geometry.NumberUtils.NaN(); double y = com.epl.geometry.NumberUtils.NaN(); double z = com.epl.geometry.NumberUtils.NaN(); double m = com.epl.geometry.NumberUtils.NaN(); if (!point.IsEmpty()) { x = point.GetX(); y = point.GetY(); if (b_export_zs) { z = point.GetZ(); } if (b_export_ms) { m = point.GetM(); } } if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportPreferMultiGeometry) == 0) { PointTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, x, y, z, m, json_writer); } else { MultiPointTaggedTextFromPoint_(precision, bFixedPoint, b_export_zs, b_export_ms, x, y, z, m, json_writer); } }
public virtual void TestPoint() { com.epl.geometry.Point pt = new com.epl.geometry.Point(); pt.SetXY(100, 200); NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M)); pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M)); NUnit.Framework.Assert.IsTrue(double.IsNaN(pt.GetM())); pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 13); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 0); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 0, 11); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.AddAttribute(com.epl.geometry.VertexDescription.Semantics.ID); NUnit.Framework.Assert.IsTrue(pt.GetID() == 0); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.SetAttribute(com.epl.geometry.VertexDescription.Semantics.ID, 0, 1); NUnit.Framework.Assert.IsTrue(pt.GetID() == 1); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsTrue(pt.GetM() == 13); pt.DropAttribute(com.epl.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(pt.GetID() == 1); NUnit.Framework.Assert.IsTrue(pt.GetZ() == 11); NUnit.Framework.Assert.IsFalse(pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M)); com.epl.geometry.Point pt1 = new com.epl.geometry.Point(); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M)); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z)); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID)); pt1.MergeVertexDescription(pt.GetDescription()); NUnit.Framework.Assert.IsFalse(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M)); NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z)); NUnit.Framework.Assert.IsTrue(pt1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID)); }
private static int ExportPointToESRIShape(int exportFlags, com.epl.geometry.Point point, System.IO.BinaryWriter shapeBuffer) { bool bExportZ = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripZs) == 0; bool bExportM = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripMs) == 0; bool bExportID = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripIDs) == 0; bool bArcViewNaNs = (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportTrueNaNs) == 0; int size = (4) + (2 * 8); /* type */ /* xy coordinate */ if (bExportZ) { size += 8; } if (bExportM) { size += 8; } if (bExportID) { size += 4; } if (shapeBuffer == null) { return(size); } else { if (((System.IO.MemoryStream)shapeBuffer.BaseStream).Capacity < size) { throw new com.epl.geometry.GeometryException("buffer is too small"); } } int type; // Determine the shape type if (!bExportZ && !bExportM) { if (bExportID) { type = com.epl.geometry.ShapeType.ShapeGeneralPoint | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapePoint; } } else { if (bExportZ && !bExportM) { if (bExportID) { type = com.epl.geometry.ShapeType.ShapeGeneralPoint | com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapePointZ; } } else { if (bExportM && !bExportZ) { if (bExportID) { type = com.epl.geometry.ShapeType.ShapeGeneralPoint | com.epl.geometry.ShapeModifiers.ShapeHasMs | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapePointM; } } else { if (bExportID) { type = com.epl.geometry.ShapeType.ShapeGeneralPoint | com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasMs | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapePointZM; } } } } int offset = 0; // write type shapeBuffer.Write(type); offset += 4; bool bEmpty = point.IsEmpty(); // write xy double x = !bEmpty?point.GetX() : com.epl.geometry.NumberUtils.NaN(); double y = !bEmpty?point.GetY() : com.epl.geometry.NumberUtils.NaN(); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(x) : x); offset += 8; shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(y) : y); offset += 8; // write Z if (bExportZ) { double z = !bEmpty?point.GetZ() : com.epl.geometry.NumberUtils.NaN(); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(z) : z); offset += 8; } // WriteM if (bExportM) { double m = !bEmpty?point.GetM() : com.epl.geometry.NumberUtils.NaN(); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(m) : m); offset += 8; } // write ID if (bExportID) { int id = !bEmpty?point.GetID() : 0; shapeBuffer.Write(id); offset += 4; } return(offset); }