Beispiel #1
0
 // Mirrors wkt
 private static void LineStringText_(bool bRing, bool b_closed, 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, int istart, int iend
                                     , com.epl.geometry.JsonWriter json_writer)
 {
     if (istart == iend)
     {
         json_writer.StartArray();
         json_writer.EndArray();
         return;
     }
     json_writer.StartArray();
     if (bRing)
     {
         PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, istart, json_writer);
         for (int point = iend - 1; point >= istart + 1; point--)
         {
             PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, point, json_writer);
         }
         PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, istart, json_writer);
     }
     else
     {
         for (int point = istart; point < iend - 1; point++)
         {
             PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, point, json_writer);
         }
         PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, iend - 1, json_writer);
         if (b_closed)
         {
             PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, istart, json_writer);
         }
     }
     json_writer.EndArray();
 }
Beispiel #2
0
 // Mirrors wkt
 private static void PolygonTaggedText_(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.AttributeStreamOfInt32
                                        paths, int path_count, com.epl.geometry.JsonWriter json_writer)
 {
     json_writer.AddFieldName("type");
     json_writer.AddValueString("Polygon");
     json_writer.AddFieldName("coordinates");
     if (position == null)
     {
         json_writer.StartArray();
         json_writer.EndArray();
         return;
     }
     PolygonText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, paths, 0, path_count, json_writer);
 }
Beispiel #3
0
        // Mirrors wkt
        private static void PolygonText_(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.AttributeStreamOfInt32 paths
                                         , int polygon_start, int polygon_end, com.epl.geometry.JsonWriter json_writer)
        {
            json_writer.StartArray();
            int istart = paths.Read(polygon_start);
            int iend   = paths.Read(polygon_start + 1);

            LineStringText_(true, true, precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, istart, iend, json_writer);
            for (int path = polygon_start + 1; path < polygon_end; path++)
            {
                istart = paths.Read(path);
                iend   = paths.Read(path + 1);
                LineStringText_(true, true, precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, istart, iend, json_writer);
            }
            json_writer.EndArray();
        }
