public override void MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Panel panel = (Panel)sender; this.FromPoint = new Point(e.X, e.Y); // draw point MG_BaseDisplay.FillPoint(panel.CreateGraphics(), brush, this.FromPoint,MG_Constant.PointRadius); // screen to map this.MapPoint = MG_BaseRender.ToPoint(this.FromPoint, this.MapView); //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(this.MapPoint); // 1.2 set field value for (int i = 0; i < this.Feature.GetFieldSet().Count();i++ ) { this.Feature.SetValue(i, null); } //2 create a new feature MG_Feature newFeature = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature); //4 clear data to store the next point this.MapPoint.Clear(); } }
/// xxx between 2 , public override string AsWKT_Reduced() {// "LINESTRING (10 20, 30 40, 50 60)" ---> "(10 20, 30 40, 50 60)" int count = this.Points.Count; if (count < 1) { return(null); } MG_Point p = (MG_Point)this.Points[0]; string front = "({0}"; //Reduced Here: "{0} ({1}"; front = String.Format(front, p.AsWKT_Reduced()); string m = ", {0}"; string mid = ""; for (int i = 1; i < count; i++) { MG_Point pp = (MG_Point)this.Points[i]; mid += String.Format(m, pp.AsWKT_Reduced()); } string end = ")"; return(front + mid + end); }
public Point Map2Screen(MG_Point point) { //scale = 0.015 229,251--->542 530 double sx = CenterScreenPoint.X - (int)((CenterMapPoint.x - point.x) / Scale); double sy = CenterScreenPoint.Y + (int)((CenterMapPoint.y - point.y) / Scale); return new Point((int)sx, (int)sy); }
public Point Map2Screen(MG_Point point) {//scale = 0.015 229,251--->542 530 double sx = CenterScreenPoint.X - (int)((CenterMapPoint.x - point.x) / Scale); double sy = CenterScreenPoint.Y + (int)((CenterMapPoint.y - point.y) / Scale); return(new Point((int)sx, (int)sy)); }
public override string AsWKT() {// "MULTIPOINT (10 20, 30 40, 50 60)" int count = this.Points.Count; if (count < 1) { return(null); } MG_Point p = (MG_Point)this.Points[0]; string front = "{0} ({1}"; front = String.Format(front, this.Type.ToString(), p.AsWKT_Reduced()); string m = ", {0}"; string mid = ""; for (int i = 1; i < count; i++) { MG_Point pp = (MG_Point)this.Points[i]; mid += String.Format(m, pp.AsWKT_Reduced()); } string end = ")"; return(front + mid + end); }
public MG_Feature(MG_Feature f) { this.FieldSet = new MG_FieldSet(); this.ValueSet = new MG_ValueSet(); this.Geometry = new MG_Geometry(); this.Symbol = new MG_Symbol(); for (int i = 0; i < f.GetFieldCount(); i++) { MG_Field field = f.GetFieldSet().GetAt(i); MG_Field newField = new MG_Field(field); this.FieldSet.Add(newField); MG_Value value = f.GetValue(i); MG_Value newValue = new MG_Value(value); this.ValueSet.Add(newValue); } MG_Geometry g = f.GetGeometry(); MG_Geometry newGeom = new MG_Geometry(); switch (g.Type) { case MG_GeometryType.NONE: break; case MG_GeometryType.POINT: newGeom = new MG_Point(g as MG_Point); break; case MG_GeometryType.MULTIPOINT: newGeom = new MG_MultiPoint(g as MG_MultiPoint); break; case MG_GeometryType.LINESTRING: newGeom = new MG_LineString(g as MG_LineString); break; case MG_GeometryType.MULTILINESTRING: newGeom = new MG_MultiLineString(g as MG_MultiLineString); break; case MG_GeometryType.POLYGON: newGeom = new MG_Polygon(g as MG_Polygon); break; case MG_GeometryType.MULTIPOLYGON: newGeom = new MG_MultiPolygon(g as MG_MultiPolygon); break; } this.Geometry = newGeom; MG_Symbol newSymbol = new MG_Symbol(f.GetSymbol()); this.Symbol = newSymbol; }
public MG_MultiPoint(MG_MultiPoint mp) { this.Type = MG_GeometryType.MULTIPOINT; this.Points = new List <MG_Point>(); if (mp != null) { for (int i = 0; i < mp.Count(); i++) { MG_Point p = new MG_Point(mp.GetAt(i)); this.Add(p); } } }
public MG_LineString(MG_LineString l) { this.Type = MG_GeometryType.LINESTRING; this.Points = new List <MG_Point>(); if (l != null) { for (int i = 0; i < l.Count(); i++) { MG_Point p = new MG_Point(l.GetAt(i)); this.Add(p); } } }
public MG_MultiPoint(MG_MultiPoint mp) { this.Type = MG_GeometryType.MULTIPOINT; this.Points = new List<MG_Point>(); if (mp != null) { for (int i = 0; i < mp.Count(); i++) { MG_Point p = new MG_Point(mp.GetAt(i)); this.Add(p); } } }
public MG_LineString(MG_LineString l) { this.Type = MG_GeometryType.LINESTRING; this.Points = new List<MG_Point>(); if (l != null) { for (int i = 0; i < l.Count(); i++) { MG_Point p = new MG_Point(l.GetAt(i)); this.Add(p); } } }
public MG_Feature(MG_Feature f) { this.FieldSet = new MG_FieldSet(); this.ValueSet = new MG_ValueSet(); this.Geometry = new MG_Geometry(); this.Symbol = new MG_Symbol(); for (int i = 0; i < f.GetFieldCount();i++ ) { MG_Field field = f.GetFieldSet().GetAt(i); MG_Field newField = new MG_Field(field); this.FieldSet.Add(newField); MG_Value value = f.GetValue(i); MG_Value newValue = new MG_Value(value); this.ValueSet.Add(newValue); } MG_Geometry g = f.GetGeometry(); MG_Geometry newGeom = new MG_Geometry(); switch (g.Type) { case MG_GeometryType.NONE: break; case MG_GeometryType.POINT: newGeom = new MG_Point(g as MG_Point); break; case MG_GeometryType.MULTIPOINT: newGeom = new MG_MultiPoint(g as MG_MultiPoint); break; case MG_GeometryType.LINESTRING: newGeom = new MG_LineString(g as MG_LineString); break; case MG_GeometryType.MULTILINESTRING: newGeom = new MG_MultiLineString(g as MG_MultiLineString); break; case MG_GeometryType.POLYGON: newGeom = new MG_Polygon(g as MG_Polygon); break; case MG_GeometryType.MULTIPOLYGON: newGeom = new MG_MultiPolygon(g as MG_MultiPolygon); break; } this.Geometry = newGeom; MG_Symbol newSymbol = new MG_Symbol(f.GetSymbol()); this.Symbol = newSymbol; }
public static void RenderPoint(Graphics g, Brush brush, int radius, MG_MapView mapview, MG_Point point) { //int realValue = GetRealValue(radius, mapview); //if (realValue < MG_Constant.PointRadius) //{ // realValue = MG_Constant.PointRadius; //} Point sp = AsPoint(point, mapview); FillPoint(g, brush, sp, radius); }
public MG_Point(MG_Point p) { this.Type = MG_GeometryType.POINT; this.x = p.x; this.y = p.y; }
private void calculateCenterMapPoint() { this.CenterMapPoint = new MG_Point((CurrentExtent.MaxX + CurrentExtent.MinX) / 2, (CurrentExtent.MaxY + CurrentExtent.MinY) / 2); }
public void Add(MG_Point p) { this.Points.Add(p); }
private void testGeometry() { MG_Point p = new MG_Point(100, 200); string type = p.Type.ToString(); string wkt = p.AsWKT(); string wkt_reduced = p.AsWKT_Reduced(); byte[] wkb = p.AsWKB(); MG_MultiPoint mp = new MG_MultiPoint(); for (int i = 0; i < 10; i++) { MG_Point pp = new MG_Point(i, i); mp.Add(pp); } type = mp.Type.ToString(); wkt = mp.AsWKT(); wkt_reduced = mp.AsWKT_Reduced(); wkb = mp.AsWKB(); MG_LineString l = new MG_LineString(); for (int i = 0; i < 10; i++) { MG_Point pp = new MG_Point(i, i); l.Add(pp); } type = l.Type.ToString(); wkt = l.AsWKT(); wkt_reduced = l.AsWKT_Reduced(); wkb = l.AsWKB(); MG_MultiLineString ml = new MG_MultiLineString(); for (int i = 0; i < 5; i++) { MG_LineString l2 = new MG_LineString(); for (int j = 0; j < 3; j++) { MG_Point pp = new MG_Point(i, j); l2.Add(pp); } ml.Add(l2); } type = ml.Type.ToString(); wkt = ml.AsWKT(); wkt_reduced = ml.AsWKT_Reduced(); wkb = ml.AsWKB(); MG_Polygon pg = new MG_Polygon(); for (int i = 0; i < 5; i++) { MG_LineString l2 = new MG_LineString(); for (int j = 0; j < 3; j++) { MG_Point pp = new MG_Point(i, j); l2.Add(pp); } pg.Add(l2); } type = pg.Type.ToString(); wkt = pg.AsWKT(); wkt_reduced = pg.AsWKT_Reduced(); wkb = pg.AsWKB(); }
public void Remove(MG_Point p) { this.Points.Remove(p); }
public MG_ToolDrawPoint(MG_Layer layer, MG_MapView mapview) : base(MG_ToolType.Tool_DrawPoint, layer, mapview) { this.MapPoint = new MG_Point(); }
public static MG_Point ToPoint(Point point, MG_MapView mapview) { MG_Point mp; if (mapview != null) { mp = mapview.Screent2Map(point); } else { mp = new MG_Point(point.X, point.Y); } return mp; }
private static Point AsPoint(MG_Point point, MG_MapView mapview) { Point sp; if (mapview != null) { sp = mapview.Map2Screen(point); } else { sp = new Point((int)point.x, (int)point.y); } return sp; }
private void panel1_MouseMove(object sender, MouseEventArgs e) { if (this.m_gBaseTool != null) { this.m_gBaseTool.MouseMove(sender, e); } // screen and map point this.m_gScreenPoint = new Point(e.X, e.Y); MG_Map map = this.getSelectedMap(); if (map != null && map.GetMapView() != null) { this.m_gMapPoint = map.GetMapView().Screent2Map(this.m_gScreenPoint); } else { this.m_gMapPoint = null; } // set status bar this.setStatusBar(); }