From 135a96d43d656b6682ae60ab29b79f2dfae52be9 Mon Sep 17 00:00:00 2001 From: silkfiy Date: Mon, 9 Nov 2026 21:22:04 -0800 Subject: [PATCH 1/4] Change 'Library' quick search to Study --- assets/esri_map_assets/mapConfig.json | 2 +- .../esrimap_study_exceptions.dart | 257 ++++++++++++++++++ .../esrimap_search_service.dart | 62 ++++- .../esrimap_ai_search_sheet.dart | 2 +- lib/ui/esrimap/esrimap.dart | 38 ++- .../esrimap_suggestions_panel_test.dart | 2 +- 6 files changed, 350 insertions(+), 13 deletions(-) create mode 100644 lib/core/models/esri_map_models/esrimap_study_exceptions.dart diff --git a/assets/esri_map_assets/mapConfig.json b/assets/esri_map_assets/mapConfig.json index 684b2dd45..695223e2d 100644 --- a/assets/esri_map_assets/mapConfig.json +++ b/assets/esri_map_assets/mapConfig.json @@ -149,7 +149,7 @@ "color": "#00C6D7" }, { - "label": "Library", + "label": "Study", "poiClass": "Library", "icon": "menu_book", "color": "#D462AD" diff --git a/lib/core/models/esri_map_models/esrimap_study_exceptions.dart b/lib/core/models/esri_map_models/esrimap_study_exceptions.dart new file mode 100644 index 000000000..be9f82b98 --- /dev/null +++ b/lib/core/models/esri_map_models/esrimap_study_exceptions.dart @@ -0,0 +1,257 @@ +/// ============================================================================ +/// File: esrimap_study_exceptions.dart +/// Description: Hand-audited study locations that the four base Study +/// aggregation legs miss, queried as a fifth leg by the Study +/// quick search. +/// ============================================================================ +/// +/// Provenance: hand-compiled from a live API audit on 2026-11-08; every +/// matchName was verified against a live response on the same date. Backend +/// data enrichment is the proper long-term fix. This table should shrink +/// over time, not grow. + +/// Which endpoint an exception entry queries. +enum StudyExceptionSource { + /// Queries the POI search endpoint. + poi, + + /// Queries the buildings search endpoint. + buildings, +} + +/// One hand-audited study location that the base Study legs miss. +class StudyException { + /// Query term sent to the search endpoint. + final String queryTerm; + + /// Endpoint this entry queries. + final StudyExceptionSource source; + + /// Exact result names (case-insensitive) to accept from the query. + final List matchNames; + + /// Provenance or approximation note for future maintainers. + final String note; + + /// Constructs a [StudyException] instance. + const StudyException({required this.queryTerm, required this.source, required this.matchNames, required this.note}); + + /// Whether [name] equals one of the match names, case-insensitively. + bool matches(String name) => matchNames.any((m) => m.trim().toLowerCase() == name.trim().toLowerCase()); +} + +/// The hand-audited exception table for the Study quick search. +class StudyExceptions { + /// All exception entries, in table order. + static const List entries = [ + // Eighth College: hall lounges are proxied by their buildings. + StudyException( + queryTerm: 'Azad', + source: StudyExceptionSource.buildings, + matchNames: ['Azad'], + note: 'proxy for hall lounges', + ), + StudyException( + queryTerm: 'Podemos', + source: StudyExceptionSource.buildings, + matchNames: ['Podemos'], + note: 'proxy for hall lounges', + ), + StudyException( + queryTerm: 'Pulse', + source: StudyExceptionSource.buildings, + matchNames: ['Pulse'], + note: 'proxy for hall lounges', + ), + StudyException( + queryTerm: 'Sankofa', + source: StudyExceptionSource.buildings, + matchNames: ['Sankofa'], + note: 'proxy for hall lounges', + ), + StudyException( + queryTerm: 'Survivance', + source: StudyExceptionSource.buildings, + matchNames: ['Survivance'], + note: 'proxy for hall lounges', + ), + StudyException( + queryTerm: "Angela's Space", + source: StudyExceptionSource.poi, + matchNames: ["Drop-off at Angela's Space"], + note: 'drop-off POI filed under Sustainability - Compost Locations; approximate', + ), + // Muir College + StudyException( + queryTerm: 'Tioga Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Tioga Hall'], + note: 'proxy for Tioga residence halls', + ), + StudyException( + queryTerm: 'Tuolumne Apartments', + source: StudyExceptionSource.poi, + matchNames: ['Tuolumne Apartments'], + note: 'proxy for Tenaya residence halls; POI is filed under Classrooms', + ), + StudyException( + queryTerm: 'Tamarack Apartments', + source: StudyExceptionSource.poi, + matchNames: ['Tamarack Apartments'], + note: 'a "Hydration Location - Tamarack Apartments" namesake is excluded by the exact match', + ), + StudyException( + queryTerm: 'Pines Restaurant', + source: StudyExceptionSource.poi, + matchNames: ['Pines Restaurant'], + note: 'Dining-class study spot', + ), + StudyException( + queryTerm: "John's Place and Market", + source: StudyExceptionSource.poi, + matchNames: ["John's Place and Market"], + note: 'outdoor seating', + ), + // Revelle College + StudyException( + queryTerm: 'Argo Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Argo Hall'], + note: 'Fleet has no data point - excluded; "Wells Fargo Hall" is excluded by the exact match', + ), + StudyException( + queryTerm: 'Charles David Keeling Apartments', + source: StudyExceptionSource.buildings, + matchNames: [ + 'Charles David Keeling Apartments 1', + 'Charles David Keeling Apartments 2', + 'Charles David Keeling Apartments 3', + ], + note: 'proxy for Keeling 1 and 3 lounges', + ), + StudyException( + queryTerm: 'Harlan Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Harlan Hall'], + note: 'proxy for floor lounges', + ), + StudyException( + queryTerm: 'Frankfurter Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Frankfurter Hall'], + note: 'proxy for floor lounges', + ), + StudyException( + queryTerm: 'Stewart Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Stewart Hall'], + note: 'proxy for floor lounges', + ), + // Warren College + StudyException( + queryTerm: 'Warren Student Activity Center', + source: StudyExceptionSource.poi, + matchNames: ['Warren Student Activity Center'], + note: 'The Courtroom; precedes the buildings twin so the richer record wins the dedupe', + ), + StudyException( + queryTerm: 'Warren Student Activity Center', + source: StudyExceptionSource.buildings, + matchNames: ['Warren Student Activity Center'], + note: 'fallback if the POI is ever removed', + ), + StudyException( + queryTerm: 'Canyon Vista Marketplace', + source: StudyExceptionSource.poi, + matchNames: ['Canyon Vista Marketplace'], + note: 'Dining-class study spot', + ), + // Sixth College + StudyException( + queryTerm: 'Commuter Center', + source: StudyExceptionSource.poi, + matchNames: ['Commuter Center'], + note: 'misfiled under Department Offices', + ), + // Seventh College + StudyException( + queryTerm: 'North Break', + source: StudyExceptionSource.poi, + matchNames: ['Seventh College- North Break (Game Room & Study Room)'], + note: 'misfiled under Mobility; approximate', + ), + // ERC + StudyException( + queryTerm: 'Africa Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Africa Hall'], + note: 'proxy for continent-hall lounges', + ), + StudyException( + queryTerm: 'Asia Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Asia Hall'], + note: 'proxy for continent-hall lounges', + ), + StudyException( + queryTerm: 'Europe Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Europe Hall'], + note: 'proxy for continent-hall lounges', + ), + StudyException( + queryTerm: 'Latin America Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Latin America Hall'], + note: 'proxy for continent-hall lounges', + ), + StudyException( + queryTerm: 'North America Hall', + source: StudyExceptionSource.buildings, + matchNames: ['North America Hall'], + note: 'proxy for continent-hall lounges', + ), + StudyException( + queryTerm: 'Asante Meeting Rooms', + source: StudyExceptionSource.poi, + matchNames: ['Asante Meeting Rooms'], + note: 'I-House; an "Asante House" namesake is excluded by the exact match', + ), + StudyException( + queryTerm: 'Cuzco House', + source: StudyExceptionSource.poi, + matchNames: ['Cuzco House'], + note: 'I-House', + ), + StudyException( + queryTerm: 'Kathmandu House', + source: StudyExceptionSource.poi, + matchNames: ['Kathmandu House'], + note: 'I-House', + ), + StudyException( + queryTerm: 'Student Activities Center', + source: StudyExceptionSource.poi, + matchNames: ['Student Activities Center'], + note: 'the "Fishbowl"; a Hydration Location namesake is excluded by the exact match', + ), + StudyException( + queryTerm: 'ERC Commuter Lounge', + source: StudyExceptionSource.poi, + matchNames: ['ERC Commuter Lounge'], + note: 'misfiled under Mobility', + ), + StudyException( + queryTerm: 'Great Hall', + source: StudyExceptionSource.poi, + matchNames: ['Great Hall'], + note: 'same-name POIs across classes dedupe to one pin; variants excluded by the exact match', + ), + StudyException( + queryTerm: 'Ventanas', + source: StudyExceptionSource.buildings, + matchNames: ['Ventanas'], + note: 'proxy for Cafe Ventanas; no cafe POI exists', + ), + ]; +} diff --git a/lib/core/services/esri_map_services/esrimap_search_service.dart b/lib/core/services/esri_map_services/esrimap_search_service.dart index 8c9ec9f4b..3efd43017 100644 --- a/lib/core/services/esri_map_services/esrimap_search_service.dart +++ b/lib/core/services/esri_map_services/esrimap_search_service.dart @@ -8,6 +8,7 @@ import 'dart:convert'; import 'dart:math' as math; import 'package:arcgis_maps/arcgis_maps.dart'; +import 'package:campus_mobile_experimental/core/models/esri_map_models/esrimap_study_exceptions.dart'; import 'package:campus_mobile_experimental/core/models/esri_map_models/map_search_result.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; @@ -37,7 +38,7 @@ class EsriMapSearchService { /// Performs an HTTP GET request to the specified [path] with optional query [params]. static Future> apiGet(String path, [Map? params]) async { final uri = Uri.parse('$BASE_URL/$path').replace(queryParameters: params); - final response = await http.get(uri); + final response = await http.get(uri).timeout(const Duration(seconds: 10)); final isResNotOk = response.statusCode != 200; if (isResNotOk) throw Exception('API error ${response.statusCode}: ${response.body}'); return jsonDecode(response.body) as Map; @@ -88,15 +89,16 @@ class EsriMapSearchService { } } - /// Queries POIs matching the search string [query]. - static Future> queryPOIs(String query) async { - final data = await apiGet('poi', {'q': query}); + /// Queries POIs matching the search string [query], up to [limit] results. + static Future> queryPOIs(String query, {int limit = 500}) async { + final data = await apiGet('poi', {'q': query, 'limit': '$limit'}); return parsePOIResults(data); } - /// Queries POIs belonging to a specific [classValue] (e.g. "Dining", "Parking"). - static Future> queryPOIsByClass(String classValue) async { - final data = await apiGet('poi', {'class': classValue, 'limit': '100'}); + /// Queries POIs belonging to a specific [classValue] (e.g. "Dining", "Parking"), + /// up to [limit] results. + static Future> queryPOIsByClass(String classValue, {int limit = 500}) async { + final data = await apiGet('poi', {'class': classValue, 'limit': '$limit'}); return parsePOIResults(data); } @@ -118,6 +120,52 @@ class EsriMapSearchService { .toList(); } + /// Merges the Study aggregation legs into a single deduplicated result list. + /// + /// The Student Services and Computer Lab legs fetch broader datasets, so only + /// results filed under the study subcategories are kept; library POIs and + /// library buildings are already scoped to study locations. The [exceptions] + /// list is appended as-is and bypasses the subtitle filters by design. + static List mergeStudyResults({ + required List libraryPois, + required List libraryBuildings, + required List studentServices, + required List computerLabs, + List exceptions = const [], + }) { + final lounges = studentServices.where((r) => r.subtitle.toLowerCase().contains('lounges')); + final labs = computerLabs.where((r) => r.subtitle.toLowerCase().contains('computer labs')); + + final uniqueNames = {}; + return [ + ...libraryPois, + ...libraryBuildings, + ...lounges, + ...labs, + ...exceptions, + ].where((r) => uniqueNames.add(r.name)).toList(); + } + + /// Fetches the hand-audited Study exception entries in parallel, keeping + /// only results whose names match an entry exactly. Each entry is guarded + /// so one failed request does not drop the others. + static Future> fetchStudyExceptions() async { + final lists = await Future.wait( + StudyExceptions.entries.map((entry) async { + try { + final results = entry.source == StudyExceptionSource.poi + ? await queryPOIs(entry.queryTerm) + : await queryBuildings(entry.queryTerm); + return results.where((r) => entry.matches(r.name)).toList(); + } catch (e) { + debugPrint('Study exception query failed (${entry.queryTerm}): $e'); + return const []; + } + }), + ); + return lists.expand((results) => results).toList(); + } + /// Loads cached building footprints from SharedPreferences. static Future loadCachedBuildings() async { final prefs = await SharedPreferences.getInstance(); diff --git a/lib/ui/esrimap/esri_map_widgets/esrimap_ai_search_sheet.dart b/lib/ui/esrimap/esri_map_widgets/esrimap_ai_search_sheet.dart index 0d3d959d4..803139eae 100644 --- a/lib/ui/esrimap/esri_map_widgets/esrimap_ai_search_sheet.dart +++ b/lib/ui/esrimap/esri_map_widgets/esrimap_ai_search_sheet.dart @@ -89,7 +89,7 @@ class _EsriAiSearchSheetState extends State { final s = subtitle.toLowerCase(); final isDining = s.contains('dining') || s.contains('food') || s.contains('coffee') || s.contains('cafe'); if (isDining) return Icons.restaurant; - final isLibrary = s.contains('library') || s.contains('academic'); + final isLibrary = s.contains('library') || s.contains('academic') || s.contains('study'); if (isLibrary) return Icons.menu_book; final isParking = s.contains('parking'); if (isParking) return Icons.local_parking; diff --git a/lib/ui/esrimap/esrimap.dart b/lib/ui/esrimap/esrimap.dart index cbe939a61..5ce0f1631 100644 --- a/lib/ui/esrimap/esrimap.dart +++ b/lib/ui/esrimap/esrimap.dart @@ -918,7 +918,9 @@ class _EsriMapState extends State with AutomaticKeepAliveClientMixin { final matched = _allPoiClasses.where((c) => c.toLowerCase().contains(q)).toList(); for (final cat in _categories) { - final matchesCat = cat.poiClassValue.toLowerCase().contains(q) && !matched.contains(cat.poiClassValue); + final matchesCat = + (cat.poiClassValue.toLowerCase().contains(q) || cat.label.toLowerCase().contains(q)) && + !matched.contains(cat.poiClassValue); if (matchesCat) matched.insert(0, cat.poiClassValue); } @@ -978,6 +980,17 @@ class _EsriMapState extends State with AutomaticKeepAliveClientMixin { } } + /// Runs one Study aggregation leg, degrading to an empty list on failure so + /// a single dead request yields partial results instead of a full error. + Future> _studyLeg(Future> leg) async { + try { + return await leg; + } catch (e) { + debugPrint('Study search leg failed: $e'); + return []; + } + } + /// Category search: queries matching locations and plots pins on the map. Future _performCategorySearch(EsriSearchCategory category) async { _cancelPendingSearch(); @@ -1000,8 +1013,27 @@ class _EsriMapState extends State with AutomaticKeepAliveClientMixin { try { var isRec = category.poiClassValue == 'Recreation Facilities'; var allResults = []; - - if (isRec) { + final isStudy = category.poiClassValue == 'Library'; + + if (isStudy) { + final legs = await Future.wait([ + _studyLeg(EsriMapSearchService.queryPOIsByClass('Library')), + _studyLeg(EsriMapSearchService.queryBuildings('library')), + _studyLeg(EsriMapSearchService.queryPOIsByClass('Student Services')), + // Load-bearing keyword: it matches the "Computer Labs" subcategory + // label and keeps the payload small; mergeStudyResults validates + // subtitles for precision. + _studyLeg(EsriMapSearchService.queryPOIs('Computer Lab')), + _studyLeg(EsriMapSearchService.fetchStudyExceptions()), + ]); + allResults = EsriMapSearchService.mergeStudyResults( + libraryPois: legs[0], + libraryBuildings: legs[1], + studentServices: legs[2], + computerLabs: legs[3], + exceptions: legs[4], + ); + } else if (isRec) { final baseSearch = EsriMapSearchService.queryPOIsByClass(category.poiClassValue); final extraSearches = >>[ EsriMapSearchService.queryBuildings('gym'), diff --git a/test/ui/esrimap/esrimap_suggestions_panel_test.dart b/test/ui/esrimap/esrimap_suggestions_panel_test.dart index 15c524e32..40fe2b4c9 100644 --- a/test/ui/esrimap/esrimap_suggestions_panel_test.dart +++ b/test/ui/esrimap/esrimap_suggestions_panel_test.dart @@ -14,7 +14,7 @@ void main() { const category = EsriSearchCategory(label: 'Dining', icon: Icons.restaurant, poiClassValue: 'Dining and Beverage'); const categories = [ category, - EsriSearchCategory(label: 'Library', icon: Icons.menu_book, poiClassValue: 'Library'), + EsriSearchCategory(label: 'Study', icon: Icons.menu_book, poiClassValue: 'Library'), EsriSearchCategory(label: 'Parking', icon: Icons.local_parking, poiClassValue: 'Parking'), EsriSearchCategory(label: 'Recreation', icon: Icons.fitness_center, poiClassValue: 'Recreation Facilities'), ]; From 1be0833fec3c2bdf10ac6a8bae00ff6215fdce41 Mon Sep 17 00:00:00 2001 From: silkfiy Date: Thu, 12 Nov 2026 12:07:28 -0800 Subject: [PATCH 2/4] Change exceptions list to be more accurate --- .../esrimap_study_exceptions.dart | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/core/models/esri_map_models/esrimap_study_exceptions.dart b/lib/core/models/esri_map_models/esrimap_study_exceptions.dart index be9f82b98..eabc07843 100644 --- a/lib/core/models/esri_map_models/esrimap_study_exceptions.dart +++ b/lib/core/models/esri_map_models/esrimap_study_exceptions.dart @@ -6,9 +6,9 @@ /// ============================================================================ /// /// Provenance: hand-compiled from a live API audit on 2026-11-08; every -/// matchName was verified against a live response on the same date. Backend -/// data enrichment is the proper long-term fix. This table should shrink -/// over time, not grow. +/// matchName was verified against a live response, with corrections +/// re-verified on 2026-11-12. Backend data enrichment is the proper +/// long-term fix. This table should shrink over time, not grow. /// Which endpoint an exception entry queries. enum StudyExceptionSource { @@ -89,16 +89,16 @@ class StudyExceptions { note: 'proxy for Tioga residence halls', ), StudyException( - queryTerm: 'Tuolumne Apartments', - source: StudyExceptionSource.poi, - matchNames: ['Tuolumne Apartments'], - note: 'proxy for Tenaya residence halls; POI is filed under Classrooms', + queryTerm: 'Tenaya Hall', + source: StudyExceptionSource.buildings, + matchNames: ['Tenaya Hall'], + note: 'proxy for Tenaya residence hall lounges', ), StudyException( queryTerm: 'Tamarack Apartments', - source: StudyExceptionSource.poi, - matchNames: ['Tamarack Apartments'], - note: 'a "Hydration Location - Tamarack Apartments" namesake is excluded by the exact match', + source: StudyExceptionSource.buildings, + matchNames: ['Tamarack Apartments East', 'Tamarack Apartments West'], + note: 'East and West buildings proxy for the complex lounges', ), StudyException( queryTerm: 'Pines Restaurant', @@ -166,13 +166,6 @@ class StudyExceptions { matchNames: ['Canyon Vista Marketplace'], note: 'Dining-class study spot', ), - // Sixth College - StudyException( - queryTerm: 'Commuter Center', - source: StudyExceptionSource.poi, - matchNames: ['Commuter Center'], - note: 'misfiled under Department Offices', - ), // Seventh College StudyException( queryTerm: 'North Break', From cd03c422416c5c734382718d8377fd05b71d71e8 Mon Sep 17 00:00:00 2001 From: silkfiy Date: Thu, 12 Nov 2026 12:20:11 -0800 Subject: [PATCH 3/4] Tighten study location list --- .../esri_map_services/esrimap_search_service.dart | 2 -- lib/ui/esrimap/esrimap.dart | 10 ++++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/core/services/esri_map_services/esrimap_search_service.dart b/lib/core/services/esri_map_services/esrimap_search_service.dart index 3efd43017..3eaa22761 100644 --- a/lib/core/services/esri_map_services/esrimap_search_service.dart +++ b/lib/core/services/esri_map_services/esrimap_search_service.dart @@ -127,7 +127,6 @@ class EsriMapSearchService { /// library buildings are already scoped to study locations. The [exceptions] /// list is appended as-is and bypasses the subtitle filters by design. static List mergeStudyResults({ - required List libraryPois, required List libraryBuildings, required List studentServices, required List computerLabs, @@ -138,7 +137,6 @@ class EsriMapSearchService { final uniqueNames = {}; return [ - ...libraryPois, ...libraryBuildings, ...lounges, ...labs, diff --git a/lib/ui/esrimap/esrimap.dart b/lib/ui/esrimap/esrimap.dart index 5ce0f1631..a66bb8a1e 100644 --- a/lib/ui/esrimap/esrimap.dart +++ b/lib/ui/esrimap/esrimap.dart @@ -1017,7 +1017,6 @@ class _EsriMapState extends State with AutomaticKeepAliveClientMixin { if (isStudy) { final legs = await Future.wait([ - _studyLeg(EsriMapSearchService.queryPOIsByClass('Library')), _studyLeg(EsriMapSearchService.queryBuildings('library')), _studyLeg(EsriMapSearchService.queryPOIsByClass('Student Services')), // Load-bearing keyword: it matches the "Computer Labs" subcategory @@ -1027,11 +1026,10 @@ class _EsriMapState extends State with AutomaticKeepAliveClientMixin { _studyLeg(EsriMapSearchService.fetchStudyExceptions()), ]); allResults = EsriMapSearchService.mergeStudyResults( - libraryPois: legs[0], - libraryBuildings: legs[1], - studentServices: legs[2], - computerLabs: legs[3], - exceptions: legs[4], + libraryBuildings: legs[0], + studentServices: legs[1], + computerLabs: legs[2], + exceptions: legs[3], ); } else if (isRec) { final baseSearch = EsriMapSearchService.queryPOIsByClass(category.poiClassValue); From daa017076038674a9600e2b8efefd99cbd34784f Mon Sep 17 00:00:00 2001 From: silkfiy Date: Thu, 12 Nov 2026 12:25:42 -0800 Subject: [PATCH 4/4] Apply dart formatting --- .../services/esri_map_services/esrimap_search_service.dart | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/core/services/esri_map_services/esrimap_search_service.dart b/lib/core/services/esri_map_services/esrimap_search_service.dart index 3eaa22761..ce931d869 100644 --- a/lib/core/services/esri_map_services/esrimap_search_service.dart +++ b/lib/core/services/esri_map_services/esrimap_search_service.dart @@ -136,12 +136,7 @@ class EsriMapSearchService { final labs = computerLabs.where((r) => r.subtitle.toLowerCase().contains('computer labs')); final uniqueNames = {}; - return [ - ...libraryBuildings, - ...lounges, - ...labs, - ...exceptions, - ].where((r) => uniqueNames.add(r.name)).toList(); + return [...libraryBuildings, ...lounges, ...labs, ...exceptions].where((r) => uniqueNames.add(r.name)).toList(); } /// Fetches the hand-audited Study exception entries in parallel, keeping