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