This is quite a thorny problem: trying to do some kind of automated insertion within wiki pages - I don't believe there's any functionality like it now. On the other hand, it would be quite a useful feature to have, since that Google Maps geocoding limit is a real problem, and renders the #geocode function nearly useless for large sites that use templates. I've been thinking about this problem, and I think I've found a reasonable solution, but first let me go through what I think won't work:

- a parser function within a template - some kind of "#place_geocode_here" function that, wherever it was called from a template, placed the actual coordinate value in the page calling the template. Problems: I'm not sure that this is technically possible, and even if it were, it could only help with pages that were created or resaved after the function was added to the template; it won't do anything for pages previously created. Similarly, if you change that call in the template, the template can't go around modifying all the pages that call it.

- in a form - you could imagine a new field parameter like "geocode on fields=", that took the names of other fields (like "geocode on fields=street address, city, country"), and placed the geocoded value in the resulting page. Problems: same as before - I don't know if it's technically possible, and it doesn't handle pages created before that geocoding was added.

- directly in a page - as Sergey noted in a separate thread, you could tell users to add a #subst call within pages when they create them. Problems: not doable within a form, too complicated for users in any case.

So that leaves what I think is the best solution: a command-line script that resaves pages, adding a coordinate value to template calls. It might look like:

AddGeocodingToPages.php template-name address-fields coordinates-field

So a sample call might be:

AddGecodingToPages.php Company "Street Address, City, Country" Coordinates

This script would go through every page that contained a call to the "Company" template, get the values for the fields labelled "Street Address", "City" and "Country", combine these values together and call Google's geocoding service on that, and if it got back a set of coordinates, add to the template call a new line, reading "|Coordinates=...". If the page already contained a "Coordinates=..." line, the script would check the page's value against what geocoding returned and update the page if necessary.

The script could be made to wait several seconds between lookup calls; or whatever a safe interval is. It could also be set to stop after doing a set number of lookups, like 5,000, to avoid causing problems. You could also then create a "cron job" to run the script, say, once a day, to handle new pages that got added.

I think the most logical place for such a script would be in the Google Geocoder extension - Sergey, any thoughts? :)

-Yaron


2009/3/20 Thomas Fellows <thomas.fellows@gmail.com>
I definitely agree -- you also want to make sure you don't break Google's API policy - which I believe limits Geocoding addresses to X number (if you're not paying them) before they blacklist you.  I was talking with Yaron, and I believe the best way to do this would be to have the geocode extension do something similar to a template substitution - where once you ping google once for the coordinates, the {{#geocode:}} tag goes away after the first time and gets replcaed with the actual coordinates - because as mentioned before - the geocoordinates aren't changing!

Anyone want to take a stab at this- or know of any extensions (tag/parser) that replace themselves with text after hitting save?

-tom

p.s. - i wonder if {{SUBS:#geocode:...}} works (or whatever the syntax is for template subs)


On Fri, Mar 20, 2009 at 5:11 PM, Keith Fligg <Keith.Fligg@pnl.gov> wrote:
Agreed, it wouldn’t be courteous to request the data from Google multiple times for the same location.  I guess what I was hoping for was a means of acquiring the lat/lng from Google if it was missing, and then turning it into a Property of the appropriate type, and then storing the property with the original record.  Then subsequent attempts to map the record would use the (stored) property.



On 3/20/09 2:05 PM, "Sergey Chernyshev" <sergey.chernyshev@gmail.com> wrote:

I would not recommend to do it on the fly simply because you don't want to run requests to Google service every time some data in the query changes - it's better to just simply augment pages with coordinates in your original documents, after all, if address didn't change, coordinates didn't either, right?

         Sergey


--
Sergey Chernyshev
http://www.sergeychernyshev.com/


2009/3/20 Thomas Fellows <thomas.fellows@gmail.com>
Oops:

I'm not sure if there is a way to geocode through an ask query (e.g., geocode a list of results on the fly).  If someone has an idea on how to do this, I'd be interested!  The way I understand to do it is the first method of adding the property.

Hope this helps a little

-tom

On Fri, Mar 20, 2009 at 8:28 AM, Thomas Fellows <thomas.fellows@gmail.com> wrote:
hey keith,

first, things to look at:

http://www.mediawiki.org/wiki/Extension:Google_Geocoder
http://www.mediawiki.org/wiki/Extension:Semantic_Google_Maps#Geocoding_addresses

There are two ways to do it - if your imported data is displayed using a template, you can create the geographic coordinate property by adding to the template something like [[Has coordinate::{{{Street Address}}}]] (or if it's separated [[Has coordinate::{{{Street Address}}}, {{{City}}}, {{{State}}}]]  etc.  -- wait for everything to refresh and your data should now have a property.

the more "on the fly" way of doing it (from the site above) - "
{{#semantic_google_map:{{#geocode:{{{Street address}}}, {{{City}}}, {{{State}}}, {{{Country}}}}}}}"


I'm not sure if there is a way to geocode  q


2009/3/19 Keith Fligg <Keith.Fligg@pnl.gov>
I’ve got several thousand pages that we imported into our MediaWiki that each contain a ‘Location’ property of type string.  We would like to be able to use the Google geocoder to lookup the coordinates of that property, and then use those coordinates to display the locations using the SemanticGoogleMaps extension.  All of this within an ask query.

The issue is that SemanticGoogleMaps is looking for a property of type ‘Geographic coordinate’ and we don’t have that information in our imported documents.  If there were some way to generate that property on the fly during the ask query, and feed it into the map, it would save us the trouble of having to process, and reimport the data.

It seems like someone must have butt up against the problem in the past, we just can’t find any reference to a solution.  Does anyone have any idea of how we might be able to get this done?

Thanks for any help,

 - Keith


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Semediawiki-user mailing list
Semediawiki-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-user




------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Semediawiki-user mailing list
Semediawiki-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-user





------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Semediawiki-user mailing list
Semediawiki-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-user