/// <summary> /// Creates an instance of this class using the provided layer /// </summary> /// <param name="layerName">The name of the layer</param> /// <param name="fileName">The path to the file</param> public ImageGDILayer(string layerName, string fileName, config incfg) :this(layerName, Image.FromFile(fileName), incfg) { ImageFilename = fileName; SetEnvelope(fileName); _envelope = new Envelope(cfg.minX,cfg.maxX,cfg.minY,cfg.maxY); }
//从内存加载图片 public void addGDIlayer(string layername, IImageDataProvider datapro, config cfg) { //delete existing same layer ILayer layer = this.mapBox.Map.GetLayerByName(layername); if (layer != null) { if (mp != null) { mp.Dispose(); mp = null; } if (img != null) { img.Dispose(); img = null; } if (p != null) { DeleteObject(p); } this.mapBox.Map.Layers.Remove(layer); ((Layer)layer).Dispose(); GC.Collect(); } //get data from data provider if (datapro == null) { DefaultData dd = new DefaultData(); mp = dd.GetData(); } else { mp = datapro.GetData(); } p = mp.GetHbitmap(); img = Image.FromHbitmap(p); ImageGDILayer gdilayer = new ImageGDILayer(layername, img, cfg); this.mapBox.Map.Layers.Insert(0, gdilayer); this.mapBox.Map.ZoomToBox(gdilayer.Envelope); this.mapBox.Refresh(); //System.Diagnostics.Process.GetCurrentProcess().MinWorkingSet = new System.IntPtr(5); }
//获取shp投影方式 public ICoordinateTransformation getmapTransform(config.ProjPara proj) { CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); CoordinateSystemFactory cFac = new CoordinateSystemFactory(); ICoordinateTransformation transform = null; //等经纬,shp数据原始投影 var epsg4326 = cFac.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]"); //目标坐标系 var epsg3857 = cFac.CreateFromWkt(getSrcCoordinate(proj)); transform = ctFac.CreateFromCoordinateSystems(epsg4326, epsg3857); return transform; }
public short[] getpoints(config cfg) { //得到选取的所有点大地坐标 List <PointF> pts = mapControl1.getPoints(); //选取的点与数据进行筛选 short[] selectData; SelectImageData imgdata = new SelectImageData(); selectData = imgdata.getSelectData(pts, cfg.width * cfg.height, cfg, mapControl1.getPixelsize()); return(selectData); }
/// <summary> /// Creates an instance of this class using the provided <paramref name="layerName"/> and <paramref name="image"/>. /// </summary> /// <param name="layerName">The layer name</param> /// <param name="image"></param> public ImageGDILayer(string layerName, Image image, config incfg) { InterpolationMode = InterpolationMode.HighQualityBicubic; LayerName = layerName; _image = image; SetEnvelope(); cfg = incfg; //for test purposes //cfg.minX = 152203.122f; //cfg.maxX = 3158014f; //cfg.minY = 3086534.736f; //cfg.maxY = 6023337.07f; _envelope = new Envelope(cfg.minX, cfg.maxX, cfg.minY, cfg.maxY); }
public double[] getEagleEnvelope(config cfg) { double[] result = mapControl1.getZoomEnvelope(cfg); return(result); }
/// <summary> /// Creates an instance of this class using the provided layer /// </summary> /// <param name="fileName">The path to the file</param> public ImageGDILayer(string fileName,config incfg) : this(Path.GetFileName(fileName), fileName,incfg) { }
public short[] getpoints(config cfg ) { //得到选取的所有点大地坐标 List<PointF> pts = mapControl1.getPoints(); //选取的点与数据进行筛选 short[] selectData; SelectImageData imgdata = new SelectImageData(); selectData = imgdata.getSelectData(pts, cfg.width * cfg.height, cfg,mapControl1.getPixelsize()); return selectData; }
public void setCfg(config incfg) { cfg = incfg; pjPara = incfg.pjPara; }
public void setcfg(config cfg) { mapControl1.setCfg(cfg); }
public double[] getZoomEnvelope(config cfg) { double[] scale = new double[4]; Envelope tmpEv = this.mapBox.Map.Envelope; double x_start = (tmpEv.MinX - cfg.minX) / (cfg.maxX - cfg.minX); double x_end = (tmpEv.MaxX - cfg.minX) / (cfg.maxX - cfg.minX); double y_start = (tmpEv.MinY - cfg.minY) / (cfg.maxY - cfg.minY); double y_end = (tmpEv.MaxY - cfg.minY) / (cfg.maxY - cfg.minY); scale[0] = x_start; scale[1] = x_end; scale[2] = y_start; scale[3] = y_end; for (int i = 0; i < scale.Count(); i++) { if (scale[i] < 0) scale[i] = 0; if (scale[i] > 1) scale[i] = 1; } return scale; }
public double[] getEagleEnvelope(config cfg) { double[] result = mapControl1.getZoomEnvelope(cfg); return result; }
//从路径加载图片 public void addGDIlayer(string layername, string filepath, config cfg) { ImageGDILayer gdilayer = new ImageGDILayer(layername, filepath, cfg); this.mapBox.Map.Layers.Insert(0, gdilayer); this.mapBox.Map.ZoomToBox(gdilayer.Envelope); this.mapBox.Refresh(); }
public void getCFG(config inCFG) { imgCon = inCFG; //imgCon.fullPath = ""; }
//test gdi layer public void addgdilayer(string layername, string filepath,config incfg) { //config cfg = getCoordinate(incfg); Envelope en = new Envelope(incfg.minX, incfg.maxX, incfg.minY, incfg.maxY); mapControl1.addGDIlayer(layername,filepath,incfg); }
public void addgdilayer(string layername, IImageDataProvider datapro, config incfg) { //config cfg = getCoordinate(incfg); Envelope en = new Envelope(incfg.minX, incfg.maxX, incfg.minY, incfg.maxY); mapControl1.addGDIlayer(layername, datapro, incfg); }
public config getCoordinate(config cfg) { Projection pj = new Projection(); PointF p1 = new PointF(); PointF p2 = new PointF(); PointF p1_proj = new PointF(); PointF p2_proj = new PointF(); p1.X = cfg.upperLeftLon; p1.Y = cfg.upperLeftLat; p1_proj = pj.GetXYFromLatLon(p1,cfg.pjPara); p2.X = cfg.lowerRightLon; p2.Y = cfg.lowerRightLat; p2_proj = pj.GetXYFromLatLon(p2, cfg.pjPara); //cfg.maxX = p2_proj.X; //cfg.minX = p1_proj.X; //cfg.maxY = p1_proj.Y; //cfg.minY = p2_proj.Y; cfg.minX = p1_proj.X; cfg.maxX = cfg.minX + cfg.resolution * cfg.width; cfg.minY = p2_proj.Y; cfg.maxY = cfg.minY + cfg.resolution * cfg.height; return cfg; }