Skip to content

[common] Extend City<T> with country, AdminRegion and type; enrich cities.xml#189

Open
comoglu wants to merge 5 commits intoSeisComP:mainfrom
comoglu:feature/cityd-state-type
Open

[common] Extend City<T> with country, AdminRegion and type; enrich cities.xml#189
comoglu wants to merge 5 commits intoSeisComP:mainfrom
comoglu:feature/cityd-state-type

Conversation

@comoglu
Copy link
Copy Markdown
Contributor

@comoglu comoglu commented Apr 13, 2026

Extends City<T> with three new fields to enable richer location descriptions in SeisComP applications.

Changes

AdminRegion struct (replaces flat state/stateFull strings)

A dedicated struct serialised as a child element:

<state abbr="NSW"><name>New South Wales</name></state>
  • abbr — ISO 3166-2 alphabetic subdivision suffix (e.g. NSW, CA); empty where only numeric codes exist (e.g. Japan, China, Türkiye)
  • name — full subdivision name

country field

Full English country name serialised as a <country> child element:

<country>Australia</country>

Allows applications to display a human-readable country name without maintaining a separate ISO A2 → name lookup table.

type field

Location type derived from GeoNames feature codes. One of (or empty if unknown):

Value Meaning
city Capital or administrative centre (PPLC, PPLA, PPLA2)
town Populated place or minor admin centre (PPL, PPLA3, PPLA4)
village Small settlement (PPLF, PPLL, PPLR, PPLS, etc.)
suburb Section of a populated place (PPLX)

Updated cities.xml

Re-enriched from freely available sources:

Field Source Coverage
countryID Natural Earth 10m country polygons 71,682 / 71,685
country Natural Earth SQLite (ne_10m_admin_0_countries) 70,242
state Natural Earth ne_10m_admin_1_states_provinces (ISO 3166-2 abbreviations) 71,654
type GeoNames cities500.txt feature codes 56,860

All fields are optional and additive — existing applications ignoring them are unaffected.

Enrichment tooling

The pipeline script used to produce the enriched cities.xml is available at
https://github.com/comoglu/cities-xml-update — allowing operators to add their own cities or re-enrich from updated upstream data.

comoglu added 4 commits April 1, 2026 18:19
Two new options for controlling the map view when an event arrives,
applied in priority order:

1. display.lonmin/max/latmin/max (already existing) — if set, the map
   is anchored to that region on every event popup, regardless of where
   the event is located. Useful for regional networks monitoring a fixed
   area (e.g. an scesv alias per region).

2. display.defaultEventRadius — configurable radius in degrees, centred
   on the event epicentre (mirrors olv.map.event.defaultRadius in scolv).
   A negative value (default) restores the original automatic behaviour
   of using the maximum arrival distance capped at 30 degrees.

If neither option is set the existing behaviour is fully preserved.
Extends EventEdit to display arrival stations on the Origins tab map,
mirroring the existing station display on the Focal Mechanism tab.

- Generalize StationLayer constructor to QWidget* and refSymbol to
  Map::Symbol* so the layer can be reused outside FMMap
- Add StationLayer and AnnotationLayer to _originMap in init(), both
  hidden by default
- Add updateOriginStations() to populate stations from arrivals:
  picks resolved via Pick::Find() with DatabaseQuery fallback (owned
  by PickPtr), station locations from inventory, distance/azimuth
  fallback when no pick is available
- Stations are colored by arrival time residual using scheme colors
- Lines are drawn from the selected origin dot to each station
- Layer visibility toggled by the existing F9 Show Stations action
Extends the City<T> template class with three new optional attributes
to carry richer location metadata sourced from GeoNames and Natural Earth:

  type      — location type, e.g. "city", "town", "village", "suburb"
  state     — ISO 3166-2 alphabetic subdivision abbreviation, e.g. "NSW", "CA"
               Only present for countries that use alphabetic codes.
  stateFull — full administrative region name, e.g. "New South Wales"

All three fields are serialized as XML attributes (NAMED_OBJECT),
consistent with the existing countryID and category fields. They default
to empty strings and are fully backwards-compatible — existing cities.xml
files without these attributes parse without error.

This allows applications such as scolv to display type and state
information via SCApp->cities() without requiring a separate supplementary
locations file.
@cla-bot cla-bot Bot added the cla-signed The CLA has been signed by all contributors label Apr 13, 2026
std::string _countryID;
double _population;
std::string _category;
std::string _type;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a type enumeration be a better approach? Is there a defined set of values for type?

Comment thread libs/seiscomp/math/coord.h Outdated
double _population;
std::string _category;
std::string _type;
std::string _state;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a dedicated class with an abbreviation would be more appropriate. In XML something like:

<state short|abbr|younameit="BRB">Brandenburg</state>

@gempa-jabe
Copy link
Copy Markdown
Contributor

I would be interested in how big that will grow. Given all the redundancy of state and type and also country cannot be for free. I haven't checked but maybe there is already a standard out there to describe such administrative information.

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 13, 2026

cities_enriched.xml

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 13, 2026

15MB

@gempa-jabe
Copy link
Copy Markdown
Contributor

OK, that is not too much of a difference. The schema itself would be something I would like to address. I personally am not a big fan of "stateFull" which is actually "state". Unfortunately I do not have the time right now.

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 13, 2026

Thanks for the feedback. To address the stateFull naming concern: in the updated implementation I have already replaced both state and stateFull flat strings with a dedicated AdminRegion that has two clear fields — abbr (ISO 3166-2 suffix, like. "NSW") and name (full subdivision name, e.g. "New South Wales"). This serializes as a child element:

New South Wales

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 13, 2026

Updating Cities xml for entire world in one rule is indeed a hard work.

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 13, 2026

cities_enriched.xml

@comoglu
Copy link
Copy Markdown
Contributor Author

comoglu commented Apr 13, 2026

I've shared the enriched cities.xml as a preview. Enriching city types globally with a single rule set is harder than I would expect — GeoNames feature codes are inconsistently applied (e.g. a 1M+ population city classified as PPL → "town" based on natural earth data (shape file)).

Before going further, I'd appreciate your direction:

Is the type field worth pursuing, or should I drop it ?
For state: the ISO 3166-2 abbreviation approach works well for ~40 countries (US, AU, CA, IN) but many countries only have numeric codes. I would go with partial coverage, if it is OK, or would you prefer I omit state for countries without alphabetic abbreviations?

- City<T>: add country() / setCountry() serialised as <country> child element
- City<T>: replace state/stateFull strings with AdminRegion { abbr, name }
  serialised as <state abbr="NSW"><name>New South Wales</name></state>
- Document fixed type values: city, town, village, suburb
- Regenerate cities.xml with country names (Natural Earth), admin region
  (ISO 3166-2 abbreviation + full name via NE admin1 shapefile), and type
  (GeoNames feature codes); 70242 country names, 71654 states, 56860 types
@comoglu comoglu changed the title Feature/cityd state type [common] Extend City<T> with country, AdminRegion and type; enrich cities.xml Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The CLA has been signed by all contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants