コード例 #1
0
 private static void SendToPipeline(IDictionary<string, object> members, SpatialPipeline pipeline, bool isGeography)
 {
     GeoJsonObjectReader reader = new GeoJsonObjectReader(pipeline);
     if (isGeography)
     {
         reader.ReadGeography(members);
     }
     else
     {
         reader.ReadGeometry(members);
     }
 }
コード例 #2
0
        private static void TestReadMethod(SpatialType spatialType, List<object> coordinates, bool isGeography, Func<List<object>, bool, ICommonLoggingPipeline> getExpectedPipeline)
        {
            int expectedPropertyCount;
            var jsonObject = GetGeoJson(spatialType, coordinates, out expectedPropertyCount);
            var expectedPipeline = getExpectedPipeline(coordinates, isGeography);

            var actualPipeline = new CallSequenceLoggingPipeline();
            var geoJsonObjectReader = new GeoJsonObjectReader(actualPipeline);
            if (isGeography)
            {
                geoJsonObjectReader.ReadGeography(jsonObject);
            }
            else
            {
                geoJsonObjectReader.ReadGeometry(jsonObject);
            }

            expectedPipeline.VerifyPipeline(actualPipeline);
        }
コード例 #3
0
        public void GeoJsonSimpleRoundTripTest()
        {
            var position = new GeographyPosition(12, 34, -12, -34);
            var coordinateSystem = CoordinateSystem.Geography(54321);

            var writer =  new GeoJsonObjectWriter();
            GeographyPipeline pipeline = (SpatialPipeline)writer;

            pipeline.SetCoordinateSystem(coordinateSystem);
            pipeline.BeginGeography(SpatialType.Point);
            pipeline.BeginFigure(position);
            pipeline.EndFigure();
            pipeline.EndGeography();

            var actualPipeline = new CallSequenceLoggingPipeline();
            var reader = new GeoJsonObjectReader(actualPipeline);
            reader.ReadGeography(writer.JsonObject);

            var expectedPipeline = new CallSequenceLoggingPipeline();

            // TODO: move the set of calls back into a delegate if the APIs come back together
            expectedPipeline.GeographyPipeline.SetCoordinateSystem(coordinateSystem);
            expectedPipeline.GeographyPipeline.BeginGeography(SpatialType.Point);
            expectedPipeline.GeographyPipeline.BeginFigure(position);
            expectedPipeline.GeographyPipeline.EndFigure();
            expectedPipeline.GeographyPipeline.EndGeography();

            actualPipeline.Verify(expectedPipeline);
        }
コード例 #4
0
        private static void TestReadMethod(SpatialType[] spatialType, List<object>[] coordinates, bool isGeography, Func<Func<List<Object>, bool, ICommonLoggingPipeline>[], List<object>[], bool, ICommonLoggingPipeline> getExpectedPipeline, Func<List<Object>, bool, ICommonLoggingPipeline>[] innerGetExpectedPipeline)
        {
            // used for Collections

            int expectedPropertyCount;
            int epsgId = isGeography ? CoordinateSystem.DefaultGeography.EpsgId.Value : CoordinateSystem.DefaultGeometry.EpsgId.Value;
            var jsonObject = GetGeoJson(spatialType, coordinates, out expectedPropertyCount, epsgId);
            var expectedPipeline = getExpectedPipeline(innerGetExpectedPipeline, coordinates, isGeography);

            var actualPipeline = new CallSequenceLoggingPipeline();
            var geoJsonObjectReader = new GeoJsonObjectReader(actualPipeline);
            if (isGeography)
            {
                geoJsonObjectReader.ReadGeography(jsonObject);
            }
            else
            {
                geoJsonObjectReader.ReadGeometry(jsonObject);
            }

            expectedPipeline.VerifyPipeline(actualPipeline);
        }