/** * Creates a LineString from the given points. * * @param points Sequence of Point composed at least by 2 points. * @return a LineString */ public static LineString of(Point... points) { return of(Arrays.asList(points)); }
/** * 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(); }
/** * Converts to a LineString. * * @return LineString */ public LineString toLineString() { return new LineString(positions()); }
protected static Polygon fromJtsPolygon(com.vividsolutions.jts.geom.Polygon src) { return Polygon.of( fromJtsLineString(src.getExteriorRing()).toLinearRing(), StreamSupport .stream(JtsLineStringIterable.forHolesOf(src).spliterator(), false) .map(AbstractJtsCodec::fromJtsLineString) .map(LinearGeometry::toLinearRing)::iterator ); }
private void fetchPoints() { for (LineString lineString : this.getLineStrings()) { for (Point point : lineString.points()) { points.add(new DPoint(point.lat(), point.lon())); } } }
protected static Polygon fromJtsPolygon(com.vividsolutions.jts.geom.Polygon src) { return Polygon.of( fromJtsLineString(src.getExteriorRing()).toLinearRing(), StreamSupport .stream(JtsLineStringIterable.forHolesOf(src).spliterator(), false) .map(AbstractJtsCodec::fromJtsLineString) .map(LinearGeometry::toLinearRing)::iterator ); }
for (Point point : lineString.points()) { DPoint dgp = projection.translateLatLonToGrid(point.lat(), point.lon()); IPoint igp=new IPoint(dgp);
/** * Creates a LineString from the given points. * * @param points Sequence of Point composed at least by 2 points. * @return a LineString */ public static LineString of(Point... points) { return of(Arrays.asList(points)); }
/** * 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(); }
/** * Converts to a LineString. * * @return LineString */ public LineString toLineString() { return new LineString(positions()); }
/** * Creates a LineString from the given points. * * @param points Iterable of Point at least by 2 points. * @return a LineString */ public static LineString of(Stream<Point> points) { return of(points.collect(Collectors.toList())); }
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()); }
/** * Creates a LineString from the given points. * * @param points Iterable of Point at least by 2 points. * @return a LineString */ public static LineString of(Stream<Point> points) { return of(points.collect(Collectors.toList())); }
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()); }
protected static LineString fromJtsLineString(com.vividsolutions.jts.geom.LineString src) { return LineString.of(StreamSupport.stream(JtsPointIterable.of(src).spliterator(), false) .map(AbstractJtsCodec::fromJtsPoint) ); }
/** * Creates a MultiLineString from the given LineStrings. * * @param lineStrings The Iterable of {@link LineString}. * @return MultiLineString. */ public static MultiLineString of(Iterable<LineString> lineStrings) { AreaPositions.Builder positionsBuilder = AreaPositions.builder(); for(LineString lineString : lineStrings) { positionsBuilder.addLinearPosition(lineString.positions()); } return new MultiLineString(positionsBuilder.build()); }
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); } }
protected static LineString fromJtsLineString(com.vividsolutions.jts.geom.LineString src) { return LineString.of(StreamSupport.stream(JtsPointIterable.of(src).spliterator(), false) .map(AbstractJtsCodec::fromJtsPoint) ); }