QueryGeometry

new SuperMap3D.QueryGeometry()

A data-class that represents a screenspace query from `Map#queryRenderedFeatures`. All the internal geometries and data are intented to be immutable and read-only. Its lifetime is only for the duration of the query and fixed state of the map while the query is being processed.

Methods

staticSuperMap3D.QueryGeometry.createFromScreenPoints(geometry, transform, The coordinates passed in to the original query_geometry method of mapbox are screen coordinates. But it doesn't work for us, we support passing in geographical coordinates. isGeo means that the incoming geometry is the geographical coordinates)QueryGeometry

Factory method to help contruct an instance while accounting for current map state.
Name Type Description
geometry
transform Transform The current map transform.
The coordinates passed in to the original query_geometry method of mapbox are screen coordinates. But it doesn't work for us, we support passing in geographical coordinates. isGeo means that the incoming geometry is the geographical coordinates isGeo
Returns:
An instance of the QueryGeometry class.

_bufferedScreenMercator()

These methods add caching on top of the terrain raycasting provided by `Transform#pointCoordinate3d`. Tiles come with different values of padding, however its very likely that multiple tiles share the same value of padding based on the style. In that case we want to reuse the result from a previously computed terrain raycast.

bufferedCameraGeometry(buffer)Array.<Point>

When the map is pitched, some of the 3D features that intersect a query will not intersect the query at the surface of the earth. Instead the feature may be closer and only intersect the query because it extrudes into the air. This returns a geometry that is a convex polygon that encompasses the query frustum and the point underneath the camera. Similar to `bufferedScreenGeometry`, buffering is added to account for variation in paint properties. Case 1: point underneath camera is exactly behind query volume +----------+ | | | | | | + + X X X X X X X X XX. Case 2: point is behind and to the right +----------+ | X | X | XX + X XXX XX XXXX X XXX XX XX X XXX. Case 3: point is behind and to the left +----------+ X | X | XX | X + X XXXX XX XXX X XXXX X XXXX XXX.
Name Type Description
buffer number The tile padding in screenspace pixels.
Returns:
The buffered query geometry.

bufferedScreenGeometry(buffer)Array.<Point>

Due to data-driven styling features do not uniform size(eg `circle-radius`) and can be offset differntly from their original location(for example with `*-translate`). This means we have to expand our query region for each tile to account for variation in these properties. Each tile calculates a tile level max padding value (in screenspace pixels) when its parsed, this function lets us calculate a buffered version of the screenspace query geometry for each tile.
Name Type Description
buffer number The tile padding in screenspace pixels.
Returns:
The buffered query geometry.

containsTile(tile, transform, use3D, cameraWrap)TilespaceQueryGeometry

Checks if a tile is contained within this query geometry.
Name Type Default Description
tile Tile The tile to check.
transform Transform The current map transform.
use3D boolean A boolean indicating whether to query 3D features.
cameraWrap number 0 A wrap value for offsetting the camera position.
Returns:
Returns `undefined` if the tile does not intersect.

isPointQuery()boolean

Returns true if the initial query by the user was a single point.
Returns:
Returns `true` if the initial query geometry was a single point.