Longitude & Latitude set to 0.000000

bkat - October 4, 2008 - 23:39
Project:Location
Version:6.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Issue tags:gmap, location, location latitude and longitue set to zero
Description

I've encountered a problem. I enabled location on a new drupal 6.4 site and entered in location data for a node. I just supplied the address and not the longitude and latitude. When they go into the database (mysql), they are set to 0.000000.

This ends up giving he node 0.000000 as the long/lat which makes the google map come up in the middle of some ocean.

I ended up working around it in location_load_location as follows:

if (isset($location['source']) && $location['source'] == LOCATION_LATLON_USER_SUBMITTED) {
// Set up location chooser or lat/lon fields from the stored location.
$location['locpick'] = array(
'user_latitude' => $location['latitude'],
'user_longitude' => $location['longitude'],
);
} else {
/* kjh: latitude/longitude are stored as 0.0000 if unset */
if ($location['latitude'] = 0.) {
unset($location['latitide']);
}

if ($location['longitude'] = 0.) {
unset($location['longitude']);
}
}

I'm sure there is a better way of doing this. If you want me to create a patch, let me know.

#1

hakimapia - October 7, 2008 - 16:39

I encountered the same problem. I got this in the edit page of my own content type:
Current coordinates
Latitude: 0.000000
Longitude: 0.000000
Source: Unknown

Please let us know if there is better way of debugging this. Thanks.

#2

kreynen - October 8, 2008 - 16:38
Status:active» by design

After installing the GMap Module and adding a Google Maps API key, my long/lat lookup works as expected. This makes sense since you don't enter an API key anywhere in the Locations configuration and without it, I'm not sure how the lookup would happen.

#3

hakimapia - October 10, 2008 - 09:16

I already configured the Google map API key in the Location Configuration for each country:
Example Belgium:
admin/settings/location/geocoding/be/google

I also configured the Google map API key in the GMap Configuration from admin/settings/gmap and enable google map geocoding from admin/settings/gmap_location.

I'm letting users to enter their own location coordinates (long and lat).
But if they don't input coordinates I believe geocoding should take place and provide the long and lat based on the provided info since I had my geocoding enabled.
Still my Longitude & Latitude is set to 0.000000.
I'm really confused. Do you know why this happens?

I am using:
Drupal-6.4
Apache Http Server 2.2.9
MySQL Server 5.0
PHP 5.2.6

Please let me know if you already encountered this and how you solved it.
Thanks.

#4

ancorgs - October 15, 2008 - 12:19
Version:6.x-3.x-dev» 5.x-3.0-rc1
Status:by design» needs review

If geocoding fails for any reason, lat&long are assigned 0 (by design, which is ok for me). But when yo try to edit the node, if you are using GMap to set latitude and longitude, the map is centered on 0,0, not in the default coords. I have fixed it modifying location.module around line 321.

I changed this:

// Use previous coordinates to center the map.
if (!empty($dv['latitude']) || !empty($dv['longitude'])) {

to:

// Use previous coordinates to center the map.
if (($dv['source'] != LOCATION_LATLON_UNDEFINED) && (!empty($dv['latitude']) || !empty($dv['longitude']))) {

and it works for me.

#5

TallDavid - October 15, 2008 - 16:47
Status:needs review» active

I'm not sure if this is the same bug, but, whenever I edit an existing location node, the latitude/longitude information gets reset to 180° 0' 0" N, 360° 0' 0" E. An example is shown below:

Location
Cindy's Palace
1102 FM 2977
Richmond, TX, 77469
United States
180° 0' 0" N, 360° 0' 0" E
See map: Google Maps http://maps.google.com/?q=180.000000+360.000000+%281102+FM+2977%2C+Richm...

This occurs both in the 5.x-3.0-rc1 version and in the "5.x-3.x-dev" datestamp = "1223597227" version. I have also tried ancorgs patch and the problem still occurs.

#6

bdragon - October 15, 2008 - 20:17

TallDavid: Err, THAT's interesting. Are you running any other patches?

#7

bdragon - October 15, 2008 - 21:45

@ #4:
Solved that problem in an alternate way, thanks

http://drupal.org/cvs?commit=146682
http://drupal.org/cvs?commit=146685

#8

TallDavid - October 16, 2008 - 04:58

bdragon, no, I am not running any other patches. I'll be happy to roll-back versions or test changes if it will help. This is being used for a listing of local voting locations for the upcoming election. Since early voting starts Monday, I'm very motivated to help get this resolved!

#9

bdragon - October 16, 2008 - 14:50

TallDavid: Contact me in #drupal?

#10

TallDavid - October 17, 2008 - 15:17

bdragon, as requested I have attached the miss-match schema report from the problematic site.

I have also updated the site to the latest dev version:

  • version = "5.x-3.x-dev"
  • project = "location"
  • datestamp = "1224115692"

I'll contact you later on IRC #drupal.

Thanks again for your assistance!

David

AttachmentSize
FBD-SchemaReport.txt 8.58 KB

#11

Matt Townsend - October 19, 2008 - 19:01

I was having this problem, but it's gone away. I switched to the 10-16 build. Then, when I went to edit the content type, I did two things:

- I disabled the street collection, as I didn't want that field anymore.
- I noticed the country collection radio button was unselected - that is, neither 'do not collect', 'required' nor 'enforce default' was selected. I selected 'enforce default.'

The geocoding is now working, and the longitude/latitude is no longer 0, 0. This may be worth playing around with.

#12

bdragon - October 20, 2008 - 18:57

Hmm, that's interesting, having country collection as an invalid option WOULD break geocoding. I wonder what the value was before?

#13

LouBabe - October 20, 2008 - 19:55

I was having the same problem and discovered that this occurred when editing an existing node (with at least one location obviously) and NOT changing any of the location fields. "Touching" even a single relevant field, such as city or address, would properly geocode the location. It's because of this line in location.module on line 1493:

    if ($changed['street'] || $changed['additional'] || $changed['city'] || $changed['province'] || $changed['country'] || $changed['postal_code'] || $location['source'] == LOCATION_LATLON_USER_SUBMITTED)

Not sure of the best fix without more digging. Maybe add a check for an existing lat/long as well?

#14

bdragon - October 20, 2008 - 20:06

Yes, I'm aware of this as well.

There are multiple bugs here. I am working on a proper solution to the re-geocoding problem.

If you manually change the latitude and longitude for your undefined locations to something other than 0 in the table ("UPDATE location SET latitude = 111 WHERE source = 0"), and change the line to

<?php
   
if ($changed['street'] || $changed['additional'] || $changed['city'] || $changed['province'] || $changed['country'] || $changed['postal_code'] || $location['source'] == LOCATION_LATLON_USER_SUBMITTED || $location['source'] == LOCATION_LATLON_UNDEFINED) {
?>

you can regeocode without having to twiddle fields. This is because of a bug that considers coordinate changes for an undefined source to be changes, when they are actually changes to undefined data, and should be disregarded. (i.e. the code currently compares them against 0 and marks the location "changed")

I have a partially written "proper" fix in my local sandbox, but it needs a bit more work.

#15

mrgoltra - October 22, 2008 - 16:44

subscribing.

#16

nhod - November 4, 2008 - 04:20

Hi bdragon... Could you give us a little taste of or update on your "proper" fix? This bug is biting us particularly hard, and if I can help you with your code in any way I'd be happy to. Thanks.

#17

caver456 - November 14, 2008 - 17:59

just ran into this today - if you're doing one (or just a few) country/countries, and you don't need the lat and long, then here's a quick fix:

in modules/location.../supported/location..inc look for the function that builds the url; for me it was:

function location_map_link_us_google($location = array())

and comment out the lines that stick lat and long into the url; but make sure to not break the code. Here's what my new section looks like inside that function:

// if ($location['latitude'] && $location['longitude']) {
// $q = urlencode($location['latitude'] . ' ' . $location['longitude'] . ' (' . implode(', ', $query_params) . ')' );
// } else if (count($query_params) > 0) {
if (count($query_params) > 0) {
$q = urlencode(implode(", ", $query_params));
}

That's it. Gets taken into account automatically when you edit and save the node in question. The map link now works and doesn't plop you just off the coast of Africa.

#18

chrishathaway - December 10, 2008 - 02:38

subscribing. I had to make the manual fix mentioned by caver456 (thanks, by the way).

#19

Morbus Iff - December 10, 2008 - 13:37

Regarding #17, I ended up doing:

if ($location['latitude'] != 0.000000 && $location['longitude'] != 0.000000) {

instead.

#20

likewhoa - December 22, 2008 - 16:45
Version:5.x-3.0-rc1» 6.x-3.x-dev

having same issue but with 6.x-3.x-dev on drupal 6.8

#21

likewhoa - December 23, 2008 - 14:16

if anyone is still having an issue with this, make sure you have enabled "Use a Google Map to set latitude and longitude " in admin/settings/location
I had this checkbox unset from a previous problem I had with location.module

#22

likewhoa - January 2, 2009 - 01:48

Well this is still an issue for me with recent -dev release, no matter what address is entered the Longitude & Latitude is set to 0.000000, the only way to get Longitude & Latitude is by manually setting a marker but it should automatically be set my location module when entering your location instead. still running this with

Drupal 6.8
GMap Module 6.x-1.x-dev (2008-Dec-31)
Location 6.x-3.x-dev (2008-Dec-30)

fix appreciated.

#23

realguess - January 25, 2009 - 21:54

I had the same problem before, and kept getting 0.000000 locational data. Finally I found out that the Google Map option was not set in admin/settings/location/geocoding. That fixed it.

Drupal 6.9
GMap 6.x-1.0
Location 6.x-3.0

#24

KarenS - January 27, 2009 - 18:37
Status:active» needs review

There are two problems here. The first is the original issue, which is that if for any reason geocoding fails, the Google map link tries to map to the location 0,0 which doesn't work.

This is caused by another issue, which is that geocoding is failing.

The original issue still needs a fix, because no matter what, geocoding will sometimes fail. Attached is a patch for the US google map .inc file, but the same fix needs to be made for any country .inc file that uses Google or adds the lat/lon to the map link.

This doesn't take care of the second issue, that geocoding is failing, but I'm not sure these belong mashed together in the same issue anyway.

AttachmentSize
location.us_.inc_.patch 825 bytes

#25

KarenS - January 27, 2009 - 19:12

A better patch based on the new function created by #7. Still needs to be applied to any other .inc files that add coordinates to the map link.

AttachmentSize
location.us_.inc_.patch 704 bytes

#26

scottrigby - February 2, 2009 - 22:48

Hi KarenS - I wasn't clear from your notes in #24 & #25... is the patch in #25 supposed to address the issue of geocoding failing?
I applied the patch (and as far as I know I have the gmap and location configurations set properly) but no geocoding is happening at all. Or is there is another issue better suited to that problem?

#27

bdragon - February 4, 2009 - 23:26
Status:needs review» active

Committed patch from #25, additionally made a similar change to location.de.inc.
http://drupal.org/cvs?commit=169153
http://drupal.org/cvs?commit=169155
http://drupal.org/cvs?commit=169157

#28

YesCT - April 15, 2009 - 20:19
Status:active» fixed
Issue tags:+location latitude and longitue set to zero

looks like this might have been fixed.

Also, putting in the phrase location.xx.inc since it had to do with country files.

#29

System Message - April 29, 2009 - 20:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#30

capellic - October 13, 2009 - 14:48

I discovered something very interesting after put a bunch of drupal_set_message() debugging statements in the geocoding/google.inc, within the google_geocode_location() function. I found that Google's API was returning a code of 620. Turns out that 620 means that the server is down -- or it could mean that you've been denied access.

When I hit the URL that Location is passing to Drupal's API in my browser, I get the XML returned that I was expecting, so it wasn't that the server was down. I then discovered that it could also mean that the request was denied due to overuse. How could that be? I have a very small site, in dev and I'm hitting their API 20 times a day -- max -- and their limit is 20,000 per day -- per IP [1].

Turns out that the block is determined by IP address and not by API key, so if you're on a shared host or using The Rackspace Cloud (Mosso), a ton of sites are using the same IP address. This is bad. Why does Google make this quota determination at the IP level? I suspect it's a measure to prevent DoS attacks. According to this thread [2], the Google Maps API team is aware of the "proxy" issue, and aware of the Rackspace Cloud issue in particular.

[1] http://code.google.com/apis/maps/faq.html#geocoder_limit
[2] http://groups.google.com/group/Google-Maps-API/browse_thread/thread/d04f...

 
 

Drupal is a registered trademark of Dries Buytaert.