/** * Returns the points composing this Geometry. * * @return {@code Iterable<Point>} a Guava lazy Iterable. */ public List<Point> points() { return positions().children().stream() .map(Point::new) .collect(Collectors.toList()); }
@Override public LinearPositions build() { Boolean isClosed = size >= 4 && first.equals(last); return new LinearPositions(singlePositions, isClosed); }
public static LinearPositions.Builder builder(LinearPositions positions) { return builder().addSinglePositions(positions.children); }
private Geometry<?> buildGeometry(final Geometry.Type type, final Positions positions, final Geometry<?> geometries) { switch (type) { case GEOMETRY_COLLECTION: return geometries; case MULTI_POLYGON: return new MultiPolygon((MultiDimensionalPositions) positions); case POLYGON: return new Polygon((AreaPositions) positions); case MULTI_LINE_STRING: return new MultiLineString((AreaPositions) positions); case LINEAR_RING: case LINE_STRING: return ((LinearPositions) positions).isClosed() ? new LinearRing((LinearPositions) positions) : new LineString((LinearPositions) positions); case MULTI_POINT: if (positions instanceof SinglePosition) { return new MultiPoint(LinearPositions.builder().addSinglePosition((SinglePosition) positions).build()); } else { return new MultiPoint((LinearPositions) positions); } case POINT: return new Point(((SinglePosition) positions)); default: throw new IllegalArgumentException("Cannot build a geometry for type: " + type); } }
public AreaPositions.Builder addLinearPosition(LinearPositions lp) { linearPositions.add(lp); allChildrenAreClosed = allChildrenAreClosed && lp.isClosed(); return this; }
public LineString(LinearPositions positions) { super(checkArgument(positions, toCheck -> toCheck.size() >= 2, "LineString must be composed by a minimum of 2 points.")); }
private Geometry<?> buildGeometry(final Geometry.Type type, final Positions positions, final Geometry<?> geometries) { switch (type) { case GEOMETRY_COLLECTION: return geometries; case MULTI_POLYGON: return new MultiPolygon((MultiDimensionalPositions) positions); case POLYGON: return new Polygon((AreaPositions) positions); case MULTI_LINE_STRING: return new MultiLineString((AreaPositions) positions); case LINEAR_RING: case LINE_STRING: return ((LinearPositions) positions).isClosed() ? new LinearRing((LinearPositions) positions) : new LineString((LinearPositions) positions); case MULTI_POINT: if (positions instanceof SinglePosition) { return new MultiPoint(LinearPositions.builder().addSinglePosition((SinglePosition) positions).build()); } else { return new MultiPoint((LinearPositions) positions); } case POINT: return new Point(((SinglePosition) positions)); default: throw new IllegalArgumentException("Cannot build a geometry for type: " + type); } }
public AreaPositions.Builder addLinearPosition(LinearPositions lp) { linearPositions.add(lp); allChildrenAreClosed = allChildrenAreClosed && lp.isClosed(); return this; }
public LineString(LinearPositions positions) { super(checkArgument(positions, toCheck -> toCheck.size() >= 2, "LineString must be composed by a minimum of 2 points.")); }
/** * Returns the points composing this Geometry. * * @return {@code Iterable<Point>} a Guava lazy Iterable. */ public List<Point> points() { return positions().children().stream() .map(Point::new) .collect(Collectors.toList()); }
public static LinearPositions.Builder builder(LinearPositions positions) { return builder().addSinglePositions(positions.children); }
/** * Return if this LineString: * - Is composed by at least 4 points * - The first and the last Point are the same. * <p> * For more details @see http://geojson.org/geojson-spec.html#linestring. * * @return true if this Linestring is closed false otherwise. */ public boolean isClosed() { return positions().isClosed(); }
@Override public LinearPositions build() { Boolean isClosed = size >= 4 && first.equals(last); return new LinearPositions(singlePositions, isClosed); }
protected com.vividsolutions.jts.geom.LineString toJtsLineString(LineString src) { return this.geometryFactory.createLineString( StreamSupport.stream(src.positions().children().spliterator(), false) .map(sp -> new Coordinate(sp.lon(), sp.lat(), sp.alt())) .toArray(Coordinate[]::new) ); }
static PositionsBuilder builderOf(Positions p) { if(p instanceof SinglePosition) { return LinearPositions.builder(); } else if (p instanceof LinearPositions) { return AreaPositions.builder(); } else if (p instanceof AreaPositions) { return MultiDimensionalPositions.builder(); } else { throw new IllegalArgumentException("No builder can be supplied for Positions " + p); } }
/** * Return if this LineString: * - Is composed by at least 4 points * - The first and the last Point are the same. * <p> * For more details @see http://geojson.org/geojson-spec.html#linestring. * * @return true if this Linestring is closed false otherwise. */ public boolean isClosed() { return positions().isClosed(); }
protected com.vividsolutions.jts.geom.LinearRing toJtsLinearRing(LinearRing src) { return this.geometryFactory.createLinearRing( StreamSupport.stream(src.positions().children().spliterator(), false) .map(sp -> new Coordinate(sp.lon(), sp.lat(), sp.alt())) .toArray(Coordinate[]::new) ); }
static PositionsBuilder builderOf(Positions p) { if(p instanceof SinglePosition) { return LinearPositions.builder(); } else if (p instanceof LinearPositions) { return AreaPositions.builder(); } else if (p instanceof AreaPositions) { return MultiDimensionalPositions.builder(); } else { throw new IllegalArgumentException("No builder can be supplied for Positions " + p); } }
protected com.vividsolutions.jts.geom.LineString toJtsLineString(LineString src) { return this.geometryFactory.createLineString( StreamSupport.stream(src.positions().children().spliterator(), false) .map(sp -> new Coordinate(sp.lon(), sp.lat(), sp.alt())) .toArray(Coordinate[]::new) ); }
/** * Creates a LineString from the given points. * * @param points Iterable of Point at least by 2 points. * @return a LineString */ public static LineString of(Iterable<Point> points) { LinearPositions.Builder positionsBuilder = LinearPositions.builder(); for(Point point : points) { positionsBuilder.addSinglePosition(point.positions()); } return new LineString(positionsBuilder.build()); }