Beispiel #4
0
 // Mirrors wkt
 private static void MultiPointTaggedText_(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, int point_count, com.epl.geometry.JsonWriter
                                           json_writer)
 {
     json_writer.AddFieldName("type");
     json_writer.AddValueString("MultiPoint");
     json_writer.AddFieldName("coordinates");
     if (position == null)
     {
         json_writer.StartArray();
         json_writer.EndArray();
         return;
     }
     LineStringText_(false, false, precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, 0, point_count, json_writer);
 }
        private static void ExportPolypathToJson(com.epl.geometry.MultiPath pp, string name, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            bool bExportZs    = pp.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
            bool bExportMs    = pp.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M);
            bool bPositionAsF = false;
            int  decimals     = 17;

            if (exportProperties != null)
            {
                object numberOfDecimalsXY = exportProperties["numberOfDecimalsXY"];
                if (numberOfDecimalsXY != null && numberOfDecimalsXY is java.lang.Number)
                {
                    bPositionAsF = true;
                    decimals     = ((java.lang.Number)numberOfDecimalsXY);
                }
            }
            jsonWriter.StartObject();
            if (bExportZs)
            {
                jsonWriter.AddPairBoolean("hasZ", true);
            }
            if (bExportMs)
            {
                jsonWriter.AddPairBoolean("hasM", true);
            }
            jsonWriter.AddPairArray(name);
            if (!pp.IsEmpty())
            {
                int n = pp.GetPathCount();
                // rings or paths
                com.epl.geometry.MultiPathImpl mpImpl = (com.epl.geometry.MultiPathImpl)pp._getImpl();
                // get impl for
                // faster
                // access
                com.epl.geometry.AttributeStreamOfDbl zs = null;
                com.epl.geometry.AttributeStreamOfDbl ms = null;
                if (bExportZs)
                {
                    zs = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                }
                if (bExportMs)
                {
                    ms = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                }
                bool bPolygon = pp is com.epl.geometry.Polygon;
                com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D();
                for (int i = 0; i < n; i++)
                {
                    jsonWriter.AddValueArray();
                    int    startindex  = pp.GetPathStart(i);
                    int    numVertices = pp.GetPathSize(i);
                    double startx      = 0.0;
                    double starty      = 0.0;
                    double startz      = com.epl.geometry.NumberUtils.NaN();
                    double startm      = com.epl.geometry.NumberUtils.NaN();
                    double z           = com.epl.geometry.NumberUtils.NaN();
                    double m           = com.epl.geometry.NumberUtils.NaN();
                    bool   bClosed     = pp.IsClosedPath(i);
                    for (int j = startindex; j < startindex + numVertices; j++)
                    {
                        pp.GetXY(j, pt);
                        jsonWriter.AddValueArray();
                        if (bPositionAsF)
                        {
                            jsonWriter.AddValueDouble(pt.x, decimals, true);
                            jsonWriter.AddValueDouble(pt.y, decimals, true);
                        }
                        else
                        {
                            jsonWriter.AddValueDouble(pt.x);
                            jsonWriter.AddValueDouble(pt.y);
                        }
                        if (bExportZs)
                        {
                            z = zs.Get(j);
                            jsonWriter.AddValueDouble(z);
                        }
                        if (bExportMs)
                        {
                            m = ms.Get(j);
                            jsonWriter.AddValueDouble(m);
                        }
                        if (j == startindex && bClosed)
                        {
                            startx = pt.x;
                            starty = pt.y;
                            startz = z;
                            startm = m;
                        }
                        jsonWriter.EndArray();
                    }
                    // Close the Path/Ring by writing the Point at the start index
                    if (bClosed && (startx != pt.x || starty != pt.y || (bExportZs && !(com.epl.geometry.NumberUtils.IsNaN(startz) && com.epl.geometry.NumberUtils.IsNaN(z)) && startz != z) || (bExportMs && !(com.epl.geometry.NumberUtils.IsNaN(startm) && com.epl.geometry.NumberUtils.IsNaN(m)) && startm
                                                                                                                                                                                                 != m)))
                    {
                        pp.GetXY(startindex, pt);
                        // getPoint(startindex);
                        jsonWriter.AddValueArray();
                        if (bPositionAsF)
                        {
                            jsonWriter.AddValueDouble(pt.x, decimals, true);
                            jsonWriter.AddValueDouble(pt.y, decimals, true);
                        }
                        else
                        {
                            jsonWriter.AddValueDouble(pt.x);
                            jsonWriter.AddValueDouble(pt.y);
                        }
                        if (bExportZs)
                        {
                            z = zs.Get(startindex);
                            jsonWriter.AddValueDouble(z);
                        }
                        if (bExportMs)
                        {
                            m = ms.Get(startindex);
                            jsonWriter.AddValueDouble(m);
                        }
                        jsonWriter.EndArray();
                    }
                    jsonWriter.EndArray();
                }
            }
            jsonWriter.EndArray();
            if (spatialReference != null)
            {
                WriteSR(spatialReference, jsonWriter);
            }
            jsonWriter.EndObject();
        }
Beispiel #6
0
        // Mirrors wkt
        private static void PointText_(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, int point, com.epl.geometry.JsonWriter json_writer
                                       )
        {
            double x = position.ReadAsDbl(2 * point);
            double y = position.ReadAsDbl(2 * point + 1);
            double z = com.epl.geometry.NumberUtils.NaN();
            double m = com.epl.geometry.NumberUtils.NaN();

            if (b_export_zs)
            {
                z = (zs != null ? zs.ReadAsDbl(point) : com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.Z));
            }
            if (b_export_ms)
            {
                m = (ms != null ? ms.ReadAsDbl(point) : com.epl.geometry.VertexDescription.GetDefaultValue(com.epl.geometry.VertexDescription.Semantics.M));
            }
            PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, x, y, z, m, json_writer);
        }
Beispiel #7
0
        // 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);
            }
        }
Beispiel #8
0
 // Mirrors wkt
 private static void PointTaggedText_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, double x, double y, double z, double m, com.epl.geometry.JsonWriter json_writer)
 {
     json_writer.AddFieldName("type");
     json_writer.AddValueString("Point");
     json_writer.AddFieldName("coordinates");
     if (com.epl.geometry.NumberUtils.IsNaN(x))
     {
         json_writer.StartArray();
         json_writer.EndArray();
         return;
     }
     PointText_(precision, bFixedPoint, b_export_zs, b_export_ms, x, y, z, m, json_writer);
 }
