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(); } }