public override void InsertRange(int start, com.epl.geometry.AttributeStreamBase src, int srcStart, int count, bool bForward, int stride, int validSize) { if (m_bReadonly) { throw new com.epl.geometry.GeometryException("invalid_call"); } if (!bForward && (stride < 1 || count % stride != 0)) { throw new System.ArgumentException(); } System.Array.Copy(m_buffer, start, m_buffer, start + count, validSize - start); if (m_buffer == ((com.epl.geometry.AttributeStreamOfFloat)src).m_buffer) { if (start < srcStart) { srcStart += count; } } if (bForward) { System.Array.Copy(((com.epl.geometry.AttributeStreamOfFloat)src).m_buffer, srcStart, m_buffer, start, count); } else { int n = count; for (int i = 0; i < count; i += stride) { n -= stride; for (int s = 0; s < stride; s++) { m_buffer[start + i + s] = ((com.epl.geometry.AttributeStreamOfFloat)src).m_buffer[srcStart + n + s]; } } } }
// public void addRange(AttributeStreamBase src, int srcStartIndex, int // count) { // if ((src == this) || !(src instanceof AttributeStreamOfFloat)) // throw new IllegalArgumentException(); // // AttributeStreamOfFloat as = (AttributeStreamOfFloat) src; // // int len = as.size(); // int oldSize = m_size; // resize(oldSize + len, 0); // for (int i = 0; i < len; i++) { // m_buffer[oldSize + i] = as.read(i); // } // } public override void AddRange(com.epl.geometry.AttributeStreamBase src, int start, int count, bool bForward, int stride) { if (m_bReadonly) { throw new com.epl.geometry.GeometryException("invalid_call"); } if (!bForward && (stride < 1 || count % stride != 0)) { throw new System.ArgumentException(); } int oldSize = m_size; int newSize = oldSize + count; Resize(newSize); if (bForward) { System.Array.Copy(((com.epl.geometry.AttributeStreamOfFloat)src).m_buffer, start, m_buffer, oldSize, count); } else { int n = count; for (int i = 0; i < count; i += stride) { n -= stride; for (int s = 0; s < stride; s++) { m_buffer[oldSize + i + s] = ((com.epl.geometry.AttributeStreamOfFloat)src).m_buffer[start + n + s]; } } } }
public override bool Equals(com.epl.geometry.AttributeStreamBase other, int start, int end) { if (other == null) { return(false); } if (!(other is com.epl.geometry.AttributeStreamOfFloat)) { return(false); } com.epl.geometry.AttributeStreamOfFloat _other = (com.epl.geometry.AttributeStreamOfFloat)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); }
/// <summary> /// Appends points from another MultiVertexGeometryImpl at the end of this /// one. /// </summary> /// <param name="src">The source MultiVertexGeometryImpl</param> public void Add(com.epl.geometry.MultiVertexGeometryImpl src, int beginIndex, int endIndex) { int endIndexC = endIndex < 0 ? src.GetPointCount() : endIndex; if (beginIndex < 0 || beginIndex > src.GetPointCount() || endIndexC < beginIndex) { throw new System.ArgumentException(); } if (beginIndex == endIndexC) { return; } MergeVertexDescription(src.GetDescription()); int count = endIndexC - beginIndex; int oldPointCount = m_pointCount; Resize(m_pointCount + count); _verifyAllStreams(); for (int iattrib = 0, nattrib = src.GetDescription().GetAttributeCount(); iattrib < nattrib; iattrib++) { int semantics = src.GetDescription()._getSemanticsImpl(iattrib); int ncomps = com.epl.geometry.VertexDescription.GetComponentCount(semantics); com.epl.geometry.AttributeStreamBase stream = GetAttributeStreamRef(semantics); com.epl.geometry.AttributeStreamBase srcStream = src.GetAttributeStreamRef(semantics); stream.InsertRange(oldPointCount * ncomps, srcStream, beginIndex * ncomps, count * ncomps, true, 1, oldPointCount * ncomps); } }
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); }
// Checked vs. Jan 11, 2011 /// <param name="bExact"> /// True, when the exact envelope need to be calculated and false /// for the loose one. /// </param> protected internal virtual void _updateAllDirtyIntervals(bool bExact) { _verifyAllStreams(); if (_hasDirtyFlag(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyIntervals)) { if (null == m_envelope) { m_envelope = new com.epl.geometry.Envelope(m_description); } else { m_envelope.AssignVertexDescription(m_description); } if (IsEmpty()) { m_envelope.SetEmpty(); return; } _updateXYImpl(bExact); // efficient method for xy's // now go through other attribues. for (int attributeIndex = 1; attributeIndex < m_description.GetAttributeCount(); attributeIndex++) { int semantics = m_description._getSemanticsImpl(attributeIndex); int ncomps = com.epl.geometry.VertexDescription.GetComponentCount(semantics); com.epl.geometry.AttributeStreamBase stream = m_vertexAttributes[attributeIndex]; for (int iord = 0; iord < ncomps; iord++) { com.epl.geometry.Envelope1D interval = new com.epl.geometry.Envelope1D(); interval.SetEmpty(); for (int i = 0; i < m_pointCount; i++) { double value = stream.ReadAsDbl(i * ncomps + iord); // some // optimization // is // possible // if // non-virtual // method // is // used interval.Merge(value); } m_envelope.SetInterval(semantics, iord, interval); } } if (bExact) { _setDirtyFlag(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyIntervals, false); } } }
// Checked vs. Jan 11, 2011 // TODO Rename to getHashCode public override int GetHashCode() { int hashCode = m_description.GetHashCode(); if (!IsEmptyImpl()) { int pointCount = GetPointCount(); for (int i = 0, n = m_description.GetAttributeCount(); i < n; i++) { int components = com.epl.geometry.VertexDescription.GetComponentCount(m_description._getSemanticsImpl(i)); com.epl.geometry.AttributeStreamBase stream = m_vertexAttributes[i]; hashCode = stream.CalculateHashImpl(hashCode, 0, pointCount * components); } } return(hashCode); }
// Checked vs. Jan 11, 2011 public override bool Equals(object other) { // Java checks if (other == this) { return(true); } if (!(other is com.epl.geometry.MultiVertexGeometryImpl)) { return(false); } com.epl.geometry.MultiVertexGeometryImpl otherMulti = (com.epl.geometry.MultiVertexGeometryImpl)other; if (!(m_description.Equals(otherMulti.m_description))) { return(false); } if (IsEmptyImpl() != otherMulti.IsEmptyImpl()) { return(false); } if (IsEmptyImpl()) { return(true); } // both geometries are empty int pointCount = GetPointCount(); int pointCountOther = otherMulti.GetPointCount(); if (pointCount != pointCountOther) { return(false); } for (int i = 0; i < m_description.GetAttributeCount(); i++) { int semantics = m_description.GetSemantics(i); com.epl.geometry.AttributeStreamBase stream = GetAttributeStreamRef(semantics); com.epl.geometry.AttributeStreamBase streamOther = otherMulti.GetAttributeStreamRef(semantics); int components = com.epl.geometry.VertexDescription.GetComponentCount(semantics); if (!stream.Equals(streamOther, 0, pointCount * components)) { return(false); } } return(true); }
//Does not check geometry type. Used to copy Polygon to Polyline internal virtual void _copyToUnsafe(com.epl.geometry.MultiVertexGeometryImpl dst) { _verifyAllStreams(); dst.m_description = m_description; dst.m_vertexAttributes = null; int nattrib = m_description.GetAttributeCount(); com.epl.geometry.AttributeStreamBase[] cloneAttributes = null; if (m_vertexAttributes != null) { cloneAttributes = new com.epl.geometry.AttributeStreamBase[nattrib]; for (int i = 0; i < nattrib; i++) { if (m_vertexAttributes[i] != null) { int ncomps = com.epl.geometry.VertexDescription.GetComponentCount(m_description._getSemanticsImpl(i)); cloneAttributes[i] = m_vertexAttributes[i].RestrictedClone(GetPointCount() * ncomps); } } } if (m_envelope != null) { dst.m_envelope = (com.epl.geometry.Envelope)m_envelope.CreateInstance(); m_envelope.CopyTo(dst.m_envelope); } else { // dst.m_envelope = (Envelope) m_envelope.clone(); dst.m_envelope = null; } dst.m_pointCount = m_pointCount; dst.m_flagsMask = m_flagsMask; dst.m_vertexAttributes = cloneAttributes; try { _copyToImpl(dst); } catch (System.Exception ex) { // copy child props dst.SetEmpty(); throw new System.Exception("", ex); } }
public override void ReplaceNaNs(int semantics, double value) { AddAttribute(semantics); if (IsEmpty()) { return; } bool modified = false; int ncomps = com.epl.geometry.VertexDescription.GetComponentCount(semantics); for (int i = 0; i < ncomps; i++) { com.epl.geometry.AttributeStreamBase streamBase = GetAttributeStreamRef(semantics); if (streamBase is com.epl.geometry.AttributeStreamOfDbl) { com.epl.geometry.AttributeStreamOfDbl dblStream = (com.epl.geometry.AttributeStreamOfDbl)streamBase; for (int ivert = 0, n = m_pointCount * ncomps; ivert < n; ivert++) { double v = dblStream.Read(ivert); if (double.IsNaN(v)) { dblStream.Write(ivert, value); modified = true; } } } else { for (int ivert = 0, n = m_pointCount * ncomps; ivert < n; ivert++) { double v = streamBase.ReadAsDbl(ivert); if (double.IsNaN(v)) { streamBase.WriteAsDbl(ivert, value); modified = true; } } } } if (modified) { NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyCoordinates); } }
/// <summary>Sets a reference to the given AttributeStream of the Geometry.</summary> /// <remarks> /// Sets a reference to the given AttributeStream of the Geometry. Once the /// buffer has been obtained, the vertices of the Geometry can be manipulated /// directly. The AttributeStream parameters are not checked for the size. <br /> /// If the attribute is missing, it will be added. <br /> /// Note, that this method does not change the vertex count in the Geometry. <br /> /// The stream can have more elements, than the Geometry point count, but /// only necessary part will be saved when exporting to a ESRI shape or other /// format. @param semantics Semantics of the attribute to assign the stream /// to. @param stream The input AttributeStream that will be assigned by /// reference. If one changes the stream later through the reference, one has /// to call NotifyStreamChanged. \exception Throws invalid_argument exception /// if the input stream type does not match that of the semantics /// persistence. /// </remarks> public virtual void SetAttributeStreamRef(int semantics, com.epl.geometry.AttributeStreamBase stream) { // int test1 = VertexDescription.getPersistence(semantics); // int test2 = stream.getPersistence(); if ((stream != null) && com.epl.geometry.VertexDescription.GetPersistence(semantics) != stream.GetPersistence()) { // input stream has wrong persistence throw new System.ArgumentException(); } // Do not check for the stream size here to allow several streams to be // attached before the point count is changed. AddAttribute(semantics); int attributeIndex = m_description.GetAttributeIndex(semantics); if (m_vertexAttributes == null) { m_vertexAttributes = new com.epl.geometry.AttributeStreamBase[m_description.GetAttributeCount()]; } m_vertexAttributes[attributeIndex] = stream; NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyAll); }
protected internal override void _assignVertexDescriptionImpl(com.epl.geometry.VertexDescription newDescription) { com.epl.geometry.AttributeStreamBase[] newAttributes = null; if (m_vertexAttributes != null) { int[] mapping = com.epl.geometry.VertexDescriptionDesignerImpl.MapAttributes(newDescription, m_description); newAttributes = new com.epl.geometry.AttributeStreamBase[newDescription.GetAttributeCount()]; for (int i = 0, n = newDescription.GetAttributeCount(); i < n; i++) { if (mapping[i] != -1) { int m = mapping[i]; newAttributes[i] = m_vertexAttributes[m]; } } } //if there are no streams we do not create them m_description = newDescription; m_vertexAttributes = newAttributes; // late assignment to try to stay m_reservedPointCount = -1; // we need to recreate the new attribute then NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyAll); }
public static void CompareGeometryContent(com.epl.geometry.MultiVertexGeometry geom1, com.epl.geometry.MultiVertexGeometry geom2) { // Geometry types NUnit.Framework.Assert.IsTrue(geom1.GetType().Value() == geom2.GetType().Value()); // Envelopes com.epl.geometry.Envelope2D env1 = new com.epl.geometry.Envelope2D(); geom1.QueryEnvelope2D(env1); com.epl.geometry.Envelope2D env2 = new com.epl.geometry.Envelope2D(); geom2.QueryEnvelope2D(env2); NUnit.Framework.Assert.IsTrue(env1.xmin == env2.xmin && env1.xmax == env2.xmax && env1.ymin == env2.ymin && env1.ymax == env2.ymax); int type = geom1.GetType().Value(); if (type == com.epl.geometry.Geometry.GeometryType.Polyline || type == com.epl.geometry.Geometry.GeometryType.Polygon) { // Part Count int partCount1 = ((com.epl.geometry.MultiPath)geom1).GetPathCount(); int partCount2 = ((com.epl.geometry.MultiPath)geom2).GetPathCount(); NUnit.Framework.Assert.IsTrue(partCount1 == partCount2); // Part indices for (int i = 0; i < partCount1; i++) { int start1 = ((com.epl.geometry.MultiPath)geom1).GetPathStart(i); int start2 = ((com.epl.geometry.MultiPath)geom2).GetPathStart(i); NUnit.Framework.Assert.IsTrue(start1 == start2); int end1 = ((com.epl.geometry.MultiPath)geom1).GetPathEnd(i); int end2 = ((com.epl.geometry.MultiPath)geom2).GetPathEnd(i); NUnit.Framework.Assert.IsTrue(end1 == end2); } } // Point count int pointCount1 = geom1.GetPointCount(); int pointCount2 = geom2.GetPointCount(); NUnit.Framework.Assert.IsTrue(pointCount1 == pointCount2); if (type == com.epl.geometry.Geometry.GeometryType.MultiPoint || type == com.epl.geometry.Geometry.GeometryType.Polyline || type == com.epl.geometry.Geometry.GeometryType.Polygon) { // POSITION com.epl.geometry.AttributeStreamBase positionStream1 = ((com.epl.geometry.MultiVertexGeometryImpl)geom1._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION); com.epl.geometry.AttributeStreamOfDbl position1 = (com.epl.geometry.AttributeStreamOfDbl)(positionStream1); com.epl.geometry.AttributeStreamBase positionStream2 = ((com.epl.geometry.MultiVertexGeometryImpl)geom2._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION); com.epl.geometry.AttributeStreamOfDbl position2 = (com.epl.geometry.AttributeStreamOfDbl)(positionStream2); for (int i = 0; i < pointCount1; i++) { double x1 = position1.Read(2 * i); double x2 = position2.Read(2 * i); NUnit.Framework.Assert.IsTrue(x1 == x2); double y1 = position1.Read(2 * i + 1); double y2 = position2.Read(2 * i + 1); NUnit.Framework.Assert.IsTrue(y1 == y2); } // Zs bool bHasZs1 = geom1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z); bool bHasZs2 = geom2.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z); NUnit.Framework.Assert.IsTrue(bHasZs1 == bHasZs2); if (bHasZs1) { com.epl.geometry.AttributeStreamBase zStream1 = ((com.epl.geometry.MultiVertexGeometryImpl)geom1._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z); com.epl.geometry.AttributeStreamOfDbl zs1 = (com.epl.geometry.AttributeStreamOfDbl)(zStream1); com.epl.geometry.AttributeStreamBase zStream2 = ((com.epl.geometry.MultiVertexGeometryImpl)geom2._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z); com.epl.geometry.AttributeStreamOfDbl zs2 = (com.epl.geometry.AttributeStreamOfDbl)(zStream2); for (int i_1 = 0; i_1 < pointCount1; i_1++) { double z1 = zs1.Read(i_1); double z2 = zs2.Read(i_1); NUnit.Framework.Assert.IsTrue(z1 == z2); } } // Ms bool bHasMs1 = geom1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M); bool bHasMs2 = geom2.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M); NUnit.Framework.Assert.IsTrue(bHasMs1 == bHasMs2); if (bHasMs1) { com.epl.geometry.AttributeStreamBase mStream1 = ((com.epl.geometry.MultiVertexGeometryImpl)geom1._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M); com.epl.geometry.AttributeStreamOfDbl ms1 = (com.epl.geometry.AttributeStreamOfDbl)(mStream1); com.epl.geometry.AttributeStreamBase mStream2 = ((com.epl.geometry.MultiVertexGeometryImpl)geom2._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M); com.epl.geometry.AttributeStreamOfDbl ms2 = (com.epl.geometry.AttributeStreamOfDbl)(mStream2); for (int i_1 = 0; i_1 < pointCount1; i_1++) { double m1 = ms1.Read(i_1); double m2 = ms2.Read(i_1); NUnit.Framework.Assert.IsTrue(m1 == m2); } } // IDs bool bHasIDs1 = geom1.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID); bool bHasIDs2 = geom2.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID); NUnit.Framework.Assert.IsTrue(bHasIDs1 == bHasIDs2); if (bHasIDs1) { com.epl.geometry.AttributeStreamBase idStream1 = ((com.epl.geometry.MultiVertexGeometryImpl)geom1._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.ID); com.epl.geometry.AttributeStreamOfInt32 ids1 = (com.epl.geometry.AttributeStreamOfInt32)(idStream1); com.epl.geometry.AttributeStreamBase idStream2 = ((com.epl.geometry.MultiVertexGeometryImpl)geom2._getImpl()).GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.ID); com.epl.geometry.AttributeStreamOfInt32 ids2 = (com.epl.geometry.AttributeStreamOfInt32)(idStream2); for (int i_1 = 0; i_1 < pointCount1; i_1++) { int id1 = ids1.Read(i_1); int id2 = ids2.Read(i_1); NUnit.Framework.Assert.IsTrue(id1 == id2); } } } }
private static int ExportMultiPathToESRIShape(bool bPolygon, int exportFlags, com.epl.geometry.MultiPath multipath, System.IO.BinaryWriter shapeBuffer) { com.epl.geometry.MultiPathImpl multipathImpl = (com.epl.geometry.MultiPathImpl)multipath._getImpl(); bool bExportZs = multipathImpl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripZs) == 0; bool bExportMs = multipathImpl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripMs) == 0; bool bExportIDs = multipathImpl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripIDs) == 0; bool bHasCurves = multipathImpl.HasNonLinearSegments(); bool bArcViewNaNs = (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportTrueNaNs) == 0; int partCount = multipathImpl.GetPathCount(); int pointCount = multipathImpl.GetPointCount(); if (!bPolygon) { for (int ipart = 0; ipart < partCount; ipart++) { if (multipath.IsClosedPath(ipart)) { pointCount++; } } } else { pointCount += partCount; } int size = (4) + (4 * 8) + (4) + (4) + (partCount * 4) + pointCount * 2 * 8; /* type */ /* envelope */ /* part count */ /* point count */ /* start indices */ /* xy coordinates */ if (bExportZs) { size += (2 * 8) + (pointCount * 8); } /* min max */ /* zs */ if (bExportMs) { size += (2 * 8) + (pointCount * 8); } /* min max */ /* ms */ if (bExportIDs) { size += pointCount * 4; } /* ids */ if (bHasCurves) { } // to-do: curves if (size >= com.epl.geometry.NumberUtils.IntMax()) { throw new com.epl.geometry.GeometryException("invalid call"); } 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 offset = 0; // Determine the shape type int type; if (!bExportZs && !bExportMs) { if (bExportIDs || bHasCurves) { type = bPolygon ? com.epl.geometry.ShapeType.ShapeGeneralPolygon : com.epl.geometry.ShapeType.ShapeGeneralPolyline; if (bExportIDs) { type |= com.epl.geometry.ShapeModifiers.ShapeHasIDs; } if (bHasCurves) { type |= com.epl.geometry.ShapeModifiers.ShapeHasCurves; } } else { type = bPolygon ? com.epl.geometry.ShapeType.ShapePolygon : com.epl.geometry.ShapeType.ShapePolyline; } } else { if (bExportZs && !bExportMs) { if (bExportIDs || bHasCurves) { type = bPolygon ? com.epl.geometry.ShapeType.ShapeGeneralPolygon : com.epl.geometry.ShapeType.ShapeGeneralPolyline; type |= com.epl.geometry.ShapeModifiers.ShapeHasZs; if (bExportIDs) { type |= com.epl.geometry.ShapeModifiers.ShapeHasIDs; } if (bHasCurves) { type |= com.epl.geometry.ShapeModifiers.ShapeHasCurves; } } else { type = bPolygon ? com.epl.geometry.ShapeType.ShapePolygonZ : com.epl.geometry.ShapeType.ShapePolylineZ; } } else { if (bExportMs && !bExportZs) { if (bExportIDs || bHasCurves) { type = bPolygon ? com.epl.geometry.ShapeType.ShapeGeneralPolygon : com.epl.geometry.ShapeType.ShapeGeneralPolyline; type |= com.epl.geometry.ShapeModifiers.ShapeHasMs; if (bExportIDs) { type |= com.epl.geometry.ShapeModifiers.ShapeHasIDs; } if (bHasCurves) { type |= com.epl.geometry.ShapeModifiers.ShapeHasCurves; } } else { type = bPolygon ? com.epl.geometry.ShapeType.ShapePolygonM : com.epl.geometry.ShapeType.ShapePolylineM; } } else { if (bExportIDs || bHasCurves) { type = bPolygon ? com.epl.geometry.ShapeType.ShapeGeneralPolygon : com.epl.geometry.ShapeType.ShapeGeneralPolyline; type |= com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasMs; if (bExportIDs) { type |= com.epl.geometry.ShapeModifiers.ShapeHasIDs; } if (bHasCurves) { type |= com.epl.geometry.ShapeModifiers.ShapeHasCurves; } } else { type = bPolygon ? com.epl.geometry.ShapeType.ShapePolygonZM : com.epl.geometry.ShapeType.ShapePolylineZM; } } } } // write type shapeBuffer.Write(type); offset += 4; // write Envelope com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D(); multipathImpl.QueryEnvelope2D(env); // calls _VerifyAllStreams shapeBuffer.Write(env.xmin); offset += 8; shapeBuffer.Write(env.ymin); offset += 8; shapeBuffer.Write(env.xmax); offset += 8; shapeBuffer.Write(env.ymax); offset += 8; // write part count shapeBuffer.Write(partCount); offset += 4; // to-do: return error if larger than 2^32 - 1 // write pointCount shapeBuffer.Write(pointCount); offset += 4; // write start indices for each part int pointIndexDelta = 0; for (int ipart = 0; ipart < partCount; ipart++) { int istart = multipathImpl.GetPathStart(ipart) + pointIndexDelta; shapeBuffer.Write(istart); offset += 4; if (bPolygon || multipathImpl.IsClosedPath(ipart)) { pointIndexDelta++; } } if (pointCount > 0) { // write xy coordinates com.epl.geometry.AttributeStreamBase positionStream = multipathImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION); com.epl.geometry.AttributeStreamOfDbl position = (com.epl.geometry.AttributeStreamOfDbl)positionStream; for (int ipart = 0; ipart < partCount; ipart++) { int partStart = multipathImpl.GetPathStart(ipart); int partEnd = multipathImpl.GetPathEnd(ipart); for (int i = partStart; i < partEnd; i++) { double x = position.Read(2 * i); double y = position.Read(2 * i + 1); shapeBuffer.Write(x); offset += 8; shapeBuffer.Write(y); offset += 8; } // If the part is closed, then we need to duplicate the start // point if (bPolygon || multipathImpl.IsClosedPath(ipart)) { double x = position.Read(2 * partStart); double y = position.Read(2 * partStart + 1); shapeBuffer.Write(x); offset += 8; shapeBuffer.Write(y); offset += 8; } } } // write Zs if (bExportZs) { com.epl.geometry.Envelope1D zInterval = multipathImpl.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(zInterval.vmin) : zInterval.vmin); offset += 8; shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(zInterval.vmax) : zInterval.vmax); offset += 8; if (pointCount > 0) { if (multipathImpl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z)) { com.epl.geometry.AttributeStreamOfDbl zs = (com.epl.geometry.AttributeStreamOfDbl)multipathImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z); for (int ipart = 0; ipart < partCount; ipart++) { int partStart = multipathImpl.GetPathStart(ipart); int partEnd = multipathImpl.GetPathEnd(ipart); for (int i = partStart; i < partEnd; i++) { double z = zs.Read(i); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(z) : z); offset += 8; } // If the part is closed, then we need to duplicate the // start z if (bPolygon || multipathImpl.IsClosedPath(ipart)) { double z = zs.Read(partStart); shapeBuffer.Write(z); offset += 8; } } } else { double z = com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.Z); if (bArcViewNaNs) { z = com.epl.geometry.Interop.TranslateToAVNaN(z); } for (int i = 0; i < pointCount; i++) { shapeBuffer.Write(z); } offset += 8; } } } // write Ms if (bExportMs) { com.epl.geometry.Envelope1D mInterval = multipathImpl.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(mInterval.vmin) : mInterval.vmin); offset += 8; shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(mInterval.vmax) : mInterval.vmax); offset += 8; if (pointCount > 0) { if (multipathImpl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M)) { com.epl.geometry.AttributeStreamOfDbl ms = (com.epl.geometry.AttributeStreamOfDbl)multipathImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M); for (int ipart = 0; ipart < partCount; ipart++) { int partStart = multipathImpl.GetPathStart(ipart); int partEnd = multipathImpl.GetPathEnd(ipart); for (int i = partStart; i < partEnd; i++) { double m = ms.Read(i); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(m) : m); offset += 8; } // If the part is closed, then we need to duplicate the // start m if (bPolygon || multipathImpl.IsClosedPath(ipart)) { double m = ms.Read(partStart); shapeBuffer.Write(m); offset += 8; } } } else { double m = com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.M); if (bArcViewNaNs) { m = com.epl.geometry.Interop.TranslateToAVNaN(m); } for (int i = 0; i < pointCount; i++) { shapeBuffer.Write(m); } offset += 8; } } } // write Curves if (bHasCurves) { } // to-do: We'll finish this later // write IDs if (bExportIDs) { if (pointCount > 0) { if (multipathImpl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.ID)) { com.epl.geometry.AttributeStreamOfInt32 ids = (com.epl.geometry.AttributeStreamOfInt32)multipathImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.ID); for (int ipart = 0; ipart < partCount; ipart++) { int partStart = multipathImpl.GetPathStart(ipart); int partEnd = multipathImpl.GetPathEnd(ipart); for (int i = partStart; i < partEnd; i++) { int id = ids.Read(i); shapeBuffer.Write(id); offset += 4; } // If the part is closed, then we need to duplicate the // start id if (bPolygon || multipathImpl.IsClosedPath(ipart)) { int id = ids.Read(partStart); shapeBuffer.Write(id); offset += 4; } } } else { int id = (int)com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.ID); for (int i = 0; i < pointCount; i++) { shapeBuffer.Write(id); } offset += 4; } } } return(offset); }
private static int ExportMultiPointToESRIShape(int exportFlags, com.epl.geometry.MultiPoint multipoint, System.IO.BinaryWriter shapeBuffer) { com.epl.geometry.MultiPointImpl multipointImpl = (com.epl.geometry.MultiPointImpl)multipoint._getImpl(); bool bExportZs = multipointImpl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripZs) == 0; bool bExportMs = multipointImpl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripMs) == 0; bool bExportIDs = multipointImpl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.ID) && (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportStripIDs) == 0; bool bArcViewNaNs = (exportFlags & com.epl.geometry.ShapeExportFlags.ShapeExportTrueNaNs) == 0; int pointCount = multipointImpl.GetPointCount(); int size = (4) + (4 * 8) + (4) + (pointCount * 2 * 8); /* type */ /* envelope */ /* point count */ /* xy coordinates */ if (bExportZs) { size += (2 * 8) + (pointCount * 8); } /* min max */ /* zs */ if (bExportMs) { size += (2 * 8) + (pointCount * 8); } /* min max */ /* ms */ if (bExportIDs) { size += pointCount * 4; } /* ids */ if (size >= com.epl.geometry.NumberUtils.IntMax()) { throw new com.epl.geometry.GeometryException("invalid call"); } 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 (!bExportZs && !bExportMs) { if (bExportIDs) { type = com.epl.geometry.ShapeType.ShapeGeneralMultiPoint | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapeMultiPoint; } } else { if (bExportZs && !bExportMs) { if (bExportIDs) { type = com.epl.geometry.ShapeType.ShapeGeneralMultiPoint | com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapeMultiPointZ; } } else { if (bExportMs && !bExportZs) { if (bExportIDs) { type = com.epl.geometry.ShapeType.ShapeGeneralMultiPoint | com.epl.geometry.ShapeModifiers.ShapeHasMs | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapeMultiPointM; } } else { if (bExportIDs) { type = com.epl.geometry.ShapeType.ShapeGeneralMultiPoint | com.epl.geometry.ShapeModifiers.ShapeHasZs | com.epl.geometry.ShapeModifiers.ShapeHasMs | com.epl.geometry.ShapeModifiers.ShapeHasIDs; } else { type = com.epl.geometry.ShapeType.ShapeMultiPointZM; } } } } // write type int offset = 0; shapeBuffer.Write(type); offset += 4; // write Envelope com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D(); multipointImpl.QueryEnvelope2D(env); // calls _VerifyAllStreams shapeBuffer.Write(env.xmin); offset += 8; shapeBuffer.Write(env.ymin); offset += 8; shapeBuffer.Write(env.xmax); offset += 8; shapeBuffer.Write(env.ymax); offset += 8; // write point count shapeBuffer.Write(pointCount); offset += 4; if (pointCount > 0) { // write xy coordinates com.epl.geometry.AttributeStreamBase positionStream = multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION); com.epl.geometry.AttributeStreamOfDbl position = (com.epl.geometry.AttributeStreamOfDbl)positionStream; for (int i = 0; i < pointCount; i++) { double x = position.Read(2 * i); double y = position.Read(2 * i + 1); shapeBuffer.Write(x); offset += 8; shapeBuffer.Write(y); offset += 8; } } // write Zs if (bExportZs) { com.epl.geometry.Envelope1D zInterval = multipointImpl.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(zInterval.vmin) : zInterval.vmin); offset += 8; shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(zInterval.vmax) : zInterval.vmax); offset += 8; if (pointCount > 0) { if (multipointImpl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z)) { com.epl.geometry.AttributeStreamOfDbl zs = (com.epl.geometry.AttributeStreamOfDbl)multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z); for (int i = 0; i < pointCount; i++) { double z = zs.Read(i); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(z) : z); offset += 8; } } else { double z = com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.Z); if (bArcViewNaNs) { z = com.epl.geometry.Interop.TranslateToAVNaN(z); } // Can we write a function that writes all these values at // once instead of doing a for loop? for (int i = 0; i < pointCount; i++) { shapeBuffer.Write(z); } offset += 8; } } } // write Ms if (bExportMs) { com.epl.geometry.Envelope1D mInterval = multipointImpl.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(mInterval.vmin) : mInterval.vmin); offset += 8; shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(mInterval.vmax) : mInterval.vmax); offset += 8; if (pointCount > 0) { if (multipointImpl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M)) { com.epl.geometry.AttributeStreamOfDbl ms = (com.epl.geometry.AttributeStreamOfDbl)multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M); for (int i = 0; i < pointCount; i++) { double m = ms.Read(i); shapeBuffer.Write(bArcViewNaNs ? com.epl.geometry.Interop.TranslateToAVNaN(m) : m); offset += 8; } } else { double m = com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.M); if (bArcViewNaNs) { m = com.epl.geometry.Interop.TranslateToAVNaN(m); } for (int i = 0; i < pointCount; i++) { shapeBuffer.Write(m); } offset += 8; } } } // write IDs if (bExportIDs) { if (pointCount > 0) { if (multipointImpl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.ID)) { com.epl.geometry.AttributeStreamOfInt32 ids = (com.epl.geometry.AttributeStreamOfInt32)multipointImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.ID); for (int i = 0; i < pointCount; i++) { int id = ids.Read(i); shapeBuffer.Write(id); offset += 4; } } else { int id = (int)com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.ID); for (int i = 0; i < pointCount; i++) { shapeBuffer.Write(id); } offset += 4; } } } return(offset); }
public abstract bool Equals(com.epl.geometry.AttributeStreamBase other, int start, int end);
/// <summary>Adds a range of elements from the source byte buffer.</summary> /// <remarks> /// Adds a range of elements from the source byte buffer. This stream is /// resized automatically to accomodate required number of elements. /// </remarks> /// <param name="startElement"> /// the index of the element in this stream to start setting /// elements from. /// </param> /// <param name="count">The number of AttributeStream elements to read.</param> /// <param name="src">The source ByteBuffer to read elements from.</param> /// <param name="sourceStart">The offset from the start of the ByteBuffer in bytes.</param> /// <param name="bForward">When False, the source is written in reversed order.</param> /// <param name="stride"> /// Used for reversed writing only to indicate the unit of /// writing. elements inside a stride are not reversed. Only the /// strides are reversed. /// </param> public abstract void WriteRange(int startElement, int count, com.epl.geometry.AttributeStreamBase src, int sourceStart, bool bForward, int stride);
/// <summary>Inserts a range of elements from the source stream.</summary> /// <remarks> /// Inserts a range of elements from the source stream. The streams must be /// of the same type. /// </remarks> /// <param name="start">The index where to start the insert.</param> /// <param name="src">The source stream to read elements from.</param> /// <param name="srcStart"> /// The index of the element in the source stream to start reading /// from. /// </param> /// <param name="count">The number of elements to read from the source stream.</param> /// <param name="validSize">The number of valid elements in this stream.</param> public abstract void InsertRange(int start, com.epl.geometry.AttributeStreamBase src, int srcStart, int count, bool bForward, int stride, int validSize);
/// <summary>Adds a range of elements from the source stream.</summary> /// <remarks> /// Adds a range of elements from the source stream. The streams must be of /// the same type. /// </remarks> /// <param name="src">The source stream to read elements from.</param> /// <param name="srcStart"> /// The index of the element in the source stream to start reading /// from. /// </param> /// <param name="count">The number of elements to add.</param> /// <param name="bForward"> /// True if adding the elements in order of the incoming source /// stream. False if adding the elements in reverse. /// </param> /// <param name="stride"> /// The number of elements to be grouped together if adding the /// elements in reverse. /// </param> public abstract void AddRange(com.epl.geometry.AttributeStreamBase src, int srcStart, int count, bool bForward, int stride);
internal static com.epl.geometry.MapGeometry ImportFromJsonParser(int gt, com.epl.geometry.JsonReader parser) { com.epl.geometry.MapGeometry mp; try { if (!com.epl.geometry.JSONUtils.IsObjectStart(parser)) { return(null); } bool bFoundSpatial_reference = false; bool bFoundHasZ = false; bool bFoundHasM = false; bool bFoundPolygon = false; bool bFoundPolyline = false; bool bFoundMultiPoint = false; bool bFoundX = false; bool bFoundY = false; bool bFoundZ = false; bool bFoundM = false; bool bFoundXMin = false; bool bFoundYMin = false; bool bFoundXMax = false; bool bFoundYMax = false; bool bFoundZMin = false; bool bFoundZMax = false; bool bFoundMMin = false; bool bFoundMMax = false; 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(); double xmin = com.epl.geometry.NumberUtils.NaN(); double ymin = com.epl.geometry.NumberUtils.NaN(); double xmax = com.epl.geometry.NumberUtils.NaN(); double ymax = com.epl.geometry.NumberUtils.NaN(); double zmin = com.epl.geometry.NumberUtils.NaN(); double zmax = com.epl.geometry.NumberUtils.NaN(); double mmin = com.epl.geometry.NumberUtils.NaN(); double mmax = com.epl.geometry.NumberUtils.NaN(); bool bHasZ = false; bool bHasM = false; com.epl.geometry.AttributeStreamOfDbl @as = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0); com.epl.geometry.AttributeStreamOfDbl bs = (com.epl.geometry.AttributeStreamOfDbl)com.epl.geometry.AttributeStreamBase.CreateDoubleStream(0); com.epl.geometry.Geometry geometry = null; com.epl.geometry.SpatialReference spatial_reference = null; while (parser.NextToken() != com.epl.geometry.JsonReader.Token.END_OBJECT) { string name = parser.CurrentString(); parser.NextToken(); if (!bFoundSpatial_reference && name.Equals("spatialReference")) { bFoundSpatial_reference = true; if (parser.CurrentToken() == com.epl.geometry.JsonReader.Token.START_OBJECT) { spatial_reference = com.epl.geometry.SpatialReference.FromJson(parser); } else { if (parser.CurrentToken() != com.epl.geometry.JsonReader.Token.VALUE_NULL) { throw new com.epl.geometry.GeometryException("failed to parse spatial reference: object or null is expected"); } } } else { if (!bFoundHasZ && name.Equals("hasZ")) { bFoundHasZ = true; bHasZ = (parser.CurrentToken() == com.epl.geometry.JsonReader.Token.VALUE_TRUE); } else { if (!bFoundHasM && name.Equals("hasM")) { bFoundHasM = true; bHasM = (parser.CurrentToken() == com.epl.geometry.JsonReader.Token.VALUE_TRUE); } else { if (!bFoundPolygon && name.Equals("rings") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Polygon)) { bFoundPolygon = true; geometry = ImportFromJsonMultiPath(true, parser, @as, bs); continue; } else { if (!bFoundPolyline && name.Equals("paths") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Polyline)) { bFoundPolyline = true; geometry = ImportFromJsonMultiPath(false, parser, @as, bs); continue; } else { if (!bFoundMultiPoint && name.Equals("points") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.MultiPoint)) { bFoundMultiPoint = true; geometry = ImportFromJsonMultiPoint(parser, @as, bs); continue; } else { if (!bFoundX && name.Equals("x") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Point)) { bFoundX = true; x = ReadDouble(parser); } else { if (!bFoundY && name.Equals("y") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Point)) { bFoundY = true; y = ReadDouble(parser); } else { if (!bFoundZ && name.Equals("z") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Point)) { bFoundZ = true; z = ReadDouble(parser); } else { if (!bFoundM && name.Equals("m") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Point)) { bFoundM = true; m = ReadDouble(parser); } } } } } } } } } } if (!bFoundXMin && name.Equals("xmin") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundXMin = true; xmin = ReadDouble(parser); } else { if (!bFoundYMin && name.Equals("ymin") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundYMin = true; ymin = ReadDouble(parser); } else { if (!bFoundMMin && name.Equals("mmin") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundMMin = true; mmin = ReadDouble(parser); } else { if (!bFoundZMin && name.Equals("zmin") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundZMin = true; zmin = ReadDouble(parser); } else { if (!bFoundXMax && name.Equals("xmax") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundXMax = true; xmax = ReadDouble(parser); } else { if (!bFoundYMax && name.Equals("ymax") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundYMax = true; ymax = ReadDouble(parser); } else { if (!bFoundMMax && name.Equals("mmax") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundMMax = true; mmax = ReadDouble(parser); } else { if (!bFoundZMax && name.Equals("zmax") && (gt == com.epl.geometry.Geometry.GeometryType.Unknown || gt == com.epl.geometry.Geometry.GeometryType.Envelope)) { bFoundZMax = true; zmax = ReadDouble(parser); } else { Windup(parser); } } } } } } } } } if (bFoundPolygon || bFoundPolyline || bFoundMultiPoint) { System.Diagnostics.Debug.Assert((geometry != null)); com.epl.geometry.MultiVertexGeometryImpl mvImpl = (com.epl.geometry.MultiVertexGeometryImpl)geometry._getImpl(); com.epl.geometry.AttributeStreamBase zs = null; com.epl.geometry.AttributeStreamBase ms = null; if (bHasZ) { geometry.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z); zs = @as; } if (bHasM) { geometry.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); ms = !bHasZ ? @as : bs; } if (bHasZ && zs != null) { mvImpl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z, zs); } if (bHasM && ms != null) { mvImpl.SetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M, ms); } mvImpl.NotifyModified(com.epl.geometry.MultiVertexGeometryImpl.DirtyFlags.DirtyAll); } else { if (bFoundX || bFoundY || bFoundY || bFoundZ) { if (com.epl.geometry.NumberUtils.IsNaN(y)) { x = com.epl.geometry.NumberUtils.NaN(); } com.epl.geometry.Point p = new com.epl.geometry.Point(x, y); if (bFoundZ) { p.SetZ(z); } if (bFoundM) { p.SetM(m); } geometry = p; } else { if (bFoundXMin || bFoundYMin || bFoundXMax || bFoundYMax || bFoundZMin || bFoundZMax || bFoundMMin || bFoundMMax) { if (com.epl.geometry.NumberUtils.IsNaN(ymin) || com.epl.geometry.NumberUtils.IsNaN(xmax) || com.epl.geometry.NumberUtils.IsNaN(ymax)) { xmin = com.epl.geometry.NumberUtils.NaN(); } com.epl.geometry.Envelope e = new com.epl.geometry.Envelope(xmin, ymin, xmax, ymax); if (bFoundZMin && bFoundZMax) { e.SetInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0, zmin, zmax); } if (bFoundMMin && bFoundMMax) { e.SetInterval(com.epl.geometry.VertexDescription.Semantics.M, 0, mmin, mmax); } geometry = e; } } } mp = new com.epl.geometry.MapGeometry(geometry, spatial_reference); } catch (System.Exception) { return(null); } return(mp); }
public override void WriteRange(int startElement, int count, com.epl.geometry.AttributeStreamBase _src, int srcStart, bool bForward, int stride) { if (startElement < 0 || count < 0 || srcStart < 0) { throw new System.ArgumentException(); } if (!bForward && (stride <= 0 || (count % stride != 0))) { throw new System.ArgumentException(); } com.epl.geometry.AttributeStreamOfFloat src = (com.epl.geometry.AttributeStreamOfFloat)_src; // the input // type must // match if (src.Size() < (int)(srcStart + count)) { throw new System.ArgumentException(); } if (count == 0) { return; } if (Size() < count + startElement) { Resize(count + startElement); } if (_src == (com.epl.geometry.AttributeStreamBase)this) { _selfWriteRangeImpl(startElement, count, srcStart, bForward, stride); return; } if (bForward) { int j = startElement; int offset = srcStart; for (int i = 0; i < count; i++) { m_buffer[j] = src.m_buffer[offset]; j++; offset++; } } else { int j = startElement; int offset = srcStart + count - stride; if (stride == 1) { for (int i = 0; i < count; i++) { m_buffer[j] = src.m_buffer[offset]; j++; offset--; } } else { for (int i = 0, n = count / stride; i < n; i++) { for (int k = 0; k < stride; k++) { m_buffer[j + k] = src.m_buffer[offset + k]; } j += stride; offset -= stride; } } } }