-
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
Conversation
I feel like I am close but having trouble understanding why it isn't working. If I can get help with one of them, I can create other filters. |
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.
Can you provide a little more detail about what isn't working, what errors you're running into, etc.? I left a few comments/questions based on what jumps out to me in your diffs.
/* Open Street Map term. An ice cream shop is a place where ice cream is sold. */ | ||
"osm.tag.ice_cream" = "amenity=ice_cream"; | ||
|
||
/* Open Street Map term. A pub is a place selling beer and other alcoholic drinks; may also provide food or accommodation (UK). */ | ||
"osm.tag.pub" = "amenity=pub"; |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I was suggesting matching the amenity
attribute of the place, rather than its name. I haven't tested this, but I'm thinking all you'd have to do is something like:
let isFoodLocation = amenity == GDLocalizedString("osm.tag.restaurant")
where amenity
should be recognized as a field of GDASpatialDataResultEntity
per
soundscape/apps/ios/GuideDogs/Code/Data/Models/Cache Models/GDASpatialDataResultEntity.swift
Line 47 in efcfa26
@objc dynamic var amenity: String! |
if value == "fast_food"{ | ||
superCategory = SuperCategory.foods | ||
return | ||
} |
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.
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 superCategory
field.
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.
I still think you can do the category assignment here. When the OSM feature is tagged with e.g. leisure=playground
, the local variable type
will be leisure
here, and value
will be playground
.
Your code helped me gain a better understanding of it. Food saw more results however not all of them appeared. Landmarks seems to be working mostly well, some results dont match since I dont consdier them to be a landmark. For exmaple, the focus lab in Troy, NY isn't a landmark and I dont know why it is being classified as one. What should I do about it? |
Here are the OSM tags for the FOCUS Lab: https://www.openstreetmap.org/node/10565967149 Of note is the I searched for "gallery" in the Soundscape codebase, and found it here, being mapped to "landmark":
That code is part of the OSM data ingestion, specifically to add custom fields that Soundscape uses. I believe the mapping there is used to determine what sound effect should be played for each map feature (for example, a "safety" item plays a different sound than a "landmark" does). The list includes many different types of locations, most of which wouldn't be considered landmarks in the colloquial sense, so we can't really depend on the |
- need to fix OSM tags and isPark
Thanks, the feedback greatly helped! |
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.
Glad I could help. I assume you're still working on the other categories, cleaning up print statements, and adding some categorization test cases? I've also added a few more comments.
let lowercasedAmenity = amenity.lowercased() | ||
|
||
let isParkLocation = parkTags.contains(lowercasedAmenity) |
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.
You'd want to do exact comparison rather than substrings, no? Otherwise you wind up matching e.g. parking lots as parks.
let parkTags = [ | ||
GDLocalizedString("osm.tag.park"), | ||
GDLocalizedString("osm.tag.garden"), | ||
GDLocalizedString("osm.tag.green_space"), | ||
GDLocalizedString("osm.tag.recreation_area"), | ||
GDLocalizedString("osm.tag.playground"), | ||
GDLocalizedString("osm.tag.nature_reserve"), | ||
GDLocalizedString("osm.tag.botanical_garden"), | ||
GDLocalizedString("osm.tag.public_garden"), | ||
GDLocalizedString("osm.tag.field"), | ||
GDLocalizedString("osm.tag.reserve") | ||
] |
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.
I believe OSM tags are always in English, so no need to localize each of these. (I know I said to use localized strings, but that was when you were comparing against place names, which are in the local language.)
For test location (Latitude: 42.732782, Longitude: -73.68809) when I filter by park, I get a result named "leisure=garden". Do you know why? Is isPark how you want the other functions to be like? |
Maybe there's a nearby green area that's tagged in OSM as |
It turns out that the place name defined by localizedName is "leasure=garden". I tested the same logic for landmakrs and it works. I'll impelment it for the other functions soon. |
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.
The quick answer to your question is that if you simply tweak your localized strings to human-readable form, you'll wind up with nice human-readable names even for unnamed OSM entities. More feedback in comments below.
"osm.tag.park" = "leisure=park"; | ||
|
||
//TODO JON | ||
"osm.tag.garden" = "leisure=garden"; | ||
"osm.tag.playground" = "leisure=playground"; | ||
"osm.tag.nature_reserve" = "leisure=nature_reserve"; | ||
"osm.tag.botanical_garden" = "leisure=botanical_garden"; | ||
"osm.tag.public_garden" = "leisure=public_garden"; | ||
"osm.tag.field" = "leisure=field"; | ||
"osm.tag.reserve" = "leisure=reserve"; | ||
"osm.tag.green_space" = "leisure=green_space"; | ||
"osm.tag.recreation_area" = "leisure=recreation_area"; |
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.
These should be the human-friendly version of the text, e.g. "osm.tag.public_garden" = "Public Garden";
. This is what gets displayed in the UI when them entity doesn't have a name.
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 comment
The 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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
This key is missing from the English localizations.
if value == "fast_food"{ | ||
superCategory = SuperCategory.foods | ||
return | ||
} |
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.
I still think you can do the category assignment here. When the OSM feature is tagged with e.g. leisure=playground
, the local variable type
will be leisure
here, and value
will be playground
.
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 comment
The 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".
GDLocalizedString("osm.tag.restaurant"), | ||
GDLocalizedString("osm.tag.fast_food"), | ||
GDLocalizedString("osm.tag.cafe"), | ||
GDLocalizedString("osm.tag.bar"), | ||
GDLocalizedString("osm.tag.ice_cream"), | ||
GDLocalizedString("osm.tag.pub"), | ||
GDLocalizedString("osm.tag.coffee_shop") |
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.
You don't need to use localized strings here, because the OSM tag will always be e.g. "restaurant" regardless of what language the name of the restaurant is in. I think you're handling this properly in landmarks and parks below.
It looks good here, categories are working in my local area. I don't have any objection to you merging PRs in the future when you think they are ready. |
This makes it easier to filter places that are nearby.
Issue#82:
https://github.com/soundscape-community/soundscape/issues/82