use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class JTSHelperTest method shouldReverseMultiPolygon.
@Test
public void shouldReverseMultiPolygon() throws OwsExceptionReport {
final GeometryFactory factory = getGeometryFactoryForSRID(4326);
testReverse(factory.createMultiPolygon(new Polygon[] { factory.createPolygon(factory.createLinearRing(randomCoordinateRing(13)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(130)), factory.createLinearRing(randomCoordinateRing(4121)), factory.createLinearRing(randomCoordinateRing(12)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(8)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(1101)), factory.createLinearRing(randomCoordinateRing(413)), factory.createLinearRing(randomCoordinateRing(123)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(89)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(112)), factory.createLinearRing(randomCoordinateRing(4)), factory.createLinearRing(randomCoordinateRing(43)) }) }));
}
use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class JTSHelperTest method factoryFromSridShouldSetSrid.
@Test
public void factoryFromSridShouldSetSrid() {
GeometryFactory factory = getGeometryFactoryForSRID(4326);
assertThat(factory, is(notNullValue()));
Geometry g = factory.createPoint(new Coordinate(1, 2));
assertThat(g, is(notNullValue()));
assertThat(g.getSRID(), is(4326));
}
use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class JTSHelperTest method shouldReverseMultiLineString.
@Test
public void shouldReverseMultiLineString() throws OwsExceptionReport {
final GeometryFactory factory = getGeometryFactoryForSRID(4326);
testReverse(factory.createMultiLineString(new LineString[] { factory.createLineString(randomCoordinateRing(21)), factory.createLineString(randomCoordinateRing(21)), factory.createLineString(randomCoordinateRing(15)) }));
}
use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class ODataFesParserTest method setup.
@Before
public void setup() {
this.parser = new ODataFesParser();
this.geometryFactory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING_SINGLE), 4326);
this.polygon = this.geometryFactory.createPolygon(new Coordinate[] { new Coordinate(-15.46, 77.98), new Coordinate(-93.51, 38.27), new Coordinate(47.10, -1.05), new Coordinate(58.71, 70.61), new Coordinate(-15.46, 77.98) });
this.wktGeometry = new WKTWriter().write(polygon).replaceFirst(" ", "").replaceAll(", ", ",");
}
use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class ODataFesParser method parseGeometry.
/**
* Parse the value expression as an {@code Geometry} in WKT or EWKT format. Geographies are handled as if they would
* be geometries.
*
* @param val the geometry value
*
* @return the geometry
*
* @throws DecodingException if the geometry is invalid
*/
private static Geometry parseGeometry(ValueExpr val) throws DecodingException {
String value = val.getValue();
if (value.startsWith(GEOGRAPHY_TYPE)) {
value = value.substring(GEOGRAPHY_TYPE.length());
}
if (value.startsWith(GEOMETRY_TYPE)) {
value = value.substring(GEOMETRY_TYPE.length());
}
value = stripQuotes(value).toUpperCase();
int srid = 4326;
if (value.startsWith(SRID_PREFIX)) {
int sep = value.indexOf(';');
if (sep > SRID_PREFIX.length() && value.length() > sep) {
try {
srid = Integer.parseInt(value.substring(SRID_PREFIX.length(), sep));
} catch (NumberFormatException ex) {
throw invalidGeometry(val, ex);
}
value = value.substring(sep + 1);
} else {
throw invalidGeometry(val);
}
}
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
GeometryFactory geometryFactory = new GeometryFactory(precisionModel, srid);
WKTReader wktReader = new WKTReader(geometryFactory);
try {
return wktReader.read(value);
} catch (ParseException ex) {
throw invalidGeometry(val, ex);
}
}
Aggregations