public void TestChainTo()
        {
            var pipeline  = SpatialImplementation.CurrentImplementation.CreateBuilder();
            var pipeline2 = SpatialImplementation.CurrentImplementation.CreateBuilder();
            var e         = new NotImplementedException();

            SpatialTestUtils.VerifyExceptionThrown <NotImplementedException>(() => pipeline.ChainTo(pipeline2), e.Message);
        }
Exemplo n.º 2
0
        public void ReadGmlInvalidSrsName()
        {
            var reader = XElement.Parse(@"<gml:Polygon xmlns:gml='http://www.opengis.net/gml' srsName='test'></gml:Polygon>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_InvalidSrsName(GmlConstants.SrsPrefix));
        }
Exemplo n.º 3
0
        public void ReadGmlPosListSingleNumber()
        {
            var reader = XElement.Parse("<gml:LineString xmlns:gml='http://www.opengis.net/gml'><gml:posList>10</gml:posList></gml:LineString>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_PosListNeedsEvenCount);
        }
Exemplo n.º 4
0
        public void ReadGmlInvalidTopLevelAttribute()
        {
            // invalid attributes on top level elements
            var reader = XElement.Parse(@"<gml:Polygon xmlns:gml='http://www.opengis.net/gml' foo='bar'></gml:Polygon>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_InvalidAttribute("foo", "gml:Polygon"));
        }
Exemplo n.º 5
0
        public void ReadGmlUnexpectedSrsName()
        {
            // changing the srsName inside a tag is invalid
            var reader = XElement.Parse(@"<gml:Point xmlns:gml='http://www.opengis.net/gml'><pos srsName='foo' /></gml:Point>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_InvalidAttribute("srsName", "pos"));
        }
Exemplo n.º 6
0
        public void ReadGmlInvalidAttribute()
        {
            // invalid attributes on inner elements
            var reader = XElement.Parse(@"<gml:Point xmlns:gml='http://www.opengis.net/gml'><pos srsDimension='3' /></gml:Point>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_InvalidAttribute("srsDimension", "pos"));
        }
Exemplo n.º 7
0
        public void ReadXmlNotOnElement()
        {
            var reader = XmlReader.Create(new StringReader("<gml:Point xmlns:gml='http://www.opengis.net/gml'><gml:pos>1.0 1.0</gml:pos></gml:Point>"));

            reader.ReadStartElement();
            reader.ReadStartElement();
            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_ExpectReaderAtElement);
        }
Exemplo n.º 8
0
        public void ErrorOnNullDestinationInCtor()
        {
            Action act = () => new TrivialReader(null);

#if NETCOREAPP3_1
            SpatialTestUtils.VerifyExceptionThrown <ArgumentNullException>(act, "Value cannot be null. (Parameter 'destination')");
#else
            SpatialTestUtils.VerifyExceptionThrown <ArgumentNullException>(act, "Value cannot be null.\r\nParameter name: destination");
#endif
        }
Exemplo n.º 9
0
        public void ReadGmlUnexpectedSrsName_Whitespace()
        {
            // Whitespace between tags should not affect how attributes are handled
            var reader = XElement.Parse(@"<gml:Point xmlns:gml='http://www.opengis.net/gml'>
            <pos srsName='foo' /></gml:Point>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_InvalidAttribute("srsName", "pos"));
        }
Exemplo n.º 10
0
        public void SpatialOperationsThrowNotImplemented()
        {
            var operations = new BaseSpatialOperations();
            var message    = new NotImplementedException().Message;

            foreach (var method in typeof(SpatialOperations).GetMethods(BindingFlags.Instance | BindingFlags.Public).Where(m => m.DeclaringType != typeof(object)))
            {
                SpatialTestUtils.VerifyExceptionThrown <NotImplementedException>(() => this.InvokeOperation(operations, method), message);
            }
        }
Exemplo n.º 11
0
        public void ErrorOnNullInputToReadMethods()
        {
            var reader = new TrivialReader(new CallSequenceLoggingPipeline());

            Action[] acts = { () => reader.ReadGeography(null), () => reader.ReadGeometry(null) };

            foreach (var act in acts)
            {
                SpatialTestUtils.VerifyExceptionThrown <ArgumentNullException>(act, "Value cannot be null.\r\nParameter name: input");
            }
        }
Exemplo n.º 12
0
        public void ReadInvalidShape()
        {
            var reader = XElement.Parse(@"<gml:Surface xmlns:gml='http://www.opengis.net/gml'>
      <gml:posList>
3 7 4 5
</gml:posList>
   </gml:Surface>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_InvalidSpatialType("Surface"));
        }
Exemplo n.º 13
0
        public void ReadUnexpectedElement()
        {
            var reader = XElement.Parse(@"<gml:LineString xmlns:gml='http://www.opengis.net/gml'>
      <gml:posList>
3 7 4 5 <MyWeirdElement/>
</gml:posList>
   </gml:LineString>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_UnexpectedElement("MyWeirdElement"));
        }
Exemplo n.º 14
0
        public void ReadGmlEmptyLinearRing()
        {
            var reader = XElement.Parse(@"<gml:Polygon xmlns:gml='http://www.opengis.net/gml'>
      <gml:exterior>
         <gml:LinearRing></gml:LinearRing>
      </gml:exterior>
   </gml:Polygon>").CreateReader();

            SpatialTestUtils.VerifyExceptionThrown <ParseErrorException>(
                () => new GmlReader(new SpatialToPositionPipeline()).ReadGeography(reader),
                Strings.GmlReader_EmptyRingsNotAllowed);
        }
Exemplo n.º 15
0
 public void InvalidPointTest()
 {
     foreach (var v in validators)
     {
         var validator = v();
         validator.SetCoordinateSystem(NonDefaultEpsgId);
         validator.BeginGeo(SpatialType.Point);
         SpatialTestUtils.VerifyExceptionThrown <FormatException>(
             () => validator.BeginFigure(10, 20, double.NaN, 40),
             Strings.Validator_InvalidPointCoordinate(10, 20, double.NaN, 40));
     }
 }
Exemplo n.º 16
0
 public void CoordinateSystemReset()
 {
     foreach (var v in validators)
     {
         var validator = v();
         validator.SetCoordinateSystem(NonDefaultEpsgId);
         validator.BeginGeo(SpatialType.MultiPoint);
         SpatialTestUtils.VerifyExceptionThrown <FormatException>(
             () => validator.SetCoordinateSystem(CoordinateSystem.DefaultGeography.EpsgId),
             Strings.Validator_SridMismatch);
     }
 }
Exemplo n.º 17
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.Equal(CoordinateSystem.Geography(1234), target.CoordinateSystem);
        }
Exemplo n.º 18
0
        public void MaxGeometryDepth()
        {
            foreach (var v in validators)
            {
                var validator = v();
                validator.SetCoordinateSystem(NonDefaultEpsgId);
                for (int i = 0; i < 28; i++)
                {
                    validator.BeginGeo(SpatialType.Collection);
                }

                SpatialTestUtils.VerifyExceptionThrown <FormatException>(
                    () => validator.BeginGeo(SpatialType.Point),
                    Strings.Validator_NestingOverflow(28));
            }
        }
Exemplo n.º 19
0
        public void UnexpectedGeometry()
        {
            var validator1 = new SpatialValidatorImplementation();

            validator1.GeographyPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeography);
            validator1.GeographyPipeline.BeginGeography(SpatialType.Point);
            SpatialTestUtils.VerifyExceptionThrown <FormatException>(
                () => validator1.GeometryPipeline.BeginGeometry(SpatialType.Point),
                Strings.Validator_UnexpectedCall("SetCoordinateSystem", "BeginPoint"));

            var validator2 = new SpatialValidatorImplementation();

            validator2.GeographyPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeography);
            validator2.GeographyPipeline.BeginGeography(SpatialType.Point);
            validator2.GeographyPipeline.BeginFigure(new GeographyPosition(45, 180, null, null));
            validator2.GeographyPipeline.EndFigure();
            SpatialTestUtils.VerifyExceptionThrown <FormatException>(
                () => validator2.GeometryPipeline.EndGeometry(),
                Strings.Validator_UnexpectedCall("SetCoordinateSystem", "End"));

            var validator3 = new SpatialValidatorImplementation();

            validator3.GeometryPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeometry);
            validator3.GeometryPipeline.BeginGeometry(SpatialType.Point);
            SpatialTestUtils.VerifyExceptionThrown <FormatException>(
                () => validator3.GeographyPipeline.BeginGeography(SpatialType.Point),
                Strings.Validator_UnexpectedCall("SetCoordinateSystem", "BeginPoint"));

            var validator4 = new SpatialValidatorImplementation();

            validator4.GeometryPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeometry);
            validator4.GeometryPipeline.BeginGeometry(SpatialType.Point);
            validator4.GeometryPipeline.BeginFigure(new GeometryPosition(45, 180, null, null));
            validator4.GeometryPipeline.EndFigure();
            SpatialTestUtils.VerifyExceptionThrown <FormatException>(
                () => validator4.GeographyPipeline.EndGeography(),
                Strings.Validator_UnexpectedCall("SetCoordinateSystem", "End"));

            var validator5 = new SpatialValidatorImplementation();

            validator5.GeographyPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeography);
            validator5.GeographyPipeline.BeginGeography(SpatialType.Point);

            SpatialTestUtils.VerifyExceptionThrown <FormatException>(
                () => validator5.GeometryPipeline.BeginFigure(new GeometryPosition(333, 3333333, 333, 333)),
                Strings.Validator_UnexpectedCall("SetCoordinateSystem", "BeginFigure"));
        }
