internal static MapShape Create(MapWay outer, IEnumerable <MapWay> inners, IEnumerable <KeyValuePair <string, string> > tags) { var len = outer.Nodes.Count(); var outerEdge = new PrimitiveLine(outer.Nodes.Take(len - 1).Select(n => new PrimitivePoint(n.Coordinate)).ToList()); var innerEdges = inners.Select(inner => new PrimitivePolygon(new PrimitiveLine(inner.Nodes.Take(len - 1).Select(n => new PrimitivePoint(n.Coordinate)).ToList()))); var primitive = new PrimitivePolygon(outerEdge, innerEdges); return(new MapShape(primitive, tags)); }
private static PolyShape Create(PrimitivePolygon polygon) { var type = PolyShapeType.Polygon.ToString(); var coordinates = new List <Coordinate>(polygon.OuterShape.Points.Select(n => new Coordinate(n.Point))); if (polygon.InnerShapes.Any()) { return(new ComplexPolyShape(coordinates, polygon.InnerShapes.Select(PolyshapeBuilder.Create).ToList(), type)); } return(new PolyShape(coordinates, type)); }
internal static MapShape Create(MapWay way, IEnumerable <KeyValuePair <string, string> > tags) { if (way.IsClosed) { var len = way.Nodes.Count(); var outerEdge = new PrimitiveLine(way.Nodes.Take(len - 1).Select(n => new PrimitivePoint(n.Coordinate)).ToList()); var primitive = new PrimitivePolygon(outerEdge, Enumerable.Empty <PrimitivePolygon>()); return(new MapShape(primitive, tags)); } else { var primitive = new PrimitiveLine(way.Nodes.Select(n => new PrimitivePoint(n.Coordinate)).ToList()); return(new MapShape(primitive, tags)); } }