Class PMTileGrid
java.lang.Object
org.jorigin.geotools.map.PMTileGrid
Helper for the Pseudo-Mercator ("PM") quadtree tile grid in
EPSG:3857 — the de-facto standard for web tile services
(OSM, Google, IGN Geoplateforme WMTS "PM" / WMS-R).
Used by CachedRendererJFX to split WMS-R
GetMap requests into 256×256 grid-aligned tiles, so the server's
tile cache is hit reliably and the identical URLs can be shared across
pan/zoom operations (URL-keyed client cache).
Grid parameters
- Origin (top-left):
(-20037508.3427892, +20037508.3427892) - Tile size: 256 px
- Zoom 0 resolution: 156543.0339280410 m/px
- Each zoom level halves the resolution (doubles the tile count per axis)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA grid-aligned PM tile descriptor. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublePixel resolution at zoom level 0 (meters/pixel).static final intClamp for the selected zoom level (most servers support up to ~22).static final intSafety cap on the number of tiles returned per request.static final doubleOrigin X (minimum easting) of the PM grid, in EPSG:3857.static final doubleOrigin Y (maximum northing) of the PM grid, in EPSG:3857.static final intTile size in pixels. -
Method Summary
Modifier and TypeMethodDescriptionstatic intlevelFor(double worldPerPixel) Picks the PM zoom level whose pixel resolution is closest to the view's pixel-to-world ratio, so tiles are fetched at the right detail level without over- or under-sampling.static doubleresolutionAt(int level) get the pixel resolution (m/px) at the given zoom level.static List<PMTileGrid.PMTile> tilesForBbox(org.geotools.geometry.jts.ReferencedEnvelope bbox, int level) Enumerates all PM tiles atlevelthat overlapbbox.static doubletileSpanAt(int level) Get the world-unit span covered by a single tile at the given zoom level.
-
Field Details
-
ORIGIN_X
public static final double ORIGIN_XOrigin X (minimum easting) of the PM grid, in EPSG:3857.- See Also:
-
ORIGIN_Y
public static final double ORIGIN_YOrigin Y (maximum northing) of the PM grid, in EPSG:3857.- See Also:
-
BASE_RES_MPP
public static final double BASE_RES_MPPPixel resolution at zoom level 0 (meters/pixel).- See Also:
-
TILE_SIZE_PX
public static final int TILE_SIZE_PXTile size in pixels.- See Also:
-
MAX_LEVEL
public static final int MAX_LEVELClamp for the selected zoom level (most servers support up to ~22).- See Also:
-
MAX_TILES_PER_REQUEST
public static final int MAX_TILES_PER_REQUESTSafety cap on the number of tiles returned per request.- See Also:
-
-
Method Details
-
levelFor
public static int levelFor(double worldPerPixel) Picks the PM zoom level whose pixel resolution is closest to the view's pixel-to-world ratio, so tiles are fetched at the right detail level without over- or under-sampling.- Parameters:
worldPerPixel- the view's resolution in world-units/pixel (typicallyenvelope.getWidth() / viewWidth)- Returns:
- zoom level clamped to
[0, MAX_LEVEL]
-
resolutionAt
public static double resolutionAt(int level) get the pixel resolution (m/px) at the given zoom level.- Parameters:
level- the zoom level- Returns:
- the pixel resolution (m/px) at the given zoom level
-
tileSpanAt
public static double tileSpanAt(int level) Get the world-unit span covered by a single tile at the given zoom level.- Parameters:
level- the zoom level- Returns:
- the world-unit span covered by a single tile at the given zoom level
-
tilesForBbox
public static List<PMTileGrid.PMTile> tilesForBbox(org.geotools.geometry.jts.ReferencedEnvelope bbox, int level) Enumerates all PM tiles atlevelthat overlapbbox. The returned tiles are grid-aligned (their extents are snapped to the PM grid, independent of the exact query bbox), which is what makes their URLs stable across pan/zoom and hittable in the WMS-R tile cache.Stops early if the request would produce more than
MAX_TILES_PER_REQUESTtiles (defensive cap against wrong zoom levels or absurdly large bounding boxes) and returns an empty list.- Parameters:
bbox- the query envelope; must carry an EPSG:3857 CRS (caller's responsibility to check)level- the zoom level (seelevelFor(double))- Returns:
- the overlapping tiles, empty if none or if capped out
-