geolith-search-builder 0.3.2

Builds geocoding indexes from Overture Maps and OpenStreetMap: Postgres COPY files, Photon and Pelias bulk files, and the search part of a .glx file
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
//! The importance of a settlement: its Wikipedia row, or a floor from what
//! the inputs say it is.
//!
//! A settlement with no row in Nominatim's Wikipedia file takes the default
//! of its class (0.187 for a city down to 0.133 for a hamlet). That loses to
//! any namesake village that has an article in a small language, whose row is
//! often 0.2 to 0.4: Tawang, a town of 11 000 and the seat of its district,
//! came after four Javanese villages. The importance of a city, town, village
//! or hamlet is now
//!
//! ```text
//! importance = max(row, floor)
//! floor      = min(0.40, base + population + prominence + capital)
//!
//! base       = default of the class: city 0.187, town 0.160, village 0.147, hamlet 0.133
//! population = 0.10 * log10(population / 1000)        from 1 000 people, else 0
//! prominence = 0.002 * (prominence - 20)              from 21, else 0
//! capital    = 0.25 a country, 0.20 a region, 0.10 a county (a city or town)
//! ```
//!
//! and a row is dropped when its item has no English article and the place
//! is stated to have under 1 000 people (a village of 99 whose only article is
//! in Romanian has 0.418 from that wiki's link counts). Neighbourhoods,
//! suburbs and quarters keep their default.
//!
//! Where each signal is read:
//!
//! - class: OSM `place`, or Overture `class` of a division point;
//! - population: OSM `population`, else Overture `population`;
//! - prominence: Overture `cartography.prominence` (1 to 100: Overture's own
//!   rating of how prominent a place is on a map), joined to an OSM node by its
//!   OSM element id;
//! - capital: OSM `capital` (any value but `no`), or Overture
//!   `capital_of_divisions` naming a county, region or country (read by the
//!   reader as `capital_of_divisions`, which Overture takes from the
//!   `admin_centre` role of an OSM boundary relation).
//!
//! The cap keeps a floor below a place with an English Wikipedia article:
//! rows of towns that have one average 0.41, cities 0.49.

use std::collections::HashMap;

use crate::division::osm_record_id;
use crate::importance::{Wikipedia, default_importance};
use geolith::source::input::InputFeature;
use geolith::tile::feature::PropValue;

/// The highest floor.
pub const FLOOR_CAP: f32 = 0.40;

/// Importance added for each tenfold of population above 1 000.
pub const POPULATION_PER_DECADE: f32 = 0.10;

/// Population below which a place has no population bonus, and a row that
/// only a small-language article backs is dropped.
pub const SMALL_POPULATION: u64 = 1_000;

/// Overture prominence up to which a place earns nothing: villages are 12,
/// towns 13 to 26.
pub const PROMINENCE_FREE: u8 = 20;

/// Importance added for each point of prominence above [`PROMINENCE_FREE`].
pub const PROMINENCE_PER_POINT: f32 = 0.002;

/// Importance added to the seat of a country or a dependency.
pub const COUNTRY_BONUS: f32 = 0.25;

/// Importance added to the seat of a region or a macroregion.
pub const REGION_BONUS: f32 = 0.20;

/// Importance added to the seat of a county, a macrocounty or a localadmin.
pub const COUNTY_BONUS: f32 = 0.10;

/// The division subtypes whose seat is a capital here.
const CAPITAL_OF: [&str; 6] = [
    "country",
    "dependency",
    "region",
    "macroregion",
    "county",
    "macrocounty",
];

/// The class of a settlement.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum SettlementClass {
    /// A city, Nominatim search rank 16.
    City,
    /// A town, rank 18.
    Town,
    /// A village, rank 19.
    Village,
    /// A hamlet, rank 20.
    Hamlet,
}

impl SettlementClass {
    /// The class of an OSM `place` value; `None` for any other (a suburb, a
    /// quarter, a neighbourhood, a state).
    #[must_use]
    pub fn from_place(place: &str) -> Option<Self> {
        Some(match place {
            "city" => Self::City,
            "town" => Self::Town,
            "village" => Self::Village,
            "hamlet" => Self::Hamlet,
            _ => return None,
        })
    }

    /// The class of an Overture `locality` division; `None` when it has none.
    #[must_use]
    pub fn from_overture(class: &str) -> Option<Self> {
        Self::from_place(class)
    }

    /// The Nominatim search rank of the class.
    #[must_use]
    pub const fn rank(self) -> u8 {
        match self {
            Self::City => 16,
            Self::Town => 18,
            Self::Village => 19,
            Self::Hamlet => 20,
        }
    }
}

