juanitacosmica / FinalProject_RoadTrippr

2 stars 4 forks source link

Use `location` When No Address #32

Open semionaut opened 2 years ago

semionaut commented 2 years ago

Nearby Search does not return adr_address so in place of this we use vicinity as a human-readable, and map-searchable output. Vicinity provides a simplified address format (without postal code).

Apparently, some locations don't contain full information for vicinity, for example parks which might not have a complete postal address, eg. Arbutus Lookout in Vancouver:

>>> print(json.dumps(sight_req, indent=4, sort_keys=True))
{
    "html_attributions": [],
    "results": [
        {
            "business_status": "OPERATIONAL",
            "geometry": {
                "location": {
                    "lat": 49.245286,
                    "lng": -123.1648432
                },
                "viewport": {
                    "northeast": {
                        "lat": 49.24663582989272,
                        "lng": -123.1634933701072
                    },
                    "southwest": {
                        "lat": 49.24393617010728,
                        "lng": -123.1661930298927
                    }
                }
            },
            "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/park-71.png",
            "icon_background_color": "#4DB546",
            "icon_mask_base_uri": "https://maps.gstatic.com/mapfiles/place_api/icons/v2/tree_pinlet",
            "name": "Arbutus Lookout",
            "opening_hours": {
                "open_now": true
            },
            "photos": [
                {
                    "height": 3210,
                    "html_attributions": [
                        "<a href=\"https://maps.google.com/maps/contrib/101506400271390830980\">A Google User</a>"
                    ],
                    "photo_reference": "Aap_uEDmDSg6BhAXybVuADbpKGwmPjwuYBG4QL5WQqPIIBBCMBnRjdStGqzAQXRWilLsk4i2NTpbRU2GlnrXOk3OK7fyaMQ-C162-jWkdbpLic8Bb0t87FTJkxPnfAWxX1Xo8c8zgPDunharfOCtNfytKg69SfhX-V79i_7aSU2cP7hY_VlE",
                    "width": 4816
                }
            ],
            "place_id": "ChIJaQBtpLtzhlQRaenNbvp15WQ",
            "plus_code": {
                "compound_code": "6RWP+43 Vancouver, British Columbia",
                "global_code": "84XR6RWP+43"
            },
            "rating": 4.6,
            "reference": "ChIJaQBtpLtzhlQRaenNbvp15WQ",
            "scope": "GOOGLE",
            "types": [
                "park",
                "point_of_interest",
                "establishment"
            ],
            "user_ratings_total": 11,
            "vicinity": "Vancouver"
        }
        ],
    "status": "OK"
}

When the API output contains low resolution for vicinity then roll_trip() needs to send location back to navigation.html for the map lookup. In such cases the user will receive no meaningful address information for that particular location.

In testing this is the first example I have seen of low-fidelity vicinity output, but there will likely be others.