internal static com.epl.geometry.Geometry PointTaggedText(int import_flags, com.epl.geometry.WktParser wkt_parser)
        {
            com.epl.geometry.Point point = new com.epl.geometry.Point();
            int current_token            = wkt_parser.NextToken();

            if (current_token == com.epl.geometry.WktParser.WktToken.attribute_z)
            {
                point.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                wkt_parser.NextToken();
            }
            else
            {
                if (current_token == com.epl.geometry.WktParser.WktToken.attribute_m)
                {
                    point.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                    wkt_parser.NextToken();
                }
                else
                {
                    if (current_token == com.epl.geometry.WktParser.WktToken.attribute_zm)
                    {
                        point.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                        point.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                        wkt_parser.NextToken();
                    }
                }
            }
            // At start of PointText
            current_token = wkt_parser.CurrentToken();
            if (current_token != com.epl.geometry.WktParser.WktToken.empty)
            {
                wkt_parser.NextToken();
                double x = wkt_parser.CurrentNumericLiteral();
                wkt_parser.NextToken();
                double y = wkt_parser.CurrentNumericLiteral();
                wkt_parser.NextToken();
                point.SetXY(x, y);
                if (wkt_parser.HasZs())
                {
                    double z = wkt_parser.CurrentNumericLiteral();
                    wkt_parser.NextToken();
                    point.SetZ(z);
                }
                if (wkt_parser.HasMs())
                {
                    double m = wkt_parser.CurrentNumericLiteral();
                    wkt_parser.NextToken();
                    point.SetM(m);
                }
            }
            return(point);
        }
Beispiel #2
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));
 }
        /// <exception cref="com.fasterxml.jackson.core.JsonParseException"/>
        /// <exception cref="System.IO.IOException"/>
        internal virtual bool TestPoint()
        {
            bool bAnswer = true;

            com.epl.geometry.Point point1     = new com.epl.geometry.Point(10.0, 20.0);
            com.epl.geometry.Point pointEmpty = new com.epl.geometry.Point();
            {
                com.fasterxml.jackson.core.JsonParser pointWebMerc1Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, point1));
                com.epl.geometry.MapGeometry          pointWebMerc1MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(pointWebMerc1Parser);
                NUnit.Framework.Assert.IsTrue(point1.GetX() == ((com.epl.geometry.Point)pointWebMerc1MP.GetGeometry()).GetX());
                NUnit.Framework.Assert.IsTrue(point1.GetY() == ((com.epl.geometry.Point)pointWebMerc1MP.GetGeometry()).GetY());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWebMerc1.GetID() == pointWebMerc1MP.GetSpatialReference().GetID() || pointWebMerc1MP.GetSpatialReference().GetID() == 3857);
                if (!CheckResultSpatialRef(pointWebMerc1MP, 102100, 3857))
                {
                    bAnswer = false;
                }
                pointWebMerc1Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(null, point1));
                pointWebMerc1MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(pointWebMerc1Parser);
                NUnit.Framework.Assert.IsTrue(null == pointWebMerc1MP.GetSpatialReference());
                if (pointWebMerc1MP.GetSpatialReference() != null)
                {
                    if (!CheckResultSpatialRef(pointWebMerc1MP, 102100, 3857))
                    {
                        bAnswer = false;
                    }
                }
                string pointEmptyString = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, pointEmpty);
                pointWebMerc1Parser = factory.CreateParser(pointEmptyString);
            }
            com.fasterxml.jackson.core.JsonParser pointWebMerc2Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc2, point1));
            com.epl.geometry.MapGeometry          pointWebMerc2MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(pointWebMerc2Parser);
            NUnit.Framework.Assert.IsTrue(point1.GetX() == ((com.epl.geometry.Point)pointWebMerc2MP.GetGeometry()).GetX());
            NUnit.Framework.Assert.IsTrue(point1.GetY() == ((com.epl.geometry.Point)pointWebMerc2MP.GetGeometry()).GetY());
            NUnit.Framework.Assert.IsTrue(spatialReferenceWebMerc2.GetLatestID() == pointWebMerc2MP.GetSpatialReference().GetLatestID());
            if (!CheckResultSpatialRef(pointWebMerc2MP, spatialReferenceWebMerc2.GetLatestID(), 0))
            {
                bAnswer = false;
            }
            {
                com.fasterxml.jackson.core.JsonParser pointWgs84Parser = factory.CreateParser(com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWGS84, point1));
                com.epl.geometry.MapGeometry          pointWgs84MP     = com.epl.geometry.GeometryEngine.JsonToGeometry(pointWgs84Parser);
                NUnit.Framework.Assert.IsTrue(point1.GetX() == ((com.epl.geometry.Point)pointWgs84MP.GetGeometry()).GetX());
                NUnit.Framework.Assert.IsTrue(point1.GetY() == ((com.epl.geometry.Point)pointWgs84MP.GetGeometry()).GetY());
                NUnit.Framework.Assert.IsTrue(spatialReferenceWGS84.GetID() == pointWgs84MP.GetSpatialReference().GetID());
                if (!CheckResultSpatialRef(pointWgs84MP, 4326, 0))
                {
                    bAnswer = false;
                }
            }
            {
                com.epl.geometry.Point p = new com.epl.geometry.Point();
                string s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"x\":null,\"y\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
                p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z);
                p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"x\":null,\"y\":null,\"z\":null,\"m\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
            }
            {
                com.epl.geometry.Point p = new com.epl.geometry.Point(10.0, 20.0, 30.0);
                p.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M);
                string s = com.epl.geometry.GeometryEngine.GeometryToJson(spatialReferenceWebMerc1, p);
                NUnit.Framework.Assert.IsTrue(s.Equals("{\"x\":10,\"y\":20,\"z\":30,\"m\":null,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}"));
            }
            {
                // import
                string s = "{\"x\":0.0,\"y\":1.0,\"z\":5.0,\"m\":11.0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}";
                com.fasterxml.jackson.core.JsonParser parser = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_pt = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Point pt = (com.epl.geometry.Point)map_pt.GetGeometry();
                NUnit.Framework.Assert.IsTrue(pt.GetX() == 0.0);
                NUnit.Framework.Assert.IsTrue(pt.GetY() == 1.0);
                NUnit.Framework.Assert.IsTrue(pt.GetZ() == 5.0);
                NUnit.Framework.Assert.IsTrue(pt.GetM() == 11.0);
            }
            {
                string s = "{\"x\" : 5.0, \"y\" : null, \"spatialReference\" : {\"wkid\" : 4326}} ";
                com.fasterxml.jackson.core.JsonParser parser = factory.CreateParser(s);
                com.epl.geometry.MapGeometry          map_pt = com.epl.geometry.GeometryEngine.JsonToGeometry(parser);
                com.epl.geometry.Point pt = (com.epl.geometry.Point)map_pt.GetGeometry();
                NUnit.Framework.Assert.IsTrue(pt.IsEmpty());
                com.epl.geometry.SpatialReference spatial_reference = map_pt.GetSpatialReference();
                NUnit.Framework.Assert.IsTrue(spatial_reference.GetID() == 4326);
            }
            return(bAnswer);
        }