internal static void MultiLineStringText_(int precision, bool b_export_zs, bool b_export_ms, com.epl.geometry.AttributeStreamOfDbl zs, com.epl.geometry.AttributeStreamOfDbl ms, com.epl.geometry.AttributeStreamOfDbl position, com.epl.geometry.AttributeStreamOfInt8 path_flags, com.epl.geometry.AttributeStreamOfInt32 paths, int path_count, System.Text.StringBuilder @string) { bool b_closed = ((path_flags.Read(0) & com.epl.geometry.PathFlags.enumClosed) != 0); LineStringText_(false, b_closed, precision, b_export_zs, b_export_ms, zs, ms, position, paths, 0, @string); for (int path = 1; path < path_count; path++) { @string.Append(", "); b_closed = ((path_flags.Read(path) & com.epl.geometry.PathFlags.enumClosed) != 0); LineStringText_(false, b_closed, precision, b_export_zs, b_export_ms, zs, ms, position, paths, path, @string); } }
// Mirrors wkt private static void MultiLineStringText_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, com.epl.geometry.AttributeStreamOfDbl zs, com.epl.geometry.AttributeStreamOfDbl ms, com.epl.geometry.AttributeStreamOfDbl position, com.epl.geometry.AttributeStreamOfInt8 path_flags, com.epl.geometry.AttributeStreamOfInt32 paths, int path_count, com.epl.geometry.JsonWriter json_writer) { bool b_closed = ((path_flags.Read(0) & com.epl.geometry.PathFlags.enumClosed) != 0); LineStringText_(false, b_closed, precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, 0, paths.Read(1), json_writer); for (int path = 1; path < path_count; path++) { b_closed = ((path_flags.Read(path) & com.epl.geometry.PathFlags.enumClosed) != 0); int istart = paths.Read(path); int iend = paths.Read(path + 1); LineStringText_(false, b_closed, precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, istart, iend, json_writer); } }
internal static void LineStringTaggedText_(int precision, bool b_export_zs, bool b_export_ms, com.epl.geometry.AttributeStreamOfDbl zs, com.epl.geometry.AttributeStreamOfDbl ms, com.epl.geometry.AttributeStreamOfDbl position, com.epl.geometry.AttributeStreamOfInt8 path_flags, com.epl.geometry.AttributeStreamOfInt32 paths, System.Text.StringBuilder @string) { @string.Append("LINESTRING "); if (b_export_zs && b_export_ms) { @string.Append("ZM "); } else { if (b_export_zs && !b_export_ms) { @string.Append("Z "); } else { if (!b_export_zs && b_export_ms) { @string.Append("M "); } } } if (position == null) { @string.Append("EMPTY"); return; } bool b_closed = ((path_flags.Read(0) & com.epl.geometry.PathFlags.enumClosed) != 0); LineStringText_(false, b_closed, precision, b_export_zs, b_export_ms, zs, ms, position, paths, 0, @string); }
public override bool Equals(com.epl.geometry.AttributeStreamBase other, int start, int end) { if (other == null) { return(false); } if (!(other is com.epl.geometry.AttributeStreamOfInt8)) { return(false); } com.epl.geometry.AttributeStreamOfInt8 _other = (com.epl.geometry.AttributeStreamOfInt8)other; int size = Size(); int sizeOther = _other.Size(); if (end > size || end > sizeOther && (size != sizeOther)) { return(false); } if (end > size) { end = size; } for (int i = start; i < end; i++) { if (Read(i) != _other.Read(i)) { return(false); } } return(true); }
/// <exception cref="java.io.ObjectStreamException"/> public virtual void SetGeometryByValue(com.epl.geometry.Geometry geometry) { try { esriShape = com.epl.geometry.GeometryEngine.GeometryToEsriShape(geometry); geometryType = geometry.GetType().Value(); if (com.epl.geometry.Geometry.IsMultiVertex(geometryType)) { com.epl.geometry.MultiVertexGeometryImpl mvImpl = (com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl(); tolerance = mvImpl.m_simpleTolerance; simpleFlag = mvImpl.GetIsSimple(0); if (!geometry.IsEmpty() && com.epl.geometry.Geometry.IsMultiPath(geometryType)) { com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)geometry._getImpl(); ogcFlags = new bool[mpImpl.GetPathCount()]; com.epl.geometry.AttributeStreamOfInt8 pathFlags = mpImpl.GetPathFlagsStreamRef(); for (int i = 0, n = mpImpl.GetPathCount(); i < n; i++) { ogcFlags[i] = (pathFlags.Read(i) & unchecked ((byte)com.epl.geometry.PathFlags.enumOGCStartPolygon)) != 0; } } } } catch (System.Exception) { throw new System.IO.InvalidDataException("Cannot serialize this geometry"); } }
// Mirrors wkt private static void MultiPolygonText_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, com.epl.geometry.AttributeStreamOfDbl zs, com.epl.geometry.AttributeStreamOfDbl ms, com.epl.geometry.AttributeStreamOfDbl position, com.epl.geometry.AttributeStreamOfInt8 path_flags, com.epl.geometry.AttributeStreamOfInt32 paths, int polygon_count, int path_count, com.epl.geometry.JsonWriter json_writer) { int polygon_start = 0; int polygon_end = 1; while (polygon_end < path_count && ((int)path_flags.Read(polygon_end) & com.epl.geometry.PathFlags.enumOGCStartPolygon) == 0) { polygon_end++; } PolygonText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, paths, polygon_start, polygon_end, json_writer); for (int ipolygon = 1; ipolygon < polygon_count; ipolygon++) { polygon_start = polygon_end; polygon_end++; while (polygon_end < path_count && ((int)path_flags.Read(polygon_end) & com.epl.geometry.PathFlags.enumOGCStartPolygon) == 0) { polygon_end++; } PolygonText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, paths, polygon_start, polygon_end, json_writer); } }
internal static void MultiPolygonText_(int precision, bool b_export_zs, bool b_export_ms, com.epl.geometry.AttributeStreamOfDbl zs, com.epl.geometry.AttributeStreamOfDbl ms, com.epl.geometry.AttributeStreamOfDbl position, com.epl.geometry.AttributeStreamOfInt8 path_flags, com.epl.geometry.AttributeStreamOfInt32 paths, int polygon_count, int path_count, System.Text.StringBuilder @string) { int polygon_start = 0; int polygon_end = 1; while (polygon_end < path_count && (path_flags.Read(polygon_end) & com.epl.geometry.PathFlags.enumOGCStartPolygon) == 0) { polygon_end++; } PolygonText_(precision, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, polygon_start, polygon_end, @string); for (int ipolygon = 1; ipolygon < polygon_count; ipolygon++) { polygon_start = polygon_end; polygon_end++; while (polygon_end < path_count && (path_flags.Read(polygon_end) & com.epl.geometry.PathFlags.enumOGCStartPolygon) == 0) { polygon_end++; } @string.Append(", "); PolygonText_(precision, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, polygon_start, polygon_end, @string); } }
// Mirrors wkt private static void LineStringTaggedText_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, com.epl.geometry.AttributeStreamOfDbl zs, com.epl.geometry.AttributeStreamOfDbl ms, com.epl.geometry.AttributeStreamOfDbl position, com.epl.geometry.AttributeStreamOfInt8 path_flags, com.epl.geometry.AttributeStreamOfInt32 paths, com.epl.geometry.JsonWriter json_writer) { json_writer.AddFieldName("type"); json_writer.AddValueString("LineString"); json_writer.AddFieldName("coordinates"); if (position == null) { json_writer.StartArray(); json_writer.EndArray(); return; } bool b_closed = ((path_flags.Read(0) & com.epl.geometry.PathFlags.enumClosed) != 0); LineStringText_(false, b_closed, precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, 0, paths.Read(1), json_writer); }
public static void TestIntervalTree_RandomConstruction() { int pointcount = 0; int passcount = 1000; int figureSize = 50; com.epl.geometry.Envelope env = new com.epl.geometry.Envelope(); env.SetCoords(-10000, -10000, 10000, 10000); com.epl.geometry.RandomCoordinateGenerator generator = new com.epl.geometry.RandomCoordinateGenerator(System.Math.Max(figureSize, 10000), env, 0.001); System.Random random = new System.Random(2013); int rand_max = 98765; System.Collections.Generic.List <com.epl.geometry.Envelope1D> intervals = new System.Collections.Generic.List <com.epl.geometry.Envelope1D>(); com.epl.geometry.AttributeStreamOfInt8 intervalsFound = new com.epl.geometry.AttributeStreamOfInt8(0); for (int i = 0; i < passcount; i++) { int r = figureSize; if (r < 3) { continue; } com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); com.epl.geometry.Point pt; for (int j = 0; j < r; j++) { int rand = random.Next(rand_max); bool bRandomNew = (r > 10) && ((1.0 * rand) / rand_max > 0.95); pt = generator.GetRandomCoord(); if (j == 0 || bRandomNew) { poly.StartPath(pt); } else { poly.LineTo(pt); } } { intervals.Clear(); com.epl.geometry.SegmentIterator seg_iter = poly.QuerySegmentIterator(); com.epl.geometry.Envelope1D interval; com.epl.geometry.Envelope1D range = poly.QueryInterval(com.epl.geometry.VertexDescription.Semantics.POSITION, 0); range.vmin -= 0.01; range.vmax += 0.01; while (seg_iter.NextPath()) { while (seg_iter.HasNextSegment()) { com.epl.geometry.Segment segment = seg_iter.NextSegment(); interval = segment.QueryInterval(com.epl.geometry.VertexDescription.Semantics.POSITION, 0); intervals.Add(interval); } } intervalsFound.Resize(intervals.Count, 0); // Just test construction for assertions com.epl.geometry.IntervalTreeImpl intervalTree = new com.epl.geometry.IntervalTreeImpl(true); Construct(intervalTree, intervals); for (int j_1 = 0; j_1 < intervals.Count; j_1++) { intervalTree.Insert(j_1); } com.epl.geometry.IntervalTreeImpl.IntervalTreeIteratorImpl iterator = intervalTree.GetIterator(range, 0.0); int count = 0; int handle; while ((handle = iterator.Next()) != -1) { count++; intervalsFound.Write(handle, unchecked ((byte)1)); } NUnit.Framework.Assert.IsTrue(count == intervals.Count); for (int j_2 = 0; j_2 < intervalsFound.Size(); j_2++) { interval = intervals[j_2]; NUnit.Framework.Assert.IsTrue(intervalsFound.Read(j_2) == 1); } for (int j_3 = 0; j_3 < intervals.Count >> 1; j_3++) { intervalTree.Remove(j_3); } iterator.ResetIterator(range, 0.0); count = 0; while ((handle = iterator.Next()) != -1) { count++; intervalsFound.Write(handle, unchecked ((byte)1)); } NUnit.Framework.Assert.IsTrue(count == intervals.Count - (intervals.Count >> 1)); for (int j_4 = (intervals.Count >> 1); j_4 < intervals.Count; j_4++) { intervalTree.Remove(j_4); } } } }
internal static com.epl.geometry.Geometry PolygonTaggedText(bool b_multi_polygon, int import_flags, com.epl.geometry.WktParser wkt_parser) { com.epl.geometry.MultiPath multi_path; com.epl.geometry.MultiPathImpl multi_path_impl; com.epl.geometry.AttributeStreamOfDbl zs = null; com.epl.geometry.AttributeStreamOfDbl ms = null; com.epl.geometry.AttributeStreamOfDbl position; com.epl.geometry.AttributeStreamOfInt32 paths; com.epl.geometry.AttributeStreamOfInt8 path_flags; position = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0); paths = (com.epl.geometry.AttributeStreamOfInt32)com.epl.geometry.AttributeStreamBase.CreateIndexStream(1, 0); path_flags = (com.epl.geometry.AttributeStreamOfInt8)com.epl.geometry.AttributeStreamBase.CreateByteStream(1, unchecked ((byte)0)); multi_path = new com.epl.geometry.Polygon(); multi_path_impl = (com.epl.geometry.MultiPathImpl)multi_path._getImpl(); int current_token = wkt_parser.NextToken(); if (current_token == com.epl.geometry.WktParser.WktToken.attribute_z) { zs = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN); multi_path_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z); wkt_parser.NextToken(); } else { if (current_token == com.epl.geometry.WktParser.WktToken.attribute_m) { ms = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN); multi_path_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); wkt_parser.NextToken(); } else { if (current_token == com.epl.geometry.WktParser.WktToken.attribute_zm) { zs = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN); ms = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0, com.epl.geometry.NumberUtils.TheNaN); multi_path_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z); multi_path_impl.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); wkt_parser.NextToken(); } } } int point_count; if (b_multi_polygon) { point_count = MultiPolygonText(zs, ms, position, paths, path_flags, wkt_parser); } else { point_count = PolygonText(zs, ms, position, paths, path_flags, 0, wkt_parser); } if (point_count != 0) { System.Diagnostics.Debug.Assert((2 * point_count == position.Size())); multi_path_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION, position); multi_path_impl.SetPathStreamRef(paths); multi_path_impl.SetPathFlagsStreamRef(path_flags); if (zs != null) { multi_path_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z, zs); } if (ms != null) { multi_path_impl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M, ms); } multi_path_impl.NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyAll); com.epl.geometry.AttributeStreamOfInt8 path_flags_clone = new com.epl.geometry.AttributeStreamOfInt8(path_flags); for (int i = 0; i < path_flags_clone.Size() - 1; i++) { if (((int)path_flags_clone.Read(i) & (int)com.epl.geometry.PathFlags.enumOGCStartPolygon) != 0) { // Should // be // clockwise if (!com.epl.geometry.InternalUtils.IsClockwiseRing(multi_path_impl, i)) { multi_path_impl.ReversePath(i); } } else { // make clockwise // Should be counter-clockwise if (com.epl.geometry.InternalUtils.IsClockwiseRing(multi_path_impl, i)) { multi_path_impl.ReversePath(i); } } } // make // counter-clockwise multi_path_impl.SetPathFlagsStreamRef(path_flags_clone); } if ((import_flags & (int)com.epl.geometry.WktImportFlags.wktImportNonTrusted) == 0) { multi_path_impl.SetIsSimple(com.epl.geometry.MultiVertexGeometryImpl.GeometryXSimple.Weak, 0.0, false); } multi_path_impl.SetDirtyOGCFlags(false); return(multi_path); }
public void _updateSegment() { if (m_nextSegmentIndex < 0 || m_nextSegmentIndex >= m_segmentCount) { throw new System.IndexOutOfRangeException(); } m_currentSegmentIndex = m_nextSegmentIndex; int startVertexIndex = GetStartPointIndex(); m_parent._verifyAllStreams(); com.epl.geometry.AttributeStreamOfInt8 segFlagStream = m_parent.GetSegmentFlagsStreamRef(); int segFlag = com.epl.geometry.SegmentFlags.enumLineSeg; if (segFlagStream != null) { segFlag = (segFlagStream.Read(startVertexIndex) & com.epl.geometry.SegmentFlags.enumSegmentMask); } com.epl.geometry.VertexDescription vertexDescr = m_parent.GetDescription(); switch (segFlag) { case com.epl.geometry.SegmentFlags.enumLineSeg: { if (m_line == null) { m_line = new com.epl.geometry.Line(); } m_currentSegment = (com.epl.geometry.Line)m_line; break; } case com.epl.geometry.SegmentFlags.enumBezierSeg: { throw com.epl.geometry.GeometryException.GeometryInternalError(); } case com.epl.geometry.SegmentFlags.enumArcSeg: { // break; throw com.epl.geometry.GeometryException.GeometryInternalError(); } default: { // break; throw com.epl.geometry.GeometryException.GeometryInternalError(); } } m_currentSegment.AssignVertexDescription(vertexDescr); int endVertexIndex = GetEndPointIndex(); m_parent.GetXY(startVertexIndex, m_dummyPoint); m_currentSegment.SetStartXY(m_dummyPoint); m_parent.GetXY(endVertexIndex, m_dummyPoint); m_currentSegment.SetEndXY(m_dummyPoint); for (int i = 1, nattr = vertexDescr.GetAttributeCount(); i < nattr; i++) { int semantics = vertexDescr.GetSemantics(i); int ncomp = com.epl.geometry.VertexDescription.GetComponentCount(semantics); for (int ord = 0; ord < ncomp; ord++) { double vs = m_parent.GetAttributeAsDbl(semantics, startVertexIndex, ord); m_currentSegment.SetStartAttribute(semantics, ord, vs); double ve = m_parent.GetAttributeAsDbl(semantics, endVertexIndex, ord); m_currentSegment.SetEndAttribute(semantics, ord, ve); } } }