Search in sources :

Example 96 with Coordinate

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));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) JTSHelperForTesting.randomCoordinate(org.n52.shetland.util.JTSHelperForTesting.randomCoordinate) Test(org.junit.Test)

Example 97 with Coordinate

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;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate)

Example 98 with Coordinate

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;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing)

Example 99 with Coordinate

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(", ", ",");
}
Also used : WKTWriter(org.locationtech.jts.io.WKTWriter) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) PrecisionModel(org.locationtech.jts.geom.PrecisionModel) Before(org.junit.Before)

Example 100 with Coordinate

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);
    }
}
Also used : GeometryUtils.wktFromJtsGeometry(com.facebook.presto.geospatial.GeometryUtils.wktFromJtsGeometry) OGCGeometry(com.esri.core.geometry.ogc.OGCGeometry) OGCGeometry.createFromEsriGeometry(com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry) Geometry(org.locationtech.jts.geom.Geometry) GeometryUtils.jsonFromJtsGeometry(com.facebook.presto.geospatial.GeometryUtils.jsonFromJtsGeometry) Coordinate(org.locationtech.jts.geom.Coordinate) PrestoException(com.facebook.presto.spi.PrestoException) TopologyException(org.locationtech.jts.geom.TopologyException) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) SqlNullable(com.facebook.presto.spi.function.SqlNullable) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Description(com.facebook.presto.spi.function.Description) SqlType(com.facebook.presto.spi.function.SqlType)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)348 Test (org.junit.Test)145 Geometry (org.locationtech.jts.geom.Geometry)69 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)65 LineString (org.locationtech.jts.geom.LineString)57 Point (org.locationtech.jts.geom.Point)57 Polygon (org.locationtech.jts.geom.Polygon)47 LinearRing (org.locationtech.jts.geom.LinearRing)45 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)37 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)32 ArrayList (java.util.ArrayList)32 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)27 Test (org.junit.jupiter.api.Test)26 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)20 MultiPoint (org.locationtech.jts.geom.MultiPoint)20 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)17 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)16 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)15 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)14 HashMap (java.util.HashMap)13