/// What the inputs say about a settlement besides its class.
#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub struct PlaceSignals {
    /// People living there, when a source says.
    pub population: Option<u64>,
    /// Overture's prominence, 1 to 100.
    pub prominence: Option<u8>,
    /// The seat of a county, a region or a country.
    pub capital: bool,
    /// The bonus of the highest seat held ([`COUNTRY_BONUS`],
    /// [`REGION_BONUS`] or [`COUNTY_BONUS`]); 0 when it is no seat.
    pub capital_bonus: f32,
}

impl PlaceSignals {
    /// These signals, with `other` where this one says nothing.
    #[must_use]
    pub fn or(self, other: Self) -> Self {
        Self {
            population: self.population.or(other.population),
            prominence: self.prominence.or(other.prominence),
            capital: self.capital || other.capital,
            capital_bonus: self.capital_bonus.max(other.capital_bonus),
        }
    }

    /// Whether any signal is set.
    #[must_use]
    pub fn any(&self) -> bool {
        self.population.is_some() || self.prominence.is_some() || self.capital
    }

    /// Whether a source states under [`SMALL_POPULATION`] people.
    #[must_use]
    pub fn small(&self) -> bool {
        self.population.is_some_and(|p| p < SMALL_POPULATION)
    }
}

/// The floor of a settlement of `class` with `signals`.
#[must_use]
pub fn floor(class: SettlementClass, signals: &PlaceSignals) -> f32 {
    let base = default_importance(class.rank());
    let population = signals
        .population
        .filter(|&p| p >= SMALL_POPULATION)
        .map_or(0.0, |p| {
            let people = f64::from(u32::try_from(p).unwrap_or(u32::MAX));
            let decades = (people / 1_000.0).log10();
            POPULATION_PER_DECADE * decades as f32
        });
    let prominence = signals
        .prominence
        .filter(|&p| p > PROMINENCE_FREE)
        .map_or(0.0, |p| {
            PROMINENCE_PER_POINT * f32::from(p - PROMINENCE_FREE)
        });
    // A county seat is not a state capital: the bonus follows the level held, so a
    // tehsil or county seat (0.10) does not pass a town of 30 000 people, and only a
    // city or a town takes it at all (a village that a ward boundary makes its
    // admin centre is no seat of anything).
    let seat = signals.capital && matches!(class, SettlementClass::City | SettlementClass::Town);
    let capital = if seat { signals.capital_bonus } else { 0.0 };
    (base + population + prominence + capital).min(FLOOR_CAP)
}

/// The importance of a settlement: `max(row, floor)`, where the row is the
/// Wikipedia importance of its `wikidata` item, dropped when its item has no
/// English article and the place has under 1 000 people.
#[must_use]
pub fn settlement_importance(
    wikipedia: &Wikipedia,
    wikidata: Option<&str>,
    class: SettlementClass,
    signals: &PlaceSignals,
) -> f32 {
    let row = wikidata
        .filter(|item| {
            let tiny = signals.small()
                || (signals.population.is_none()
                    && matches!(class, SettlementClass::Village | SettlementClass::Hamlet)
                    && !signals.capital
                    && signals.prominence.is_none_or(|p| p <= PROMINENCE_FREE));
            !(tiny && wikipedia.english_title(item).is_none())
        })
        .and_then(|item| wikipedia.get(item));
    let floor = floor(class, signals);
    row.map_or(floor, |row| row.max(floor))
}

/// A number written in an OSM `population` tag: digits, with spaces, commas
/// or underscores between groups. Anything else (`1.2 million`, `~5000`,
/// `1.234`, an empty string) is not read.
#[must_use]
pub fn parse_population(text: &str) -> Option<u64> {
    let digits: String = text
        .chars()
        .filter(|c| !matches!(c, ' ' | ',' | '_' | '\u{a0}'))
        .collect();
    if digits.is_empty() || !digits.bytes().all(|b| b.is_ascii_digit()) {
        return None;
    }
    digits.parse().ok()
}

fn prop_int(feature: &InputFeature, key: &str) -> Option<i64> {
    match feature.properties.get(key)? {
        PropValue::I64(v) => Some(*v),
        PropValue::U64(v) => i64::try_from(*v).ok(),
        _ => None,
    }
}

fn prop_str<'a>(feature: &'a InputFeature, key: &str) -> Option<&'a str> {
    match feature.properties.get(key)? {
        PropValue::Str(s) if !s.trim().is_empty() => Some(s.trim()),
        _ => None,
    }
}

