Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Show Airports on pure satellite maps (using the embedded airport database) #345

Open
noneofnine opened this issue Nov 19, 2024 · 1 comment

Comments

@noneofnine
Copy link

noneofnine commented Nov 19, 2024

tar1090 has a nice database with airports ICAO and IATA - just hidden in the search function.

I wanted to see the airports shown as labels on the map.

This helps a lot when using pure satellite maps - but even when using the OSM map with all the info the airports icons are just to small and the ICAO and IATA codes are not visible.

My crude way to implement was

The database used in the search function is located here /usr/local/share/tar1090/git-db/airport-coords.json

This needs to be converted to geojson.

Create a bash script

/usr/local/share/tar1090/convert_airports_combined.sh

#!/bin/bash

jq '{
  type: "FeatureCollection",
  features: (
    to_entries
    | group_by(.value | tostring)
    | map({
        type: "Feature",
        properties: {
          name: (map(.key) | join("/"))
        },
        geometry: {
          type: "Point",
          coordinates: [.[0].value[1], .[0].value[0]]
        }
      })
  )
}' /usr/local/share/tar1090/git-db/airport-coords.json > /usr/local/share/tar1090/html/geojson/airports.geojson

This will combine airports which have two database entries from ICAO and IATA like Düsseldorf with EDDL and DUS.
The result is now one entry with "EDDL/DUS". Without this, both labels will be shown unreadable mixed one onto the other.

The script creates the file /usr/local/share/tar1090/html/geojson/airports.geojson

We need to add this as a new layer and add the option to display it

Edit /usr/local/share/tar1090/html/layers_*.js

Added this code just above the line

...
return layers_group;

// Show all Airports on the map from converted database
world.push(createGeoJsonLayer('World Airports', 'airports', 'geojson/airports.geojson', 'rgba(52, 50, 168, 0.3)', 'rgba(52, 50, 168, 1)', true, 8, 5));

search for let createGeoJsonLayer

Change the geojson layer creation code to check in the new parameter of minZoom

replace
let createGeoJsonLayer = function (title, name, url, fill, stroke, showLabel = true) {
with
let createGeoJsonLayer = function (title, name, url, fill, stroke, showLabel = true, Zoom1 = 0, Zoom2 = 20) {

Change the code to check for MinZoom Level and existence of the slash between ICAO and IATA code and display the label depending on the zoom level:

replace
text: showLabel ? feature.get("name") : "",
with
text: showLabel && OLMap.getView().getZoom() >= Zoom1 ? feature.get("name") : showLabel && OLMap.getView().getZoom() >= Zoom2 && feature.get("name").includes("/") ? feature.get("name").split("/")[1] : "",

Yes - i should have used a variables instead for calling functions more than once and spread this expression in if then else statements.

Zoom1 and Zoom2 are a new parameters - so this does not harm the other geojson layers already in use.

Reload the browser with ctrl-F5 to reload, click on the layers button, select a satellite map,

Enable the new "World Airports" checkmark

LayerButton

and you can see this

AirportLabels

I am not sure where/how to put this into the tar1090 project - maybe add this in the update script of the database repo tar1090-db

To not overflow the map with the labels:

  • zoom level below 5 labels are off
  • zoom level above 5 IATA code is shown
  • zoom level above 8 ICAO / IATA code is shown
@noneofnine
Copy link
Author

noneofnine commented Nov 22, 2024

Added code to dynamically show nothing, IATA only or both ICAO/IATO codes depending on zoom level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant