Skip to content

Commit

Permalink
Add OSM-based synthetic geolocation field for micro-regions
Browse files Browse the repository at this point in the history
Field:   district_postcode_city_sensorid
Format:  District, Postcode, City (#SensorID)
Example: Regierungsbezirk Darmstadt, 60385, Frankfurt (#76777)
  • Loading branch information
amotl committed Dec 17, 2022
1 parent 4fae26d commit 9389977
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ in progress
- Fix "Luftdaten-Viewer Grafana" documentation section about
exporting station metadata from PostGIS to JSON file.
Thanks, @ohobby.
- Add OSM-based synthetic geolocation field for micro-regions.
Thanks, @ohobby.


2022-12-05 0.21.1
Expand Down
3 changes: 3 additions & 0 deletions luftdatenpumpe/target/rdbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def create_views(self):
-- Synthesized fields.
concat('(#', CAST({prefix}_stations.station_id AS text), ')') AS station_id_suffix,
concat('(#', CAST({prefix}_sensors.sensor_id AS text), ')') AS sensor_id_suffix,
concat('(', {prefix}_osmdata.osm_country_code, ')') AS country_code_suffix,
-- OSM fields.
Expand All @@ -349,6 +350,8 @@ def create_views(self):
concat(concat_ws(', ', osm_state, osm_country), ' ', country_code_suffix) AS state_and_country,
concat(concat_ws(', ', osm_city, osm_state, osm_country), ' ', country_code_suffix)
AS city_and_state_and_country,
concat(concat_ws(', ', osm_state_district, osm_postcode, osm_city), ' ', sensor_id_suffix)
AS district_postcode_city_sensorid,
{self.render_fields(conditional_fields_stage2)}
ABS(DATE_PART('day', sensor_last_date - now())) <= 7 AS is_active
Expand Down

0 comments on commit 9389977

Please sign in to comment.