示例#1
0
 public static MapPoint ReadPoint( JsonArray coordinates )
 {
     coordinates.RequireArgument<JsonArray>( "coordinates" ).NotNull<JsonArray>();
     return ReadCoordinates( coordinates );
 }
示例#2
0
        public static MapPoint ReadCoordinates( JsonArray coordinates )
        {
            coordinates.RequireArgument<JsonArray>( "coordinates" ).NotNull<JsonArray>();

            if( coordinates.Count > 3 )
                throw new InvalidOperationException( "Only a maximum of 3 coordinate values can be present." );
            if( coordinates.Count < 2 )
                throw new InvalidOperationException( "A minimum of 2 coordinate values must be present." );

            return new MapPoint( (double)coordinates[0], (double)coordinates[ 1 ] );
        }
示例#3
0
        public static PointCollection ReadLineString( JsonArray points )
        {
            points.RequireArgument<JsonArray>( "points" ).NotNull<JsonArray>();

            PointCollection linestring = new PointCollection();
            foreach( JsonValue entry in points )
            {
                JsonArray coordinates = entry as JsonArray;
                linestring.Add(ReadPoint(coordinates));
            }
            return linestring;
        }
示例#4
0
        public static MultiPoint ReadMultiPoint( JsonArray points )
        {
            points.RequireArgument<JsonArray>( "points" ).NotNull<JsonArray>();

            MultiPoint multiPoint = new MultiPoint();
            foreach( JsonValue entry in points )
            {
                JsonArray coordinates = entry as JsonArray;
                multiPoint.Points.Add(ReadPoint(coordinates));
            }
            return multiPoint;
        }
示例#5
0
        private static PointCollection ReadRing( JsonArray points )
        {
            points.RequireArgument<JsonArray>( "points" ).NotNull<JsonArray>();

            PointCollection ringCoords = new PointCollection();
            foreach( JsonValue entry in points )
            {
                JsonArray coordinates = entry as JsonArray;
                ringCoords.Add( ReadPoint( coordinates ) );
            }
            return ringCoords;
        }
示例#6
0
        private static Geometry ReadMultiLineString( JsonArray paths )
        {
            paths.RequireArgument<JsonArray>( "paths" ).NotNull<JsonArray>();

            Polyline lines = new Polyline();
            foreach( JsonValue entry in paths )
            {
                JsonArray line = entry as JsonArray;
                lines.Paths.Add(ReadLineString(line));
            }

            return lines;
        }
示例#7
0
        private static Polygon ReadRings( JsonArray rings )
        {
            rings.RequireArgument<JsonArray>( "rings" ).NotNull<JsonArray>();

            Polygon areas = new Polygon();
            foreach( JsonValue entry in rings )
            {
                JsonArray line = entry as JsonArray;
                areas.Rings.Add( ReadRing( line ) );
            }

            return areas;
        }
示例#8
0
        private static Polygon ReadPolygon( JsonArray rings )
        {
            rings.RequireArgument<JsonArray>( "rings" ).NotNull<JsonArray>();

            return ReadRings( rings );
        }
示例#9
0
        private static Geometry ReadMultiPolygon( JsonArray polygons )
        {
            polygons.RequireArgument<JsonArray>( "polygons" ).NotNull<JsonArray>();

            Polygon areas = new Polygon();
            foreach( JsonValue polygon in polygons )
            {
                JsonArray polygonCoords = polygon as JsonArray;
                Polygon poly = ReadPolygon( polygonCoords );
                poly.Rings.ForEach<PointCollection>( item => areas.Rings.Add( item ) );
            }

            return areas;
        }
示例#10
0
        public static Dictionary<int, string> ReadLayerReferenceArray( JsonArray json )
        {
            json.RequireArgument<JsonArray>( "json" ).NotNull<JsonArray>();

            Dictionary<int, string> lyrRefs = new Dictionary<int, string>();
            foreach( JsonValue item in json )
            {
                if( !( item is JsonObject ) )
                    throw new FormatException( "All entries in a layer reference array should be of type JsonObjects." );

                KeyValuePair<int, string> entry = ReadLayerReference( item as JsonObject );
                lyrRefs.Add(entry.Key, entry.Value );
            }

            return lyrRefs;
        }
示例#11
0
        public static List<FieldMetadata> ReadFieldMetadataArray( JsonArray json )
        {
            json.RequireArgument<JsonArray>( "json" ).NotNull<JsonArray>();

            List<FieldMetadata> flds = new List<FieldMetadata>();
            foreach( JsonValue item in json )
            {
                if( !( item is JsonObject ) )
                    throw new FormatException( "All entries in a field metadata array should be of type JsonObject." );

                FieldMetadata fld = ReadFieldMetadata( item as JsonObject );
                flds.Add( fld );
            }

            return flds;
        }