Subscribe to this thread
Home - General / All posts - SQL Distance Earth across 180 meridian
kgf93 post(s)
#29-Jun-14 06:49

Anybody now if it possible to use sql distanceearth when the points are in different hemispheres.

My query returns a distance for all the records where both longitudes are under 180 but returns 0 if longitude for one point is postive(eg 170.000) and the other point is negative(eg -177.00). drawing is in lat/long

kgf93 post(s)
#29-Jun-14 07:08

Have figured it out, distance earth works fine, in the underlying query I was using I had added the workaround below to get the points to show together on a map across the meridian.

AssignCoordSys(NewPoint(CAST(IIf([Longitude]<150,180+(180-([Longitude])*-1),[Longitude]) AS DOUBLE), CAST([Latitude] AS DOUBLE)), CoordSys("Latitude / Longitude")) [GeomData]

So some of the points had longitudes over 180 which gave null result in distance earth, so now have two queries, one for the map and another for distance calculation.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.