Elevation data is easy to import -> now mandatory

pull/78/head
Konstantin Gründger 2019-03-17 14:50:54 +01:00
rodzic a67aef730e
commit c90efb910c
3 zmienionych plików z 12 dodań i 9 usunięć

Wyświetl plik

@ -57,18 +57,19 @@ For best performance you should use [TimescaleDB](https://www.timescale.com), wh
``` ```
8. Optional: Import world elevation data (needed for AGL calculation) 8. Optional: Import world elevation data (needed for AGL calculation)
For Europe we can get the DEM as GeoTIFF files from the 8.1 Sources: There are many sources for DEM data. It is important that the spatial reference system (SRID) is the same as the database.
[European Environment Agency](https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1). 8.1.1 The [GMTED2010 Viewer](https://topotools.cr.usgs.gov/gmted_viewer/viewer.htm) provides data for the world. Just download the data you need.
Because the spatial reference system (SRID) of these files is 3035 and we want 4326 we have to convert them: 8.1.2 For Europe we can get the DEM as GeoTIFF files from the [European Environment Agency](https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1).
Because the SRID of these files is 3035 and we want 4326 we have to convert them:
``` ```
gdalwarp -s_srs "EPSG:3035" -t_srs "EPSG:4326" source.tif target.tif gdalwarp -s_srs "EPSG:3035" -t_srs "EPSG:4326" source.tif target.tif
``` ```
Then we can import the GeoTIFF into the elevation table: 8.2 Then we can import the GeoTIFF into the elevation table:
``` ```
raster2pgsql -c -C -I -M -t 100x100 elevation_data.tif public.elevation | psql -d ogn raster2pgsql -s 4326 -c -C -I -M -t 100x100 elevation_data.tif public.elevation | psql -d ogn
``` ```
There is also a [Vagrant](https://www.vagrantup.com/) environment for the development of ogn-python. There is also a [Vagrant](https://www.vagrantup.com/) environment for the development of ogn-python.

Wyświetl plik

@ -21,6 +21,7 @@ def update_entries(session, start, end, logger=None):
# considered time interval should not exceed a complete day # considered time interval should not exceed a complete day
if end - start > timedelta(days=1): if end - start > timedelta(days=1):
logger.warn("timeinterval start='{}' and end='{}' is too big.".format(start, end)) logger.warn("timeinterval start='{}' and end='{}' is too big.".format(start, end))
return
# check if we have any airport # check if we have any airport
airports_query = session.query(Airport).limit(1) airports_query = session.query(Airport).limit(1)
@ -133,6 +134,6 @@ def update_entries(session, start, end, logger=None):
result = session.execute(ins) result = session.execute(ins)
session.commit() session.commit()
insert_counter = result.rowcount insert_counter = result.rowcount
logger.warn("Inserted {} TakeoffLandings".format(insert_counter)) logger.info("Inserted {} TakeoffLandings".format(insert_counter))
return "Inserted {} TakeoffLandings".format(insert_counter) return "Inserted {} TakeoffLandings".format(insert_counter)

Wyświetl plik

@ -130,10 +130,11 @@ def update_aircraft_beacons(postfix):
quality = CASE WHEN ab.location IS NOT NULL AND r.location IS NOT NULL AND ST_DistanceSphere(ab.location, r.location) > 0 AND ab.signal_quality IS NOT NULL quality = CASE WHEN ab.location IS NOT NULL AND r.location IS NOT NULL AND ST_DistanceSphere(ab.location, r.location) > 0 AND ab.signal_quality IS NOT NULL
THEN CAST(signal_quality + 20*log(ST_DistanceSphere(ab.location, r.location)/10000) AS REAL) THEN CAST(signal_quality + 20*log(ST_DistanceSphere(ab.location, r.location)/10000) AS REAL)
ELSE NULL ELSE NULL
END END,
agl = CAST(ab.altitude - ST_Value(e.rast, ab.location) AS REAL)
FROM devices AS d, receivers AS r FROM devices AS d, receivers AS r, elevation AS e
WHERE ab.device_id IS NULL and ab.receiver_id IS NULL AND ab.address = d.address AND ab.receiver_name = r.name; WHERE ab.device_id IS NULL and ab.receiver_id IS NULL AND ab.address = d.address AND ab.receiver_name = r.name AND ST_Intersects(e.rast, ab.location);
""".format(postfix)) """.format(postfix))
db.session.commit() db.session.commit()