Beispiel #9
0
        private static void ExportGeometryToGeoJson_(int export_flags, com.epl.geometry.Geometry geometry, com.epl.geometry.JsonWriter json_writer)
        {
            int type = geometry.GetType().Value();

            switch (type)
            {
            case com.epl.geometry.Geometry.GeometryType.Polygon:
            {
                ExportPolygonToGeoJson_(export_flags, (com.epl.geometry.Polygon)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.Polyline:
            {
                ExportPolylineToGeoJson_(export_flags, (com.epl.geometry.Polyline)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.MultiPoint:
            {
                ExportMultiPointToGeoJson_(export_flags, (com.epl.geometry.MultiPoint)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.Point:
            {
                ExportPointToGeoJson_(export_flags, (com.epl.geometry.Point)geometry, json_writer);
                return;
            }

            case com.epl.geometry.Geometry.GeometryType.Envelope:
            {
                ExportEnvelopeToGeoJson_(export_flags, (com.epl.geometry.Envelope)geometry, json_writer);
                return;
            }

            default:
            {
                throw new System.Exception("not implemented for this geometry type");
            }
            }
        }
        private static void ExportToJson_(com.epl.geometry.Geometry geometry, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            try
            {
                int type = geometry.GetType().Value();
                switch (type)
                {
                case com.epl.geometry.Geometry.GeometryType.Point:
                {
                    ExportPointToJson((com.epl.geometry.Point)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.MultiPoint:
                {
                    ExportMultiPointToJson((com.epl.geometry.MultiPoint)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.Polyline:
                {
                    ExportPolylineToJson((com.epl.geometry.Polyline)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.Polygon:
                {
                    ExportPolygonToJson((com.epl.geometry.Polygon)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                case com.epl.geometry.Geometry.GeometryType.Envelope:
                {
                    ExportEnvelopeToJson((com.epl.geometry.Envelope)geometry, spatialReference, jsonWriter, exportProperties);
                    break;
                }

                default:
                {
                    throw new System.Exception("not implemented for this geometry type");
                }
                }
            }
            catch (System.Exception)
            {
            }
        }
        private static void WriteSR(com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter)
        {
            int wkid = spatialReference.GetOldID();

            if (wkid > 0)
            {
                jsonWriter.AddPairObject("spatialReference");
                jsonWriter.AddPairInt("wkid", wkid);
                int latest_wkid = spatialReference.GetLatestID();
                if (latest_wkid > 0 && latest_wkid != wkid)
                {
                    jsonWriter.AddPairInt("latestWkid", latest_wkid);
                }
                jsonWriter.EndObject();
            }
            else
            {
                string wkt = spatialReference.GetText();
                if (wkt != null)
                {
                    jsonWriter.AddPairObject("spatialReference");
                    jsonWriter.AddPairString("wkt", wkt);
                    jsonWriter.EndObject();
                }
            }
        }
        private static void ExportEnvelopeToJson(com.epl.geometry.Envelope env, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            bool bExportZs    = env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
            bool bExportMs    = env.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M);
            bool bPositionAsF = false;
            int  decimals     = 17;

            if (exportProperties != null)
            {
                object numberOfDecimalsXY = exportProperties["numberOfDecimalsXY"];
                if (numberOfDecimalsXY != null && numberOfDecimalsXY is java.lang.Number)
                {
                    bPositionAsF = true;
                    decimals     = ((java.lang.Number)numberOfDecimalsXY);
                }
            }
            jsonWriter.StartObject();
            if (env.IsEmpty())
            {
                jsonWriter.AddPairNull("xmin");
                jsonWriter.AddPairNull("ymin");
                jsonWriter.AddPairNull("xmax");
                jsonWriter.AddPairNull("ymax");
                if (bExportZs)
                {
                    jsonWriter.AddPairNull("zmin");
                    jsonWriter.AddPairNull("zmax");
                }
                if (bExportMs)
                {
                    jsonWriter.AddPairNull("mmin");
                    jsonWriter.AddPairNull("mmax");
                }
            }
            else
            {
                if (bPositionAsF)
                {
                    jsonWriter.AddPairDouble("xmin", env.GetXMin(), decimals, true);
                    jsonWriter.AddPairDouble("ymin", env.GetYMin(), decimals, true);
                    jsonWriter.AddPairDouble("xmax", env.GetXMax(), decimals, true);
                    jsonWriter.AddPairDouble("ymax", env.GetYMax(), decimals, true);
                }
                else
                {
                    jsonWriter.AddPairDouble("xmin", env.GetXMin());
                    jsonWriter.AddPairDouble("ymin", env.GetYMin());
                    jsonWriter.AddPairDouble("xmax", env.GetXMax());
                    jsonWriter.AddPairDouble("ymax", env.GetYMax());
                }
                if (bExportZs)
                {
                    com.epl.geometry.Envelope1D z = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                    jsonWriter.AddPairDouble("zmin", z.vmin);
                    jsonWriter.AddPairDouble("zmax", z.vmax);
                }
                if (bExportMs)
                {
                    com.epl.geometry.Envelope1D m = env.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0);
                    jsonWriter.AddPairDouble("mmin", m.vmin);
                    jsonWriter.AddPairDouble("mmax", m.vmax);
                }
            }
            if (spatialReference != null)
            {
                WriteSR(spatialReference, jsonWriter);
            }
            jsonWriter.EndObject();
        }
        private static void ExportPointToJson(com.epl.geometry.Point pt, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            bool bExportZs    = pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
            bool bExportMs    = pt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M);
            bool bPositionAsF = false;
            int  decimals     = 17;

            if (exportProperties != null)
            {
                object numberOfDecimalsXY = exportProperties["numberOfDecimalsXY"];
                if (numberOfDecimalsXY != null && numberOfDecimalsXY is java.lang.Number)
                {
                    bPositionAsF = true;
                    decimals     = ((java.lang.Number)numberOfDecimalsXY);
                }
            }
            jsonWriter.StartObject();
            if (pt.IsEmpty())
            {
                jsonWriter.AddPairNull("x");
                jsonWriter.AddPairNull("y");
                if (bExportZs)
                {
                    jsonWriter.AddPairNull("z");
                }
                if (bExportMs)
                {
                    jsonWriter.AddPairNull("m");
                }
            }
            else
            {
                if (bPositionAsF)
                {
                    jsonWriter.AddPairDouble("x", pt.GetX(), decimals, true);
                    jsonWriter.AddPairDouble("y", pt.GetY(), decimals, true);
                }
                else
                {
                    jsonWriter.AddPairDouble("x", pt.GetX());
                    jsonWriter.AddPairDouble("y", pt.GetY());
                }
                if (bExportZs)
                {
                    jsonWriter.AddPairDouble("z", pt.GetZ());
                }
                if (bExportMs)
                {
                    jsonWriter.AddPairDouble("m", pt.GetM());
                }
            }
            if (spatialReference != null)
            {
                WriteSR(spatialReference, jsonWriter);
            }
            jsonWriter.EndObject();
        }
        private static void ExportMultiPointToJson(com.epl.geometry.MultiPoint mpt, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
        {
            bool bExportZs    = mpt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
            bool bExportMs    = mpt.HasAttribute(com.epl.geometry.VertexDescription.Semantics.M);
            bool bPositionAsF = false;
            int  decimals     = 17;

            if (exportProperties != null)
            {
                object numberOfDecimalsXY = exportProperties["numberOfDecimalsXY"];
                if (numberOfDecimalsXY != null && numberOfDecimalsXY is java.lang.Number)
                {
                    bPositionAsF = true;
                    decimals     = ((java.lang.Number)numberOfDecimalsXY);
                }
            }
            jsonWriter.StartObject();
            if (bExportZs)
            {
                jsonWriter.AddPairBoolean("hasZ", true);
            }
            if (bExportMs)
            {
                jsonWriter.AddPairBoolean("hasM", true);
            }
            jsonWriter.AddPairArray("points");
            if (!mpt.IsEmpty())
            {
                com.epl.geometry.MultiPointImpl mpImpl = (com.epl.geometry.MultiPointImpl)mpt._getImpl();
                // get impl
                // for
                // faster
                // access
                com.epl.geometry.AttributeStreamOfDbl zs = null;
                com.epl.geometry.AttributeStreamOfDbl ms = null;
                if (bExportZs)
                {
                    zs = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                }
                if (bExportMs)
                {
                    ms = (com.epl.geometry.AttributeStreamOfDbl)mpImpl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                }
                com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D();
                int n = mpt.GetPointCount();
                for (int i = 0; i < n; i++)
                {
                    mpt.GetXY(i, pt);
                    jsonWriter.AddValueArray();
                    if (bPositionAsF)
                    {
                        jsonWriter.AddValueDouble(pt.x, decimals, true);
                        jsonWriter.AddValueDouble(pt.y, decimals, true);
                    }
                    else
                    {
                        jsonWriter.AddValueDouble(pt.x);
                        jsonWriter.AddValueDouble(pt.y);
                    }
                    if (bExportZs)
                    {
                        double z = zs.Get(i);
                        jsonWriter.AddValueDouble(z);
                    }
                    if (bExportMs)
                    {
                        double m = ms.Get(i);
                        jsonWriter.AddValueDouble(m);
                    }
                    jsonWriter.EndArray();
                }
            }
            jsonWriter.EndArray();
            if (spatialReference != null)
            {
                WriteSR(spatialReference, jsonWriter);
            }
            jsonWriter.EndObject();
        }
Beispiel #15
0
 // Mirrors wkt
 private static void PolygonTaggedTextFromEnvelope_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, double xmin, double ymin, double xmax, double ymax, double zmin, double zmax, double mmin, double mmax, com.epl.geometry.JsonWriter json_writer)
 {
     json_writer.AddFieldName("type");
     json_writer.AddValueString("Polygon");
     json_writer.AddFieldName("coordinates");
     if (com.epl.geometry.NumberUtils.IsNaN(xmin))
     {
         json_writer.StartArray();
         json_writer.EndArray();
         return;
     }
     WriteEnvelopeAsGeoJsonPolygon_(precision, bFixedPoint, b_export_zs, b_export_ms, xmin, ymin, xmax, ymax, zmin, zmax, mmin, mmax, json_writer);
 }
Beispiel #16
0
        // 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);
        }
Beispiel #17
0
 private static void ExportSpatialReference(int export_flags, com.epl.geometry.SpatialReference spatial_reference, com.epl.geometry.JsonWriter json_writer)
 {
     if (spatial_reference != null)
     {
         int wkid = spatial_reference.GetLatestID();
         if (wkid <= 0)
         {
             throw new com.epl.geometry.GeometryException("invalid call");
         }
         json_writer.StartObject();
         json_writer.AddFieldName("type");
         json_writer.AddValueString("name");
         json_writer.AddFieldName("properties");
         json_writer.StartObject();
         json_writer.AddFieldName("name");
         string authority = ((com.epl.geometry.SpatialReferenceImpl)spatial_reference).GetAuthority();
         authority = authority.ToUpper();
         System.Text.StringBuilder crs_identifier = new System.Text.StringBuilder(authority);
         crs_identifier.Append(':');
         crs_identifier.Append(wkid);
         json_writer.AddValueString(crs_identifier.ToString());
         json_writer.EndObject();
         json_writer.EndObject();
     }
     else
     {
         json_writer.AddValueNull();
     }
 }
Beispiel #18
0
        // 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);
            }
        }
Beispiel #19
0
        // Mirrors wkt
        private static void ExportPolylineToGeoJson_(int export_flags, com.epl.geometry.Polyline polyline, com.epl.geometry.JsonWriter json_writer)
        {
            com.epl.geometry.MultiPathImpl polyline_impl = (com.epl.geometry.MultiPathImpl)polyline._getImpl();
            int point_count = polyline_impl.GetPointCount();
            int path_count  = polyline_impl.GetPathCount();

            if (point_count > 0 && path_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 = polyline_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0;
            bool b_export_ms = polyline_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");
            }
            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)polyline_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION);
                path_flags = polyline_impl.GetPathFlagsStreamRef();
                paths      = polyline_impl.GetPathStreamRef();
                if (b_export_zs)
                {
                    if (polyline_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z))
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)polyline_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                    }
                }
                if (b_export_ms)
                {
                    if (polyline_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M))
                    {
                        ms = (com.epl.geometry.AttributeStreamOfDbl)polyline_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                    }
                }
            }
            if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportPreferMultiGeometry) == 0 && path_count <= 1)
            {
                LineStringTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, json_writer);
            }
            else
            {
                MultiLineStringTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, path_flags, paths, path_count, json_writer);
            }
        }
Beispiel #20
0
        // Mirrors wkt
        private static void ExportMultiPointToGeoJson_(int export_flags, com.epl.geometry.MultiPoint multipoint, com.epl.geometry.JsonWriter json_writer)
        {
            com.epl.geometry.MultiPointImpl multipoint_impl = (com.epl.geometry.MultiPointImpl)multipoint._getImpl();
            int  point_count = multipoint_impl.GetPointCount();
            int  precision   = 17 - (31 & (export_flags >> 13));
            bool bFixedPoint = (com.epl.geometry.GeoJsonExportFlags.geoJsonExportPrecisionFixedPoint & export_flags) != 0;
            bool b_export_zs = multipoint_impl.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0;
            bool b_export_ms = multipoint_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");
            }
            com.epl.geometry.AttributeStreamOfDbl position = null;
            com.epl.geometry.AttributeStreamOfDbl zs       = null;
            com.epl.geometry.AttributeStreamOfDbl ms       = null;
            if (point_count > 0)
            {
                position = (com.epl.geometry.AttributeStreamOfDbl)multipoint_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.POSITION);
                if (b_export_zs)
                {
                    if (multipoint_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.Z))
                    {
                        zs = (com.epl.geometry.AttributeStreamOfDbl)multipoint_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.Z);
                    }
                }
                if (b_export_ms)
                {
                    if (multipoint_impl._attributeStreamIsAllocated(com.epl.geometry.VertexDescription.Semantics.M))
                    {
                        ms = (com.epl.geometry.AttributeStreamOfDbl)multipoint_impl.GetAttributeStreamRef(com.epl.geometry.VertexDescription.Semantics.M);
                    }
                }
            }
            MultiPointTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, zs, ms, position, point_count, json_writer);
        }
