pinballmap / pbm

Pinball Map
https://pinballmap.com
GNU General Public License v3.0
108 stars 25 forks source link

Create geographic boundaries so that Contact/Suggested Locations go to appropriate admin #1089

Closed RyanTG closed 2 years ago

RyanTG commented 5 years ago

Goal: If a user is on regionless (or the new app) and they use the Contact or Suggest a Location forms, the message goes to the appropriate admin.

Currently:

RyanTG commented 5 years ago

Also, on the regionless suggest a location form, we could add a "region" dropdown. Sometimes people use this form, but they intend for the location to be in a certain region. Usually I can figure it out...

ericwagericwag commented 5 years ago

Not sure if this comment is helpful, but since I thought about it, I thought I'd pass it along.

In the Bay Area Region, it was very difficult to draw boundary lines for the various zones in the Region. [I understand other Regions (Portland?) use Zones to denote neighborhoods within a city, but we use them to denote groups of cities / towns.]

Sometimes geographic features (bodies of water, mountains) are useful. But in other cases, there is no easy way to define boundaries.

After lots of trial and error, I found it useful to define the bounds of my region's Zones (and my region's boundaries) by County. As you probably know, everything from San Francisco to San Jose is one big strip city with lots of little towns along the way. Using County helped me draw boundaries in a non-arbitrary fashion. For example, the Bay Area region's counties are... Alameda County Contra Costa County Marin County Napa County Solano County Sonoma County Santa Cruz County San Mateo County San Francisco County Santa Clara County

Perhaps this could be helpful in defining geographic boundaries in states which have multiple regions. You'd have to kick it back to the Regional admins to define who owns what, but at least it would be a start.

In researching this a bit, I found two data sources which could be helpful.

(A) Here is a USGS map layer defining the boundaries of county and county "equivalents". (Louisiana has "parishes" and Alaska has "boroughs" https://nationalmap.gov/small_scale/mld/countyp.html

(B) Here is a commercial package which maps Zip codes to counties. https://www.unitedstateszipcodes.org/zip-code-database/

Not sure if any of this is useful, but there you go.

RyanTG commented 5 years ago

Personally, I hate Zones. They're a disaster! They're not remotely consistent from one region to another, and most regions don't have them at all. The updated app doesn't use them for now, because they don't really fit into the design scheme/flow.

I do agree that using a County or Zip or Neighborhood dataset could help automatically populate them.

For this particular issue, though, I think we simply need to create a bounding box for each region. The bounding box will be TopLeft lat/lon, TopRight lat/lon, BottomRight lat/lon, BottomLeft lat/lon of all the points currently into the region. That will create a rough boundary that we can then direct these submissions into.

scottwainstock commented 5 years ago

I'm going to use the "near" functionality rather than a bounding box... similar concept... I'll search within a 200 mile radius, grab the first region I find.

scottwainstock commented 5 years ago

Added the ability to send lat/lon to the location suggestion endpoint: 650e3ff5bb4211ba135d14c133777998d12397e1

I deployed that. I'll add the ability to send lat/lon to the contact endpoint next.

cc @bpoore

scottwainstock commented 5 years ago

Thinking about this a little more... I get how a "closest region within 200 miles" won't work for places like Japan. So, I'll add in the bounding boxes. In the meantime we can use the new lat/lon interface... that isn't going to change after I add the bounding.

RyanTG commented 5 years ago

Sweet, thanks.

So if it finds more than one within 200 miles it chooses the closest?

I’ll monitor how well this is working, given the widely different sizes of regions (like Colorado vs Redding). It searches for the closest region lay/lon centerpoint, right? And not the closest location and checks the region of that closest location?

Never mind just saw your comment

scottwainstock commented 5 years ago

@RyanTG The gem we're using seems to do the reverse of what we want to do with bounding boxes... so what do you think about this functionality instead?

To search for objects near a certain point where each object has a different distance requirement (which is defined in the database), you can pass a column name for the radius:

Venue.near([40.71, 99.23], :effective_radius)

That way we define an "effective_radius" for each region... larger ones for places like Japan... smaller ones for places like Portland.

RyanTG commented 5 years ago

Yeah I like that idea. I was wondering if that was an option. Should I define the radii?

scottwainstock commented 5 years ago

I'll create the field and default them all to 200 miles, make the field editable in rails admin, and we can chip away on accuracy from there. None of this should impact production right now anyway, it'll only get invoked when you pass a lat/lon to suggest/contact API endpoints... so we have some time.

I bet there are online tools that give you good visualizations of area given a center lat/lon point and a mileage for radius.

RyanTG commented 5 years ago

I could also open a table in pgadmin or qgis and analyze it.

RyanTG commented 5 years ago

Would be cool to use that value for the events radius, too.

Only minor downside is places like Japan and Finland are super oblong, so the radius will pull in stuff that’s outside the country.

scottwainstock commented 5 years ago

f714244b750d6de82651aea7f202c3e0e15d25b1 I'll add this functionality to the comment endpoint too.

scottwainstock commented 5 years ago

comment endpoint: 8c9d644644e8f0e2290ec5d6beb2fddcf04f82a8

I'm going to move on to other app requirement issues... let me know if I missed anything here that the app needs.

cc @bpoore @RyanTG

RyanTG commented 5 years ago

Could we get this added to the staging server so we can test it?

scottwainstock commented 5 years ago

It's not on there? I thought I deployed/migrated both. That's my SOP.

On Mon, Mar 4, 2019 at 2:49 PM Ryan TG notifications@github.com wrote:

Could we get this added to the staging server so we can test it?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/scottwainstock/pbm/issues/1089#issuecomment-469453890, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK-LXB1lA6GkB1WeFtSSwbpGjIesDAAks5vTaMAgaJpZM4XgTYk .

RyanTG commented 5 years ago

Guh, it is. My mistake. I, uh, didn't look first.

RyanTG commented 5 years ago

Thanks. I removed the "For Mobile App" "pending review" labels, and will leave this issue open for the future, so we can add this feature to the website. (I know the effective radius field is on the website, but we also need the website to pass a lat/lon in those submissions)