-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGet_CityName.sql
8 lines (8 loc) · 1 KB
/
Get_CityName.sql
1
2
3
4
5
6
7
8
CREATE OR REPLACE FUNCTION Get_CityName(in_geom geometry) RETURNS VARCHAR AS $$
DECLARE +
place_name VARCHAR; +
BEGIN +
SELECT display_name INTO place_name FROM geonames ORDER BY geom <-> ST_Centroid(in_geom) LIMIT 1;
RETURN place_name; +
END; +
$$ LANGUAGE plpgsql;