Search in sources :

Example 1 with JtsShapeFactory

use of org.locationtech.spatial4j.shape.jts.JtsShapeFactory in project janusgraph by JanusGraph.

the class GeoshapeHelperTest method setUp.

@BeforeEach
public void setUp() {
    this.helper = new JtsGeoshapeHelper();
    this.factory = new JtsShapeFactory(helper.context, helper.factory);
}
Also used : JtsShapeFactory(org.locationtech.spatial4j.shape.jts.JtsShapeFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with JtsShapeFactory

use of org.locationtech.spatial4j.shape.jts.JtsShapeFactory in project traccar by tananaev.

the class GeofencePolygon method calculateArea.

@Override
public double calculateArea() {
    JtsShapeFactory jtsShapeFactory = new JtsSpatialContextFactory().newSpatialContext().getShapeFactory();
    ShapeFactory.PolygonBuilder polygonBuilder = jtsShapeFactory.polygon();
    for (Coordinate coordinate : coordinates) {
        polygonBuilder.pointXY(coordinate.getLon(), coordinate.getLat());
    }
    return polygonBuilder.build().getArea(SpatialContext.GEO) * DEG_TO_KM * DEG_TO_KM;
}
Also used : ShapeFactory(org.locationtech.spatial4j.shape.ShapeFactory) JtsShapeFactory(org.locationtech.spatial4j.shape.jts.JtsShapeFactory) JtsShapeFactory(org.locationtech.spatial4j.shape.jts.JtsShapeFactory) JtsSpatialContextFactory(org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory)

Aggregations

JtsShapeFactory (org.locationtech.spatial4j.shape.jts.JtsShapeFactory)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 JtsSpatialContextFactory (org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory)1 ShapeFactory (org.locationtech.spatial4j.shape.ShapeFactory)1