Skip to content

Commit

Permalink
add table argument to waterboard api
Browse files Browse the repository at this point in the history
  • Loading branch information
OnnoEbbens committed Dec 13, 2023
1 parent 49a8e1d commit b0f6e9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nlmod/read/waterboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def get_configuration():
"level_areas": {
"url": "https://kaarten.hhnk.nl/arcgis/rest/services/ws/ws_peilgebieden_vigerend/MapServer",
"layer": 4,
# "table": 6,
"summer_stage": [
"ZOMER",
"STREEFPEIL_ZOMER",
Expand Down Expand Up @@ -524,6 +525,7 @@ def get_data(wb, data_kind, extent=None, max_record_count=None, config=None, **k
config = get_configuration()
# some default values
layer = 0
table = None
index = "CODE"
server_kind = "arcrest"
f = "geojson"
Expand All @@ -536,6 +538,8 @@ def get_data(wb, data_kind, extent=None, max_record_count=None, config=None, **k
url = conf["url"]
if "layer" in conf:
layer = conf["layer"]
if "table" in conf:
table = conf["table"]
if "index" in conf:
index = conf["index"]
if "server_kind" in conf:
Expand All @@ -551,8 +555,10 @@ def get_data(wb, data_kind, extent=None, max_record_count=None, config=None, **k
extent,
f=f,
max_record_count=max_record_count,
table=table,
**kwargs,
)

elif server_kind == "wfs":
gdf = webservices.wfs(
url, layer, extent, max_record_count=max_record_count, **kwargs
Expand Down
9 changes: 9 additions & 0 deletions nlmod/read/webservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def arcrest(
f="geojson",
max_record_count=None,
timeout=120,
table=None,
**kwargs,
):
"""Download data from an arcgis rest FeatureServer.
Expand All @@ -47,6 +48,8 @@ def arcrest(
maximum number of records for request.
timeout : int, optional
timeout time of request. Default is 120.
table : int, optional
can be used to link a layer to a table, not yet implemented.
Note
----
Expand Down Expand Up @@ -146,6 +149,12 @@ def arcrest(
gdf = gpd.GeoDataFrame()
else:
gdf = gpd.GeoDataFrame.from_features(features, crs=sr)
if table is not None:
raise NotImplementedError("work in progress")
url_query = f"{url}/{table}/query"
pgbids = ",".join([str(v) for v in gdf["OBJECTID"].values])
params["where"] = f"PEILGEBIEDVIGERENDID IN ({pgbids})"
data = _get_data(url_query, params, timeout=timeout)
return gdf


Expand Down

0 comments on commit b0f6e9c

Please sign in to comment.