units=imperial returns meters instead of feet

1,080 views
Skip to first unread message

Gus Gustafson

unread,
May 27, 2011, 11:08:10 AM5/27/11
to google-maps-ap...@googlegroups.com
In the query:
 
http://maps.googleapis.com/maps/api/distancematrix/json?origins=160+Wyoming+Ave+Carbondale+PA&destinations=
915+NORTHERN+BLVD+CLARKS+SUMMIT+PA|1105+ONEILL+HWY+DUNMORE+PA|130+WYOMING+AVE+SCRANTON+PA|101+N+MAIN+AVE+SCRANTON+PA|330+MEADOW+AVE+SCRANTON+PA&mode=driving&language=en-US&sensor=false&units=imperial
 
a fragment of the JSON response is
 

"rows": [ {

"elements": [ {

"status": "OK",

"duration": {

"value": 1624,

"text": "27 mins"

},

"distance": {

"value": 24345,

"text": "15.1 mi"

}

}, ....

When I divide 24345 feet by 5280 I obtain 4.6 miles. When I convert 24345 meters to miles, I obtain 15.1 miles. This is not what the documentation regarding units=imperial states.  I would have expected that the "value" would have been 79872.

Any thoughts?

 

Barry Hunter

unread,
May 27, 2011, 11:13:20 AM5/27/11
to google-maps-ap...@googlegroups.com
The documentation does specifically say

> Note: this unit system setting only affects the "text" displayed within "distance" fields. The "distance" fields also contain "values" which are always expressed in meters.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps API Web Services" group.
> To post to this group, send email to
> google-maps-ap...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-api-web-...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api-web-services?hl=en.
>

Gus Gustafson

unread,
May 27, 2011, 11:17:20 AM5/27/11
to google-maps-ap...@googlegroups.com
Thanks.  Missed that. Too bad, feet are easier to convert to miles than are meters.
 
Thanks again,
 
Gus
--
Gus Gustafson

160 Wyoming Avenue
Carbondale, PA 18407
Cell:     (570) 766-5529

Barry Hunter

unread,
May 27, 2011, 11:19:28 AM5/27/11
to google-maps-ap...@googlegroups.com
Umm, ins't converting meters to feet, trival tho?

feet = meters * 0.3048;

Barry Hunter

unread,
May 27, 2011, 11:21:29 AM5/27/11
to google-maps-ap...@googlegroups.com
Ha, I got the operator wrong, still easy tho

feet = meters / 0.3048;

Gus Gustafson

unread,
May 27, 2011, 12:28:47 PM5/27/11
to google-maps-ap...@googlegroups.com
The major problem is the conversion factor.  With feet to miles it is simply a matter of dividing the value to be converted by 5280.
 
Converting meters to miles is not as simple. The biggest problem is to determine the factor to be used. Although it seems like a simple process, it is not.  An interesting article is found at
 
 
To avoid converting from meters to feet and then converting feet to miles, I would use the constants
 
1 Mile = 1609.3440006146921597227828997904 Meters
1 meter = 0.000621371192 miles
 
So 24345 meters times 0.000621371192 miles/meter equals 15.12728166924 miles. Now precision begins to play a part.  But all you need to do is to truncate the resulting miles at some desired decimal place (this step is also required in the divide by 5280 method).
 
But don't you think that dividing feet by 5280 is simpler?
 
Regards,
 
Gus

Barry Hunter

unread,
May 27, 2011, 12:39:14 PM5/27/11
to google-maps-ap...@googlegroups.com
On 27 May 2011 17:28, Gus Gustafson <gggus...@gmail.com> wrote:
> The major problem is the conversion factor.  With feet to miles it is simply
> a matter of dividing the value to be converted by 5280.
>
> Converting meters to miles is not as simple. The biggest problem is to
> determine the factor to be used. Although it seems like a simple process, it
> is not.  An interesting article is found at
>
> http://en.wikipedia.org/wiki/Metre
>
> To avoid converting from meters to feet and then converting feet to miles, I
> would use the constants
>
> 1 Mile = 1609.3440006146921597227828997904 Meters

Do you really need that accuracy? that sort of accuracy is sub-atomic!

Just use 1609.344


> 1 meter = 0.000621371192 miles
>
> So 24345 meters times 0.000621371192 miles/meter equals 15.12728166924
> miles. Now precision begins to play a part.  But all you need to do is to
> truncate the resulting miles at some desired decimal place (this step is
> also required in the divide by 5280 method).
>
> But don't you think that dividing feet by 5280 is simpler?

Frankly no.

But if you want feet its still trivial to get it.

Gus Gustafson

unread,
May 27, 2011, 9:14:07 PM5/27/11
to google-maps-ap...@googlegroups.com
I'm now having a problem with your response. Since Google did exempt distance from the rule, that will suffice. Let me know when you've programmed scientific applications. Then let me know your take on the error function.
 
Thanks for your initial observation.

Chris Broadfoot

unread,
May 29, 2011, 12:59:53 AM5/29/11
to google-maps-ap...@googlegroups.com
On Sat, May 28, 2011 at 11:14 AM, Gus Gustafson <gggus...@gmail.com> wrote:
I'm now having a problem with your response. Since Google did exempt distance from the rule, that will suffice. Let me know when you've programmed scientific applications. Then let me know your take on the error function.

I've never heard of a scientific application that uses feet instead of metres.

This is an absolutely trivial conversion to perform, and there much to be said for always knowing distance.value is returned in metres.

Chris

Gus Gustafson

unread,
May 29, 2011, 9:21:34 AM5/29/11
to google-maps-ap...@googlegroups.com
To what extent have you programmed applications for US consumers? In the US naval services, units are imperial, not metric.
 
--
You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.
To post to this group, send email to google-maps-ap...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api-web-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api-web-services?hl=en.

Sebastien dube

unread,
May 29, 2011, 10:39:42 AM5/29/11
to google-maps-ap...@googlegroups.com
No offense Gus but
I think the question has been answered at this point and yes it is extremely annoying to have to manage units just for US consumers or simply put... the US.

Have a nice day GUS and don't take units discussion too personnaly, not worth waisting your energy and happiness over it!

Barry Hunter

unread,
May 29, 2011, 5:39:35 PM5/29/11
to google-maps-ap...@googlegroups.com
On 29 May 2011 15:39, Sebastien dube <dube.se...@gmail.com> wrote:
No offense Gus but
I think the question has been answered at this point and yes it is extremely annoying to have to manage units just for US consumers or simply put... the US.

We still use Miles for long distances in the UK too. Although conversely short distances are often in meters 
 
:)
Reply all
Reply to author
Forward
0 new messages