public static Geometry getJts(final PolyLine polyLine) { if (polyLine instanceof Polygon) { return new JtsPolygonConverter().convert((Polygon) polyLine); } return new JtsPolyLineConverter().convert(polyLine); }
protected MultiPolygonClipper(final MultiPolygon clipping) { this.jtsClippings = new JtsMultiPolygonConverter().convert(clipping); }
public static Polygon toPolygon(final List<Coordinate> coordinates) { return toPolygon(coordinates.toArray(new Coordinate[coordinates.size()])); }
@Override public String convert(final PolyLine polyLine) { final Geometry geometry = new JtsPolyLineConverter().convert(polyLine); return new WKTWriter().write(geometry); } }
@Override public String convert(final MultiPolygon multiPolygon) { final com.vividsolutions.jts.geom.MultiPolygon geometry = new JtsMultiPolygonToMultiPolygonConverter() .backwardConvert(multiPolygon); return new WKTWriter().write(geometry); } }
/** * This will return the centroid of a given polygon. It can handle complex polygons including * multiple polygons. This will not necessarily return a location that is contained within the * original polygon. For example if you have two concentric circles forming a donut shape, one * smaller one contained within the bigger one. The centroid of that polygon will be at the * center technically outside of the polygon. This is a very different concept to a * representative point. * * @return a Location object that is the centroid of the polygon */ public Location center() { final Point point = JTS_POLYGON_CONVERTER.convert(this).getCentroid(); return new JtsLocationConverter().backwardConvert(point.getCoordinate()); }
@Override public String convert(final MultiPolyLine multiPolyLine) { final MultiLineString geometry = new JtsMultiPolyLineConverter().convert(multiPolyLine); return new WKTWriter().write(geometry); } }
@Override public String convert(final Polygon polygon) { final Geometry geometry = new JtsPolygonConverter().convert(polygon); return new WKTWriter().write(geometry); } }
@Override public String convert(final Location location) { final Geometry geometry = new JtsPointConverter().convert(location); final String wkt = new WKTWriter().write(geometry); return wkt; } }
/** * Tests that the {@link PolyLine}'s geometry is valid * * @param polyline * the {@link PolyLine} to test * @return {@code true} if the {@link PolyLine} has valid geometry, otherwise {@code false} */ public static boolean isValidPolyLine(final PolyLine polyline) { final LineString lineString = POLYLINE_CONVERTER.convert(polyline); return lineString.isSimple(); }
/** * @param location * The {@link Location} to check * @return the resulting {@link CountryCodeProperties} * @see #getCountryCodeISO3(Geometry) */ public CountryCodeProperties getCountryCodeISO3(final Location location) { return this.getCountryCodeISO3(JTS_POINT_CONVERTER.convert(location)); }
/** * Tests that the {@link Polygon}'s geometry is valid * * @param polygon * the {@link Polygon} to test * @return {@code true} if the {@link Polygon} has valid geometry, otherwise {@code false} */ public static boolean isValidPolygon(final Polygon polygon) { final com.vividsolutions.jts.geom.Polygon jtsPolygon = POLYGON_CONVERTER.convert(polygon); return jtsPolygon.isSimple(); }
@Override public LineString convert(final PolyLine polyLine) { return new LineString(COORDINATE_ARRAY_CONVERTER.convert(polyLine), FACTORY); } }
@Override public Polygon backwardConvert(final com.vividsolutions.jts.geom.Polygon object) { return LINEAR_RING_CONVERTER.backwardConvert((LinearRing) object.getExteriorRing()); }
/** * @param collection * The collection to stream * @return The JTS {@link Geometry} {@link Iterable} as JTS {@link Polygon}s */ public static Iterable<Polygon> streamPolygons(final GeometryCollection collection) { return Iterables.translate(stream(collection), geometry -> (Polygon) geometry); }
@Override public com.vividsolutions.jts.geom.Polygon convert(final Polygon object) { return new com.vividsolutions.jts.geom.Polygon(LINEAR_RING_CONVERTER.convert(object), new LinearRing[0], FACTORY); } }
@Override public byte[] convert(final MultiPolygon multiPolygon) { final Geometry geometry = new JtsMultiPolygonToMultiPolygonConverter() .backwardConvert(multiPolygon); final byte[] wkb = new WKBWriter().write(geometry); return wkb; } }
/** * Returns a location that is the closest point within the polygon to the centroid. The function * delegates to the Geometry class which delegates to the InteriorPointPoint class. You can see * the javadocs in the link below. <a href= * "http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/algorithm/InteriorPointPoint"> * http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/algorithm/InteriorPointPoint * </a> .html * * @return location that is the closest point within the polygon to the centroid */ public Location interiorCenter() { final Point point = JTS_POLYGON_CONVERTER.convert(this).getInteriorPoint(); return new JtsLocationConverter().backwardConvert(point.getCoordinate()); }
@Override public byte[] convert(final Polygon polygon) { final Geometry geometry = new JtsPolygonConverter().convert(polygon); final byte[] wkb = new WKBWriter().write(geometry); return wkb; } }
@Override public byte[] convert(final Location location) { final Geometry geometry = new JtsPointConverter().convert(location); final byte[] wkb = new WKBWriter().write(geometry); return wkb; } }