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 static async Task <SqlFeatureDataSource> CreateFromShapefileAsync(string shpFileName, string label, Encoding dataEncoding = null, SrsBase targetSrs = null, Encoding headerEncoding = null, bool correctFarsiCharacters = true) { var features = await ShapefileHelper.ReadAsSqlFeatureAsync(shpFileName, dataEncoding, targetSrs, headerEncoding, correctFarsiCharacters, label); var result = new SqlFeatureDataSource(features, i => i.Label); //result.ToDataTableMappingFunc = sqlFeatureToDataTableMapping; return(result); }
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)); } }
private void AssignCustomFileIcons(TreeNodeAdv node, string filename, RepositoryItemType itemType) { if (itemType == RepositoryItemType.Vector && filename.ToLower().EndsWith(".shp")) { var type = ShapefileHelper.GetGeometryType(filename); node.LeftImageIndices = new[] { GetVectorIcon(type) }; } if (filename.ToLower().EndsWith(".vrt")) { node.LeftImageIndices = new[] { (int)RepositoryIcon.VrtFile }; } if (filename.ToLower().EndsWith(".sqlite")) { node.LeftImageIndices = new[] { (int)RepositoryIcon.Sqlite }; } }
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); }
public void ForbiddenNames() { Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName(null), true); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName(""), true); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("bg00_d00.shp"), true); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("tr99_d00"), true); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("cs55_d00.shp"), true); // Right now we don't have the settings to test these, and they aren't used by the app currently anyway //Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("z327_d00"), true); //Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("zt00_d00.shp"), true); //Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("vt00_d00"), true); //Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("co00_d00.shp"), true); //Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("co00_d00"), true); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("co00_d0a_shp.zip"), false); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("co00_da0_shp.zip"), false); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("co00_daa_shp.zip"), false); Assert.AreEqual(ShapefileHelper.IsForbiddenShapefileName("co00_d00_shp.zip"), false); }