5

Mathematica's AirportData[] is hopelessly outdated.

I'm trying to manually add entries for some common ICAO airport codes, such as OTHH (Doha) or FAOR (Johannesburg)

store = EntityStore["Airport" -> 
   <|"Entities" -> 
     <|"JNB Airport" -> <|"ICAO" -> "FAOR", 
        "coordinates" -> 
         CityData[{"Johannesburg", "Gauteng", "SouthAfrica"}, 
          "Coordinates"] |>,
      "DOH Airport" -> <|"ICAO" -> "OTHH", 
        "coordinates" -> 
         CityData[{{"Doha", "Doha", "Qatar"}}, "Coordinates"] |>
      |>
    |>]
EntityRegister[store]
AirportData["FAOR"]

Gives

Missing["UnknownEntity", {"Airport", "FAOR"}]

How do I affiliate an entity with AirportData[] without also deleting all the other elements in AirportData[]

Tomi
  • 4,366
  • 16
  • 31

2 Answers2

2

(Not really an answer, but too long for a comment)

I am not sure whether I should consider the documentation entirely clear about that. But from the details section in ref/EntityRegister):

Entity types that appear in EntityStores[] are considered before built-in entity types.

This I would read so that if you register an entity-store for type "Airport", then only that store will be searched for entries when using either Entity["Airport",...] or AirportData. And this is what seems to happen in your case and is in agreement with the documentation.

Consequently, only chance I see to achieve what you want would be to read out all data from the internal store, add/replace what you need and register that new entity-store. The main task here would be to do that in an efficient way, which most probably would need some spelunking where the internal "Airport" store comes from...

Albert Retey
  • 23,585
  • 60
  • 104
1

Maybe something like this:

newStore = 
 EntityStore[
  "Airport" -> <|
    "Entities" -> <|
      "FAOR Airport" -> <|
        "FullName" -> "O.R. Tambo International Airport", 
        "ICAO" -> "FAOR", "IATA" -> "JNB", 
        "Coordinates" -> {-26.1391667, 28.246}, 
        "TimeZone" -> "Africa/Johannesburg"|>, 
      "OTHH Airport" -> <|"FullName" -> "Hamad International Airport",
         "ICAO" -> "OTHH", "IATA" -> "DOH", 
        "Coordinates" -> {25.2611, 51.565}, 
        "TimeZone" -> "Asia/Qatar"|>|>|>]
EntityRegister[newStore]
Entity["Airport", "FAOR Airport"]
Entity["Airport", "OTHH Airport"]
Jakob
  • 276
  • 8
  • 2
    For me this replaces the internal entity store for airports, so that only the two entries in the new store are available. Is this different for you? I think the question was exactly about that: how to add to an existing store so that all other entries of the existing store would still be available. – Albert Retey May 09 '23 at 06:36