use of org.openlca.geo.calc.Bounds in project olca-app by GreenDelta.
the class ResultMap method bsize.
private double bsize(Pair<Location, Feature> pair) {
return bsize.computeIfAbsent(pair.first, loc -> {
Feature f = pair.second;
Bounds bounds = Bounds.of(f);
return Math.abs(bounds.maxX - bounds.minX) * Math.abs(bounds.maxY - bounds.minY);
});
}
use of org.openlca.geo.calc.Bounds in project olca-app by GreenDelta.
the class MapView method initProjection.
/**
* Find an initial zoom and center and calculate the projections.
*/
private void initProjection() {
projections.clear();
if (layers.isEmpty()) {
return;
}
// find the centered projection
FeatureCollection ref = null;
for (LayerConfig config : layers) {
if (config.isCenter()) {
ref = config.layer;
break;
}
}
// with the largest bounds
if (ref == null) {
ref = layers.get(0).layer;
}
// calculate the center
Bounds bounds = Bounds.of(ref);
Point center = bounds.center();
translation.center.x = center.x;
translation.center.y = center.y;
// try to find a good initial zoom
Rectangle canvSize = canvas.getBounds();
zoom = 0;
for (int z = 0; z < 21; z++) {
Point topLeft = new Point(bounds.minX, bounds.minY);
Point bottomRight = new Point(bounds.maxX, bounds.maxY);
WebMercator.apply(topLeft, z);
WebMercator.apply(bottomRight, z);
if ((bottomRight.x - topLeft.x) > canvSize.width)
break;
if ((bottomRight.y - topLeft.y) > canvSize.height)
break;
zoom = z;
}
// finally, project the layers
projectLayers();
}
Aggregations