Example usage for com.mongodb.client.model.geojson Polygon getCoordinates

List of usage examples for com.mongodb.client.model.geojson Polygon getCoordinates

Introduction

In this page you can find the example usage for com.mongodb.client.model.geojson Polygon getCoordinates.

Prototype

public PolygonCoordinates getCoordinates() 

Source Link

Document

Gets the GeoJSON coordinates of the polygon

Usage

From source file:com.bc.fiduceo.db.MongoDbDriver.java

License:Open Source License

@SuppressWarnings("unchecked")
static List<PolygonCoordinates> gePolygonCoordinates(MultiPolygon multiPolygon) {
    List<Polygon> s2PolygonList = (List<Polygon>) multiPolygon.getInner();
    List<PolygonCoordinates> polygonCoordinatesList = new ArrayList<>();
    for (Polygon s2Polygon : s2PolygonList) {
        ArrayList<Position> positions = extractPointsFromGeometry(s2Polygon.getCoordinates());

        if (!positions.get(0).equals(positions.get(positions.size() - 1))) {
            positions.add(positions.get(0));
        }/*from  w  w  w  . j a v  a  2 s.  co  m*/
        polygonCoordinatesList.add(new PolygonCoordinates(positions));
    }
    return polygonCoordinatesList;
}