/** * Create a LinearRing from the given points. * * @param points Point Iterable composed at least by 4 points, with the first and the last that are the same. * @return a LinearRing */ public static LinearRing of(Stream<Point> points) { return of(points::iterator); }
/** * Create a LinearRing from the given points. * * @param points Point Iterable composed at least by 4 points, with the first and the last that are the same. * @return a LinearRing */ public static LinearRing of(Stream<Point> points) { return of(points::iterator); }
/** * Create a LinearRing from the given points. * * @param points Point sequence composed at least by 4 points, with the first and the last that are the same. * @return a LinearRing */ public static LinearRing of(Point... points) { return of(Arrays.asList(points)); }
/** * Create a LinearRing from the given points. * * @param points Point sequence composed at least by 4 points, with the first and the last that are the same. * @return a LinearRing */ public static LinearRing of(Point... points) { return of(Arrays.asList(points)); }
protected static LinearRing fromJtsLinearRing(com.vividsolutions.jts.geom.LinearRing src) { return LinearRing.of(StreamSupport .stream(JtsPointIterable.of(src).spliterator(), false) .map(AbstractJtsCodec::fromJtsPoint)::iterator ); }
protected static LinearRing fromJtsLinearRing(com.vividsolutions.jts.geom.LinearRing src) { return LinearRing.of(StreamSupport .stream(JtsPointIterable.of(src).spliterator(), false) .map(AbstractJtsCodec::fromJtsPoint)::iterator ); }
@Test public void shouldHandleLinearRing() { LinearRing source = LinearRing.of(Point.from(12.3, 45.3), Point.from(43.9, 5.8), Point.from(43.9, 5.8), Point.from(12.3, 45.3)); LinearRing parsed = toTest.fromJson(toTest.toJson(source), LinearRing.class); assertThat(parsed, equalTo(source)); }
@Test public void shouldHandlePolygonWithoutHoles() { Polygon source = Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)) ); Polygon parsed = this.toTest.fromJson(this.toTest.toJson(source), Polygon.class); assertThat(parsed, equalTo(source)); }
@Test public void shouldHandleMultiPolygonWithSinglePolygonWithoutHoles() { MultiPolygon source = MultiPolygon.of( Polygon.of(LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3))) ); MultiPolygon parsed = this.toTest.fromJson(this.toTest.toJson(source), MultiPolygon.class); assertThat(parsed, equalTo(source)); }
@Test public void shouldHandlePolygon() { Polygon source = Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)) ); Polygon parsed = toTest.fromJson(toTest.toJson(source), Polygon.class); assertThat(parsed, equalTo(source)); }
@Test public void shouldHandleMultiPolygonWithSinglePolygonWithHoles() { MultiPolygon source = MultiPolygon.of( Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(150.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(150.3, 45.3)), LinearRing.of(Point.from(140.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(140.3, 45.3)) ) ); MultiPolygon parsed = this.toTest.fromJson(this.toTest.toJson(source), MultiPolygon.class); assertThat(parsed, equalTo(source)); }
@Test public void shouldHandleMultiPolygonWithPolygonsWithoutHoles() { MultiPolygon source = MultiPolygon.of( Polygon.of(LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3))), Polygon.of(LinearRing.of(Point.from(150.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(150.3, 45.3))) ); MultiPolygon parsed = this.toTest.fromJson(this.toTest.toJson(source), MultiPolygon.class); assertThat(parsed, equalTo(source)); }
@Test public void shouldHandleMultiPolygon() { MultiPolygon source = MultiPolygon.of( Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)) ), Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)) ) ); MultiPolygon parsed = toTest.fromJson(toTest.toJson(source), MultiPolygon.class); assertThat(parsed, equalTo(source)); }
LineString.of(Point.from(14.5, 47.3), Point.from(42.19, 3.8)) )); geometries.add(LinearRing.of(Point.from(12.3, 45.3), Point.from(43.9, 5.8), Point.from(43.9, 5.8), Point.from(12.3, 45.3))); geometries.add(Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)) )); geometries.add(MultiPolygon.of( Polygon.of( LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(150.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(150.3, 45.3)) ), Polygon.of( LinearRing.of(Point.from(102.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(102.3, 45.3)), LinearRing.of(Point.from(104.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(104.3, 45.3)) LinearRing.of(Point.from(120.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(120.3, 45.3)), LinearRing.of(Point.from(110.3, 45.3), Point.from(100, -50.8), Point.from(100, 5.8), Point.from(110.3, 45.3))