use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class RectangularMapGrid method getMapTileName.
default String getMapTileName(final Geometry geometry) {
final CoordinateSystem coordinateSystem = getCoordinateSystem();
final Geometry projectedGeometry = geometry.convertGeometry(coordinateSystem.getGeometryFactory());
final Point centroid = projectedGeometry.getCentroid();
final Point coordinate = centroid.getPoint();
final String mapsheet = getMapTileName(coordinate.getX(), coordinate.getY());
return mapsheet;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class WikipediaBoundingBoxLayerWorker method handleBackground.
@Override
protected List<LayerRecord> handleBackground() {
BoundingBox boundingBox = this.boundingBox;
GeometryFactory geometryFactory = this.geometryFactory;
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projCs = (ProjectedCoordinateSystem) coordinateSystem;
geometryFactory = projCs.getGeographicCoordinateSystem().getGeometryFactory();
boundingBox = boundingBox.convert(geometryFactory);
}
final List<LayerRecord> results = (List) this.geoNamesService.getWikipediaArticles(boundingBox);
for (final Record record : results) {
final String title = record.getValue("title");
final String wikipediaUrl = record.getValue("wikipediaUrl");
final String thumbnailImage = record.getValue("thumbnailImg");
final Point point = record.getGeometry();
String text;
if (thumbnailImage != null) {
text = "<html><b>" + title + "</b><br /><img src=\"" + thumbnailImage + "\" /><br /></html>";
} else {
text = "<html><b>" + title + "</b><br /></html>";
}
// if (viewport instanceof ComponentViewport2D) {
// final ComponentViewport2D componentViewport =
// (ComponentViewport2D)viewport;
// componentViewport.addHotSpot(geometryFactory, point, text, "http://"
// + wikipediaUrl);
// }
}
return results;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class MeasureOverlay method setMeasureGeometry.
public void setMeasureGeometry(Geometry measureGeometry) {
if (measureGeometry == null) {
measureGeometry = EMPTY_GEOMETRY;
}
if (measureGeometry != this.measureGeometry) {
this.measureGeometry = measureGeometry;
if (measureGeometry == null) {
this.measureLabel = "";
} else {
Unit<Length> lengthUnit = Units.METRE;
final CoordinateSystem coordinateSystem = measureGeometry.getCoordinateSystem();
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
lengthUnit = coordinateSystem.getLengthUnit();
}
final double length = measureGeometry.getLength(lengthUnit);
@SuppressWarnings("unchecked") final Unit<Area> areaUnit = (Unit<Area>) lengthUnit.multiply(lengthUnit);
final double area = measureGeometry.getArea(areaUnit);
final String unitString = lengthUnit.toString();
synchronized (MEASURE_FORMAT) {
final StringBuilder label = new StringBuilder();
final String lengthString = MEASURE_FORMAT.format(Doubles.makePrecise(100, length));
label.append(lengthString);
label.append(unitString);
if (this.measureDataType == DataTypes.POLYGON && measureGeometry instanceof Polygon) {
final String areaString = MEASURE_FORMAT.format(Doubles.makePrecise(100, area));
label.append(" \n");
label.append(areaString);
label.append(unitString);
label.append('\u00B2');
}
this.measureLabel = label.toString();
}
}
setXorGeometry(null);
}
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class FixedScaleZoomMode method getBoundingBox.
/**
* Get the best bounding box matching the zoom mode policy
* <ul>
* <li>If the coordinate system for the bounding box wasn't specified it will
* be set to the coordinate system of the viewport.</li>
* <li>The bounding box will be converted to the coordinate system of the
* viewport.</li>
* </ul>
*
* @param viewport The viewport.
* @param boundingBox The bounding box.
* @return The bounding box.
*/
@Override
public BoundingBox getBoundingBox(final ComponentViewport2D viewport, final BoundingBox boundingBox) {
final double viewAspectRatio = viewport.getViewAspectRatio();
if (!Double.isNaN(viewAspectRatio) && !boundingBox.isEmpty()) {
final GeometryFactory geometryFactory = viewport.getGeometryFactory();
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
final BoundingBox areaBoundingBox = coordinateSystem.getAreaBoundingBox();
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);
}
}
double maxScale = viewport.getMaxScale();
maxScale = getScale(maxScale, false);
double scale = getScale(viewport, newBoundingBox);
if (!Double.isNaN(scale)) {
scale = getScale(scale, false);
if (scale > maxScale) {
scale = maxScale;
}
final double x = newBoundingBox.getCentreX();
final double y = newBoundingBox.getCentreY();
final BoundingBox boundingBox2 = viewport.getBoundingBox(x, y, scale);
// y2);
return boundingBox2;
}
return newBoundingBox;
}
return boundingBox;
}
use of com.revolsys.geometry.cs.CoordinateSystem in project com.revolsys.open by revolsys.
the class ComponentViewport2D method setGeometryFactoryPreEvent.
@Override
protected void setGeometryFactoryPreEvent(final GeometryFactory geometryFactory) {
final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
if (coordinateSystem != null) {
final BoundingBox areaBoundingBox = coordinateSystem.getAreaBoundingBox();
final double minX = areaBoundingBox.getMinX();
final double maxX = areaBoundingBox.getMaxX();
final double minY = areaBoundingBox.getMinY();
final double maxY = areaBoundingBox.getMaxY();
final double logMinX = Math.log10(Math.abs(minX));
final double logMinY = Math.log10(Math.abs(minY));
final double logMaxX = Math.log10(Math.abs(maxX));
final double logMaxY = Math.log10(Math.abs(maxY));
final double maxLog = Math.abs(Math.max(Math.max(logMinX, logMinY), Math.max(logMaxX, logMaxY)));
this.maxIntegerDigits = (int) Math.floor(maxLog + 1);
this.maxDecimalDigits = 15 - this.maxIntegerDigits;
final BoundingBox boundingBox = getBoundingBox();
if (Property.hasValue(boundingBox)) {
final BoundingBox newBoundingBox = boundingBox.convert(geometryFactory);
BoundingBox intersection = newBoundingBox.intersection(areaBoundingBox);
if (intersection.isEmpty()) {
intersection = areaBoundingBox;
}
setBoundingBox(intersection);
}
}
}
Aggregations