Exemplo n.º 20
0
        public void InvalidPointTest()
        {
            var pipeline = SpatialImplementation.CurrentImplementation.CreateBuilder();

            pipeline.GeographyPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeography);
            pipeline.GeographyPipeline.BeginGeography(SpatialType.Point);
            SpatialTestUtils.VerifyExceptionThrown <ArgumentException>(() => pipeline.GeographyPipeline.BeginFigure(new GeographyPosition(double.NaN, 122, null, null)), Strings.InvalidPointCoordinate(double.NaN, "latitude"));
            pipeline.GeographyPipeline.Reset();

            pipeline.GeographyPipeline.BeginGeography(SpatialType.Point);
            SpatialTestUtils.VerifyExceptionThrown <ArgumentException>(() => pipeline.GeographyPipeline.BeginFigure(new GeographyPosition(47, double.NegativeInfinity, null, null)), Strings.InvalidPointCoordinate(double.NegativeInfinity, "longitude"));
            pipeline.GeographyPipeline.Reset();

            pipeline.GeometryPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeometry);
            pipeline.GeometryPipeline.BeginGeometry(SpatialType.Point);
            SpatialTestUtils.VerifyExceptionThrown <ArgumentException>(() => pipeline.GeometryPipeline.BeginFigure(new GeometryPosition(double.PositiveInfinity, 122, null, null)), Strings.InvalidPointCoordinate(double.PositiveInfinity, "x"));
            pipeline.GeometryPipeline.Reset();

            pipeline.GeometryPipeline.BeginGeometry(SpatialType.Point);
            SpatialTestUtils.VerifyExceptionThrown <ArgumentException>(() => pipeline.GeometryPipeline.BeginFigure(new GeometryPosition(123, double.NaN, null, null)), Strings.InvalidPointCoordinate(double.NaN, "y"));
            pipeline.GeometryPipeline.Reset();
        }
Exemplo n.º 21
0
        public void ErrorOnNullDestinationInCtor()
        {
            Action act = () => new TrivialReader(null);

            SpatialTestUtils.VerifyExceptionThrown <ArgumentNullException>(act, "Value cannot be null.\r\nParameter name: destination");
        }