when using gmap to set locations, the lat/lng are very precise:
37.5769636963459,-96.3864898681641

but when it is saved, it doesn't save all that.

is there any reason not to crank the precision up a bit?

Comments

yesct’s picture

Issue tags: +location bdragon check

tagging, needs someone who understands the module to comment (although others are welcome to comment too! It makes it easier for a maintainer to comment if others have thought through something first)

hutch’s picture

In location.install

'longitude' => array(
  'description' => 'Location longitude (decimal degrees).',
  'type' => 'numeric',
  'precision' => 10,
  'scale' => 6,
  'not null' => TRUE,
  'default' => 0.0,
),

shows as
decimal(10,6)
in phpmyadmin

to get the full accuracy (with one more for comfort)
decimal(18,14)
would be required, so

'longitude' => array(
  'description' => 'Location longitude (decimal degrees).',
  'type' => 'numeric',
  'precision' => 18,
  'scale' => 14,
  'not null' => TRUE,
  'default' => 0.0,
),

should do it, same for latitude of course.

I notice that what google returns are not always the same length, and users might adjust them afterwards so there might be an argument for using 20 and 16, that would cover it for sure.

yesct’s picture

Is there any reason to not use the most precision possible?
Is there a compelling use case for making precision a setting?

hutch’s picture

Is there any reason to not use the most precision possible?
I could imagine that a large site doing a lot of proximity searches might prefer a smaller field, this would speed up the calculations I would think, but for most cases I would prefer the high precision. I already use decimal(20, 16) on the sites I host, I adjusted it immediately after install.

The decimal data type in mysql truncates the number if the number coming in is longer than the space available.

Conversely if the number is shorter it is padded out with zeroes.

Geocoded lat/lons coming in from Google have a precision of 6 or sometimes 7, but if users adjust them afterwards a much higher precision can be achieved.

So overall I would vote for a change to a higher precision, this would have to be an update function in location install.

Is there a compelling use case for making precision a setting?
Tricky, it is done in the table creation routine in location.install. A quick look at the php manual does not show up a good way to adjust the number and even if you did it would still be stored in whatever the lat/lon fields are set up to take, pointless really.

Having said all this I looked it up on wikipedia:
http://en.wikipedia.org/wiki/Decimal_degrees

This states that
6 decimal places is accurate to approx. 0.111 m
That's about 10 centimeters or 4 inches

So perhaps we should just leave it as it is ;-)

yesct’s picture

Status: Active » Closed (won't fix)
Issue tags: -location bdragon check

Good detective work.

HA. I agree 10 centimeters or 4 inches... we can leave it as is.