/// The signals of an Overture division point.
#[must_use]
pub fn division_signals(feature: &InputFeature) -> PlaceSignals {
    PlaceSignals {
        population: prop_int(feature, "population").and_then(|p| u64::try_from(p).ok()),
        prominence: prop_int(feature, "cartography.prominence").and_then(|p| u8::try_from(p).ok()),
        capital: prop_str(feature, "capital_of_divisions")
            .is_some_and(|list| list.split(';').any(|subtype| CAPITAL_OF.contains(&subtype))),
        capital_bonus: prop_str(feature, "capital_of_divisions").map_or(0.0, |list| {
            list.split(';').map(subtype_bonus).fold(0.0, f32::max)
        }),
    }
}

/// The signals an OSM element's own tags give: `population` and `capital`.
#[must_use]
pub fn osm_signals(population: Option<&str>, capital: Option<&str>) -> PlaceSignals {
    let capital = capital.map(str::trim);
    let seat = capital.is_some_and(|value| !value.eq_ignore_ascii_case("no"));
    PlaceSignals {
        population: population.and_then(parse_population),
        prominence: None,
        capital: seat,
        capital_bonus: if seat {
            capital.map_or(COUNTRY_BONUS, capital_value_bonus)
        } else {
            0.0
        },
    }
}

/// The bonus of a division subtype Overture names in `capital_of_divisions`.
fn subtype_bonus(subtype: &str) -> f32 {
    match subtype {
        "country" | "dependency" => COUNTRY_BONUS,
        "region" | "macroregion" => REGION_BONUS,
        "county" | "macrocounty" | "localadmin" => COUNTY_BONUS,
        _ => 0.0,
    }
}

/// The bonus of an OSM `capital` value: `yes` and `2` are a country, `3` and `4`
/// a region, `5` and `6` a county (`capital=<admin_level>`: in India a district
/// is admin_level 5, a state 4). An unknown value counts as a county: the
/// smallest bonus rather than the largest.
fn capital_value_bonus(value: &str) -> f32 {
    match value {
        "yes" | "2" => COUNTRY_BONUS,
        "3" | "4" => REGION_BONUS,
        _ => COUNTY_BONUS,
    }
}

/// The Overture signals of the division points that came from OSM, by OSM
/// record id, so the OSM pass can use the prominence, the population and the
/// capital flag Overture holds for an OSM node. Only places that say
/// something are kept.
#[derive(Debug, Default)]
pub struct PlaceSignalIndex {
    by_osm_id: HashMap<u64, PlaceSignals>,
}

impl PlaceSignalIndex {
    /// Notes one division point.
    pub fn add(&mut self, feature: &InputFeature) {
        if prop_str(feature, "subtype") != Some("locality") {
            return;
        }
        let Some(id) = osm_record_id(feature) else {
            return;
        };
        let signals = division_signals(feature);
        if signals.population.is_some()
            || signals.capital
            || signals.prominence.is_some_and(|p| p > PROMINENCE_FREE)
        {
            self.by_osm_id.insert(id, signals);
        }
    }

    /// The signals of an OSM element, none when Overture has nothing.
    #[must_use]
    pub fn get(&self, osm_record_id: u64) -> PlaceSignals {
        self.by_osm_id
            .get(&osm_record_id)
            .copied()
            .unwrap_or_default()
    }

    /// Places held.
    #[must_use]
    pub fn len(&self) -> usize {
        self.by_osm_id.len()
    }

    /// Whether none is held.
    #[must_use]
    pub fn is_empty(&self) -> bool {
        self.by_osm_id.is_empty()
    }
}

#[cfg(test)]
mod tests {
    use std::sync::Arc;

    use super::*;
    use geolith::source::input::DataSource;

    fn s(v: &str) -> PropValue {
        PropValue::Str(v.to_string())
    }

    fn division(props: &[(&str, PropValue)]) -> InputFeature {
        InputFeature {
            id: 1,
            geometry: Arc::new(geo::Geometry::Point(geo::Point::new(91.86, 27.59))),
            properties: props
                .iter()
                .map(|(k, v)| ((*k).to_string(), v.clone()))
                .collect(),
            bbox: None,
            source: DataSource::Overture {
                theme: "divisions".into(),
                otype: "division".into(),
            },
        }
    }

