Class VectorTilesRequestScale
VectorTilesFeatureSource.determineZoomLevel(org.geotools.api.data.Query), superseding the
GEOMETRY_GENERALIZATION and GEOMETRY_DISTANCE hints provided by the renderer.
Rationale being that StreamingRenderer computes the generalization distance in a way that's inconsistent
with the map scale, results in different values for different tiles on the same map, and often, especially when doing
reprojection, the generalization distances result in querying much higher tile levels than it should, leading to
traversing too many tiles from the PMTiles or other vector tiles datastore. It also always performs the query in the
layer's native CRS.
Usage:
try {
VectorTilesRequestScale.set(scaleDenominator);
// perform feature source queries...
} finally {
VectorTilesRequestScale.clear();
}
When set, the scale denominator is converted to a resolution using the OGC standard pixel size of 0.28mm (0.00028
meters): resolution = scaleDenominator * 0.00028
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clears the scale denominator for the current thread.static OptionalDoubleget()Returns the scale denominator set for the current thread, if any.static voidset(double requestScale) Sets the scale denominator for the current thread's vector tile requests.
-
Method Details
-
set
public static void set(double requestScale) Sets the scale denominator for the current thread's vector tile requests.The scale denominator represents the ratio between a distance on the map and the corresponding distance on the ground. For example, a scale denominator of 50000 means 1 unit on the map equals 50000 units on the ground.
- Parameters:
requestScale- the scale denominator value (e.g., 50000 for 1:50,000 scale)
-
get
Returns the scale denominator set for the current thread, if any.- Returns:
- an
OptionalDoublecontaining the scale denominator if set, or an empty optional if not set
-
clear
public static void clear()Clears the scale denominator for the current thread.This method should be called in a
finallyblock to ensure proper cleanup and prevent memory leaks in thread pool environments.
-