internal static void ExportPolygonToWkt(int export_flags, com.epl.geometry.Polygon polygon, System.Text.StringBuilder @string)
        {
            com.epl.geometry.MultiPathImpl polygon_impl = (com.epl.geometry.MultiPathImpl)polygon._getImpl();
            if ((export_flags & com.epl.geometry.WktExportFlags.wktExportFailIfNotSimple) != 0)
            {
                int simple = polygon_impl.GetIsSimple(0.0);
                if (simple != com.epl.geometry.MultiVertexGeometryImpl.GeometryXSimple.Strong)
                {
                    throw new com.epl.geometry.GeometryException("corrupted geometry");
                }
            }
            int point_count   = polygon.GetPointCount();
            int polygon_count = polygon_impl.GetOGCPolygonCount();

            if (point_count > 0 && polygon_count == 0)
            {
                throw new com.epl.geometry.GeometryException("corrupted geometry");
            }
            int  precision   = 17 - (7 & (export_flags >> 13));
            bool b_export_zs = polygon_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.WktExportFlags.wktExportStripZs) == 0;
            bool b_export_ms = polygon_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M) && (export_flags & com.epl.geometry.WktExportFlags.wktExportStripMs) == 0;
            int  path_count  = 0;

            com.epl.geometry.AttributeStreamOfDbl   position   = null;
            com.epl.geometry.AttributeStreamOfDbl   zs         = null;
            com.epl.geometry.AttributeStreamOfDbl   ms         = null;
            com.epl.geometry.AttributeStreamOfInt8  path_flags = null;
            com.epl.geometry.AttributeStreamOfInt32 paths      = null;
            if (point_count > 0)
            {
                position   = (com.epl.geometry.AttributeStreamOfDbl)(polygon_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION));
                path_flags = polygon_impl.GetPathFlagsStreamRef();
                paths      = polygon_impl.GetPathStreamRef();
                path_count = polygon_impl.GetPathCount();
                if (b_export_zs)
                {
                    if (polygon_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z))
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)polygon_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                    }
                }
                if (b_export_ms)
                {
                    if (polygon_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M))
                    {
                        ms = (com.epl.geometry.AttributeStreamOfDbl)polygon_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                    }
                }
            }
            if ((export_flags & com.epl.geometry.WktExportFlags.wktExportPolygon) != 0)
            {
                if (polygon_count > 1)
                {
                    throw new System.ArgumentException("Cannot export a Polygon with specified export flags: " + export_flags);
                }
                PolygonTaggedText_(precision, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, path_count, @string);
            }
            else
            {
                MultiPolygonTaggedText_(precision, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, polygon_count, path_count, @string);
            }
        }
예제 #2
0
        // Mirrors wkt
        private static void ExportPolygonToGeoJson_(int export_flags, com.epl.geometry.Polygon polygon, com.epl.geometry.JsonWriter json_writer)
        {
            com.epl.geometry.MultiPathImpl polygon_impl = (com.epl.geometry.MultiPathImpl)(polygon._getImpl());
            if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportFailIfNotSimple) != 0)
            {
                int simple = polygon_impl.GetIsSimple(0.0);
                if (simple != com.epl.geometry.MultiVertexGeometryImpl.GeometryXSimple.Strong)
                {
                    throw new com.epl.geometry.GeometryException("corrupted geometry");
                }
            }
            int point_count   = polygon.GetPointCount();
            int polygon_count = polygon_impl.GetOGCPolygonCount();

            if (point_count > 0 && polygon_count == 0)
            {
                throw new com.epl.geometry.GeometryException("corrupted geometry");
            }
            int  precision   = 17 - (31 & (export_flags >> 13));
            bool bFixedPoint = (com.epl.geometry.GeoJsonExportFlags.geoJsonExportPrecisionFixedPoint & export_flags) != 0;
            bool b_export_zs = polygon_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0;
            bool b_export_ms = polygon_impl.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");
            }
            int path_count = 0;

            com.epl.geometry.AttributeStreamOfDbl   position   = null;
            com.epl.geometry.AttributeStreamOfDbl   zs         = null;
            com.epl.geometry.AttributeStreamOfDbl   ms         = null;
            com.epl.geometry.AttributeStreamOfInt8  path_flags = null;
            com.epl.geometry.AttributeStreamOfInt32 paths      = null;
            if (point_count > 0)
            {
                position   = (com.epl.geometry.AttributeStreamOfDbl)polygon_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION);
                path_flags = polygon_impl.GetPathFlagsStreamRef();
                paths      = polygon_impl.GetPathStreamRef();
                path_count = polygon_impl.GetPathCount();
                if (b_export_zs)
                {
                    if (polygon_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z))
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)polygon_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                    }
                }
                if (b_export_ms)
                {
                    if (polygon_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M))
                    {
                        ms = (com.epl.geometry.AttributeStreamOfDbl)polygon_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                    }
                }
            }
            if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportPreferMultiGeometry) == 0 && polygon_count <= 1)
            {
                PolygonTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, paths, path_count, json_writer);
            }
            else
            {
                MultiPolygonTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, polygon_count, path_count, json_writer);
            }
        }