public static Grid FromShapeFile(string shapeFilePath, RutenettType rutenettType, int epsgCode) { var grid = new Grid(rutenettType); Shapefile shapeFile = Shapefile.OpenFile(shapeFilePath); var numFeatures = shapeFile.NumRows(); for (var i = 0; i < numFeatures; i++) { var feature = shapeFile.GetFeature(i); var cell = new GridCell(); cell.CellId = feature.DataRow[0].ToString(); var text = new SqlChars(feature.BasicGeometry.ToString()); cell.Geometry = SqlGeometry.STGeomFromText(text, epsgCode); grid.Cells.Add(cell); } return(grid); }
public static Byte[] GetMap(MapRequest mapReq) { string filepath = @"D:\MyDocuments\pkumap\"; Bitmap tempbmp = new Bitmap(mapReq.Width, mapReq.Height); for (int i = 0; i < mapReq.layers.Length; i++) { string filename = filepath + mapReq.layers[i] + ".shp"; Shapefile shp = new Shapefile(filename); FeatureClass fc = shp.GetFeature(); tempbmp = fc.DrawBMP(mapReq.bbox, tempbmp, mapReq.styles[0]); } MemoryStream ms = new MemoryStream(); tempbmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); byte[] bitmapData = new Byte[ms.Length]; bitmapData = ms.ToArray(); return(bitmapData); }