    fn signals(population: Option<u64>, prominence: Option<u8>, capital: bool) -> PlaceSignals {
        PlaceSignals {
            population,
            prominence,
            capital,
            capital_bonus: if capital { COUNTY_BONUS } else { 0.0 },
        }
    }

    /// The floors, worked out by hand from the formula in the module doc:
    /// the class default plus 0.10 per tenfold of population from 1 000,
    /// plus 0.002 per point of prominence above 20, plus 0.25 for a seat,
    /// at most 0.40.
    #[test]
    fn the_floor_of_each_case_written_out() {
        let none = signals(None, None, false);
        let cases = [
            (SettlementClass::City, none, 0.186_68),
            (SettlementClass::Town, none, 0.160_01),
            (SettlementClass::Village, none, 0.146_68),
            (SettlementClass::Hamlet, none, 0.133_34),
            // 0.16001 + 0.10 * log10(11)
            (
                SettlementClass::Town,
                signals(Some(11_000), None, false),
                0.264_15,
            ),
            // under 1 000 people there is no bonus, at 1 000 it is 0
            (
                SettlementClass::Town,
                signals(Some(999), None, false),
                0.160_01,
            ),
            (
                SettlementClass::Town,
                signals(Some(1_000), None, false),
                0.160_01,
            ),
            // 0.14668 + 0.10 * log10(100)
            (
                SettlementClass::Village,
                signals(Some(100_000), None, false),
                0.346_68,
            ),
            // up to 20 earns nothing; 58 earns 0.002 * 38
            (
                SettlementClass::Village,
                signals(None, Some(12), false),
                0.146_68,
            ),
            (
                SettlementClass::Town,
                signals(None, Some(20), false),
                0.160_01,
            ),
            (
                SettlementClass::Town,
                signals(None, Some(58), false),
                0.236_01,
            ),
            // a county seat, a town: 0.16001 + 0.10; a country seat: 0.16001 + 0.25
            (SettlementClass::Town, signals(None, None, true), 0.260_01),
            (
                SettlementClass::Town,
                PlaceSignals {
                    capital: true,
                    capital_bonus: COUNTRY_BONUS,
                    ..PlaceSignals::default()
                },
                0.40,
            ),
            (
                SettlementClass::Hamlet,
                signals(Some(10_000_000), Some(100), true),
                0.40,
            ),
        ];
        for (class, given, want) in cases {
            let got = floor(class, &given);
            assert!(
                (got - want).abs() < 1e-4,
                "{class:?} {given:?}: {got}, not {want}"
            );
        }
    }

    const ROWS: &str = "en\ta\tLondon\t0.892\tQ84\n\
ro\ta\tTiny\t0.418\tQ1\n\
en\ta\tHallstatt\t0.50\tQ2\n\
sv\ta\tLow\t0.05\tQ3\n";

    fn wikipedia() -> Wikipedia {
        Wikipedia::read(ROWS.as_bytes()).expect("rows")
    }

    #[test]
    fn the_importance_is_the_larger_of_the_row_and_the_floor() {
        let w = wikipedia();
        let none = signals(None, None, false);
        let at = |item: Option<&str>, class, given: &PlaceSignals| {
            settlement_importance(&w, item, class, given)
        };
        // a row above the floor stays, a floor above the row wins, no row is the floor
        assert!((at(Some("Q84"), SettlementClass::City, &none) - 0.892).abs() < 1e-6);
        assert!((at(Some("Q3"), SettlementClass::Town, &none) - 0.160_01).abs() < 1e-4);
        assert!((at(None, SettlementClass::Town, &none) - 0.160_01).abs() < 1e-4);
        assert!((at(Some("Q999"), SettlementClass::Town, &none) - 0.160_01).abs() < 1e-4);
        let seat = signals(None, None, true);
        assert!((at(Some("Q3"), SettlementClass::Town, &seat) - 0.260_01).abs() < 1e-4);
        let country = PlaceSignals {
            capital: true,
            capital_bonus: COUNTRY_BONUS,
            ..PlaceSignals::default()
        };
        assert!((at(Some("Q3"), SettlementClass::Town, &country) - 0.40).abs() < 1e-6);
    }

