garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

cartopolis-agent · 2026-11-29T17:01:30Z

feat(map): call a statue by its title instead of "Artwork"

Walking up to a statue said "Use Artwork". Two causes, one per source:

- OSM's named artworks: a `tourism=artwork` with a `name` is read from
  the tile's `pois` twice — as the furniture it is drawn as and as a named
  place on the very same point — and in `WorldPlaces::nearest` the
  nameless prop, listed first, won the tie. The prop now takes the name
  of a place standing on its point (within 0.5 m) and that place is not
  added as a second prompt.
- Wikidata's statues, which atlas adds: their title now arrives in the
  registers cell (`prop_names`), and `municipal::registered_names` hands
  it to `insert_cell` at the point the prop stands.

The prompt reads "Look at Peerd van Ome Loeks (Artwork)": an artwork's
verb is "Look at" rather than "Use", and `Interactable::detail` names
the kind after a prop that has a name of its own. The MCP surroundings
list such a prop among the named things rather than counting it.
.../cartopolis/src/systems/dev/mcp/agent/world.rs  |   4 +-
 .../cartopolis/src/systems/dev/mcp/surroundings.rs |   7 +-
 crates/cartopolis/src/systems/map/map_geometry.rs  |   8 ++
 crates/cartopolis/src/systems/map/municipal.rs     |  67 +++++++++--
 crates/cartopolis/src/systems/map/world_places.rs  | 127 ++++++++++++++++++++-
 crates/cartopolis/src/systems/player/interact.rs   |   6 +-
 docs/notes/municipal-registers.md                  |  18 ++-
 7 files changed, 218 insertions(+), 19 deletions(-)

