Beispiel #1
0
 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);
        }