    /// A row that only a small-language article backs is dropped for a place
    /// stated to have under 1 000 people; a famous small place with an English
    /// article keeps its row, and so does a place of unknown population.
    #[test]
    fn a_small_language_row_of_a_tiny_place_is_dropped() {
        let w = wikipedia();
        let tiny = signals(Some(99), None, false);
        let village = |item, given: &PlaceSignals| {
            settlement_importance(&w, Some(item), SettlementClass::Village, given)
        };
        assert!((village("Q1", &tiny) - 0.146_68).abs() < 1e-4, "dropped");
        assert!(
            (village("Q2", &tiny) - 0.50).abs() < 1e-6,
            "an English article: kept"
        );
        assert!(
            (village("Q1", &signals(None, None, false)) - 0.146_68).abs() < 1e-4,
            "unknown population, no lift: dropped"
        );
        // a village a source lifts (prominence above 20) keeps its row
        assert!((village("Q1", &signals(None, Some(30), false)) - 0.418).abs() < 1e-6);
        assert!((village("Q1", &signals(Some(1_000), None, false)) - 0.418).abs() < 1e-6);
    }

    #[test]
    fn only_a_city_a_town_a_village_or_a_hamlet_has_a_floor() {
        for place in ["city", "town", "village", "hamlet"] {
            assert!(SettlementClass::from_place(place).is_some(), "{place}");
        }
        for place in [
            "suburb",
            "quarter",
            "neighbourhood",
            "state",
            "locality",
            "",
        ] {
            assert!(SettlementClass::from_place(place).is_none(), "{place}");
        }
    }

    #[test]
    fn a_population_tag_is_read_only_when_it_is_a_plain_number() {
        for (text, want) in [
            ("11000", Some(11_000)),
            ("11,000", Some(11_000)),
            ("11 000", Some(11_000)),
            ("1_000_000", Some(1_000_000)),
            ("0", Some(0)),
            ("1.2 million", None),
            ("~5000", None),
            ("1.234", None),
            ("", None),
            ("abc", None),
            ("99999999999999999999999", None),
        ] {
            assert_eq!(parse_population(text), want, "{text:?}");
        }
    }

    #[test]
    fn osm_tags_give_population_and_capital() {
        assert_eq!(
            osm_signals(Some("11000"), None),
            signals(Some(11_000), None, false)
        );
        for (capital, want) in [("yes", true), ("4", true), ("no", false), ("NO", false)] {
            assert_eq!(osm_signals(None, Some(capital)).capital, want, "{capital}");
        }
        assert_eq!(osm_signals(None, None), PlaceSignals::default());
    }

    #[test]
    fn overture_gives_population_prominence_and_the_seats_it_holds() {
        let tawang = division(&[
            ("population", PropValue::I64(11_000)),
            ("cartography.prominence", PropValue::I64(58)),
            ("capital_of_divisions", s("county")),
        ]);
        assert_eq!(
            division_signals(&tawang),
            signals(Some(11_000), Some(58), true)
        );
        // the seat of a municipality only is not a capital here
        let seat = division(&[("capital_of_divisions", s("localadmin"))]);
        assert!(!division_signals(&seat).capital);
        let both = division(&[("capital_of_divisions", s("localadmin;region"))]);
        assert!(division_signals(&both).capital);
        assert_eq!(division_signals(&division(&[])), PlaceSignals::default());
    }

    /// An OSM-sourced locality Overture says something about is found by its
    /// OSM element id; one it says nothing about, or a point of another
    /// subtype, is not held.
    #[test]
    fn the_index_holds_the_osm_sourced_localities_with_something_to_say() {
        let point = |subtype: &str, record: &str, extra: &[(&str, PropValue)]| {
            let mut props = vec![
                ("subtype", s(subtype)),
                ("sources.dataset", s("OpenStreetMap")),
                ("sources.record_id", s(record)),
            ];
            props.extend(extra.iter().cloned());
            division(&props)
        };
        let mut index = PlaceSignalIndex::default();
        index.add(&point(
            "locality",
            "n10@1",
            &[("cartography.prominence", PropValue::I64(58))],
        ));
        index.add(&point(
            "locality",
            "n11@1",
            &[("cartography.prominence", PropValue::I64(12))],
        ));
        index.add(&point(
            "locality",
            "n12@1",
            &[("population", PropValue::I64(99))],
        ));
        index.add(&point(
            "county",
            "n13@1",
            &[("capital_of_divisions", s("county"))],
        ));
        assert_eq!(index.len(), 2);
        assert_eq!(index.get(10).prominence, Some(58));
        assert_eq!(
            index.get(12).population,
            Some(99),
            "a small population is kept too"
        );
        assert_eq!(
            index.get(11),
            PlaceSignals::default(),
            "prominence 12 says nothing"
        );
        assert_eq!(
            index.get(13),
            PlaceSignals::default(),
            "a county is not a settlement"
        );
        assert_eq!(index.get(99), PlaceSignals::default());
    }
}