/// <summary> /// Changed but not tested. 93.03.21 /// </summary> /// <returns></returns> public byte[] AsWkb() { List <byte> result = new List <byte>(); if (this.Parts.Count() == 1) { result.AddRange(OgcWkbMapFunctions.ToWkbLineStringZM( ShapeHelper.GetPoints(this, 0), ShapeHelper.GetZValues(this, 0), ShapeHelper.GetMeasures(this, 0))); } else { result.Add((byte)IRI.Standards.OGC.SFA.WkbByteOrder.WkbNdr); result.AddRange(BitConverter.GetBytes((uint)IRI.Standards.OGC.SFA.WkbGeometryType.MultiLineStringZM)); result.AddRange(BitConverter.GetBytes((uint)this.parts.Length)); for (int i = 0; i < this.parts.Length; i++) { result.AddRange( OgcWkbMapFunctions.ToWkbLineStringZM( ShapeHelper.GetPoints(this, this.Parts[i]), ShapeHelper.GetZValues(this, this.Parts[i]), ShapeHelper.GetMeasures(this, this.Parts[i]))); } } return(result.ToArray()); }
//always returns polygon not multi polygon public Geometry <Point> AsGeometry() { if (this.NumberOfParts > 1) { List <Geometry <Point> > parts = new List <Geometry <Point> >(this.NumberOfParts); for (int i = 0; i < NumberOfParts; i++) { //parts[i] = new Geometry<Point>(ShapeHelper.GetPoints(this, Parts[i]), GeometryType.LineString, Srid); parts.Add(new Geometry <Point>(ShapeHelper.GetPoints(this, Parts[i]), GeometryType.LineString, Srid)); } //1399.07.26 //return new Geometry<Point>(parts, GeometryType.Polygon, Srid); return(Geometry <Point> .CreatePolygonOrMultiPolygon(parts, Srid)); } else if (this.NumberOfParts == 1) { return(new Geometry <Point>(new List <Geometry <Point> >() { new Geometry <Point>(ShapeHelper.GetPoints(this, Parts[0]), GeometryType.LineString, Srid) }, GeometryType.Polygon, Srid)); } else { return(Geometry <Point> .CreateEmpty(GeometryType.Polygon, Srid)); } }
public string AsSqlServerWkt() { StringBuilder result = new StringBuilder("MULTILINESTRING("); for (int i = 0; i < NumberOfParts; i++) { result.Append( string.Format("{0},", SqlServerWktMapFunctions.PointZGroupElementToWkt( ShapeHelper.GetPoints(this, i), ShapeHelper.GetZValues(this, i), ShapeHelper.GetMeasures(this, this.Parts[i])))); } return(result.Remove(result.Length - 1, 1).Append(")").ToString()); }
/// <summary> /// Returs Kml representation of the point. Note: Z,M values are igonred /// </summary> /// <returns></returns> static IRI.Ket.KmlFormat.Primitives.PlacemarkType AsPlacemark(PolyLineZ polyline, Func <IRI.Ham.SpatialBase.Point, IRI.Ham.SpatialBase.Point> projectToGeodeticFunc = null, byte[] color = null) { IRI.Ket.KmlFormat.Primitives.PlacemarkType placemark = new KmlFormat.Primitives.PlacemarkType(); List <IRI.Ket.KmlFormat.Primitives.LineStringType> linestrings = new List <KmlFormat.Primitives.LineStringType>(); IRI.Ket.KmlFormat.Primitives.MultiGeometryType multiGeometry = new KmlFormat.Primitives.MultiGeometryType(); IEnumerable <string> coordinates; if (projectToGeodeticFunc != null) { coordinates = polyline.parts .Select(i => string.Join(" ", ShapeHelper.GetPoints(polyline, i) .Select(j => { var temp = projectToGeodeticFunc(new IRI.Ham.SpatialBase.Point(j.X, j.Y)); return(string.Format("{0},{1}", temp.X, temp.Y)); }).ToArray())); } else { coordinates = polyline.Parts .Select(i => string.Join(" ", ShapeHelper.GetPoints(polyline, i) .Select(j => string.Format("{0},{1}", j.X, j.Y)) .ToArray())); } foreach (string item in coordinates) { IRI.Ket.KmlFormat.Primitives.LineStringType linestring = new KmlFormat.Primitives.LineStringType(); linestring.coordinates = item; linestrings.Add(linestring); } multiGeometry.AbstractGeometryObjectExtensionGroup = linestrings.ToArray(); placemark.AbstractFeatureObjectExtensionGroup = new KmlFormat.Primitives.AbstractObjectType[] { multiGeometry }; return(placemark); }
//Error Prone: not checking for multipolygon cases public byte[] AsWkb() { List <byte> result = new List <byte>(); result.Add((byte)IRI.Standards.OGC.SFA.WkbByteOrder.WkbNdr); result.AddRange(BitConverter.GetBytes((uint)IRI.Standards.OGC.SFA.WkbGeometryType.Polygon)); result.AddRange(BitConverter.GetBytes((uint)this.parts.Length)); for (int i = 0; i < this.parts.Length; i++) { result.AddRange(OgcWkbMapFunctions.ToWkbLinearRing(ShapeHelper.GetPoints(this, this.Parts[i]))); } return(result.ToArray()); }
public Geometry <Point> AsGeometry() { if (this.NumberOfParts > 1) { List <Geometry <Point> > parts = new List <Geometry <Point> >(this.NumberOfParts); for (int i = 0; i < NumberOfParts; i++) { //parts[i] = new Geometry<Point>(ShapeHelper.GetPoints(this, Parts[i]), GeometryType.LineString, Srid); parts.Add(new Geometry <Point>(ShapeHelper.GetPoints(this, Parts[i]), GeometryType.LineString, Srid)); } return(new Geometry <Point>(parts, GeometryType.MultiLineString, Srid)); } else if (this.NumberOfParts == 1) { return(new Geometry <Point>(ShapeHelper.GetPoints(this, Parts[0]), GeometryType.LineString, Srid)); } else { return(Geometry <Point> .CreateEmpty(GeometryType.LineString, Srid)); } }
public EsriPoint[] GetPart(int partNo) { return(ShapeHelper.GetPoints(this, Parts[partNo])); }