Skip to content

Commit 5b97462

Browse files
Kharude, Sachinsackh
authored andcommitted
Fix: added mode and viz_sampling params in space class method features_in_tile
Signed-off-by: Kharude, Sachin <sachin.kharude@here.com>
1 parent a8beab4 commit 5b97462

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ _build/
1111
.vscode
1212
.debug.env
1313
xyz.log
14-
.coverage.*
14+
.coverage.*
15+
xyzspaces.egg-info/

changes/features/pr.96.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
support the new `force2D` parameter for all the APIs used to read features.

tests/space/test_space_objects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from xyzspaces import XYZ
2929
from xyzspaces.datasets import (
30+
MICROSOFT_BUILDINGS_SPACE_ID,
3031
get_chicago_parks_data,
3132
get_countries_data,
3233
get_microsoft_buildings_space,
@@ -848,3 +849,30 @@ def test_force_2d(space_object):
848849
)
849850
features = list(res)
850851
assert len(features[0]["geometry"]["coordinates"][0][0]) == 2
852+
853+
854+
@pytest.mark.skipif(not XYZ_TOKEN, reason="No token found.")
855+
def test_get_space_tile_sampling(api):
856+
"""Get space tile and compare all available sampling rates."""
857+
space = Space.from_id(MICROSOFT_BUILDINGS_SPACE_ID)
858+
params = dict(tile_type="web", tile_id="11_585_783",)
859+
tile_raw = list(space.features_in_tile(mode="raw", **params))
860+
tile_viz_off = list(
861+
space.features_in_tile(mode="viz", viz_sampling="off", **params)
862+
)
863+
tile_viz_low = list(
864+
space.features_in_tile(mode="viz", viz_sampling="low", **params)
865+
)
866+
tile_viz_med = list(
867+
space.features_in_tile(mode="viz", viz_sampling="med", **params)
868+
)
869+
tile_viz_high = list(
870+
space.features_in_tile(mode="viz", viz_sampling="high", **params)
871+
)
872+
873+
len_raw = len(tile_raw)
874+
len_viz_off = len(tile_viz_off)
875+
len_viz_low = len(tile_viz_low)
876+
len_viz_med = len(tile_viz_med)
877+
len_viz_high = len(tile_viz_high)
878+
assert len_raw > len_viz_off > len_viz_low > len_viz_med >= len_viz_high

xyzspaces/spaces.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,8 @@ def features_in_tile(
726726
limit: Optional[int] = None,
727727
geo_dataframe: Optional[bool] = None,
728728
force_2d: Optional[bool] = None,
729+
mode: Optional[str] = None,
730+
viz_sampling: Optional[str] = None,
729731
) -> Generator[Feature, None, None]:
730732
"""
731733
Get features in tile.
@@ -772,6 +774,11 @@ def features_in_tile(
772774
:param force_2d: If set to True the features in the response
773775
will have only X and Y components, by default all
774776
x,y,z coordinates will be returned.
777+
:param mode: A string to indicate how to optimize the resultset and
778+
geometries for display. Allowed values are ``raw`` and ``viz``.
779+
:param viz_sampling: A string to indicate the sampling strength in
780+
case of ``mode=viz``. Allowed values are: ``low``, ``med``,
781+
``high``, and ``off``, default: ``med``.
775782
:raises ValueError: If `tile_type` is invalid, valid tile_types are
776783
`quadkeys`, `web`, `tms` and `here`.
777784
"""
@@ -790,6 +797,8 @@ def features_in_tile(
790797
margin=margin,
791798
limit=limit,
792799
force_2d=force_2d,
800+
mode=mode,
801+
viz_sampling=viz_sampling,
793802
)
794803
if geo_dataframe is not None:
795804
yield gpd.GeoDataFrame.from_features(

0 commit comments

Comments
 (0)