Background: I'm trying to use google maps API and I've got to the point where I can get data from json files. I'm trying to update my dataset with the json file's information, but I'm having difficulties.
You'll be given an address range or street and a Latitude Longitude from the google's json files, and I need to check which address is corresponding to which json address.
The json file will have multiple blocks of code like what you see below:
"distance" : {
"text" : "999 ft",
"value" : 999
},
"duration" : {
"text" : "999 min",
"value" : 999
},
"end_address" : "3722-3788 Street, City, ST 11111, USA",
"end_location" : {
"lat" : 40.0000000,
"lng" : 100.0000000
},
My data will have Latitude, Longitude and an address where I can compare to see if my addresses are part of the json's addresses. The problem is, My data will have exactly where a house address is, while Google's (above) will have approximate/ the street they reside on.
Problem: My data will sometimes have a longitude of 40.0005001, latitude 99.799999 (which are close, but not equal) and an address of 3750 Street, City, ST 11111, USA (which is in the within the bounds, but not exactly the same).
Q: How do I check if my the json's end_address is close enough to my actual address? I don't need the house numbers exactly, mostly just the right street name, etc. (Note: all the fields we'll be comparing are strings, but can be converted to double if needed.)
I've tried comparing only 3 decimal places for each latitude and longitude, but it's not getting the comparisons right. Each would be lat/lng below would be rounded.
if (deliveryLatitude == endLatitude && deliveryLongitude == endLongitude) {