Just to not re-invent the wheel. I assume some of you much smarter and better looking people have already used Google for geocoding and have gone to the trouble of creating all the BOs required to handle the results. (All I need is Lat and Long, but it seems like I have to work my way up the food tree.). Wondering if anyone wants to "share" their BO structure.
Part 2. I have the requirement to determine driving time between 2 locations, so my plan is to geocode each of them, then call the google distance api. Has anyone found a better, easier to use service besides google. Since I will be routing trucks, it would be a huge plus to be able to restrict roads that trucks are NOT allowed on.
Thanks
Bruce
Google Geocoding
-
- Posts: 50
- Joined: Sun Aug 10, 2008 7:40 pm
- Location: Tulsa, OK
- Contact:
Re: Google Geocoding
Pretty sure Google has no features for 'special' routing. You might take a look at PCMiler. It allows for various routing options; overhead height, no tolls, miles by state for State Fuel Tax requirements, etc. Don't remember it providing the time - we didn't need that. We have interfaced PCMiler with an Alpha5 system and before that Foxpro.
Don't remember the pricing for the server version.
Don't remember the pricing for the server version.
Dan
_______________________________________________
V8.4 Developer Edition Build 2722. MS SQL Windows
_______________________________________________
V8.4 Developer Edition Build 2722. MS SQL Windows
-
- Posts: 7523
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Google Geocoding
Check out the DISTANCE function available out-of-the-box. It may prove useful
Aware IM Support Team
-
- Posts: 50
- Joined: Sun Aug 10, 2008 7:40 pm
- Location: Tulsa, OK
- Contact:
Re: Google Geocoding
Mark showed me this once - which is quick and easy - and shows time. We use at a non-trucking client. You don't need a key.
Example:
DISPLAY URL 'https://www.google.com/maps/dir/'+Syste ... ip+',+USA/' IN NEW WINDOW
Example:
DISPLAY URL 'https://www.google.com/maps/dir/'+Syste ... ip+',+USA/' IN NEW WINDOW
Dan
_______________________________________________
V8.4 Developer Edition Build 2722. MS SQL Windows
_______________________________________________
V8.4 Developer Edition Build 2722. MS SQL Windows
-
- Posts: 50
- Joined: Sun Aug 10, 2008 7:40 pm
- Location: Tulsa, OK
- Contact:
Re: Google Geocoding
Sorry that didn't work like I thought.
'https://www.google.com/maps/dir/'+Syste ... ip+',+USA/' IN NEW WINDOW
'https://www.google.com/maps/dir/'+Syste ... ip+',+USA/' IN NEW WINDOW
Dan
_______________________________________________
V8.4 Developer Edition Build 2722. MS SQL Windows
_______________________________________________
V8.4 Developer Edition Build 2722. MS SQL Windows
Re: Google Geocoding
I have no problem in call the Google Rest function, just in parsing the return. I have used Postman and AppGyver and both can parse the request. However, I have not been able to in Aware. ALL I need is the lat and lng. The response looks like follows: It would be nice if I could start with the node "location" (under geometry) and just get the 2 fields. Has anyone figured out how to do this?
Thanks
Bruce
{
"results" : [
{
"address_components" : [
{
"long_name" : "8439",
"short_name" : "8439",
"types" : [ "street_number" ]
},
{
"long_name" : "Southwest 88th Court",
"short_name" : "SW 88th Ct",
"types" : [ "route" ]
},
{
"long_name" : "Ocala",
"short_name" : "Ocala",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Marion County",
"short_name" : "Marion County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Florida",
"short_name" : "FL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "34481",
"short_name" : "34481",
"types" : [ "postal_code" ]
},
{
"long_name" : "8917",
"short_name" : "8917",
"types" : [ "postal_code_suffix" ]
}
],
"formatted_address" : "8439 SW 88th Ct, Ocala, FL 34481, USA",
"geometry" : {
"location" : {
"lat" : 29.0773262,
"lng" : -82.26593099999999
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 29.0786751802915,
"lng" : -82.2645820197085
},
"southwest" : {
"lat" : 29.0759772197085,
"lng" : -82.26727998029151
}
}
},
"place_id" : "EiU4NDM5IFNXIDg4dGggQ3QsIE9jYWxhLCBGTCAzNDQ4MSwgVVNBIhsSGQoUChIJe6EI-xh56IgRgRSos57hFRIQ90E",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
Thanks
Bruce
{
"results" : [
{
"address_components" : [
{
"long_name" : "8439",
"short_name" : "8439",
"types" : [ "street_number" ]
},
{
"long_name" : "Southwest 88th Court",
"short_name" : "SW 88th Ct",
"types" : [ "route" ]
},
{
"long_name" : "Ocala",
"short_name" : "Ocala",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Marion County",
"short_name" : "Marion County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Florida",
"short_name" : "FL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "34481",
"short_name" : "34481",
"types" : [ "postal_code" ]
},
{
"long_name" : "8917",
"short_name" : "8917",
"types" : [ "postal_code_suffix" ]
}
],
"formatted_address" : "8439 SW 88th Ct, Ocala, FL 34481, USA",
"geometry" : {
"location" : {
"lat" : 29.0773262,
"lng" : -82.26593099999999
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 29.0786751802915,
"lng" : -82.2645820197085
},
"southwest" : {
"lat" : 29.0759772197085,
"lng" : -82.26727998029151
}
}
},
"place_id" : "EiU4NDM5IFNXIDg4dGggQ3QsIE9jYWxhLCBGTCAzNDQ4MSwgVVNBIhsSGQoUChIJe6EI-xh56IgRgRSos57hFRIQ90E",
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
Re: Google Geocoding
If you have the complete JSON string in 1 Plain Text attribute, the following will parse it and give you the lat and lng.
Assuming you have a BO called GPSreply with a your JSON string in a Plain Text attribute called JSONreply.
You will need 3 more Plan Text attributes:
TempResult to hold the data after some initial parsing
lat and lng to hold the parsed out latitude and longitude
The following rules will parse you JSON.
Rule 1. I tested this by copying your JSON above into my BO attribute and it contained new line characters. This rule will remove those. If your actual JSON response is 1 long string with no new line characters, this rule may be skipped.
Rule 2: Remove unneeded JSON. This will remove most of the JSON before and after the lat and lng and store what is left in the TempResult.
Rules 3 and 4. Both of these rules populate the lat and lng from the data in TempResult. 2 rules are needed if it is possible for the lng to come before the lat. If lat is always before the lng, only rule 3 is needed.
Rule 3. lat comes before lng
Rule 4. lng comes before lat
Assuming you have a BO called GPSreply with a your JSON string in a Plain Text attribute called JSONreply.
You will need 3 more Plan Text attributes:
TempResult to hold the data after some initial parsing
lat and lng to hold the parsed out latitude and longitude
The following rules will parse you JSON.
Rule 1. I tested this by copying your JSON above into my BO attribute and it contained new line characters. This rule will remove those. If your actual JSON response is 1 long string with no new line characters, this rule may be skipped.
Code: Select all
GPSreply.JSONreply=REPLACE_PATTERN(GPSreply.JSONreply, CR(), '')
Code: Select all
GPSreply.TempResult=REPLACE_PATTERN(REPLACE_PATTERN(GPSreply.JSONreply, '^.*location\x22 : \{', ''), '\}.*$', '')
Rule 3. lat comes before lng
Code: Select all
IF MATCHES(GPSreply.TempResult, '^.*lat.*lng.*$')='Yes' Then
GPSreply.lat=REPLACE_PATTERN(REPLACE_PATTERN(GPSreply.TempResult, '^.*lat.*?: ', ''), ',.*$', '')
GPSreply.lng=TRIM(REPLACE_PATTERN(GPSreply.TempResult, '^.*lng.*:', ''))
Code: Select all
IF MATCHES(GPSreply.TempResult, '^.*lng.*lat.*$')='Yes' Then
GPSreply.lng=REPLACE_PATTERN(REPLACE_PATTERN(GPSreply.TempResult, '^.*lng.*?: ', ''), ',.*$', '')
GPSreply.lat=TRIM(REPLACE_PATTERN(GPSreply.TempResult, '^.*lat.*:', ''))
Bob