← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


commit 26cdc875bd2b3245e922f0e551e1fb8c4696e70f
parent db9798134739fa2df689d11da4e5e5f2dcea4fac
Author: Michael Camilleri <[email protected]>
Date:   Sat, 17 Oct 2026 05:22:27 +0900

Filter MapKit POI from user-defined POIs

Diffstat

MNotes/Design.md | 23++++++++++++++---------
MReportage/Views/Survey/PlacePicker.swift | 22+++++++++++++++++-----
MTests/Unit/PlacePickerTests.swift | 25+++++++++++++++++++++++++

3 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/Notes/Design.md b/Notes/Design.md

@@ -247,10 +247,14 @@ is a fallback if MapKit's terms turn out to forbid storing names.
 
 Candidates, in order:
 
-1. **The user's own places**, from history: saved places and every venue
-   answered before, ranked by distance from the current location, then by use
-   and recency. This needs no network, and covers most answers: 14 saved names
-   account for 80% of the archive's location answers.
+1. **The user's saved places**: the places they named themselves, ranked by
+   distance from the current location, then by use and recency. This needs no
+   network, and covers most answers: 14 saved names account for 80% of the
+   archive's location answers. As in Reporter, a venue picked from the
+   directory isn't added to this list. Venues answered before come back when
+   the directory lists them again, merged with their token, or in a search. A
+   place is saved when its token has no external ID; in the archive, no place
+   was used both ways.
 2. **Nearby places** from `MKLocalPointsOfInterestRequest`, when nothing in
    history is close.
 3. **Search** across history and MapKit together. MapKit matches queries in
@@ -268,11 +272,12 @@ In the survey (`PlacePicker`):
   spread of past answers, so the one used more is the better guess. A place's
   coordinate is the token's own, or else the centre of where its answers were
   given.
-- **Sections.** With a location: the user's places within 500 m, then nearby
-  MapKit places (within 250 m, closest first). Places further away are found
-  by searching. Without a location: all the user's places by use. A search
-  lists the user's matching places at any distance, then MapKit's results in
-  MapKit's order, biased to a 20 km region around the location.
+- **Sections.** With a location: the user's saved places within 500 m, then
+  nearby MapKit places (within 250 m, closest first). Places further away are
+  found by searching. Without a location: all the saved places by use. A
+  search lists the user's matching places, saved or venues, at any distance,
+  then MapKit's results in MapKit's order, biased to a 20 km region around
+  the location.
 - **Merging.** A MapKit place that's one of the user's places is shown as
   theirs, at MapKit's coordinate: the same MapKit ID, or a place without one
   with the same name within 200 m.

diff --git a/Reportage/Views/Survey/PlacePicker.swift b/Reportage/Views/Survey/PlacePicker.swift

@@ -41,10 +41,11 @@ struct PlaceSection: Identifiable, Hashable, Sendable {
 
 /// Searching, choosing and adding a place for one `location` question.
 ///
-/// Candidates come in the order the design gives: the user's own places near
-/// the report's location, ranked by distance, then nearby directory places.
-/// Places further away are found by searching, which looks through the
-/// user's places and the directory together. A directory place that's already one
+/// Candidates come in the order the design gives: the user's saved places
+/// near the report's location, ranked by distance, then nearby directory
+/// places. Places further away are found by searching, which looks through
+/// the user's places, including venues answered before, and the directory
+/// together. A directory place that's already one
 /// of the user's places is shown as theirs.
 @MainActor
 @Observable
@@ -252,7 +253,10 @@ final class PlacePicker {
     private func update() {
         let text = query.trimmingCharacters(in: .whitespacesAndNewlines)
         let origin = location?.coordinate
-        let matching = text.isEmpty ? entries : entries.filter { $0.text.localizedStandardContains(text) }
+        let matching =
+            text.isEmpty
+            ? entries.filter(\.isSavedPlace)
+            : entries.filter { $0.text.localizedStandardContains(text) }
         let own = PlaceRanking.rank(matching, from: origin).map { ranked in
             PlaceCandidate(
                 id: ranked.entry.id,
@@ -339,3 +343,11 @@ final class PlacePicker {
         String(candidate.id.dropFirst(mapKitPrefix.count))
     }
 }
+
+extension VocabularyEntry {
+    /// Whether the user saved the place by name, rather than answering with
+    /// a venue from a directory. As in Reporter, only saved places are listed
+    /// without a search: a venue answered before comes back when the
+    /// directory lists it again, or when it's searched for.
+    var isSavedPlace: Bool { externalID == nil }
+}

diff --git a/Tests/Unit/PlacePickerTests.swift b/Tests/Unit/PlacePickerTests.swift

@@ -212,6 +212,31 @@ struct PlacePickerTests {
         #expect(picker.sections.map(\.kind) == [.yours, .nearby])
     }
 
+    @Test("Venues are listed only when the directory has them or they're searched for")
+    func venues() async {
+        let entries = Self.entries + [
+            Self.entry(
+                "venue", "Ramen Shop", uses: 50, at: Self.north(20),
+                externalID: ExternalPlaceID(source: .foursquare, value: "F1")),
+            Self.entry(
+                "picked", "Bookshop", uses: 2, at: Self.north(40),
+                externalID: ExternalPlaceID(source: .mapKit, value: "M1")),
+        ]
+        let directory = FakeDirectory(nearby: [
+            Self.directoryPlace("M1", "Books & Co", at: Self.north(40))
+        ])
+        let picker = makePicker(entries: entries, directory: directory)
+        #expect(picker.candidate(id: "venue") == nil)
+        #expect(picker.candidate(id: "picked") == nil)
+
+        picker.setLocation(LocationContext(coordinate: Self.here))
+        await picker.settle()
+        #expect(ids(picker) == [.yours: ["bar", "cafe", "home"], .nearby: ["picked"]])
+
+        picker.query = "ramen"
+        #expect(ids(picker)[.yours] == ["venue"])
+    }
+
     @Test("Clearing removes the choice and the search")
     func clear() throws {
         let picker = makePicker()