User login

Assigning geographical coordinates to Drupal content and using it to select or sort nearby content: brainstorm

location (API, module)
http://drupal.org/project/location

location.module supports proximity searches for content. Content (i.e., 'nodes') can be tagged with a physical snail mail location (whether full or partial). What number of location fields (e.g., 'street', 'city', 'postal code', 'country', 'province') are collected for each node type (and whether they are required or optional) is configurable in the default workflow for each node type.

As of September 25:
5.x-1.x-dev 2007-Aug-23

Technically, each activity-discussion group could propose multiple events/activities, each with a different location

proximity by geographical coordinates
calculate distance between coordinates

http://www.web-max.ca/PHP/misc_2.php
Calculate distance between 2 sets of longitude / latitude coordinates.
Takes two sets of coordinates in decimal longitude and latitude format and returns the distance in kilometers.

<?php
$lat1 = 46.2341938036161;
$lon1 = -63.124778021257015;

$lat2 = 46.4141938036161;
$lon2 = -63.118571124705284;

$distance = (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180);

print($distance);
?>

Place to check results:
http://www.gpsvisualizer.com/calculators

I wonder if a level of triage would help: immediately reject all nodes where the latitude is +10 or -10 our target, say.

Filtering by country can help but "getting rid of borders" is attractive. Maybe we can program in bordering countries, and restrict the calculation to that.

Have all distance calculations for content kept in a table, so that it's just one query on the table rather than asking each node and running the calculations? I'm not sure how this would interact with views other filtering though. That is, views starts with all nodes, then throws out all non-Event type nodes, and then (say) throws out all Events not in tagged confirmed. Could it then turn to this table to further filter this set, passing in an "IN (4, 6, 84, 93 ...)" query? (Shudders.) Or even sort a result set?

A huge amount of older discussion about mapping is here, no explicit mention of point to point distance:
http://groups.drupal.org/node/4323
Including the mothersclick guy saying he wrote a custom solution.

The Geo module is supposed to do location one better, but it's in development:
http://drupal.org/project/geo

I would really like autocomplete for countries with synonyms - so it would be great to implement countries as a taxonomy.

Then, based on your country, it should show you address information in a form you're used to-- with the goal for us in all cases to come up with an accurate geolocation of latitude and longitude.

Other related modules:

http://drupal.org/project/cck_address

This module makes available as a single CCK field all of the fields you'd expect for a user to enter in an address. Currently, only U.S. and Canadian addresses are supported, but a framework is in place to support adding other countries.

It uses active select to only show information for the selected country, but again only U.S. and Canada are really in. (Spain and India are coming to cck address extensions module.)

I don't think it has much to offer us.

http://drupal.org/project/gmap
What we ultimately need, or writing our own implementation of the Google Maps API. Though the maintainer wants to make GMap better and more generalized and open to other modules, it still looks like our best bet.
5.x-1.x-dev 2007-Sep-20

This module also adds some functionality to location.module that can allow the node locations to be set in an interactively. Then the location of the current node can be shown in a block if it has lat/long information stored for it in the location.module. All of the nodes that have lat/long location information can be viewed on a common map.

Looks like our best candidate by far, with location.module.

This has nothing nothing to do with anything, but it's amazing that I searched for just the word location without the world Drupal anywhere and the fourth result:

location.module at 4th result in search for just location

Searched words: 
geo location latitude longitude mapping organic groups geolocation organic groups geocode

Comments

Hey You may also find

Hey

You may also find GeoDan's modules over at http://geodaniel.org/drupal-modules useful.

I'm not sure how far along some of them are (although KMS and GeoRSS feeds are certainly working) but integrating with OpenStreetMap and open GIS systems would certainly be attractive for WSF...

I've found in the past that geo-coding wise, for global applications, GeoNames.org web-service provides good responses... There are some patches in the issue queue for location on Drupal.org that implement GeoNames geocoding in various ways.

There was at one time, though I've not seen anything of it recently, a proposal to create a widget which ran a general search for a location using JSON/Ajax to return the rough area someone was trying to locate, and then, using a Google Map, invited the user to clarify their exact location by putting a pin in the map.

Tim

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.