protected Map GetMap(IContextRequest request) { string type = request.GetParam("MAP_TYPE"); if (String.IsNullOrEmpty(type)) { throw new WmsParameterNotSpecifiedException("MAP_TYPE"); } if (String.Equals(type, "DEF", StringComparison.InvariantCultureIgnoreCase)) { return(ShapefileHelper.Default()); } if (String.Equals(type, "SPH", StringComparison.InvariantCultureIgnoreCase)) { return(ShapefileHelper.Spherical()); } if (String.Equals(type, "SQL", StringComparison.InvariantCultureIgnoreCase)) { return(DatabaseHelper.SqlServer()); } if (String.Equals(type, "BRU", StringComparison.InvariantCultureIgnoreCase)) { return(BruTileHelper.Osm()); } string format = String.Format("unsupported map type: '{0}'", type); throw new NotSupportedException(format); }
public JsonResult GetData(string layer, int z, int x, int y) { if (String.IsNullOrEmpty(layer)) { throw new ArgumentNullException("layer"); } Map map = ShapefileHelper.Spherical(); IQueryable <VectorLayer> coll = map.Layers .AsQueryable() .OfType <VectorLayer>() .Where(l => l.Enabled && l.IsQueryEnabled) .Where(l => String.Equals(l.LayerName, layer)); VectorLayer query = coll.SingleOrDefault(); if (query == null) { throw new ArgumentException("Layer not found: " + layer); } if (query.SRID != 4326) { throw new ArgumentException("Only EPSG:4326 supported"); } using (Utf8Grid grid = new Utf8Grid(UtfGridResolution, x, y, z)) { Envelope bbox = this.GetBoundingBoxInLatLngWithMargin(x, y, z); var ds = new FeatureCollectionSet(); query.ExecuteIntersectionQuery(bbox, ds); IEnumerable <GeoJSON> data = GeoJSONHelper.GetData(ds); int i = 1; foreach (GeoJSON val in data) { IGeometry geom = val.Geometry; IDictionary <string, object> dict = val.Values; grid.FillPolygon(geom, i, dict); i = i + 1; } Utf8GridResults results = grid.CreateUtfGridJson(); return(this.Json(new { keys = results.Keys, data = results.Data, grid = results.Grid, }, JsonRequestBehavior.AllowGet)); } }
protected Map GetMap(HttpRequest request) { string type = request.Params["MAP_TYPE"]; if (String.Equals(type, "DEF", StringComparison.InvariantCultureIgnoreCase)) { return(ShapefileHelper.Default()); } if (String.Equals(type, "SPH", StringComparison.InvariantCultureIgnoreCase)) { return(ShapefileHelper.Spherical()); } if (String.Equals(type, "SQL", StringComparison.InvariantCultureIgnoreCase)) { return(DatabaseHelper.SqlServer()); } string format = String.Format("unsupported map type: '{0}'", type); throw new NotSupportedException(format); }