[postgis-users] Newbie help
Nahum Castro
pedro1_72 at yahoo.com
Thu May 31 09:30:50 PDT 2007
--- Andy Dale <andy.dale at gmail.com> escribió:
> I have just started using PostGis 1.2.0 on
> Postgresql 8.1.4. Most of the
> data I wish to store in is Long/Lat type coords in
> the format ((N|S|E|W)
> degrees, minutes, seconds, tenths of seconds,
> hundredths of seconds), with
> the degrees for latitude being 2 digits and degrees
> for longitude being
> 3 digits. The characters
> N,S,E,W are there just to specify if the relevant
> coord is north/south
> of the equator, or east/west of the zero meridian.
> Is it possible to
> just store the data in the (D)DD:MM:
> SS.TenthsHundredths format (usually WSG84
> datum) and use them for calculations, or must i
> first convert them to
> the decimal equivalent
> before saving them ?? And if i have to convert can
> postgis perform the
> transformation/calculation for me.
>
>
> Cheers,
>
> Andy
> > _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
>
http://postgis.refractions.net/mailman/listinfo/postgis-users
>
I use this stored procedure to do that.
----------------------------------------
CREATE or replace FUNCTION convertir_latlon( value
INTEGER ) RETURNS float AS $$
DECLARE
arg INTEGER;
grados float;
minutos float;
segundos float;
dd float;
BEGIN
arg := value;
IF length(arg) = 7 THEN
BEGIN
segundos := substr(arg,6,2);
minutos := substr(arg,4,2);
grados := substr(arg,1,3);
dd := grados + (minutos/60) +
(segundos/3600);
RETURN dd;
END;
ELSE
BEGIN
segundos := substr(arg,5,2);
minutos := substr(arg,3,2);
grados := substr(arg,1,2);
dd := grados + (minutos/60) +
(segundos/3600);
RETURN dd;
END;
END IF;
END;
$$ LANGUAGE 'plpgsql';
-----------------------------------------------------------
modify to suit your needs.
Saludos desde México
--
Nahum Castro
Leon, Guanajuato, Mexico
http://www.leon-linux.com
e-mail: pedro1_72 [en] yahoo [punto] com
Llama gratis a cualquier PC del mundo.
Con una excelente calidad de sonido.
http://mx.messenger.yahoo.com/
More information about the postgis-users
mailing list