org.locationtech.jts.geom.impl.CoordinateArraySequence Java Examples

The following examples show how to use org.locationtech.jts.geom.impl.CoordinateArraySequence. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JTSHelper.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
private CoordinateSequence convert(CoordinateSequence coordinates) {
    return new CoordinateArraySequence(coordinates);
}
 
Example #2
Source File: JtsAdapterFactoryTest.java    From geogson with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleGeometryCollection() {

  // somewhere in the east of Austria in MGI / Austria GK M34, precision in millimeter
  GeometryFactory gf = new GeometryFactory(new PrecisionModel(1000), 31259);
  GeometryCollection source = gf.createGeometryCollection(new Geometry[] {
      gf.createPoint(new Coordinate(763220, 300880)),
      gf.createMultiPoint(new Coordinate[] {
          new Coordinate(763225.1234, 300885.9876),
          new Coordinate(763230.2345, 300890.0123) }),
      gf.createLineString(new Coordinate[] { new Coordinate(763390, 300390),
          new Coordinate(763310, 300310) }),
      new MultiLineString(
          new LineString[] {
              gf.createLineString(new Coordinate[] {
                  new Coordinate(763410, 300410),
                  new Coordinate(763450, 300400) }),
              new LineString(new CoordinateArraySequence(new Coordinate[] {
                  new Coordinate(763360, 300360),
                  new Coordinate(763370, 300370),
                  new Coordinate(763380, 300375) }), gf) }, gf),
      new MultiLineString(
          new LineString[] {
              gf.createLineString(new Coordinate[] {
                  new Coordinate(763410, 300410),
                  new Coordinate(763450, 300400) }) }, gf), 
      gf.createPolygon(new LinearRing(
          new CoordinateArraySequence(new Coordinate[] {
              new Coordinate(763000, 300000), new Coordinate(763050, 300000),
              new Coordinate(763050, 300050), new Coordinate(763000, 300050),
              new Coordinate(763000, 300000) }), gf),
          new LinearRing[] { new LinearRing(new CoordinateArraySequence(
              new Coordinate[] { new Coordinate(763010, 300010),
                  new Coordinate(763020, 300010),
                  new Coordinate(763020, 300020),
                  new Coordinate(763010, 300020),
                  new Coordinate(763010, 300010) }), gf) }),
      gf.createMultiPolygon(new Polygon[] { new Polygon(new LinearRing(
          new CoordinateArraySequence(new Coordinate[] {
              new Coordinate(763000, 300000), new Coordinate(763050, 300000),
              new Coordinate(763050, 300050), new Coordinate(763000, 300050),
              new Coordinate(763000, 300000) }), gf),
          new LinearRing[] { new LinearRing(new CoordinateArraySequence(
              new Coordinate[] { new Coordinate(763010, 300010),
                  new Coordinate(763020, 300010),
                  new Coordinate(763020, 300020),
                  new Coordinate(763010, 300020),
                    new Coordinate(763010, 300010) }), gf) }, gf) }),
      gf.createGeometryCollection(new Polygon[] { new Polygon(new LinearRing(
          new CoordinateArraySequence(new Coordinate[] {
              new Coordinate(763700, 300000), new Coordinate(763750, 300000),
              new Coordinate(763750, 300050), new Coordinate(763700, 300050),
              new Coordinate(763700, 300000) }), gf),
          new LinearRing[] { new LinearRing(new CoordinateArraySequence(
              new Coordinate[] { new Coordinate(763710, 300010),
                  new Coordinate(763720, 300010),
                  new Coordinate(763720, 300020),
                  new Coordinate(763710, 300020),
                  new Coordinate(763710, 300010) }), gf) }, gf) }) });

    GeometryCollection parsed = this.toTest.fromJson(this.toTest.toJson(source), GeometryCollection.class);

    // this works with any GeometryFactory
    assertThat(parsed, equalTo(source));
    // should match the defined static GeometryFactory
    assertThat(parsed.getPrecisionModel(), equalTo(new PrecisionModel(PrecisionModel.FLOATING)));
    assertThat(parsed.getSRID(), equalTo(4326));
    // should not match with given source (as GeometryFactory of source and toTest differ!)
    assertThat(parsed.getPrecisionModel(), is(not(equalTo(source.getPrecisionModel()))));
    assertThat(parsed.getSRID(), is(not(equalTo(source.getSRID()))));
}