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;
}
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;
}
Aggregations