Active
Project:
Geo
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Mar 2010 at 13:42 UTC
Updated:
22 Oct 2010 at 05:19 UTC
Same request as a similar recent issue, but not directly related & more generic.
Starting a big project using the GeoNames db, and if I get a positive quick response, I'll release as a simple module that maintains and queries this data source (time permitting).
This contains simple lat/long points:
latitude : latitude in decimal degrees (wgs84)
longitude : longitude in decimal degrees (wgs84)
And I'm about to add another column POINT (using Postgres), but I thought that I see if this is possible with Geo to make this more generic.
Due to the size, a node based solution is simply not feasible.
Any suggestions?
Comments
Comment #1
allie mickaWhat you really want to do is write a handler for Geocode. I've always wanted a Geonames backend for Geocode, and nobody has had the time to write one.
What the Geocode module does is allow its backends to declare what type of data they're able to accept (e.g. text string), and what type of data they're able to return (point data, text representations of other data, etc.)
It is likely that you want to start with a dependency on http://drupal.org/project/geonames From there, writing a Geocode backend would be pretty short work.
Once that exists, we'll all have access to Openlayers data for CCK formatters and Views filters ("find me things located near [geonames-data-for] my city".
You will also be able to use Geocode to get point data into Geo's CCK fields, your own fields, or into a custom module by simply calling geocode().
Why use Geo to store your data? The easy part is storing values into a column. The tricky parts, which Geo aims to solve, are:
Your code to create a new Geo Dataset would look something like this:
Comment #2
alan d. commentedThank you for the very clear and detailed answer.
I'll see if I have the time in the next few weeks to have a play. Currently I have the import in the following table:
Even after filtering out a lot of the unwanted types, I still ended up with 4.5 million rows. The queries for distance within xxx were still acceptable with the latest versions Postgres/Postgris. I think I read that Postgris automatically adds a bounding box limit from v1.5 that simplified the query.
Any module will have to use a batch API, as the import took forever, about 3 hours. It is so much easier to set the memory high with no timeouts!
Comment #3
alan d. commentedK, I got this working on the base data install, slight modifications:
And the data was successfully retrieved using:
Issues with the definition, no indexes generated.
As I work through the non-field usage, I update the post. As stated above, 3.5 Million nodes is going to kill the site, but I need access to the values!
Comment #4
ahtih commentedThings seem to have changed a bit since then, because "if (!$geo)" is never triggered even if the dataset did not exist. The following works (using "geonamesdb" name as an example):
Comment #5
ahtih commentedActually, there is another problem with all of the above code: it assumes that by hook_install() time, Geo is already properly installed. This assumption is not always correct when Geo is being installed/enabled at the same time as our module; Drupal does not observe module dependency order in this case, and calls their hook_install()'s at arbitrary order.
Other modules use hook_requirements() to get around that, perhaps we should too. But this would mean installing our whole schema in hook_requirements('runtime') rather than in hook_install(). I don't know if this is ok from Drupal core's viewpoint? Does anyone know?