Beispiel #21
0
        // Mirrors wkt
        private static void ExportPointToGeoJson_(int export_flags, com.epl.geometry.Point point, com.epl.geometry.JsonWriter json_writer)
        {
            int  precision   = 17 - (31 & (export_flags >> 13));
            bool bFixedPoint = (com.epl.geometry.GeoJsonExportFlags.geoJsonExportPrecisionFixedPoint & export_flags) != 0;
            bool b_export_zs = point.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0;
            bool b_export_ms = point.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");
            }
            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();

            if (!point.IsEmpty())
            {
                x = point.GetX();
                y = point.GetY();
                if (b_export_zs)
                {
                    z = point.GetZ();
                }
                if (b_export_ms)
                {
                    m = point.GetM();
                }
            }
            if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportPreferMultiGeometry) == 0)
            {
                PointTaggedText_(precision, bFixedPoint, b_export_zs, b_export_ms, x, y, z, m, json_writer);
            }
            else
            {
                MultiPointTaggedTextFromPoint_(precision, bFixedPoint, b_export_zs, b_export_ms, x, y, z, m, json_writer);
            }
        }
Beispiel #22
0
 // Mirrors wkt
 private static int PointText_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, double x, double y, double z, double m, com.epl.geometry.JsonWriter json_writer)
 {
     json_writer.StartArray();
     json_writer.AddValueDouble(x, precision, bFixedPoint);
     json_writer.AddValueDouble(y, precision, bFixedPoint);
     if (b_export_zs)
     {
         json_writer.AddValueDouble(z, precision, bFixedPoint);
     }
     if (b_export_ms)
     {
         json_writer.AddValueDouble(m, precision, bFixedPoint);
     }
     json_writer.EndArray();
     return(1);
 }
