private static IGeoShapeQuery ParseShapeQuery(JToken shape, JsonSerializer serializer) { var geometry = GeoShapeConverter.ReadJToken(shape, serializer); return(new GeoShapeQuery { Shape = geometry }); }
private static IGeoShapeQuery ParseShapeQuery(JToken shape, JsonSerializer serializer) { var type = shape["type"]; var typeName = type?.Value <string>().ToUpperInvariant(); var geometry = GeoShapeConverter.ReadJToken(shape, serializer); switch (typeName) { case GeoShapeType.Circle: return(new GeoShapeCircleQuery { Shape = geometry as ICircleGeoShape }); case GeoShapeType.Envelope: return(new GeoShapeEnvelopeQuery { Shape = geometry as IEnvelopeGeoShape }); case GeoShapeType.LineString: return(new GeoShapeLineStringQuery { Shape = geometry as ILineStringGeoShape }); case GeoShapeType.MultiLineString: return(new GeoShapeMultiLineStringQuery { Shape = geometry as IMultiLineStringGeoShape }); case GeoShapeType.Point: return(new GeoShapePointQuery { Shape = geometry as IPointGeoShape }); case GeoShapeType.MultiPoint: return(new GeoShapeMultiPointQuery { Shape = geometry as IMultiPointGeoShape }); case GeoShapeType.Polygon: return(new GeoShapePolygonQuery { Shape = geometry as IPolygonGeoShape }); case GeoShapeType.MultiPolygon: return(new GeoShapeMultiPolygonQuery { Shape = geometry as IMultiPolygonGeoShape }); case GeoShapeType.GeometryCollection: return(new GeoShapeGeometryCollectionQuery { Shape = geometry as IGeometryCollection }); default: return(null); } }
private static IGeoShapeQuery ParseShapeQuery(JToken shape, JsonSerializer serializer) { var type = shape["type"]; var typeName = type?.Value <string>(); var geometry = GeoShapeConverter.ReadJToken(shape, serializer); switch (typeName) { case "circle": return(new GeoShapeCircleQuery { Shape = geometry as ICircleGeoShape }); case "envelope": return(new GeoShapeEnvelopeQuery { Shape = geometry as IEnvelopeGeoShape }); case "linestring": return(new GeoShapeLineStringQuery { Shape = geometry as ILineStringGeoShape }); case "multilinestring": return(new GeoShapeMultiLineStringQuery { Shape = geometry as IMultiLineStringGeoShape }); case "point": return(new GeoShapePointQuery { Shape = geometry as IPointGeoShape }); case "multipoint": return(new GeoShapeMultiPointQuery { Shape = geometry as IMultiPointGeoShape }); case "polygon": return(new GeoShapePolygonQuery { Shape = geometry as IPolygonGeoShape }); case "multipolygon": return(new GeoShapeMultiPolygonQuery { Shape = geometry as IMultiPolygonGeoShape }); case "geometrycollection": return(new GeoShapeGeometryCollectionQuery { Shape = geometry as IGeometryCollection }); default: return(null); } }
private static IGeoShapeQuery ParseShapeQuery(JToken shape, JsonSerializer serializer) { var type = shape["type"]; var typeName = type?.Value <string>(); var ignoreUnmapped = shape["ignore_unmapped"]?.Value <bool?>(); var geometry = GeoShapeConverter.ReadJToken(shape, serializer); switch (typeName) { case "circle": return(new GeoShapeCircleQuery { Shape = SetIgnoreUnmapped(geometry as ICircleGeoShape, ignoreUnmapped) }); case "envelope": return(new GeoShapeEnvelopeQuery { Shape = SetIgnoreUnmapped(geometry as IEnvelopeGeoShape, ignoreUnmapped) }); case "linestring": return(new GeoShapeLineStringQuery { Shape = SetIgnoreUnmapped(geometry as ILineStringGeoShape, ignoreUnmapped) }); case "multilinestring": return(new GeoShapeMultiLineStringQuery { Shape = SetIgnoreUnmapped(geometry as IMultiLineStringGeoShape, ignoreUnmapped) }); case "point": return(new GeoShapePointQuery { Shape = SetIgnoreUnmapped(geometry as IPointGeoShape, ignoreUnmapped) }); case "multipoint": return(new GeoShapeMultiPointQuery { Shape = SetIgnoreUnmapped(geometry as IMultiPointGeoShape, ignoreUnmapped) }); case "polygon": return(new GeoShapePolygonQuery { Shape = SetIgnoreUnmapped(geometry as IPolygonGeoShape, ignoreUnmapped) }); case "multipolygon": return(new GeoShapeMultiPolygonQuery { Shape = SetIgnoreUnmapped(geometry as IMultiPolygonGeoShape, ignoreUnmapped) }); case "geometrycollection": var geometryCollection = geometry as IGeometryCollection; if (geometryCollection != null) { foreach (var innerGeometry in geometryCollection.Geometries) { SetIgnoreUnmapped(innerGeometry, ignoreUnmapped); } } return(new GeoShapeGeometryCollectionQuery { Shape = geometryCollection }); default: return(null); } }