cartodb-postgresql/scripts-available/CDB_LatLng.sql
Paul Norman ea7c16fbaf Convert some simple functions from plpgsql to sql
SQL is a faster language to call, and these are very simple functions.
2015-12-21 23:59:26 -08:00

20 lines
548 B
PL/PgSQL

--
-- Create a valid GEOMETRY in 4326 from a lat/lng pair
--
-- @param lat A numeric latitude value.
--
-- @param lng A numeric longitude value.
--
--
CREATE OR REPLACE FUNCTION CDB_LatLng (lat NUMERIC, lng NUMERIC) RETURNS geometry as $$
-- this function is silly
SELECT ST_SetSRID(ST_MakePoint(lng,lat),4326);
$$ language SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION CDB_LatLng (lat FLOAT8, lng FLOAT8) RETURNS geometry as $$
-- this function is silly
SELECT ST_SetSRID(ST_MakePoint(lng,lat),4326);
$$ language SQL IMMUTABLE;