/// <summary> /// Cast linearring to web linearring /// </summary> /// <param name="linearRing"></param> /// <returns></returns> public static WebLinearRing ToWebLinearRing(this ILinearRing linearRing) { return(new WebLinearRing { Points = (from c in linearRing.Coordinates select c.ToWebPoint()).ToList() }); }
internal static Geometries.LinearRing ToSharpMapLinearRing(NTSLinearRing geom) { Collection <Geometries.Point> vertices = new Collection <Geometries.Point>(); foreach (Coordinate coordinate in geom.Coordinates) { vertices.Add(ToSharpMapPoint(coordinate)); } return(new Geometries.LinearRing(vertices)); }
internal static DotSpatial.Topology.LinearRing ToDotSpatialLinearRing(GeoAPI.Geometries.ILinearRing geom) { Collection <DotSpatial.Topology.Point> vertices = new Collection <DotSpatial.Topology.Point>(); foreach (Coordinate coordinate in geom.Coordinates) { DotSpatial.Topology.Point p = ToDotSpatialPoint(coordinate); vertices.Add(p); } return(new DotSpatial.Topology.LinearRing(vertices)); }
private static ILinearRing ReProject(this ILinearRing linearRing, ICoordinateTransformation transformator) { var pointCount = linearRing.NumPoints; var coordinates = new Coordinate[pointCount]; for (var i = 0; i < pointCount; i++) { coordinates[i] = linearRing.GetCoordinateN(i).ReProject(transformator); } return(new LinearRing(coordinates)); }
internal static NTSPolygon ToNTSPolygon(Geometries.Polygon geom, IGeometryFactory factory) { NTSLinearRing shell = ToNTSLinearRing(geom.ExteriorRing, factory); NTSLinearRing[] holes = new NTSLinearRing[geom.InteriorRings.Count]; int index = 0; foreach (Geometries.LinearRing hole in geom.InteriorRings) { holes[index++] = ToNTSLinearRing(hole, factory); } return(factory.CreatePolygon(shell, holes) as NTSPolygon); }
private static IPolygon ReProject(this IPolygon polygon, ICoordinateTransformation transformator) { var shell = ((ILinearRing)polygon.ExteriorRing).ReProject(transformator); var ringCount = polygon.NumInteriorRings; var holes = new ILinearRing[ringCount]; for (var i = 0; i < ringCount; i++) { holes[i] = ((ILinearRing)polygon.GetInteriorRingN(i)).ReProject(transformator); } return(new Polygon(shell, holes)); }
private static SMGeometry SqlGeometryToSharpMapPolygon(SqlGeometry geometry, Factory factory) { var fact = factory ?? Services.CreateGeometryFactory((int)geometry.STSrid); //exterior ring var exterior = fact.CreateLinearRing(GetPoints(geometry.STExteriorRing())); SMLinearRing[] interior = null; if (geometry.STNumInteriorRing() > 0) { interior = new SMLinearRing[(int)geometry.STNumInteriorRing()]; for (var i = 1; i <= geometry.STNumInteriorRing(); i++) { interior[i - 1] = fact.CreateLinearRing(GetPoints(geometry.STInteriorRingN(i))); } } return(Services.CreateGeometryFactory((int)geometry.STSrid).CreatePolygon(exterior, interior)); }
private static void AddRing(SqlGeometryBuilder builder, SMLinearRing linearRing) { if (linearRing.NumPoints < 3) { return; } //if (linearRing.Area == 0) // return; var coords = linearRing.Coordinates; builder.BeginFigure(coords[0].X, coords[0].Y); for (var i = 1; i < linearRing.NumPoints; i++) { var pt = coords[i]; builder.AddLine(pt.X, pt.Y); } builder.EndFigure(); }
/// <summary> /// Cast Web Polygon to Polygon /// </summary> /// <param name="webPolygon"></param> /// <returns></returns> public static IPolygon ToPolygon(this WebPolygon webPolygon) { //First ring is shell var shell = webPolygon.LinearRings[0].ToLinearRing(); ILinearRing[] holes = null; var ringCount = webPolygon.LinearRings.Count; //All other rings are holes if (ringCount > 1) { holes = new ILinearRing[ringCount - 1]; for (var i = 1; i < ringCount; i++) { holes[i - 1] = webPolygon.LinearRings[i].ToLinearRing(); } } return(new Polygon(shell, holes)); }
private static SMGeometry SqlGeometryToSharpMapPolygon(SqlGeometry geometry, Factory factory) { var fact = factory ?? Services.CreateGeometryFactory((int)geometry.STSrid); //exterior ring var exterior = fact.CreateLinearRing(GetPoints(geometry.STExteriorRing())); SMLinearRing[] interior = null; if (geometry.STNumInteriorRing()>0) { interior = new SMLinearRing[(int)geometry.STNumInteriorRing()]; for (var i = 1; i <= geometry.STNumInteriorRing(); i++) interior[i - 1] = fact.CreateLinearRing(GetPoints(geometry.STInteriorRingN(i))); } return Services.CreateGeometryFactory((int)geometry.STSrid).CreatePolygon(exterior, interior); }
private static void AddRing(SqlGeometryBuilder builder, SMLinearRing linearRing) { if (linearRing.NumPoints < 3) return; //if (linearRing.Area == 0) // return; var coords = linearRing.Coordinates; builder.BeginFigure(coords[0].X, coords[0].Y); for (var i = 1; i < linearRing.NumPoints; i++) { var pt = coords[i]; builder.AddLine(pt.X, pt.Y); } builder.EndFigure(); }
internal static Geometries.LinearRing ToSharpMapLinearRing(NTSLinearRing geom) { Collection<Geometries.Point> vertices = new Collection<Geometries.Point>(); foreach (Coordinate coordinate in geom.Coordinates) vertices.Add(ToSharpMapPoint(coordinate)); return new Geometries.LinearRing(vertices); }
internal static NTSPolygon ToNTSPolygon(Geometries.Polygon geom, IGeometryFactory factory) { NTSLinearRing shell = ToNTSLinearRing(geom.ExteriorRing, factory); NTSLinearRing[] holes = new NTSLinearRing[geom.InteriorRings.Count]; int index = 0; foreach (Geometries.LinearRing hole in geom.InteriorRings) holes[index++] = ToNTSLinearRing(hole, factory); return factory.CreatePolygon(shell, holes) as NTSPolygon; }