Beispiel #1
0
        public void ReadGeometryCoordinateSystem()
        {
            var reader = XElement.Parse("<gml:Point xmlns:gml='http://www.opengis.net/gml'><gml:pos>1.0 1.0</gml:pos></gml:Point>").CreateReader();

            var target = new SpatialToPositionPipeline();

            new GmlReader(target).ReadGeometry(reader);
            Assert.AreEqual(CoordinateSystem.DefaultGeometry, target.CoordinateSystem);
        }
 public void PointsToPositions()
 {
     GeographyPoint p = TestData.PointG();
     var s = new SpatialToPositionPipeline();
     p.SendTo(s);
     Assert.Equal(1, s.Coordinates.Count);
     Assert.Equal(new PositionData(p.Latitude, p.Longitude, p.Z, p.M), s.Coordinates[0]);
     Assert.Equal(p.CoordinateSystem, s.CoordinateSystem);
 }
Beispiel #3
0
        public void ReadCoordinateSystemDefaultNamespace()
        {
            var reader = XElement.Parse("<gml:Point xmlns:gml='http://www.opengis.net/gml' srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0 1.0</gml:pos></gml:Point>").CreateReader();

            var target = new SpatialToPositionPipeline();

            new GmlReader(target).ReadGeography(reader);
            Assert.AreEqual(CoordinateSystem.Geography(1234), target.CoordinateSystem);
        }
Beispiel #4
0
        public void PointsToPositions()
        {
            GeographyPoint p = TestData.PointG();
            var            s = new SpatialToPositionPipeline();

            p.SendTo(s);
            Assert.AreEqual(1, s.Coordinates.Count);
            Assert.AreEqual(new PositionData(p.Latitude, p.Longitude, p.Z, p.M), s.Coordinates[0]);
            Assert.AreEqual(p.CoordinateSystem, s.CoordinateSystem);
        }
Beispiel #5
0
        public void ReaderIgnoreCountAttributes()
        {
            // should ignore axisLabels and uomLabels attribute on any element
            var reader   = XElement.Parse(@"<gml:LineString xmlns:gml='http://www.opengis.net/gml'><gml:posList count='foo'/></gml:LineString>").CreateReader();
            var pipeline = new SpatialToPositionPipeline();

            new GmlReader(pipeline).ReadGeography(reader);

            Assert.AreEqual(pipeline.Coordinates.Count, 0);
        }
Beispiel #6
0
        public void ReaderIgnoreIdAttribute()
        {
            // should ignore axisLabels and uomLabels attribute on any element
            var reader   = XElement.Parse(@"<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:id='id1' id='id2'><gml:pos axisLabels='foo' uomLabels='bar'/></gml:Point>").CreateReader();
            var pipeline = new SpatialToPositionPipeline();

            new GmlReader(pipeline).ReadGeography(reader);

            Assert.AreEqual(pipeline.Coordinates.Count, 0);
        }
Beispiel #7
0
        public void ResetReader()
        {
            var invalidReader = XElement.Parse("<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/5555\"><gml:pos>1</gml:pos></gml:Point>").CreateReader();
            var validReader   = XElement.Parse("<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>2 2</gml:pos></gml:Point>").CreateReader();

            var target    = new SpatialToPositionPipeline();
            var gmlReader = new GmlReader(target);

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(() => gmlReader.ReadGeography(invalidReader), Strings.GmlReader_PosNeedTwoNumbers);
            gmlReader.Reset();
            gmlReader.ReadGeography(validReader);
            Assert.AreEqual(CoordinateSystem.Geography(1234), target.CoordinateSystem);
        }
