use of org.locationtech.jts.geom.Coordinate 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.Coordinate in project arctic-sea by 52North.
the class ReverseOf method matches.
@Override
public boolean matches(Object item) {
if (item == null || item.getClass() != original.getClass()) {
return false;
}
Geometry geom = (Geometry) item;
Coordinate[] orig = original.getCoordinates();
Coordinate[] switched = geom.getCoordinates();
if (orig.length != switched.length) {
return false;
}
for (int i = 0; i < orig.length; ++i) {
if (!isSwitched(orig[i], switched[i])) {
return false;
}
}
return true;
}
use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class GeoJSONTest method randomLinearRing.
private LinearRing randomLinearRing(int srid) {
Coordinate p = randomCoordinate();
LinearRing geometry = geometryFactory.createLinearRing(new Coordinate[] { p, randomCoordinate(), randomCoordinate(), randomCoordinate(), p });
geometry.setSRID(srid);
return geometry;
}
use of org.locationtech.jts.geom.Coordinate 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.Coordinate in project presto by prestodb.
the class GeoFunctions method geometryNearestPoints.
@SqlNullable
@Description("Return the closest points on the two geometries")
@ScalarFunction("geometry_nearest_points")
@SqlType("array(" + GEOMETRY_TYPE_NAME + ")")
public static Block geometryNearestPoints(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
Geometry leftGeometry = deserialize(left);
Geometry rightGeometry = deserialize(right);
if (leftGeometry.isEmpty() || rightGeometry.isEmpty()) {
return null;
}
try {
Coordinate[] nearestCoordinates = DistanceOp.nearestPoints(leftGeometry, rightGeometry);
BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, 2);
GEOMETRY.writeSlice(blockBuilder, serialize(createJtsPoint(nearestCoordinates[0])));
GEOMETRY.writeSlice(blockBuilder, serialize(createJtsPoint(nearestCoordinates[1])));
return blockBuilder.build();
} catch (TopologyException e) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
}
}
Aggregations