public static string ToWkt(PolylineBag2 <double> geom) { if (geom != null) { Polyline2 <double> cur; StringBuilder sb = new StringBuilder(); sb.Append("MULTILINESTRING("); for (uint i = 0; i < geom.PartCount; i++) { sb.Append('('); cur = geom[i]; for (uint j = 0; j < cur.VertexCount; j++) { sb.Append(cur[j].X); sb.Append(' '); sb.Append(cur[j].Y); sb.Append(','); } sb.Length = sb.Length - 1; //truncate last , sb.Append("),"); } if (geom.PartCount > 0) { sb[sb.Length - 1] = ')'; } else { sb.Append(')'); } return(sb.ToString()); } return(string.Empty); }
public static JObject ToGeoJson(PolylineBag2 <double> geom) { if (geom == null) { return((JObject)null); } JObject jobject = new JObject(); jobject.Add("type", (JToken) new JValue("MultiLineString")); JArray jarray1 = new JArray(); foreach (Polyline2 <double> lineString in geom) { JArray jarray2 = new JArray(); foreach (Point2 <double> coordinateN in lineString) { jarray2.Add((JToken) new JArray() { (JToken) new JValue(coordinateN.X), (JToken) new JValue(coordinateN.Y) }); } jarray1.Add((JToken)jarray2); } jobject.Add("coordinates", (JToken)jarray1); return(jobject); }
public PolylineBag2(PolylineBag2 <T> cloned) { if (cloned == null) { throw new ArgumentNullException(); } this.Lines = cloned.Lines; }
public int CompareTo(PolylineBag2 <T> other) { if (other == null) { return(1); } if (object.ReferenceEquals(this, other)) { return(0); } if (object.ReferenceEquals(this.Lines, other.Lines)) { return(0); } return(this.Envelope.CompareTo(other.Envelope)); }
public bool Equals(PolylineBag2 <T> other) { if (other == null) { return(false); } if (object.ReferenceEquals(this, other)) { return(true); } if (object.ReferenceEquals(this.Lines, other.Lines)) { return(true); } if (this.VertexCount.Equals(other.VertexCount) && this.Envelope.Equals(other.Envelope)) { Polyline2 <T> us; Polyline2 <T> them; for (int i = 0; i < this.Lines.Length; i++) { us = this.Lines[i]; them = other.Lines[i]; if (us.Points.Length != them.Points.Length) { return(false); //can't be the same } for (int j = 0; j < us.Points.Length; j++) { if (!us.Points[j].Equals(them.Points[j])) { return(false); } } } return(true); } return(false); }