-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating more filter options #101
Changes from 11 commits
5a74197
e507a88
b9d0795
72de1ae
0784e5b
7c08f36
38f7713
2d72132
aa738ee
26f477e
fc66606
79a0629
60f11c0
0cf1e84
4b83c94
97e660e
3ffa533
02d7c31
fc6cb05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -12,22 +12,131 @@ extension GDASpatialDataResultEntity: Typeable { | |||
|
||||
func isOfType(_ type: PrimaryType) -> Bool { | ||||
switch type { | ||||
case .transit: return isOfType(.transitStop) | ||||
case .transit: | ||||
return isOfType(.transitStop) | ||||
case .food: | ||||
return isFood() | ||||
case .landmarks: | ||||
return isLandmarks() | ||||
case .park: | ||||
return isPark() | ||||
case .hotel: | ||||
return isHotel() | ||||
} | ||||
} | ||||
|
||||
func isOfType(_ type: SecondaryType) -> Bool { | ||||
switch type { | ||||
case .transitStop: return isTransitStop() | ||||
case .transitStop: | ||||
return isTransitStop() | ||||
case .food: | ||||
return isFood() | ||||
case .landmarks: | ||||
return isLandmarks() | ||||
case .park: | ||||
return isPark() | ||||
case .hotel: | ||||
return isHotel() | ||||
} | ||||
} | ||||
|
||||
private func isTransitStop() -> Bool { | ||||
print("Raw superCategory: \(superCategory)") | ||||
guard let category = SuperCategory(rawValue: superCategory) else { | ||||
print("Failed to map superCategory to SuperCategory enum") | ||||
return false | ||||
} | ||||
print("Mapped category: \(category)") | ||||
let isTransitLocation = category == .mobility && localizedName.lowercased().contains(GDLocalizedString("osm.tag.bus_stop").lowercased()) | ||||
print("Transit location check: \(isTransitLocation)") | ||||
if isTransitLocation { | ||||
print("Transit location found: \(localizedName)") | ||||
} | ||||
return isTransitLocation | ||||
} | ||||
|
||||
//convinence store | ||||
private func isFood() -> Bool { | ||||
print("Raw superCategory: \(superCategory)") | ||||
guard let category = SuperCategory(rawValue: superCategory) else { | ||||
print("Failed to map superCategory to SuperCategory enum") | ||||
return false | ||||
} | ||||
print("Mapped category: \(category)") | ||||
let isFoodLocation = category == .places && | ||||
localizedName.lowercased().contains(GDLocalizedString("osm.tag.restaurant").lowercased()) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was suggesting matching the
where soundscape/apps/ios/GuideDogs/Code/Data/Models/Cache Models/GDASpatialDataResultEntity.swift Line 47 in efcfa26
|
||||
// let osmTags = ["amenity=restaurant", "amenity=bar", "amenity=cafe", "amenity=fast_food", "amenity=ice_cream", "amenity=pub"] | ||||
|
||||
// List of restaurant-related OSM tags using localized strings | ||||
print("Transit location check: \(isFoodLocation)") | ||||
|
||||
return category == .mobility && localizedName.lowercased().contains(GDLocalizedString("osm.tag.bus_stop").lowercased()) | ||||
if isFoodLocation { | ||||
print("Food location found: \(localizedName)") | ||||
} | ||||
|
||||
return isFoodLocation | ||||
} | ||||
|
||||
|
||||
|
||||
|
||||
private func isLandmarks() -> Bool { | ||||
guard let category = SuperCategory(rawValue: superCategory) else { | ||||
return false | ||||
} | ||||
|
||||
let landmarkKeywords = ["monument", "statue", "museum", "historic", "landmark", "cathedral"] | ||||
|
||||
for keyword in landmarkKeywords { | ||||
if localizedName.lowercased().contains(keyword) { | ||||
return true | ||||
} | ||||
} | ||||
|
||||
return category == .landmarks | ||||
} | ||||
|
||||
private func isPark() -> Bool { | ||||
guard let category = SuperCategory(rawValue: superCategory) else { | ||||
return false | ||||
} | ||||
|
||||
let parkKeywords = [ | ||||
"park", "garden", "green space", "recreation area", "playground", | ||||
"nature reserve", "botanical garden", "public garden", "field", "reserve" | ||||
] | ||||
|
||||
// Keywords to exclude parking lots | ||||
let excludeKeywords = [ | ||||
"parking lot", "car park", "parking", "garage", "park and ride" | ||||
] | ||||
|
||||
let lowercasedName = localizedName.lowercased() | ||||
|
||||
// Check if the name contains any park keyword | ||||
var containsParkKeyword = false | ||||
for keyword in parkKeywords { | ||||
if lowercasedName.contains(keyword) { | ||||
containsParkKeyword = true | ||||
break | ||||
} | ||||
} | ||||
|
||||
// Check if the name contains any exclude keyword | ||||
var containsExcludeKeyword = false | ||||
for keyword in excludeKeywords { | ||||
if lowercasedName.contains(keyword) { | ||||
containsExcludeKeyword = true | ||||
break | ||||
} | ||||
} | ||||
|
||||
return containsParkKeyword && !containsExcludeKeyword | ||||
} | ||||
|
||||
|
||||
|
||||
private func isHotel() -> Bool { | ||||
return false | ||||
} | ||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,30 @@ class GeoJsonFeature { | |
return | ||
} | ||
|
||
//TODO JON | ||
if value == "fast_food"{ | ||
superCategory = SuperCategory.foods | ||
return | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this not work to assign the supercategory? This feels like the right place to be doing the classification of GeoJSON features, so the later filtering logic can be based entirely on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think you can do the category assignment here. When the OSM feature is tagged with e.g. |
||
|
||
if value == "restaurants"{ | ||
superCategory = SuperCategory.foods | ||
return | ||
} | ||
|
||
|
||
if value == "food"{ | ||
superCategory = SuperCategory.foods | ||
return | ||
} | ||
|
||
|
||
if value == "deli"{ | ||
superCategory = SuperCategory.foods | ||
return | ||
} | ||
|
||
|
||
// Case: Banks | ||
if value == "bank" { | ||
superCategory = SuperCategory.places | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,11 @@ struct NearbyTableFilter: Equatable { | |
static var defaultFilters: [NearbyTableFilter] { | ||
return [ | ||
.defaultFilter, | ||
NearbyTableFilter(type: .transit) | ||
NearbyTableFilter(type: .transit), | ||
NearbyTableFilter(type: .food), | ||
NearbyTableFilter(type: .landmarks), | ||
NearbyTableFilter(type: .park), | ||
NearbyTableFilter(type: .hotel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be consistent with pluralization, both in variable names and displayed strings. Transit and Food are both collective nouns, but Landmarks, Parks, and Hotels need a trailing "s". |
||
] | ||
} | ||
|
||
|
@@ -50,12 +54,24 @@ struct NearbyTableFilter: Equatable { | |
self.type = type | ||
|
||
if let type = type { | ||
switch type { | ||
case .transit: | ||
self.localizedString = GDLocalizedString("filter.transit") | ||
self.image = UIImage(named: "Transit") | ||
} | ||
} else { | ||
switch type { | ||
case .transit: | ||
self.localizedString = GDLocalizedString("filter.transit") | ||
self.image = UIImage(named: "Transit") | ||
case .food: | ||
self.localizedString = GDLocalizedString("filter.food_drink") | ||
self.image = UIImage(named: "Food and Drinks") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these icons exist? I see an image next to Transit, but not the others. |
||
case .landmarks: | ||
self.localizedString = GDLocalizedString("filter.landmarks") | ||
self.image = UIImage(named: "Landmarks") | ||
case .park: | ||
self.localizedString = GDLocalizedString("filter.park") | ||
self.image = UIImage(named: "Parks") | ||
case .hotel: | ||
self.localizedString = GDLocalizedString("filter.hotel") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This key is missing from the English localizations. |
||
self.image = UIImage(named: "Hotel") | ||
} | ||
} else { | ||
// There is no `PrimaryType` filter selected | ||
self.localizedString = GDLocalizedString("filter.all") | ||
self.image = UIImage(named: "AllPlaces") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't include
amenity=
here. These should be the tag values, not keys.