Search in sources :

Example 1 with BasicVector

use of org.la4j.vector.dense.BasicVector in project ddf by codice.

the class OverlayMetacardTransformer method calculateBoundingBox.

public static List<Vector> calculateBoundingBox(List<Vector> boundary) {
    double maxLon = Collections.max(boundary, Comparator.comparing(v -> v.get(0))).get(0);
    double minLon = Collections.min(boundary, Comparator.comparing(v -> v.get(0))).get(0);
    double maxLat = Collections.max(boundary, Comparator.comparing(v -> v.get(1))).get(1);
    double minLat = Collections.min(boundary, Comparator.comparing(v -> v.get(1))).get(1);
    List<Vector> boundingBox = new ArrayList<>();
    boundingBox.add(new BasicVector(new double[] { minLon, maxLat }));
    boundingBox.add(new BasicVector(new double[] { maxLon, minLat }));
    return boundingBox;
}
Also used : ArrayList(java.util.ArrayList) BasicVector(org.la4j.vector.dense.BasicVector) Vector(org.la4j.Vector) BasicVector(org.la4j.vector.dense.BasicVector)

Example 2 with BasicVector

use of org.la4j.vector.dense.BasicVector in project ddf by codice.

the class OverlayMetacardTransformer method parseBoundary.

private List<Vector> parseBoundary(String location) throws CatalogTransformerException {
    final Geometry geometry = parseGeometry(location);
    if (!canHandleGeometry(geometry)) {
        throw new CatalogTransformerException("The Image boundary is not a rectangle");
    }
    final Coordinate[] coordinates = geometry.getCoordinates();
    List<Vector> boundary = new ArrayList<>();
    // Using indices rather than for-each because the first coordinate is duplicated.
    for (int i = 0; i < 4; i++) {
        boundary.add(new BasicVector(new double[] { coordinates[i].x, coordinates[i].y }));
    }
    return boundary;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryUtils.parseGeometry(ddf.catalog.transformer.GeometryUtils.parseGeometry) GeometryUtils.canHandleGeometry(ddf.catalog.transformer.GeometryUtils.canHandleGeometry) Coordinate(com.vividsolutions.jts.geom.Coordinate) ArrayList(java.util.ArrayList) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) BasicVector(org.la4j.vector.dense.BasicVector) Vector(org.la4j.Vector) BasicVector(org.la4j.vector.dense.BasicVector)

Aggregations

ArrayList (java.util.ArrayList)2 Vector (org.la4j.Vector)2 BasicVector (org.la4j.vector.dense.BasicVector)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 GeometryUtils.canHandleGeometry (ddf.catalog.transformer.GeometryUtils.canHandleGeometry)1 GeometryUtils.parseGeometry (ddf.catalog.transformer.GeometryUtils.parseGeometry)1