diff --git a/crates/cartopolis/src/systems/dev/mcp/agent/world.rs b/crates/cartopolis/src/systems/dev/mcp/agent/world.rs
index 4f7db336..c5819a7a 100644
--- a/crates/cartopolis/src/systems/dev/mcp/agent/world.rs
+++ b/crates/cartopolis/src/systems/dev/mcp/agent/world.rs
@@ -607,7 +607,7 @@ pub(super) fn use_target(target: &Target, w: &mut AgentWorld) -> String {
         Target::Thing(i) if i.seat_spot(w.here()).is_some() => sit_on(i, w),
         Target::Thing(i) => {
             w.avatar.pending_emote = Some(Emote::Interact);
-            match i.kind.detail() {
+            match i.detail() {
                 Some(d) => format!("{} {} ({d})", i.kind.verb().to_lowercase(), i.name),
                 None => format!(
                     "{} the {}",
@@ -654,7 +654,7 @@ pub(super) fn find_near(
         if seats_only && i.seat_spot(here).is_none() {
             continue;
         }
-        if !matches(&i.name, i.kind.detail()) {
+        if !matches(&i.name, i.detail()) {
             continue;
         }
         if best.as_ref().is_none_or(|(_, b)| d < *b) {
diff --git a/crates/cartopolis/src/systems/dev/mcp/surroundings.rs b/crates/cartopolis/src/systems/dev/mcp/surroundings.rs
index bb7d570a..544f55f6 100644
--- a/crates/cartopolis/src/systems/dev/mcp/surroundings.rs
+++ b/crates/cartopolis/src/systems/dev/mcp/surroundings.rs
@@ -439,8 +439,13 @@ pub fn describe(scene: &Scene) -> (String, Value) {
     let mut furniture: Vec<(String, usize, f32, &str)> = Vec::new();
     for (i, _) in scene.places.within(scene.here, scene.radius) {
         let (d, dir) = how_far(scene.here, i.pos);
+        // A prop with a name of its own (a statue's title) is a named thing,
+        // not one of "3 Artworks".
         match i.kind {
-            InteractKind::Place { .. } => named.push((&i.name, i.kind.detail(), d, dir, i.pos)),
+            InteractKind::Place { .. } => named.push((&i.name, i.detail(), d, dir, i.pos)),
+            InteractKind::Prop(_) if i.detail().is_some() => {
+                named.push((&i.name, i.detail(), d, dir, i.pos));
+            }
             InteractKind::Prop(_) => match furniture.iter_mut().find(|f| f.0 == i.name) {
                 Some(f) => {
                     f.1 += 1;
diff --git a/crates/cartopolis/src/systems/map/map_geometry.rs b/crates/cartopolis/src/systems/map/map_geometry.rs
index 09cc4be0..872f1afa 100644
--- a/crates/cartopolis/src/systems/map/map_geometry.rs
+++ b/crates/cartopolis/src/systems/map/map_geometry.rs
@@ -2222,6 +2222,14 @@ fn spawn_geometry_task(
                                             veg_seed(cell),
                                         );
                                         cell_places.surveyed.8 = city_props.len();
+                                        // …with the statues' titles, which an
+                                        // instance cannot carry.
+                                        cell_places.prop_names = municipal::registered_names(
+                                            &registered,
+                                            cell.0,
+                                            cell.1,
+                                            tile_m,
+                                        );
                                         items.extend(city_props);
                                         // …and the surveyed boundaries, which are
                                         // lines rather than point props and so get
diff --git a/crates/cartopolis/src/systems/map/municipal.rs b/crates/cartopolis/src/systems/map/municipal.rs
index 0ac727fb..64b83eab 100644
--- a/crates/cartopolis/src/systems/map/municipal.rs
+++ b/crates/cartopolis/src/systems/map/municipal.rs
@@ -48,6 +48,7 @@ use crate::services::tdbag_url;
 use crate::systems::coverage::CoverageSlot;
 use crate::systems::furniture::{FurnitureInstance, FurnitureKind};
 use crate::systems::scatter::{TreeForm, TreeInstance};
+use bevy::math::Vec2;
 use cartopolis_geo::formats::registers::{self, SUPPLIES_TREES};
 
 /// The zoom cells are cut at — `map_geometry::GEOMETRY_ZOOM`, because these
@@ -99,7 +100,7 @@ pub struct RegisteredTree {
 }
 
 /// One street object as a register placed it.
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq)]
 pub struct RegisteredProp {
     pub lat: f64,
     pub lng: f64,
@@ -107,6 +108,9 @@ pub struct RegisteredProp {
     /// sRGB body colour where the register says something the form can show (a
     /// container's waste fraction); `None` is the colour the form always had.
     pub paint: Option<u32>,
+    /// What it is called — a statue's title from Wikidata; `None` for the
+    /// city's lamp posts and bins, which have no name.
+    pub name: Option<String>,
 }
 
 /// A kind of content a register is the authority on.
@@ -165,13 +169,15 @@ fn parse_cell(text: &str) -> Option<RegisteredCell> {
             .collect(),
         props: doc
             .props
-            .into_iter()
-            .filter_map(|registers::Prop(lat, lng, slug, paint)| {
+            .iter()
+            .enumerate()
+            .filter_map(|(i, registers::Prop(lat, lng, slug, paint))| {
                 Some(RegisteredProp {
-                    lat,
-                    lng,
-                    kind: FurnitureKind::from_slug(&slug)?,
-                    paint,
+                    lat: *lat,
+                    lng: *lng,
+                    kind: FurnitureKind::from_slug(slug)?,
+                    paint: *paint,
+                    name: doc.prop_name(i).map(str::to_string),
                 })
             })
             .collect(),
@@ -266,6 +272,26 @@ pub fn registered_props(
     crate::systems::furniture::place_surveyed(tile, tile_m, seed, &points)
 }
 
+/// The names of this cell's registered props, at the tile-local point
+/// [`registered_props`] stands each one: what `WorldPlaces` calls a statue
+/// instead of "Artwork".
+#[must_use]
+pub fn registered_names(
+    cell: &RegisteredCell,
+    cx: i64,
+    cy: i64,
+    tile_m: f32,
+) -> Vec<(Vec2, String)> {
+    cell.props
+        .iter()
+        .filter_map(|p| {
+            let name = p.name.clone()?;
+            crate::systems::surveyed::cell_local(p.lat, p.lng, cx, cy, REGISTER_ZOOM, tile_m)
+                .map(|(x, z)| (Vec2::new(x, z), name))
+        })
+        .collect()
+}
+
 /// This cell's parking bays as rings in the tile-local metre frame. Kept whole
 /// where a ring leaves the cell: atlas files a bay under the cell of its first
 /// corner, and a bay is two metres across.
@@ -319,6 +345,33 @@ mod tests {
         );
     }
 
+    /// A statue's title reaches the prop, and stands where the prop stands.
+    #[test]
+    fn a_statue_keeps_its_title_into_the_cell_frame() {
+        let (cx, cy) = (8491, 5320);
+        let (north, west) = cartopolis_core::world::tile_to_lat_lng(cx, cy, REGISTER_ZOOM);
+        let (lat, lng) = (north - 0.0005, west + 0.0005);
+        let cell = parse_cell(&format!(
+            r#"{{"prop_names":["","Het Peerd van Ome Loeks"],"props":[[{lat},{lng},"lamp"],[{lat},{lng},"artwork"]]}}"#
+        ))
+        .unwrap();
+        assert_eq!(cell.props[0].name, None);
+        assert_eq!(
+            cell.props[1].name.as_deref(),
+            Some("Het Peerd van Ome Loeks")
+        );
+
+        let tile_m = 1000.0;
+        let names = registered_names(&cell, cx, cy, tile_m);
+        assert_eq!(names.len(), 1, "the lamp has no name to give");
+        let (x, z) =
+            crate::systems::surveyed::cell_local(lat, lng, cx, cy, REGISTER_ZOOM, tile_m).unwrap();
+        assert_eq!(
+            names[0],
+            (Vec2::new(x, z), "Het Peerd van Ome Loeks".to_string())
+        );
+    }
+
     /// Suppression is per kind: a cell that supplies trees and lamp posts says
     /// nothing about benches, so the BGT's benches must survive over it.
     #[test]
diff --git a/crates/cartopolis/src/systems/map/world_places.rs b/crates/cartopolis/src/systems/map/world_places.rs
index 36e87064..dae68d9d 100644
--- a/crates/cartopolis/src/systems/map/world_places.rs
+++ b/crates/cartopolis/src/systems/map/world_places.rs
@@ -42,6 +42,10 @@ pub struct CellPlaces {
     /// recipe nothing calls plus three arms here that exist only to say "never
     /// reached".
     pub colliders: Vec<(Vec2, f32)>,
+    /// Names for props standing at these tile-local points — a statue's title
+    /// from Wikidata (`municipal::registered_names`), which the `furniture`
+    /// it stands for cannot carry. See [`artwork_name`].
+    pub prop_names: Vec<(Vec2, String)>,
     pub pois: Vec<Poi>,
     pub addresses: Vec<Address>,
     /// Drivable centrelines for `systems::traffic`. Carried here rather than in
@@ -109,6 +113,17 @@ pub struct SeatSpot {
 }
 
 impl Interactable {
+    /// The prompt's descriptive suffix: [`InteractKind::detail`], and for a prop
+    /// that has a name of its own, what it is — "Het Peerd van Ome Loeks
+    /// (Artwork)", where a nameless one is just "Artwork".
+    #[must_use]
+    pub fn detail(&self) -> Option<&'static str> {
+        match self.kind {
+            InteractKind::Prop(kind) if self.name != prop_name(kind) => Some(prop_name(kind)),
+            kind => kind.detail(),
+        }
+    }
+
     /// Where on this thing an avatar standing at `from` would sit, or `None` if
     /// nobody sits on it.
     ///
@@ -179,6 +194,7 @@ impl InteractKind {
             Self::Prop(FurnitureKind::Bench | FurnitureKind::PicnicTable) => "Sit at",
             Self::Prop(FurnitureKind::Board) => "Read",
             Self::Prop(FurnitureKind::Fountain) => "Watch",
+            Self::Prop(FurnitureKind::Artwork) => "Look at",
             Self::Prop(FurnitureKind::Car) => "Drive",
             Self::Prop(_) => "Use",
         }
@@ -236,6 +252,35 @@ fn prop_name(kind: FurnitureKind) -> &'static str {
     }
 }
 
+/// How near a name must stand to an artwork to be its name: the same point,
+/// read twice — off one `pois` feature, or off one register row — so equal to
+/// the bit, and this only absorbs the rounding of two conversions.
+const SAME_SPOT_M: f32 = 0.5;
+
+/// An artwork's own name, or `None` for "Artwork".
+///
+/// Two sources, both at the prop's own point: the register's (a statue
+/// Wikidata added, `prop_names`), and OpenStreetMap's — a named
+/// `tourism=artwork` is read twice from the tile, once as the furniture it
+/// is drawn as and once as a named place ([`Poi`]). The prop takes that name
+/// and the place is marked `taken`, so one statue is one prompt. Before this
+/// the two stood on one point, and the unnamed prop, listed first, won every
+/// tie: the prompt said "Artwork" with the title a centimetre away.
+fn artwork_name(
+    at: Vec2,
+    prop_names: &[(Vec2, String)],
+    pois: &[Poi],
+    taken: &mut [bool],
+) -> Option<String> {
+    let near = |p: Vec2| p.distance_squared(at) < SAME_SPOT_M * SAME_SPOT_M;
+    if let Some((_, name)) = prop_names.iter().find(|(p, _)| near(*p)) {
+        return Some(name.clone());
+    }
+    let i = (0..pois.len()).find(|&i| !taken[i] && near(Vec2::new(pois[i].x, pois[i].z)))?;
+    taken[i] = true;
+    Some(pois[i].name.clone())
+}
+
 /// Whether walking up to this form should offer the player anything.
 ///
 /// Solid and interactable are separate questions, and the street lighting is what
@@ -405,6 +450,8 @@ impl WorldPlaces {
         let mut props: Vec<(Vec2, f32)> = Vec::new();
         let mut jets: Vec<Vec2> = Vec::new();
         let mut lamps: Vec<Vec3> = Vec::new();
+        // The named places an artwork took its name from (`artwork_name`).
+        let mut taken_pois = vec![false; places.pois.len()];
 
         for f in &places.furniture {
             let pos = origin + Vec2::new(f.x, f.z);
@@ -428,14 +475,27 @@ impl WorldPlaces {
             if afloat || !prop_interactable(f.kind) {
                 continue;
             }
+            let name = (f.kind == FurnitureKind::Artwork)
+                .then(|| {
+                    artwork_name(
+                        Vec2::new(f.x, f.z),
+                        &places.prop_names,
+                        &places.pois,
+                        &mut taken_pois,
+                    )
+                })
+                .flatten();
             interactables.push(Interactable {
                 pos,
                 yaw: f.yaw,
-                name: prop_name(f.kind).to_string(),
+                name: name.unwrap_or_else(|| prop_name(f.kind).to_string()),
                 kind: InteractKind::Prop(f.kind),
             });
         }
-        for p in places.pois {
+        for (p, taken) in places.pois.into_iter().zip(taken_pois) {
+            if taken {
+                continue;
+            }
             interactables.push(Interactable {
                 pos: origin + Vec2::new(p.x, p.z),
                 yaw: 0.0,
@@ -859,6 +919,69 @@ mod tests {
         assert_eq!(places.props().count(), 0, "but never a wall");
     }
 
+    /// A statue is called by its title — OSM's, read off the same `pois`
+    /// feature, or Wikidata's from the register — and is one prompt, not a
+    /// nameless "Artwork" standing on its own title.
+    #[test]
+    fn an_artwork_is_called_by_its_title() {
+        let mut places = WorldPlaces::default();
+        places.insert_cell(
+            (0, 0),
+            0.0,
+            0.0,
+            CellPlaces {
+                furniture: vec![
+                    furniture(0.0, 0.0, FurnitureKind::Artwork),
+                    furniture(50.0, 0.0, FurnitureKind::Artwork),
+                    furniture(100.0, 0.0, FurnitureKind::Artwork),
+                ],
+                pois: vec![
+                    Poi {
+                        x: 0.0,
+                        z: 0.0,
+                        name: "Het Peerd van Ome Loeks".into(),
+                        category: PoiCategory::Culture,
+                        kind: Some("Artwork"),
+                    },
+                    poi(110.0, 0.0, "De Drie Uiltjes"),
+                ],
+                prop_names: vec![(Vec2::new(50.0, 0.0), "Landbouw en Veeteelt".into())],
+                ..Default::default()
+            },
+        );
+        let prompt = |at: f32| places.nearest(Vec2::new(at, 0.0), 1.0).unwrap();
+
+        let osm = prompt(0.0);
+        assert_eq!(osm.name, "Het Peerd van Ome Loeks");
+        assert!(osm.kind == InteractKind::Prop(FurnitureKind::Artwork));
+        assert_eq!(
+            (osm.kind.verb(), osm.detail()),
+            ("Look at", Some("Artwork"))
+        );
+        assert_eq!(
+            places.within(Vec2::ZERO, 1.0).count(),
+            1,
+            "the place it was named from is not a second prompt"
+        );
+
+        assert_eq!(
+            prompt(50.0).name,
+            "Landbouw en Veeteelt",
+            "Wikidata's title"
+        );
+
+        let nameless = prompt(100.0);
+        assert_eq!(
+            (nameless.name.as_str(), nameless.detail()),
+            ("Artwork", None)
+        );
+        assert_eq!(
+            prompt(110.0).name,
+            "De Drie Uiltjes",
+            "a café ten metres off stays itself"
+        );
+    }
+
     /// A street and a number make one label; a number on its own still answers.
     #[test]
     fn addresses_read_as_a_street_and_a_number() {
diff --git a/crates/cartopolis/src/systems/player/interact.rs b/crates/cartopolis/src/systems/player/interact.rs
index 37ea1221..342754fd 100644
--- a/crates/cartopolis/src/systems/player/interact.rs
+++ b/crates/cartopolis/src/systems/player/interact.rs
@@ -199,7 +199,7 @@ impl TargetInfo {
             name: i.name.clone(),
             glyph: i.kind.glyph(),
             verb: i.kind.verb(),
-            detail: i.kind.detail(),
+            detail: i.detail(),
             pos: i.pos,
             seat: i.seat_spot(from),
             prim_id: None,
@@ -688,9 +688,7 @@ pub fn track_interaction_target(
 
     let nearest = places.nearest(pos, INTERACT_RADIUS);
     let changed = match (&state.target, nearest) {
-        (Some(a), Some(b)) => {
-            a.verb != b.kind.verb() || a.detail != b.kind.detail() || a.name != b.name
-        }
+        (Some(a), Some(b)) => a.verb != b.kind.verb() || a.detail != b.detail() || a.name != b.name,
         (None, None) => false,
         _ => true,
     };
diff --git a/docs/notes/municipal-registers.md b/docs/notes/municipal-registers.md
index db6a98da..e9b97ed1 100644
--- a/docs/notes/municipal-registers.md
+++ b/docs/notes/municipal-registers.md
@@ -1,7 +1,7 @@
 ---
 topic: map
 triggers: [municipal.rs, pipeline/registers.rs, formats/registers.rs, "registers/", Register, Source, Yields, Supply, REGISTERS, bomen, lichtmasten, municipal trees, street lighting, Groningen, maps.groningen.nl, WFS, city register, the study quay, BOOMHOOGTE, FRACTIE, containers, laadpalen, fonteinen, parkeervakken, parking bays, park_in_bays, Wikidata, public art, statues, artwork, benches, speelplekken, Kunstpunt, kunstsoort, Overpass, osm_has, Nijmegen, Amsterdam, Rotterdam, "Den Haag", Utrecht, ArcGIS]
-updated: 2026-11-07
+updated: 2026-11-29
 ---
 
 # The trees a city surveys, where the country's register is empty
@@ -190,6 +190,17 @@ already in OSM, **16 added**; 30 dropped as on a wall or in the paving.
 Wikidata's coordinates are rougher than a survey — usually metres, sometimes
 tens — so a statue is on the right square, not necessarily on its exact spot.
 
+**A statue is called by its title** (2026-11-29). The art query asks each work's
+label, Dutch else English — over central Groningen all 52 works have one — and
+the cell carries it as `prop_names`, index for index with `props`: a key of its
+own, because a fifth element of `Prop` would make every installed client drop
+the cell. OSM's own artworks needed no new data: a named `tourism=artwork` is in
+the tile's `pois` twice, as the furniture and as a named place on the same point,
+and the unnamed prop won the tie in `WorldPlaces::nearest`. The prop now takes
+the place's name and the place is dropped (`world_places::artwork_name`), so the
+prompt reads "Look at Het Peerd van Ome Loeks (Artwork)". A cell written before
+this has no names and reads as before; a re-run of `registers` brings them.
+
 ## Asking external services as little as possible
 
 A `registers` run asks each source **once**: one WFS request per city layer (nine
@@ -312,8 +323,9 @@ operational database and a ninth band costs nothing to add there.
 - **Two cities.** Every other municipality needs its own entry in atlas's
   `REGISTERS`: its endpoint, its layer and field names, its readers. What the
   others publish is below.
-- **Artwork names.** Wikidata has the title of every statue; the cell format
-  carries none yet, so the proximity prompt says "Artwork".
+- **Only the title.** Who a memorial commemorates (`P547`), its maker (`P170`)
+  and year are on Wikidata too and not shown; the title often says the first
+  ("gedenkteken Ben Ali Libi"). OSM artworks without a `name` stay "Artwork".
 - **Most of the city's sculpture is not drawn.** ~370 works Wikidata files as
   sculpture or work of art are left out until something open says which stand
   free (above).