Beispiel #23
0
        // Mirrors wkt
        private static void ExportEnvelopeToGeoJson_(int export_flags, com.epl.geometry.Envelope envelope, com.epl.geometry.JsonWriter json_writer)
        {
            int  precision   = 17 - (31 & (export_flags >> 13));
            bool bFixedPoint = (com.epl.geometry.GeoJsonExportFlags.geoJsonExportPrecisionFixedPoint & export_flags) != 0;
            bool b_export_zs = envelope.HasAttribute(com.epl.geometry.VertexDescription.Semantics.Z) && (export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportStripZs) == 0;
            bool b_export_ms = envelope.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");
            }
            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();

            if (!envelope.IsEmpty())
            {
                xmin = envelope.GetXMin();
                ymin = envelope.GetYMin();
                xmax = envelope.GetXMax();
                ymax = envelope.GetYMax();
                com.epl.geometry.Envelope1D interval;
                if (b_export_zs)
                {
                    interval = envelope.QueryInterval(com.epl.geometry.VertexDescription.Semantics.Z, 0);
                    zmin     = interval.vmin;
                    zmax     = interval.vmax;
                }
                if (b_export_ms)
                {
                    interval = envelope.QueryInterval(com.epl.geometry.VertexDescription.Semantics.M, 0);
                    mmin     = interval.vmin;
                    mmax     = interval.vmax;
                }
            }
            if ((export_flags & com.epl.geometry.GeoJsonExportFlags.geoJsonExportPreferMultiGeometry) == 0)
            {
                PolygonTaggedTextFromEnvelope_(precision, bFixedPoint, b_export_zs, b_export_ms, xmin, ymin, xmax, ymax, zmin, zmax, mmin, mmax, json_writer);
            }
            else
            {
                MultiPolygonTaggedTextFromEnvelope_(precision, bFixedPoint, b_export_zs, b_export_ms, xmin, ymin, xmax, ymax, zmin, zmax, mmin, mmax, json_writer);
            }
        }
Beispiel #24
0
 // Mirrors wkt
 private static void WriteEnvelopeAsGeoJsonPolygon_(int precision, bool bFixedPoint, bool b_export_zs, bool b_export_ms, double xmin, double ymin, double xmax, double ymax, double zmin, double zmax, double mmin, double mmax, com.epl.geometry.JsonWriter json_writer)
 {
     json_writer.StartArray();
     json_writer.StartArray();
     json_writer.StartArray();
     json_writer.AddValueDouble(xmin, precision, bFixedPoint);
     json_writer.AddValueDouble(ymin, precision, bFixedPoint);
     if (b_export_zs)
     {
         json_writer.AddValueDouble(zmin, precision, bFixedPoint);
     }
     if (b_export_ms)
     {
         json_writer.AddValueDouble(mmin, precision, bFixedPoint);
     }
     json_writer.EndArray();
     json_writer.StartArray();
     json_writer.AddValueDouble(xmax, precision, bFixedPoint);
     json_writer.AddValueDouble(ymin, precision, bFixedPoint);
     if (b_export_zs)
     {
         json_writer.AddValueDouble(zmax, precision, bFixedPoint);
     }
     if (b_export_ms)
     {
         json_writer.AddValueDouble(mmax, precision, bFixedPoint);
     }
     json_writer.EndArray();
     json_writer.StartArray();
     json_writer.AddValueDouble(xmax, precision, bFixedPoint);
     json_writer.AddValueDouble(ymax, precision, bFixedPoint);
     if (b_export_zs)
     {
         json_writer.AddValueDouble(zmin, precision, bFixedPoint);
     }
     if (b_export_ms)
     {
         json_writer.AddValueDouble(mmin, precision, bFixedPoint);
     }
     json_writer.EndArray();
     json_writer.StartArray();
     json_writer.AddValueDouble(xmin, precision, bFixedPoint);
     json_writer.AddValueDouble(ymax, precision, bFixedPoint);
     if (b_export_zs)
     {
         json_writer.AddValueDouble(zmax, precision, bFixedPoint);
     }
     if (b_export_ms)
     {
         json_writer.AddValueDouble(mmax, precision, bFixedPoint);
     }
     json_writer.EndArray();
     json_writer.StartArray();
     json_writer.AddValueDouble(xmin, precision, bFixedPoint);
     json_writer.AddValueDouble(ymin, precision, bFixedPoint);
     if (b_export_zs)
     {
         json_writer.AddValueDouble(zmin, precision, bFixedPoint);
     }
     if (b_export_ms)
     {
         json_writer.AddValueDouble(mmin, precision, bFixedPoint);
     }
     json_writer.EndArray();
     json_writer.EndArray();
     json_writer.EndArray();
 }
 private static void ExportPolylineToJson(com.epl.geometry.Polyline pp, com.epl.geometry.SpatialReference spatialReference, com.epl.geometry.JsonWriter jsonWriter, System.Collections.Generic.IDictionary <string, object> exportProperties)
 {
     ExportPolypathToJson(pp, "paths", spatialReference, jsonWriter, exportProperties);
 }