Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
Dave,
Web calls from VFP require a COM object, or Rick's WestWind tool for C# DLL interaction. I am working with a COM control which has both http and JSON built into it. The full suite has many things, including pop, SMTP, IMAPI, and more. You can find it inexpensive at http://chilkatsoft.com The developer is responsive to support request. There are many FoxPro examples on the site.
I will say building JSON is faster with string building in VFP, than with any tool I've used.
I have tried the VFP classes available to use JSON with the project data I'm working on. The speed of them is far too slow. The larger more complex the JSON, the slower the VFP tools worked. This COM object is quick. And looping through an array doesn't require much. https://www.example-code.com/foxpro/json_paths.asp
HTH, Tracy
On September 13, 2016 6:44:10 AM EDT, Dave Crozier DaveC@Flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
Thanks Tracy, I have all the complete set of Chilkat controls from about 4 years ago for POP and SMTP access etc and it worked really well. I'll give it a second visit seeing as how I purchased it to see if it holds any treasures.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Tracy Pearson Sent: 13 September 2016 13:00 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
Dave,
Web calls from VFP require a COM object, or Rick's WestWind tool for C# DLL interaction. I am working with a COM control which has both http and JSON built into it. The full suite has many things, including pop, SMTP, IMAPI, and more. You can find it inexpensive at http://chilkatsoft.com The developer is responsive to support request. There are many FoxPro examples on the site.
I will say building JSON is faster with string building in VFP, than with any tool I've used.
I have tried the VFP classes available to use JSON with the project data I'm working on. The speed of them is far too slow. The larger more complex the JSON, the slower the VFP tools worked. This COM object is quick. And looping through an array doesn't require much. https://www.example-code.com/foxpro/json_paths.asp
HTH, Tracy
On September 13, 2016 6:44:10 AM EDT, Dave Crozier DaveC@Flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
-- Sent from my Android device with K-9 Mail. Please excuse my brevity.
[excessive quoting removed by server]
I could send you some code which uses the vfpconnection from sweet potato, it builds a URL to pass the parameters in (in my case just a uk postcode) and then uses the JSON project from VFPX to process the response and give you the longitude and latitude etc.
Let me know if it sounds close to what is required and I will dig it out this evening.
Regards
Chris.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Dave Crozier Sent: 13 September 2016 11:44 To: profoxtech@leafe.com Subject: Google API for Geocoding ... Again
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
Chris, That would be brilliant. Like most of these things once you get going and have something to build on then it's OK... I just don't seem to have any bricks at the moment!
Many thanks.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Chris Davis Sent: 13 September 2016 13:27 To: profox@leafe.com Subject: RE: Google API for Geocoding ... Again
I could send you some code which uses the vfpconnection from sweet potato, it builds a URL to pass the parameters in (in my case just a uk postcode) and then uses the JSON project from VFPX to process the response and give you the longitude and latitude etc.
Let me know if it sounds close to what is required and I will dig it out this evening.
Regards
Chris.
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Dave Crozier Sent: 13 September 2016 11:44 To: profoxtech@leafe.com Subject: Google API for Geocoding ... Again
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
Hi Dave Not tried Google stuff but does it work as soap? The following is what I use to talk to one of my own web services.
LPARAMETERS cSeason LOCAL loStationData AS "XML Web Service" LOCAL loException, lcErrorMsg, loWSHandler, oResult coord.displaymethod = PROGRAM() TRY loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC")+"_ws3client.vcx") loStationData = loWSHandler.SetupClient("http://www.airportslots.org/StationSupport/StationD ata.asmx?WSDL", "StationData", "StationDataSoap") oResult = loStationData.GetSeasonData(cSeason) CATCH TO loException MESSAGEBOX(loException.Message,0,STR(loException.ErrorNo)) oResult = .F. FINALLY ENDTRY RETURN oResult
Al
-----Original Message-----
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
Thanks Al, I'd forgotten that you had a lot of early "tribulations" with Soap!
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Allen Pollard Sent: 13 September 2016 13:27 To: profox@leafe.com Subject: RE: Google API for Geocoding ... Again
Hi Dave Not tried Google stuff but does it work as soap? The following is what I use to talk to one of my own web services.
LPARAMETERS cSeason LOCAL loStationData AS "XML Web Service" LOCAL loException, lcErrorMsg, loWSHandler, oResult coord.displaymethod = PROGRAM() TRY loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC")+"_ws3client.vcx") loStationData = loWSHandler.SetupClient("http://www.airportslots.org/StationSupport/StationD ata.asmx?WSDL", "StationData", "StationDataSoap") oResult = loStationData.GetSeasonData(cSeason) CATCH TO loException MESSAGEBOX(loException.Message,0,STR(loException.ErrorNo)) oResult = .F. FINALLY ENDTRY RETURN oResult
Al
-----Original Message-----
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
[excessive quoting removed by server]
Dave
The VFP code at the link below will work assuming you have Rick Strahl's Web Connect installed. I tried it with the SPS Weblog JSON class but the JSON is too complex for it to handle. You need .NET 4.0 or above installed. You won't use .NET directly (Web Connection does internally) however up-to-date Windows installations will almost certainly have it already.
It will return an object that you can inspect and take whatever you need from. You're on your own there!
Here: https://gist.github.com/anonymous/0e45c7824526ce10f22a1dad2e1a028b
Make the service and call it as needed from your app.
var address = "123 something st, somewhere"; var requestUri = string.Format(" http://maps.googleapis.com/maps/api/geocode/xml?address=%7B0%7D&sensor=f...", Uri.EscapeDataString(address));
var request = WebRequest.Create(requestUri); var response = request.GetResponse(); var xdoc = XDocument.Load(response.GetResponseStream());
var result = xdoc.Element("GeocodeResponse").Element("result"); var locationElement = result.Element("geometry").Element("location"); var lat = locationElement.Element("lat"); var lng = locationElement.Element("lng");
make address your input param and output lat and lng.
On Tue, Sep 13, 2016 at 5:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
A hideously-ugly hack that might do the trick would be to automate an IE browser session, feed it the URL, and parse the source result searching first for "location" then for the nearest "lat" and "long" in the resultant source.
On Tue, Sep 13, 2016 at 6:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
Tried that Ted but Google never actually return the Lat/Long and the API call is the only way to retrieve it.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ted Roche Sent: 13 September 2016 14:46 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
A hideously-ugly hack that might do the trick would be to automate an IE browser session, feed it the URL, and parse the source result searching first for "location" then for the nearest "lat" and "long" in the resultant source.
On Tue, Sep 13, 2016 at 6:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
Well, perhaps I'm missing something; I'll recheck my work. I just registered for an API key and used the Google examples and my new API key to get results that show up in my browser.
Of course, I'm not using IE nor Windows, just Chrome on Linux, but it should work the same, if IE is compatible with this.
On Tue, Sep 13, 2016 at 9:47 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Tried that Ted but Google never actually return the Lat/Long and the API call is the only way to retrieve it.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ted Roche Sent: 13 September 2016 14:46 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
A hideously-ugly hack that might do the trick would be to automate an IE browser session, feed it the URL, and parse the source result searching first for "location" then for the nearest "lat" and "long" in the resultant source.
On Tue, Sep 13, 2016 at 6:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
I converted all the examples to run in VFP by generating a html file from VFP using textmerge etc. which was then called by IE and couldn't find any reference to lat/longs anywhere.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ted Roche Sent: 13 September 2016 14:58 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
Well, perhaps I'm missing something; I'll recheck my work. I just registered for an API key and used the Google examples and my new API key to get results that show up in my browser.
Of course, I'm not using IE nor Windows, just Chrome on Linux, but it should work the same, if IE is compatible with this.
On Tue, Sep 13, 2016 at 9:47 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Tried that Ted but Google never actually return the Lat/Long and the API call is the only way to retrieve it.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ted Roche Sent: 13 September 2016 14:46 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
A hideously-ugly hack that might do the trick would be to automate an IE browser session, feed it the URL, and parse the source result searching first for "location" then for the nearest "lat" and "long" in the resultant source.
On Tue, Sep 13, 2016 at 6:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
Ah, I see the problem. Testing on WinTen and IELast, it "helps" me by deciding it wants to download a json.json file and asks which app I want to use from the Microsoft Store. In current versions of Chrome and FireFox, it just returns the correct answer: the json, displayed as the text that it is.
This is drop-dead simple XML-RPC: send an http request for a result, encoding the parameters in the URL, get a result to parse. There's no need to wrap it in an ugly Microsoft COM-plexified Web Service. I'd be much more inclined to use something like wget for windows (http://gnuwin32.sourceforge.net/packages/wget.htm), or similar functionality like Rick Strahl's Client Tools, if you're already using them, and write a quick-and-dirty VFP to assemble the URL (and your API key!) and shell out to the wget command, then slurping in the result with FileToStr and parsing the results.
On Tue, Sep 13, 2016 at 10:18 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
I converted all the examples to run in VFP by generating a html file from VFP using textmerge etc. which was then called by IE and couldn't find any reference to lat/longs anywhere.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ted Roche Sent: 13 September 2016 14:58 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
Well, perhaps I'm missing something; I'll recheck my work. I just registered for an API key and used the Google examples and my new API key to get results that show up in my browser.
Of course, I'm not using IE nor Windows, just Chrome on Linux, but it should work the same, if IE is compatible with this.
On Tue, Sep 13, 2016 at 9:47 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Tried that Ted but Google never actually return the Lat/Long and the API call is the only way to retrieve it.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Ted Roche Sent: 13 September 2016 14:46 To: profox@leafe.com Subject: Re: Google API for Geocoding ... Again
A hideously-ugly hack that might do the trick would be to automate an IE browser session, feed it the URL, and parse the source result searching first for "location" then for the nearest "lat" and "long" in the resultant source.
On Tue, Sep 13, 2016 at 6:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
Or you can just use the WinHTTP library in Windows as per the Gist I linked earlier, and get a string back straight into VFP. The hardest part of all this is going to be parsing the JSON to be honest.
Alan, Your solution worked like a dream, thanks. Just knocking it into a useable class now to allow input and output from our system within the daily constraints set by Google on free accounts.
Looks like I won't have to pull any more of my "minimalist" hair out tonight!!
Dave (& Tom)
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 13 September 2016 16:15 To: profoxtech@leafe.com Subject: Re: Google API for Geocoding ... Again
Or you can just use the WinHTTP library in Windows as per the Gist I linked earlier, and get a string back straight into VFP. The hardest part of all this is going to be parsing the JSON to be honest.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
FUNCTION geocode LPARAMETERS lcpostcode
lcurl="http://maps.googleapis.com/maps/api/geocode/json?address=##ADDRESS##"
lojson=NEWOBJECT('json')
lctempurl=STRTRAN(lcurl,"##ADDRESS##",STRTRAN(ALLTRIM(lcpostcode)," ","")) lcget=httptostr(lctempurl) lcret="" loquery=lojson.decode(lcget) IF ALLTRIM(loquery.get("status"))="OK" loresult=loquery._results.get(1) logeo=loresult.get("geometry") loloc=logeo.get("location") lcret=ALLTRIM(TRANSFORM(loloc.get("lat")))+","+ALLTRIM(TRANSFORM(loloc.get("lng"))) endif RELEASE lojson
RETURN lcret
Json code is from https://github.com/sait/vfpjson Httptostr is part of vfpconnection from sweet potato
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Dave Crozier Sent: 13 September 2016 16:26 To: profoxtech@leafe.com Subject: RE: Google API for Geocoding ... Again
Alan, Your solution worked like a dream, thanks. Just knocking it into a useable class now to allow input and output from our system within the daily constraints set by Google on free accounts.
Looks like I won't have to pull any more of my "minimalist" hair out tonight!!
Dave (& Tom)
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 13 September 2016 16:15 To: profoxtech@leafe.com Subject: Re: Google API for Geocoding ... Again
Or you can just use the WinHTTP library in Windows as per the Gist I linked earlier, and get a string back straight into VFP. The hardest part of all this is going to be parsing the JSON to be honest.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
Chris, With a few modifications unique to how I WANT IT TO FUNCTION THAT WORKED LIKE A DREAM
Thanks for the input!
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Chris Davis Sent: 13 September 2016 16:33 To: profox@leafe.com Subject: RE: Google API for Geocoding ... Again
FUNCTION geocode LPARAMETERS lcpostcode
lcurl="http://maps.googleapis.com/maps/api/geocode/json?address=##ADDRESS##"
lojson=NEWOBJECT('json')
lctempurl=STRTRAN(lcurl,"##ADDRESS##",STRTRAN(ALLTRIM(lcpostcode)," ","")) lcget=httptostr(lctempurl) lcret="" loquery=lojson.decode(lcget) IF ALLTRIM(loquery.get("status"))="OK" loresult=loquery._results.get(1) logeo=loresult.get("geometry") loloc=logeo.get("location") lcret=ALLTRIM(TRANSFORM(loloc.get("lat")))+","+ALLTRIM(TRANSFORM(loloc.get("lng"))) endif RELEASE lojson
RETURN lcret
Json code is from https://github.com/sait/vfpjson Httptostr is part of vfpconnection from sweet potato
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Dave Crozier Sent: 13 September 2016 16:26 To: profoxtech@leafe.com Subject: RE: Google API for Geocoding ... Again
Alan, Your solution worked like a dream, thanks. Just knocking it into a useable class now to allow input and output from our system within the daily constraints set by Google on free accounts.
Looks like I won't have to pull any more of my "minimalist" hair out tonight!!
Dave (& Tom)
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 13 September 2016 16:15 To: profoxtech@leafe.com Subject: Re: Google API for Geocoding ... Again
Or you can just use the WinHTTP library in Windows as per the Gist I linked earlier, and get a string back straight into VFP. The hardest part of all this is going to be parsing the JSON to be honest.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
No worries glad it was of use
On 14 Sep 2016, at 09:47, Dave Crozier DaveC@Flexipol.co.uk wrote:
Chris, With a few modifications unique to how I WANT IT TO FUNCTION THAT WORKED LIKE A DREAM
Thanks for the input!
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Chris Davis Sent: 13 September 2016 16:33 To: profox@leafe.com Subject: RE: Google API for Geocoding ... Again
FUNCTION geocode LPARAMETERS lcpostcode
lcurl="http://maps.googleapis.com/maps/api/geocode/json?address=##ADDRESS##"
lojson=NEWOBJECT('json')
lctempurl=STRTRAN(lcurl,"##ADDRESS##",STRTRAN(ALLTRIM(lcpostcode)," ","")) lcget=httptostr(lctempurl) lcret="" loquery=lojson.decode(lcget) IF ALLTRIM(loquery.get("status"))="OK" loresult=loquery._results.get(1) logeo=loresult.get("geometry") loloc=logeo.get("location") lcret=ALLTRIM(TRANSFORM(loloc.get("lat")))+","+ALLTRIM(TRANSFORM(loloc.get("lng"))) endif
RELEASE lojson
RETURN lcret
Json code is from https://github.com/sait/vfpjson Httptostr is part of vfpconnection from sweet potato
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Dave Crozier Sent: 13 September 2016 16:26 To: profoxtech@leafe.com Subject: RE: Google API for Geocoding ... Again
Alan, Your solution worked like a dream, thanks. Just knocking it into a useable class now to allow input and output from our system within the daily constraints set by Google on free accounts.
Looks like I won't have to pull any more of my "minimalist" hair out tonight!!
Dave (& Tom)
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Alan Bourke Sent: 13 September 2016 16:15 To: profoxtech@leafe.com Subject: Re: Google API for Geocoding ... Again
Or you can just use the WinHTTP library in Windows as per the Gist I linked earlier, and get a string back straight into VFP. The hardest part of all this is going to be parsing the JSON to be honest.
-- Alan Bourke alanpbourke (at) fastmail (dot) fm
[excessive quoting removed by server]
On Tue, Sep 13, 2016 at 11:14 AM, Alan Bourke alanpbourke@fastmail.fm wrote:
Or you can just use the WinHTTP library in Windows as per the Gist I linked earlier, and get a string back straight into VFP. The hardest part of all this is going to be parsing the JSON to be honest.
Missed that. Well done, good solution.
Ok - yes, I'm dredging up a VERY Old thread here!
So, here's the deal. A woman I worked with for this Jewish Holiday Pop-up shop here in SF this past late Nov./early Dec. - she wants me to do a kind of Admin task for her. She's going to give me a spreadsheet of locations - and wants me to use Google Maps to find the distances traveled. She then has to note the distances back into the spreadsheet. It may have to do with reimbursement based upon mileage.
As such, was hoping I could potentially whip up something Simple to help me automate the process - so, I was looking at this particular discussion thread.
So - Ted - I was curious about your hack. I actually HAVE a LONG Time ago done something similar - to launch IE. But, for the life of me - I no longer remember what the VFP code was to do exactly that. Can you maybe throw me a bone here on how to launch IE from inside VFP? I suspect it DOES have something to do with the Run command in VFP...
TIA,
-K-
On 9/13/2016 6:46 AM, Ted Roche wrote:
A hideously-ugly hack that might do the trick would be to automate an IE browser session, feed it the URL, and parse the source result searching first for "location" then for the nearest "lat" and "long" in the resultant source.
On Tue, Sep 13, 2016 at 6:44 AM, Dave Crozier DaveC@flexipol.co.uk wrote:
Fellow Gentlemen, I posted a request about doing geocoding requests to receive back a Lat/Long dataset for various addresses a few weeks ago and now find that Google do in fact provide a Geocoding service:
https://developers.google.com/maps/documentation/geocoding/start
The responses back from the requests are all JSON from a Java Script API run by Google. I have looked over Rick's Westwind site to try and get a start on using this method to get back a JSON response but seem to be getting nowhere fast. Anyone got any ideas on a simple & neat way of retrieving this data back using VFP programmatically? Either that or anyone know a free Geocoding site that would handle up to 100 name and address calls per day ideally by sending a text file and receiving one back which could be automated from the VFP end.
Never even looked at Web services in anger before so it all seems a little baffling and terribly long winded at the moment unless I am missing something obvious.
Note I don't want to have to drop into an intermediate program/language to accomplish this, if possible.
Dave
[excessive quoting removed by server]
On Mon, Jan 28, 2019 at 10:25 AM Kurt @ Gmail kurthwendt@gmail.com wrote:
Ok - yes, I'm dredging up a VERY Old thread here!
So, here's the deal. A woman I worked with for this Jewish Holiday Pop-up shop here in SF this past late Nov./early Dec. - she wants me to do a kind of Admin task for her. She's going to give me a spreadsheet of locations - and wants me to use Google Maps to find the distances traveled. She then has to note the distances back into the spreadsheet. It may have to do with reimbursement based upon mileage.
I did something like this back in 2008 or so and I'm pretty darn sure I posted it here but I'll be darned if I can find it. Maybe your Search-Fu is better than mine so you might be able to dig it up.
I used MS Access to do the work but it did the exact thing you are trying to do.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
Not sure if this will help as only glancing at these emails but in vfp I do visit the following URL
http://maps.googleapis.com/maps/api/geocode/json?address=##ADDRESS##
using either vfpconnection or the Microsoft html thing ( I can be more specific if required)
the ##ADDRESS## is replaced with a postcode for instance
http://maps.googleapis.com/maps/api/geocode/json?address=WS98ER
You used to be able to do this all day long (there was a throttle that kicked in at some point based on your IP address but the limit was something like 5000 calls a day)
These days I believe you need an API key which you would need to pass in with the query to get your JSON back with the lat and lng in.
I believe you need a paid for account now but you get $200 dollars usage credit each month for the API which I think for modest usage is plenty.
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of M Jarvis Sent: Monday, 28 January 2019 19:27 To: profoxtech@leafe.com Subject: Re: Google API for Geocoding ... Again
On Mon, Jan 28, 2019 at 10:25 AM Kurt @ Gmail kurthwendt@gmail.com wrote:
Ok - yes, I'm dredging up a VERY Old thread here!
So, here's the deal. A woman I worked with for this Jewish Holiday Pop-up shop here in SF this past late Nov./early Dec. - she wants me to do a kind of Admin task for her. She's going to give me a spreadsheet of locations - and wants me to use Google Maps to find the distances traveled. She then has to note the distances back into the spreadsheet. It may have to do with reimbursement based upon mileage.
I did something like this back in 2008 or so and I'm pretty darn sure I posted it here but I'll be darned if I can find it. Maybe your Search-Fu is better than mine so you might be able to dig it up.
I used MS Access to do the work but it did the exact thing you are trying to do.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]
The pay for this gig is So Small - that it would not be worth it to pay for any SW to assist with this task.
As is, I found simple code to allow me to open a URL within a Browser window/tab from within VFP. And, I did Google Mapping between locations for directions - and figured I could just pass this as a URL. So - I made this little app that allows me to plug in up to 4 locations (as the woman would make multiple stops) - with the start & end of her trip being her home location. So, although its rather simple - it works for my purposes.
Thank you everyone for your input on this!
-K-
On 2/4/2019 6:39 AM, Chris Davis wrote:
Not sure if this will help as only glancing at these emails but in vfp I do visit the following URL
http://maps.googleapis.com/maps/api/geocode/json?address=##ADDRESS##
using either vfpconnection or the Microsoft html thing ( I can be more specific if required)
the ##ADDRESS## is replaced with a postcode for instance
http://maps.googleapis.com/maps/api/geocode/json?address=WS98ER
You used to be able to do this all day long (there was a throttle that kicked in at some point based on your IP address but the limit was something like 5000 calls a day)
These days I believe you need an API key which you would need to pass in with the query to get your JSON back with the lat and lng in.
I believe you need a paid for account now but you get $200 dollars usage credit each month for the API which I think for modest usage is plenty.
-----Original Message----- From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of M Jarvis Sent: Monday, 28 January 2019 19:27 To: profoxtech@leafe.com Subject: Re: Google API for Geocoding ... Again
On Mon, Jan 28, 2019 at 10:25 AM Kurt @ Gmail kurthwendt@gmail.com wrote:
Ok - yes, I'm dredging up a VERY Old thread here!
So, here's the deal. A woman I worked with for this Jewish Holiday Pop-up shop here in SF this past late Nov./early Dec. - she wants me to do a kind of Admin task for her. She's going to give me a spreadsheet of locations - and wants me to use Google Maps to find the distances traveled. She then has to note the distances back into the spreadsheet. It may have to do with reimbursement based upon mileage.
I did something like this back in 2008 or so and I'm pretty darn sure I posted it here but I'll be darned if I can find it. Maybe your Search-Fu is better than mine so you might be able to dig it up.
I used MS Access to do the work but it did the exact thing you are trying to do.
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]