public override string AsWKT() { // "LINESTRING (10 20, 30 40, 50 60)" // "MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10), (40 40, 30 30, 40 20, 30 10))" int count = this.LineStrings.Count; if (count < 1) { return(null); } MG_LineString l = (MG_LineString)this.LineStrings[0]; string front = "{0} ({1}"; front = String.Format(front, this.Type.ToString(), l.AsWKT_Reduced()); string m = ", {0}"; string mid = ""; for (int i = 1; i < count; i++) { MG_LineString ll = (MG_LineString)this.LineStrings[i]; mid += String.Format(m, ll.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_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_MultiLineString(MG_MultiLineString ml) { this.Type = MG_GeometryType.MULTILINESTRING; this.LineStrings = new List<MG_LineString>(); if (ml != null) { for (int i = 0; i < ml.Count(); i++) { MG_LineString l = new MG_LineString(ml.GetAt(i)); this.LineStrings.Add(l); } } }
public MG_MultiLineString(MG_MultiLineString ml) { this.Type = MG_GeometryType.MULTILINESTRING; this.LineStrings = new List <MG_LineString>(); if (ml != null) { for (int i = 0; i < ml.Count(); i++) { MG_LineString l = new MG_LineString(ml.GetAt(i)); this.LineStrings.Add(l); } } }
public static void RenderLineString(Graphics g, Pen pen, MG_MapView mapview, MG_LineString lineString) { int count = lineString.Count(); if (count < 2) return; Point[] points = new Point[count]; for (int i = 0; i < count; i++) { MG_Point mp = lineString.GetAt(i); points[i] = AsPoint(mp, mapview); } DrawLineString(g, pen, points); }
public MG_Polygon(MG_Polygon p) { this.Type = MG_GeometryType.POLYGON; this.LineStrings = new List <MG_LineString>(); if (p != null) { for (int i = 0; i < p.Count(); i++) { MG_LineString l = new MG_LineString(p.GetAt(i)); this.LineStrings.Add(l); } } }
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_Polygon(MG_Polygon p) { this.Type = MG_GeometryType.POLYGON; this.LineStrings = new List<MG_LineString>(); if (p != null) { for (int i = 0; i < p.Count(); i++) { MG_LineString l = new MG_LineString(p.GetAt(i)); this.LineStrings.Add(l); } } }
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 void Remove(MG_LineString l) { this.LineStrings.Remove(l); }
public void Add(MG_LineString l) { this.LineStrings.Add(l); }
public MG_ToolDrawPolygon(MG_Layer layer, MG_MapView mapview) : base(MG_ToolType.Tool_DrawPolygon, layer, mapview) { this.LineString = new MG_LineString(); this.Polygon = new MG_Polygon(); }
public MG_ToolDrawLineString(MG_Layer layer, MG_MapView mapview) : base(MG_ToolType.Tool_DrawLineString, layer, mapview) { this.LineString = new MG_LineString(); }
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 override void MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { this.IsMouseDown = false; // screen point to map point MG_LineString MapLineString = new MG_LineString(); for (int i = 0; i < this.LineString.Count();i++ ) { MG_Point screenPoint = this.LineString.GetAt(i); Point screen = new Point((int)screenPoint.x, (int)screenPoint.y); MG_Point mapPoint = MG_BaseRender.ToPoint(screen, this.MapView); MapLineString.Add(mapPoint); } MG_LineString MapLineStringOther = new MG_LineString(); for (int i = 0; i < this.LineStringOther.Count(); i++) { MG_Point screenPoint = this.LineStringOther.GetAt(i); Point screen = new Point((int)screenPoint.x, (int)screenPoint.y); MG_Point mapPoint = MG_BaseRender.ToPoint(screen, this.MapView); MapLineStringOther.Add(mapPoint); } //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(MapLineString); // 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 newFeature1 = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature1); //4 clear data to store the next linestring this.LineString.Clear(); //1 create a feature // 1.1 set geometry this.Feature.SetGeometry(MapLineStringOther); // 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 newFeature2 = new MG_Feature(this.Feature); //3 add new feature to layer this.Layer.AddFeature(newFeature2); //4 clear data to store the next linestring this.LineStringOther.Clear(); } }