/** * Get a bounding box in the provided projection * * @param projection * desired projection * * @return bounding box * @since 3.1.0 */ public BoundingBox getBoundingBox(Projection projection) { BoundingBox boundingBox = getBoundingBox(); if (boundingBox != null && projection != null) { ProjectionTransform transform = getProjection().getTransformation( projection); if (!transform.isSameProjection()) { boundingBox = boundingBox.transform(transform); } } return boundingBox; }
/** * Get the web mercator point * * @param transform * @param point * @return web mercator point */ private Point getPoint(ProjectionTransform transform, Point point) { return transform.transform(point); }
.getTransformation(toEpsg); ProjectionTransform transformFrom = srs.getTransformation(transformTo .getToProjection()); .transform(geometry); GeoPackageGeometryData projectedGeometryData = new GeoPackageGeometryData( -1); .transform(projectedGeometry);
/** * Transform the bounding box using the provided projection transform * * @param transform * projection transform * @return transformed bounding box * @since 3.0.0 */ public BoundingBox transform(ProjectionTransform transform) { GeometryEnvelope envelope = buildEnvelope(); GeometryEnvelope transformedEnvelope = transform.transform(envelope); BoundingBox transformed = new BoundingBox(transformedEnvelope); return transformed; }
/** * Get a bounding box in the provided projection * * @param projection * desired projection * * @return bounding box * @since 3.1.0 */ public BoundingBox getBoundingBox(Projection projection) { BoundingBox boundingBox = getBoundingBox(); if (projection != null) { ProjectionTransform transform = getProjection().getTransformation( projection); if (!transform.isSameProjection()) { boundingBox = boundingBox.transform(transform); } } return boundingBox; }
ProjectionTransform transform = projection.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); requestBoundingBox = boundingBox; if (!transform.isSameProjection()) { requestBoundingBox = requestBoundingBox.transform(transform);
.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); requestBoundingBox = boundingBox; if (!transform.isSameProjection()) { requestBoundingBox = requestBoundingBox .transform(transform);
ProjectionTransform transform, Graphics2D graphics, Point point) { Point projectedPoint = transform.transform(point);
ProjectionTransform transformProjectionToContents = projection.getTransformation(contents.getProjection()); BoundingBox contentsBoundingBox = boundingBox; if (!transformProjectionToContents.isSameProjection()) { contentsBoundingBox = contentsBoundingBox.transform(transformProjectionToContents); boolean sameProjection = transformProjectionToTileMatrixSet.isSameProjection(); BoundingBox updateBoundingBox = boundingBox; if (!sameProjection) {
double latitude = requestBoundingBox.getMaxLatitude() - (y * requestedHeightUnitsPerPixel); ProjCoordinate fromCoord = new ProjCoordinate(longitude, latitude); ProjCoordinate toCoord = transformRequestToTiles.transform(fromCoord); double projectedLongitude = toCoord.x; double projectedLatitude = toCoord.y;
.getTransformation(contents.getProjection()); BoundingBox contentsBoundingBox = boundingBox; if (!transformProjectionToContents.isSameProjection()) { contentsBoundingBox = contentsBoundingBox .transform(transformProjectionToContents); .getTransformation(tileMatrixProjection); boolean sameProjection = transformProjectionToTileMatrixSet .isSameProjection(); BoundingBox updateBoundingBox = boundingBox; if (!sameProjection) {
latitude); ProjCoordinate toCoord = transformRequestToTiles .transform(fromCoord); double projectedLongitude = toCoord.x; double projectedLatitude = toCoord.y;
.getTransformation(contentsSrs.getProjection()); BoundingBox contentsBoundingBox = bbox; if (!transform.isSameProjection()) { contentsBoundingBox = bbox.transform(transform);
/** * Convert the bounding box coordinates to a new web mercator bounding box * * @param boundingBox * bounding box * @return bounding box */ public static BoundingBox toWebMercator(BoundingBox boundingBox) { double minLatitude = Math.max(boundingBox.getMinLatitude(), ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE); double maxLatitude = Math.min(boundingBox.getMaxLatitude(), ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE); Point lowerLeftPoint = new Point(false, false, boundingBox.getMinLongitude(), minLatitude); Point upperRightPoint = new Point(false, false, boundingBox.getMaxLongitude(), maxLatitude); ProjectionTransform toWebMercator = ProjectionFactory.getProjection( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); lowerLeftPoint = toWebMercator.transform(lowerLeftPoint); upperRightPoint = toWebMercator.transform(upperRightPoint); BoundingBox mercatorBox = new BoundingBox(lowerLeftPoint.getX(), lowerLeftPoint.getY(), upperRightPoint.getX(), upperRightPoint.getY()); return mercatorBox; }
.getTransformation(contentsSrs.getProjection()); BoundingBox contentsBoundingBox = bbox; if (!transform.isSameProjection()) { contentsBoundingBox = bbox.transform(transform);
latitude); ProjCoordinate toCoord = transformRequestToCoverage .transform(fromCoord); double projectedLongitude = toCoord.x; double projectedLatitude = toCoord.y;
/** * Get the tile grid for the location specified as the projection * * @param point * point * @param zoom * zoom level * @param projection * projection * @return tile grid * @since 1.1.0 */ public static TileGrid getTileGrid(Point point, int zoom, Projection projection) { ProjectionTransform toWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); Point webMercatorPoint = toWebMercator.transform(point); BoundingBox boundingBox = new BoundingBox(webMercatorPoint.getX(), webMercatorPoint.getY(), webMercatorPoint.getX(), webMercatorPoint.getY()); return getTileGrid(boundingBox, zoom); }
/** * Get the path of the line string * * @param simplifyTolerance * simplify tolerance in meters * @param boundingBox * @param transform * @param lineString */ private Path2D getPath(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, LineString lineString) { Path2D path = null; // Try to simplify the number of points in the LineString List<Point> lineStringPoints = simplifyPoints(simplifyTolerance, lineString.getPoints()); for (Point point : lineStringPoints) { Point projectedPoint = transform.transform(point); float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox, projectedPoint.getX()); float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox, projectedPoint.getY()); if (path == null) { path = new Path2D.Double(); path.moveTo(x, y); } else { path.lineTo(x, y); } } return path; }