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);
        }
예제 #2
0
 public override com.epl.geometry.Envelope1D QueryInterval(int semantics, int ordinate)
 {
     return(m_impl.QueryInterval(semantics, ordinate));
 }