trackberry-airports 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE.txt +38 -0
- data/README.md +92 -0
- data/data/airports.csv +9052 -0
- data/lib/trackberry/airports/builder.rb +261 -0
- data/lib/trackberry/airports/diff.rb +255 -0
- data/lib/trackberry/airports/version.rb +12 -0
- data/lib/trackberry/airports.rb +155 -0
- metadata +74 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ca7818ec91a88ba3d1c18e8fcb9517f87d89cfc94c937c1909fd816c50877608
|
|
4
|
+
data.tar.gz: 9973e103fe6303cd960d54db00b117da582830eba75ac969890c11a11c890d12
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f84769f1883adff0d24a33eb84a42852fd141aad7a0d4759e33347d600c1bb094cf6db3a452843f2e194b05edf3741403af6fa48096403616cdfeb24b99dd73e
|
|
7
|
+
data.tar.gz: 11a2a886ebe1ca31ca2b0ec7d59ed35eff2d84d967988fe2aeb6d8c0ed24bc0764bd06fdbd036ad0900db8496193c04ee2c9ae2f7b0518cedc087c7af16fcf12
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Data refreshes are minor versions, opened as pull requests by the monthly refresh workflow. Code changes are written here by hand.
|
|
4
|
+
|
|
5
|
+
## 0.1.1 — 2026-10-26
|
|
6
|
+
|
|
7
|
+
Published on rubygems.org instead of GitHub Packages. The table is licensed under the ODbL, as a derivative of OpenFlights' database; the code stays MIT.
|
|
8
|
+
|
|
9
|
+
## 0.1.0 — 2026-10-20
|
|
10
|
+
|
|
11
|
+
First release: every OurAirports airport with an IATA code, with the city it serves (from OpenFlights), the town it stands in, its position and its ISO 3166-2 subdivision path, and the monthly refresh.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Édouard Brière
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The MIT License above covers the code. It does not cover the airport table.
|
|
26
|
+
|
|
27
|
+
data/airports.csv and data/sources/served_cities.csv contain information from
|
|
28
|
+
OpenFlights (https://openflights.org/data), © OpenFlights contributors, which
|
|
29
|
+
is made available under the Open Database License (ODbL) 1.0:
|
|
30
|
+
https://opendatacommons.org/licenses/odbl/1-0/. Any rights in individual
|
|
31
|
+
contents of the database are licensed under the Database Contents License:
|
|
32
|
+
https://opendatacommons.org/licenses/dbcl/1-0/. Both files are made available
|
|
33
|
+
under the same terms.
|
|
34
|
+
|
|
35
|
+
The rest of the table comes from public-domain sources: OurAirports
|
|
36
|
+
(https://ourairports.com/data/) for the airports, and Natural Earth
|
|
37
|
+
(https://www.naturalearthdata.com) for the states-and-provinces map that
|
|
38
|
+
places some of them.
|
data/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# trackberry-airports
|
|
2
|
+
|
|
3
|
+
Every airport with an IATA code (about 9,000), with its name, city, position and ISO 3166-2 subdivision, as a table shipped inside the gem. No network calls.
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
require "trackberry/airports"
|
|
7
|
+
|
|
8
|
+
Trackberry::Airports.find("FRA") # => #<data Trackberry::Airports::Airport iata="FRA", icao="EDDF", ...>
|
|
9
|
+
Trackberry::Airports.city("FRA") # => "Frankfurt"
|
|
10
|
+
Trackberry::Airports.country("FRA") # => "DE"
|
|
11
|
+
Trackberry::Airports.coordinates("FRA") # => { "lat" => 50.0267, "lng" => 8.5584 }
|
|
12
|
+
Trackberry::Airports.subdivision_path("SXB") # => ["FR-67", "FR-6AE", "FR-GES"]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
An unknown code answers `nil` (or `[]` for a path): carriers send city codes ("LON") and codes of airports that have closed, and that is ordinary, not an error.
|
|
16
|
+
|
|
17
|
+
## Why not the `airports` gem
|
|
18
|
+
|
|
19
|
+
[`airports`](https://github.com/timrogers/airports) is the established gem for this, and it does the plain lookup well. This one exists for what it does not do:
|
|
20
|
+
|
|
21
|
+
- **Fresh data.** `airports` is built from OpenFlights, which stopped updating in 2019, and adds the airports opened since by hand (`BER`, `HYD`). This one is built from OurAirports, which is still maintained, and rebuilt every month behind checks that stop a bad download from shipping.
|
|
22
|
+
- **Where the airport is, inside its country.** `airports` gives the country as a name ("United Kingdom"). This one gives the ISO 3166-2 country code and subdivision path, which is what a regional holiday calendar or a customs rule keys on.
|
|
23
|
+
- **Numbers as numbers.** Coordinates are floats, not strings.
|
|
24
|
+
|
|
25
|
+
`airports` has time zones; this one does not. If that is all you need, use it.
|
|
26
|
+
|
|
27
|
+
## Subdivisions
|
|
28
|
+
|
|
29
|
+
`subdivision_path` is the ISO 3166-2 code of the area the airport is in and every code above it, most specific first, the same shape [seaports](https://github.com/Trackberry/seaports) gives for a port. Hand it to a holiday calendar that matches a holiday at any level of the path, such as Trackberry's own (not published):
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
Trackberry::Holidays.holiday?(Date.new(2027, 5, 27), Trackberry::Airports.subdivision_path("MUC")) # => true, Corpus Christi in Bavaria
|
|
33
|
+
Trackberry::Holidays.holiday?(Date.new(2027, 5, 27), Trackberry::Airports.subdivision_path("HAM")) # => false, not in Hamburg
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Where the code comes from, best first (the `subdivision_source` column says which):
|
|
37
|
+
|
|
38
|
+
| Source | Airports | Example |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `override`: a reviewed list, `data/sources/subdivision_overrides.csv` | 0 | |
|
|
41
|
+
| `boundaries`: the airport's position on Natural Earth's states-and-provinces map | 831 | Strasbourg `FR-67`, Beijing `CN-BJ` |
|
|
42
|
+
| `ourairports`: OurAirports' `iso_region` | 7,903 | Frankfurt `DE-HE`, Hamburg `DE-HH` |
|
|
43
|
+
|
|
44
|
+
The map is used two ways:
|
|
45
|
+
- **To go below OurAirports.** OurAirports stops at the top level: Grand Est for Strasbourg. When the map finds an area inside that code, the airport gets the longer path: Bas-Rhin, inside the European Collectivity of Alsace, inside Grand Est. Some rules are kept at those levels. Alsace and Moselle have two public holidays the rest of France does not, which a calendar would key on `FR-6AE` and `FR-57`; Nager.Date does not list them yet. When the map disagrees with OurAirports, OurAirports wins. The map answers with the area containing the airport, and only for an airport outside every area (built on reclaimed land, past the drawn coastline) with the nearest one within 10 km.
|
|
46
|
+
- **To fill a gap.** OurAirports still writes some codes ISO has replaced, such as China's pre-2017 numeric ones, and `XX-U-A` for "unassigned".
|
|
47
|
+
|
|
48
|
+
8,734 of 9,051 airports are placed. The 317 left have no subdivision because both sources still use codes ISO has retired (Poland, Norway, South Africa, Czechia, Kazakhstan) or the territory has none (French Polynesia, Puerto Rico). None of them is in a country whose public holidays differ by region, so a holiday lookup by country is complete for them.
|
|
49
|
+
|
|
50
|
+
Every code is checked against ISO 3166-2 when the table is built. The ISO hierarchy and the map lookup are seaports' `Seaports::Subdivisions` and `Seaports::Boundaries`, used by the build only: the gem itself depends on neither.
|
|
51
|
+
|
|
52
|
+
## Cities
|
|
53
|
+
|
|
54
|
+
`city` is the city the airport serves, the one a carrier, a courier or a person names: "Brussels", "Athens", "Leipzig". `municipality` is the town it stands in, as OurAirports gives it: "Zaventem", "Spata-Artemida", "Schkeuditz". They are the same for most airports.
|
|
55
|
+
|
|
56
|
+
The served city comes from [OpenFlights](https://openflights.org/data) for the 6,000 airports it lists. OpenFlights stopped updating in 2019, so its cities were extracted once into `data/sources/served_cities.csv` by `script/extract_served_cities.rb`, from a pinned commit. A city carries over only when OpenFlights puts the airport within 50 km of OurAirports' position, so a code IATA has since given to another airport does not bring the old city with it. Every other airport takes its municipality, without a trailing note in brackets: "Helsinki", not "Helsinki (Vantaa)".
|
|
57
|
+
|
|
58
|
+
The subdivision always follows where the airport is, not the city it serves: Cincinnati's airport is in Kentucky (`US-KY`), not Ohio.
|
|
59
|
+
|
|
60
|
+
## Data
|
|
61
|
+
|
|
62
|
+
[OurAirports](https://ourairports.com/data/) (public domain), filtered to airports with an IATA code that are not closed. When two rows share a code, the one with scheduled flights wins, then the larger airport. Coordinates are rounded to four decimal places (about ten metres).
|
|
63
|
+
|
|
64
|
+
Served cities: [OpenFlights](https://openflights.org/data), © OpenFlights contributors, available under the [Open Database License](https://opendatacommons.org/licenses/odbl/1-0/).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
The code is MIT. The table (`data/airports.csv`) is a derivative of OpenFlights' database, so it is under the [ODbL 1.0](https://opendatacommons.org/licenses/odbl/1-0/): a database you build from it and use publicly has to credit OpenFlights and be offered under the ODbL too. Using the gem to look airports up does not. See `LICENSE.txt`.
|
|
69
|
+
|
|
70
|
+
## Refresh
|
|
71
|
+
|
|
72
|
+
`.github/workflows/refresh.yml` runs on the 3rd of every month:
|
|
73
|
+
|
|
74
|
+
1. `rake airports:refresh` downloads OurAirports, the ISO 3166-2 list and the Natural Earth map, and rebuilds `data/airports.csv`.
|
|
75
|
+
2. `Trackberry::Airports::Diff` checks the result before anything ships:
|
|
76
|
+
- at least 8,500 airports;
|
|
77
|
+
- the table shrinks by no more than 2%;
|
|
78
|
+
- airports with a subdivision fall by no more than 2%;
|
|
79
|
+
- no more than 2% move to another principal subdivision;
|
|
80
|
+
- two dozen major airports (FRA, LHR, JFK, LIM…) are all present;
|
|
81
|
+
- fourteen of them, in countries whose holidays differ by region, keep their principal subdivision (FRA in `DE-HE`, MUC in `DE-BY`…), because one country's codes breaking stays under the percentage caps.
|
|
82
|
+
3. If it passes, the job opens a pull request listing every added, removed, renamed, moved, re-citied and resubdivided airport, and starts CI on it. If it fails, or a download fails, it opens an issue instead.
|
|
83
|
+
|
|
84
|
+
Merging a refresh bumps the minor version, and `.github/workflows/release.yml` publishes it to [rubygems.org](https://rubygems.org/gems/trackberry-airports).
|
|
85
|
+
|
|
86
|
+
To rebuild from files already on disk: `bundle exec rake "airports:refresh[airports.csv,iso_3166-2.json,admin1.geojson]"`.
|
|
87
|
+
|
|
88
|
+
## Install
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
gem "trackberry-airports", "~> 0.1", require: "trackberry/airports"
|
|
92
|
+
```
|