Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/esri_map_assets/mapConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"color": "#00C6D7"
},
{
"label": "Library",
"label": "Study",
"poiClass": "Library",
"icon": "menu_book",
"color": "#D462AD"
Expand Down
250 changes: 250 additions & 0 deletions lib/core/models/esri_map_models/esrimap_study_exceptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
/// ============================================================================
/// 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, 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 {
/// 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<String> 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<StudyException> 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: 'Tenaya Hall',
source: StudyExceptionSource.buildings,
matchNames: ['Tenaya Hall'],
note: 'proxy for Tenaya residence hall lounges',
),
StudyException(
queryTerm: 'Tamarack Apartments',
source: StudyExceptionSource.buildings,
matchNames: ['Tamarack Apartments East', 'Tamarack Apartments West'],
note: 'East and West buildings proxy for the complex lounges',
),
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',
),
// 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',
),
];
}
55 changes: 48 additions & 7 deletions lib/core/services/esri_map_services/esrimap_search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -37,7 +38,7 @@ class EsriMapSearchService {
/// Performs an HTTP GET request to the specified [path] with optional query [params].
static Future<Map<String, dynamic>> apiGet(String path, [Map<String, String>? 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<String, dynamic>;
Expand Down Expand Up @@ -88,15 +89,16 @@ class EsriMapSearchService {
}
}

/// Queries POIs matching the search string [query].
static Future<List<MapSearchResult>> queryPOIs(String query) async {
final data = await apiGet('poi', {'q': query});
/// Queries POIs matching the search string [query], up to [limit] results.
static Future<List<MapSearchResult>> 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<List<MapSearchResult>> 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<List<MapSearchResult>> queryPOIsByClass(String classValue, {int limit = 500}) async {
final data = await apiGet('poi', {'class': classValue, 'limit': '$limit'});
return parsePOIResults(data);
}

Expand All @@ -118,6 +120,45 @@ 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<MapSearchResult> mergeStudyResults({
required List<MapSearchResult> libraryBuildings,
required List<MapSearchResult> studentServices,
required List<MapSearchResult> computerLabs,
List<MapSearchResult> 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 = <String>{};
return [...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<List<MapSearchResult>> 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 <MapSearchResult>[];
}
}),
);
return lists.expand((results) => results).toList();
}

/// Loads cached building footprints from SharedPreferences.
static Future<void> loadCachedBuildings() async {
final prefs = await SharedPreferences.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class _EsriAiSearchSheetState extends State<EsriAiSearchSheet> {
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;
Expand Down
Loading
Loading