Changes between Initial Version and Version 1 of UsersWikiGeographyFunctions


Ignore:
Timestamp:
Dec 2, 2013, 3:12:09 PM (8 years ago)
Author:
Mike Taves
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiGeographyFunctions

    v1 v1  
     1= Functions for the geography type =
     2
     3== Great Circle Mapper ==
     4[http://www.gcmap.com Great Circle Mapper] is a website that shows lines on the globe that follow great circles, which is analogous to the shortest travel direction a plane would take between locations. The logic used for great circles is the same used for PostGIS' geography type.
     5
     6This helper function returns a URL for the Great Circle Mapper website that shows the path of a geography linestring on the Earth.
     7
     8{{{
     9CREATE FUNCTION ST_AsGreatCircleMapperURL(geography) RETURNS text AS
     10$BODY$SELECT 'http://www.gcmap.com/mapui?P=' ||
     11  string_agg(
     12    abs(ST_Y(geom))::text ||
     13      CASE WHEN ST_Y(geom) < 0 THEN 'S' ELSE 'N' END
     14    || '+' ||
     15    abs(ST_X(geom))::text ||
     16      CASE WHEN ST_X(geom) < 0 THEN 'W' ELSE 'E' END,
     17  '-') || '&MS=wls&DU=km' AS url
     18FROM ST_DumpPoints($1::geometry)$BODY$
     19LANGUAGE sql IMMUTABLE;
     20}}}
     21
     22Examples:
     23{{{
     24SELECT ST_AsGreatCircleMapperURL('POLYGON ((35 10, 45 45, -15 40, -10 20, 35 10))'::geography);
     25}}}
     26http://www.gcmap.com/mapui?P=10N+35E-45N+45E-40N+15W-20N+10W-10N+35E&MS=wls&DU=km
     27
     28{{{
     29SELECT ST_AsGreatCircleMapperURL(ST_MakeEnvelope(-75, -80, 110, 3)::geography);
     30}}}
     31http://www.gcmap.com/mapui?P=80S+75W-3N+75W-3N+110E-80S+110E-80S+75W&MS=wls&DU=km