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);
        }
예제 #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));
        }
예제 #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);
        }
예제 #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"));
        }
예제 #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"));
        }
예제 #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"));
        }
예제 #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);
        }
예제 #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
        }
예제 #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"));
        }
예제 #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);
            }
        }
예제 #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");
            }
        }
예제 #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"));
        }
예제 #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"));
        }
예제 #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);
        }
예제 #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));
     }
 }
예제 #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);
     }
 }
예제 #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);
        }
예제 #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));
            }
        }
예제 #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"));
        }
        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();
        }
예제 #21
0
        public void ErrorOnNullDestinationInCtor()
        {
            Action act = () => new TrivialReader(null);

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