use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class FactorZoomMode method getBoundingBox.
/**
* Get the best bounding box matching the zoom mode policy
*
* @param viewport The viewport.
* @param boundingBox The bounding box.
* @return The bounding box.
*/
@Override
public BoundingBox getBoundingBox(final ComponentViewport2D viewport, final BoundingBox boundingBox) {
final GeometryFactory geometryFactory = viewport.getGeometryFactory();
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
final GeometryFactory bboxGeometryFactory = boundingBox.getGeometryFactory();
BoundingBox newBoundingBox = boundingBox;
if (bboxGeometryFactory == null) {
newBoundingBox = boundingBox.convert(geometryFactory);
} else {
if (bboxGeometryFactory.equals(geometryFactory)) {
newBoundingBox = boundingBox;
} else {
newBoundingBox = boundingBox.convert(geometryFactory);
}
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final BoundingBox areaBoundingBox = coordinateSystem.getAreaBoundingBox();
newBoundingBox = boundingBox.intersection(areaBoundingBox);
}
}
final double viewAspectRatio = viewport.getViewAspectRatio();
final double modelAspectRatio = newBoundingBox.getAspectRatio();
if (viewAspectRatio != modelAspectRatio) {
final double width = newBoundingBox.getWidth();
final double height = newBoundingBox.getHeight();
if (viewAspectRatio > modelAspectRatio) {
final double newWidth = height * viewAspectRatio;
final double deltaX = (newWidth - width) / 2;
newBoundingBox = newBoundingBox.expand(deltaX, 0);
} else if (viewAspectRatio < modelAspectRatio) {
final double newHeight = width / viewAspectRatio;
final double deltaY = (newHeight - height) / 2;
newBoundingBox = newBoundingBox.expand(0, deltaY);
}
}
return newBoundingBox;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class GeometryTestUtil method getCentre.
private static Point getCentre(final GeometryFactory geometryFactory) {
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
final BoundingBox areaBoundingBox = coordinateSystem.getAreaBoundingBox();
final Point centre = areaBoundingBox.getCentre();
return centre;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class MapPanel method zoomToWorld.
public void zoomToWorld() {
final GeometryFactory geometryFactory = getGeometryFactory();
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
final BoundingBox boundingBox = coordinateSystem.getAreaBoundingBox();
setBoundingBox(boundingBox);
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class Viewport2D method toDisplayValue.
public double toDisplayValue(final Quantity<Length> value) {
double convertedValue;
final Unit<Length> unit = value.getUnit();
if (unit.equals(CustomUnits.PIXEL)) {
convertedValue = QuantityType.doubleValue(value, CustomUnits.PIXEL);
} else {
convertedValue = QuantityType.doubleValue(value, Units.METRE);
final CoordinateSystem coordinateSystem = this.geometryFactory2d.getCoordinateSystem();
if (coordinateSystem instanceof GeographicCoordinateSystem) {
final GeographicCoordinateSystem geoCs = (GeographicCoordinateSystem) coordinateSystem;
final double radius = geoCs.getDatum().getEllipsoid().getSemiMajorAxis();
convertedValue = Math.toDegrees(convertedValue / radius);
}
final double modelUnitsPerViewUnit = getModelUnitsPerViewUnit();
convertedValue = convertedValue / modelUnitsPerViewUnit;
}
return convertedValue;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class Project method toMap.
@Override
public MapEx toMap() {
final MapEx map = super.toMap();
BoundingBox boundingBox = getViewBoundingBox();
if (!RectangleUtil.isEmpty(boundingBox)) {
BoundingBox defaultBoundingBox = null;
final GeometryFactory geometryFactory = getGeometryFactory();
if (geometryFactory != null) {
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
if (coordinateSystem != null) {
defaultBoundingBox = coordinateSystem.getAreaBoundingBox();
}
boundingBox = boundingBox.convert(geometryFactory);
}
addToMap(map, "viewBoundingBox", boundingBox, defaultBoundingBox);
final Map<String, BoundingBox> zoomBookmarks = getZoomBookmarks();
addToMap(map, "zoomBookmarks", zoomBookmarks);
}
final ProjectFrame projectFrame = ProjectFrame.get(this);
if (projectFrame != null) {
final Rectangle frameBounds = projectFrame.getBounds();
if (frameBounds != null) {
map.put("frameBounds", Arrays.asList(frameBounds.x, frameBounds.y, frameBounds.width, frameBounds.height));
}
}
return map;
}
Aggregations