private static IGeometryObject toGeometry(this PatternPairMatch wktPattern) { switch (wktPattern.Left.Groups[1].Value.ToLower()) { case "point": return(wktPattern.toPoint()); case "polygon": return(wktPattern.toPolygon()); case "linestring": return(wktPattern.toLineString()); case "multipolygon": return(wktPattern.toMultiPolygon()); case "multipoint": return(wktPattern.toMultiPoint()); case "multilinestring": return(wktPattern.toMultiLineString()); case "geometrycollection": return(wktPattern.toGeometryCollection()); default: throw new Exception($@"Unable to Parse Geometry Type '{wktPattern.Left.Groups[1].Value}'"); } }
private static MultiPoint toMultiPoint(this PatternPairMatch match) { IEnumerable <Point> points; if (match.Children.Count > 0) { points = match.Children.Select(pointMatch => new Point(WktPointToPosition(pointMatch.Content))); } else { points = WktPointsToPositions(match.Content).Select(position => new Point(position)); } // only 1 level of points return(new MultiPoint(points)); }
private static GeometryCollection toGeometryCollection(this PatternPairMatch match) { return(new GeometryCollection(match.Children.Select(geometry => geometry.toGeometry()))); }
private static MultiPolygon toMultiPolygon(this PatternPairMatch match) { // 2 levels of points return(new MultiPolygon(match.Children.Select(polygonMatch => polygonMatch.toPolygon()))); }
private static Polygon toPolygon(this PatternPairMatch match) { // 2 levels of points return(new Polygon(match.Children.Select(lineStringMatch => lineStringMatch.toLineString()))); }
private static MultiLineString toMultiLineString(this PatternPairMatch match) { // only 1 level of points return(new MultiLineString(match.Children.Select(lineStringMatch => lineStringMatch.toLineString()))); }
private static LineString toLineString(this PatternPairMatch match) { // only 1 level of points return(new LineString(match.Content.WktPointsToPositions())); }
private static Point toPoint(this PatternPairMatch match) { return(new Point(WktPointToPosition(match.Content))); }