public static MapPoint ReadPoint( JsonArray coordinates ) { coordinates.RequireArgument<JsonArray>( "coordinates" ).NotNull<JsonArray>(); return ReadCoordinates( coordinates ); }
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 ] ); }
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; }
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; }
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; }
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; }
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; }
private static Polygon ReadPolygon( JsonArray rings ) { rings.RequireArgument<JsonArray>( "rings" ).NotNull<JsonArray>(); return ReadRings( rings ); }
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; }
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; }
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; }