Beispiel #8
0
        public void ReaderIgnoreNameAndDescriptionOnLineString()
        {
            // should ignore axisLabels and uomLabels attribute on any element
            var reader   = XElement.Parse(@"<gml:LineString xmlns:gml='http://www.opengis.net/gml'><gml:name>Foo</gml:name>
<gml:description/><!--empty--><gml:name><complexName/></gml:name><!--empty-->
<gml:posList/><gml:name/><gml:descriptionReference/>
   <gml:identifier codeSpace=""http://www.example.com/"">string</gml:identifier></gml:LineString>").CreateReader();
            var pipeline = new SpatialToPositionPipeline();

            new GmlReader(pipeline).ReadGeography(reader);

            Assert.AreEqual(pipeline.Coordinates.Count, 0);
        }
        public void ReadGeographyPipeline()
        {
            var textReader = new StringReader("POINT(10 20 NULL 40)POINT(10 30 NULL 40)SRID=1234;POINT(10 30 NULL 40)");
            var serializer = new SpatialToPositionPipeline();

            Assert.AreEqual(0, serializer.Coordinates.Count);
            this.d4Formatter.Read <Geography>(textReader, serializer);
            Assert.AreEqual(1, serializer.Coordinates.Count);
            this.d4Formatter.Read <Geography>(textReader, serializer);
            Assert.AreEqual(2, serializer.Coordinates.Count);
            this.d4Formatter.Read <Geography>(textReader, serializer);
            Assert.AreEqual(3, serializer.Coordinates.Count);
            Assert.AreEqual(new PositionData(20, 10, null, 40), serializer.Coordinates[0]);
            Assert.AreEqual(new PositionData(30, 10, null, 40), serializer.Coordinates[1]);
            Assert.AreEqual(new PositionData(30, 10, null, 40), serializer.Coordinates[2]);
            Assert.AreEqual(CoordinateSystem.Geography(1234), serializer.CoordinateSystem);
        }
Beispiel #10
0
        public void ReaderIgnoreNameAndDescriptionOnMultiType()
        {
            // should ignore axisLabels and uomLabels attribute on any element
            var reader   = XElement.Parse(@"<gml:MultiPoint gml:id=""ID"" xmlns:gml='http://www.opengis.net/gml'>
   <gml:metaDataProperty>
      <gml:GenericMetaData>Any text, intermingled with:
         <!--any element-->
      </gml:GenericMetaData>
   </gml:metaDataProperty>
   <gml:description>string</gml:description>
   <gml:pointMember>
      <gml:Point gml:id=""ID"">
         <gml:pos>1.0 1.0</gml:pos>
      </gml:Point>
   </gml:pointMember>
   <gml:identifier codeSpace=""http://www.example.com/"">string</gml:identifier>
   <gml:pointMember>
      <gml:Point gml:id=""ID"">
         <gml:pos>2.0 2.0</gml:pos>
      </gml:Point>
   </gml:pointMember>
   <gml:name>string</gml:name>
   <gml:pointMembers>
      <gml:Point gml:id=""ID"">
         <gml:metaDataProperty>...
         </gml:metaDataProperty>
         <gml:description>string</gml:description>
         <gml:descriptionReference/>
         <gml:identifier codeSpace=""http://www.example.com/"">string</gml:identifier>
         <gml:name>string</gml:name>
         <gml:pos>1.0 1.0</gml:pos>
      </gml:Point>
   </gml:pointMembers>
   <gml:descriptionReference/>
</gml:MultiPoint>").CreateReader();
            var pipeline = new SpatialToPositionPipeline();

            new GmlReader(pipeline).ReadGeography(reader);

            Assert.AreEqual(pipeline.Coordinates.Count, 3);
        }
Beispiel #11
0
        public void ReaderIgnoreNameAndDescriptionOnPolygon()
        {
            // should ignore axisLabels and uomLabels attribute on any element
            var reader   = XElement.Parse(@"<gml:Polygon gml:id=""ID"" xmlns:gml='http://www.opengis.net/gml'>
        <gml:metaDataProperty>
            <gml:GenericMetaData>Any text, intermingled with:
               <!--any element-->
            </gml:GenericMetaData>
        </gml:metaDataProperty>
        <gml:name>Foo</gml:name>
        <gml:description/>
        <!--empty-->
        <gml:exterior>
           <!--empty-->
           <gml:LinearRing>
              <gml:posList>1.0 1.0 2.0 2.0 3.0 3.0 1.0 1.0</gml:posList>
           </gml:LinearRing>
        </gml:exterior>
        <gml:name><complexName/></gml:name>
        <gml:interior>
           <gml:LinearRing>
              <gml:posList>1.0 1.0 2.0 2.0 3.0 3.0 1.0 1.0</gml:posList>
           </gml:LinearRing>
        </gml:interior>
        <gml:descriptionReference/>
        <gml:interior>
           <gml:LinearRing>
              <gml:posList>1.0 1.0 2.0 2.0 3.0 3.0 1.0 1.0</gml:posList>
           </gml:LinearRing>
        </gml:interior>
        <gml:identifier codeSpace=""http://www.example.com/"">string</gml:identifier>
    </gml:Polygon>").CreateReader();
            var pipeline = new SpatialToPositionPipeline();

            new GmlReader(pipeline).ReadGeography(reader);

            Assert.AreEqual(pipeline.Coordinates.Count, 12);
        }
Beispiel #12
0
        public void ReadGmlPosNumbers_WhitespaceSeparated()
        {
            var payloads = new[]
            {
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0\t1.0</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0\r1.0</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0\n1.0</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos> 1.0&#x9;1.0\t</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos> 1.0&#xD;1.0\t</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos> 1.0&#xA;1.0\t</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0  1.0</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>\t\t1.0 1.0</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0 1.0\n\n</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos> 1.0\t1.0\t</gml:pos></gml:Point>",
                "<gml:Point xmlns:gml='http://www.opengis.net/gml' gml:srsName=\"http://www.opengis.net/def/crs/EPSG/0/1234\"><gml:pos>1.0\t\n \r\n1.0</gml:pos></gml:Point>",
            };

            var target = new SpatialToPositionPipeline();

            foreach (var payload in payloads)
            {
                new GmlReader(target).ReadGeography(XmlReader.Create(new StringReader(payload)));
            }
        }
 public void ReadGeographyPipeline()
 {
     var textReader = new StringReader("POINT(10 20 NULL 40)POINT(10 30 NULL 40)SRID=1234;POINT(10 30 NULL 40)");
     var serializer = new SpatialToPositionPipeline();
     Assert.Equal(0, serializer.Coordinates.Count);
     this.d4Formatter.Read<Geography>(textReader, serializer);
     Assert.Equal(1, serializer.Coordinates.Count);
     this.d4Formatter.Read<Geography>(textReader, serializer);
     Assert.Equal(2, serializer.Coordinates.Count);
     this.d4Formatter.Read<Geography>(textReader, serializer);
     Assert.Equal(3, serializer.Coordinates.Count);
     Assert.Equal(new PositionData(20, 10, null, 40), serializer.Coordinates[0]);
     Assert.Equal(new PositionData(30, 10, null, 40), serializer.Coordinates[1]);
     Assert.Equal(new PositionData(30, 10, null, 40), serializer.Coordinates[2]);
     Assert.Equal(CoordinateSystem.Geography(1234), serializer.CoordinateSystem);
 }