forked from geopython/pygeoapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow configurable expand to SensorThings provider (geopython#1879)
* Allow configurable expand to SensorThings provider * Update license year
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Authors: Benjamin Webb <[email protected]> | ||
# Authors: Tom Kralidis <[email protected]> | ||
# | ||
# Copyright (c) 2023 Benjamin Webb | ||
# Copyright (c) 2024 Benjamin Webb | ||
# Copyright (c) 2022 Tom Kralidis | ||
# | ||
# Permission is hereby granted, free of charge, to any person | ||
|
@@ -518,6 +518,10 @@ def _generate_mappings(self, provider_def: dict): | |
LOGGER.debug('Using default @iot.id for id field') | ||
self.id_field = '@iot.id' | ||
|
||
# Custom expand | ||
if provider_def.get('expand'): | ||
EXPAND[self.entity] = provider_def['expand'] | ||
|
||
# Create intra-links | ||
self.intralink = provider_def.get('intralink', False) | ||
if self.intralink and provider_def.get('rel_link'): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# | ||
# Authors: Benjamin Webb <[email protected]> | ||
# | ||
# Copyright (c) 2022 Benjamin Webb | ||
# Copyright (c) 2024 Benjamin Webb | ||
# | ||
# Permission is hereby granted, free of charge, to any person | ||
# obtaining a copy of this software and associated documentation | ||
|
@@ -138,3 +138,27 @@ def test_get(config): | |
assert result['id'] == '9' | ||
assert result['properties']['name'] == 'Depth Below Surface' | ||
assert isinstance(result['properties']['Thing'], dict) | ||
|
||
|
||
def test_custom_expand(config): | ||
p = SensorThingsProvider(config) | ||
fields = p.get_fields() | ||
assert 'Observations' in fields | ||
assert 'ObservedProperty' in fields | ||
assert 'Sensor' in fields | ||
|
||
config['expand'] = 'Thing/Locations' | ||
p = SensorThingsProvider(config) | ||
fields = p.get_fields() | ||
assert len(fields) == 12 | ||
assert 'Observations' not in fields | ||
assert 'ObservedProperty' not in fields | ||
assert 'Sensor' not in fields | ||
|
||
config['expand'] = 'Thing/Locations,Observations' | ||
p = SensorThingsProvider(config) | ||
fields = p.get_fields() | ||
assert len(fields) == 14 | ||
assert 'Observations' in fields | ||
assert 'ObservedProperty' not in fields | ||
assert 'Sensor' not in fields |