/** * Create a projection transformation from provided projection to Web Mercator * * @param projection projection from * @return transform */ protected ProjectionTransform getProjectionToWebMercatorTransform(Projection projection) { return projection.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); }
/** * Get the web mercator point * * @param transform * @param point * @return web mercator point */ private Point getPoint(ProjectionTransform transform, Point point) { return transform.transform(point); }
if (projection != null && projection.getUnit() != Units.METRES) { ProjectionTransform toWebMercator = projection .getTransformation(WEB_MERCATOR_PROJECTION); points = toWebMercator.transform(points); if (projection != null && projection.getUnit() != Units.METRES) { ProjectionTransform fromWebMercator = WEB_MERCATOR_PROJECTION .getTransformation(projection); simplifiedPoints = fromWebMercator.transform(simplifiedPoints);
/** * 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; }
/** * Adjust the tile matrix set and web mercator bounds for Google tile format */ private void adjustGoogleBounds() { // Set the tile matrix set bounding box to be the world BoundingBox standardWgs84Box = new BoundingBox(-ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH, ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE, ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH, ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE); ProjectionTransform wgs84ToWebMercatorTransform = ProjectionFactory.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); tileGridBoundingBox = standardWgs84Box.transform(wgs84ToWebMercatorTransform); }
/** * 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 tile grid for the location specified as WGS84 * * @param point * point * @param zoom * zoom level * @return tile grid * @since 1.1.0 */ public static TileGrid getTileGridFromWGS84(Point point, int zoom) { Projection projection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); return getTileGrid(point, zoom, projection); }
/** * Adjust the tile matrix set and bounds * * @param boundingBox bounding box * @param zoom zoom */ private void adjustBounds(BoundingBox boundingBox, int zoom) { // Google Tile Format if (googleTiles) { adjustGoogleBounds(); } else if (projection.getUnit() instanceof DegreeUnit) { adjustGeoPackageBoundsWGS84(boundingBox, zoom); } else { adjustGeoPackageBounds(boundingBox, zoom); } }
if (projection != null && projection.getUnit() != Units.METRES) { ProjectionTransform toWebMercator = projection .getTransformation(WEB_MERCATOR_PROJECTION); points = toWebMercator.transform(points); if (projection != null && projection.getUnit() != Units.METRES) { ProjectionTransform fromWebMercator = WEB_MERCATOR_PROJECTION .getTransformation(projection); simplifiedPoints = fromWebMercator.transform(simplifiedPoints);
/** * Adjust the tile matrix set and web mercator bounds for Google tile format */ private void adjustGoogleBounds() { // Set the tile matrix set bounding box to be the world BoundingBox standardWgs84Box = new BoundingBox( -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH, ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE, ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH, ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE); ProjectionTransform wgs84ToWebMercatorTransform = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); tileGridBoundingBox = standardWgs84Box .transform(wgs84ToWebMercatorTransform); }
/** * 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; }
/** * Create a projection transformation from WGS84 to Web Mercator * * @return transform */ protected ProjectionTransform getWgs84ToWebMercatorTransform() { return WGS_84_PROJECTION.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); }
/** * Constructor with specified tile size * * @param tileDao tile dao * @param width width * @param height height */ public GeoPackageTileRetriever(TileDao tileDao, Integer width, Integer height) { tileDao.adjustTileMatrixLengths(); Projection webMercator = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR); tileCreator = new TileCreator(tileDao, width, height, webMercator); }
/** * 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; }
/** * Adjust the tile matrix set and bounds * * @param boundingBox * bounding box * @param zoom * zoom */ private void adjustBounds(BoundingBox boundingBox, int zoom) { // Google Tile Format if (googleTiles) { adjustGoogleBounds(); } else if (projection.getUnit() instanceof DegreeUnit) { adjustGeoPackageBoundsWGS84(boundingBox, zoom); } else { adjustGeoPackageBounds(boundingBox, zoom); } }
/** * Create a projection transformation from the feature dao projection to Web * Mercator * * @return transform */ protected ProjectionTransform getWebMercatorTransform() { return this.featureDao.getProjection().getTransformation( ProjectionConstants.EPSG_WEB_MERCATOR); }
/** * Get the projection for the Spatial Reference System * * @return projection * @since 3.0.0 */ public Projection getProjection() { String authority = getOrganization(); long code = getOrganizationCoordsysId(); String definition = getDefinition_12_063(); if (definition == null) { definition = getDefinition(); } Projection projection = ProjectionFactory.getProjection(authority, code, null, definition); return projection; }
/** * Get the projection transform from the provided projection to the Spatial * Reference System projection * * @param projection * from projection * @return projection transform * @since 3.0.0 */ public ProjectionTransform getTransformation(Projection projection) { Projection projectionTo = getProjection(); return projection.getTransformation(projectionTo); }
/** * Get the bounding box in the feature projection from the bounding box in * the provided projection * * @param boundingBox bounding box * @param projection projection * @return feature projected bounding box */ private BoundingBox getFeatureBoundingBox(BoundingBox boundingBox, Projection projection) { ProjectionTransform projectionTransform = projection .getTransformation(featureDao.getProjection()); BoundingBox featureBoundingBox = boundingBox .transform(projectionTransform); return featureBoundingBox; }
/** * Query for the feature index bounds and return 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 projectionTransform = getProjection() .getTransformation(projection); boundingBox = boundingBox.transform(projectionTransform); } return boundingBox; }