[Google Maps API v3] Re: Google calculated Distance differs PostGIS

2011-12-23 Thread Luca Borzani
Thank You everyone for the help, especially to Marcelo for noticing
the mistake (shame on me!).

On 22 Dic, 21:58, John Coryat  wrote:
> Marcelo,
>
> Good catch...
>
> -John

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



[Google Maps API v3] Google calculated Distance differs PostGIS

2011-12-22 Thread Luca Borzani
The problem is:

distance calculated in postgis differs (not slightly) from distance
returned by google maps. This brings to inconsistency in what the user
sees on the map.

Example:

We have two points with SRID 4326
A)  POINT(45.5398382001 10.22295620)
B)  POINT(45.53945870 10.22567910)
* you can place the coords in google and see what the result looks
like

Google will give a distance of 220meters, PostGIS of about 304 meters
(or about 305 meters using a spheroid)

Now, I understand routing distance (i.e. google distance) it's not the
same as spatial distance (i.e. calculated with st_distance in postgis)
but still I can't explain why the result differs so much.
How can I make PostGis calculate the same (more or less) distance as
google?

Now I explain why this is an issue.

phase 1)
I let the user indicate pointA on the map adding a marker. Then I draw
a circle, with center pointA, and radius of 250 meters. PointB (assume
it's already loaded on the map, because of a previous query) will be
included (visually) in the circle area, because according to google
pointB is 220 meters away from pointA. So the user confirms the action
and saves to the db.

phase 2)
I want to let the user mark (later, when he logs in again perhaps) a
point on the map and draw a circle as before, this time pointB is not
already placed on the map (so the user does not have a visual clue of
where pointB actually is). I'm going to query PostGis to know if there
are any points that intersects the circle drawn by the user.

assume we have a very simple table with just one row that holds pointB
and a query like this SELECT * FROM mytable where ST_DWithin(:pointA,
pointB, 250.0)

now the problem is that this query won't return any result because
according to postgis pointB is 304 meters away from pointA.
But wait, when the user created pointA he SAW ON THE MAP that PointB
IS in the area of the circle with center PointA and radius 250 meters.

So, I can I fix this? I could use a tolerance in my queries, but what
value should i assign to the tolerance(based on which logic?). 100
meters? Could work sometimes, maybe other times not, it could be too
much or too little.

I'll appreciate any help,thanks

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