Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * PostgreSQL distance calcuration functions and operators.
- **/
- -- CREATE EXTENSION cube;
- -- CREATE EXTENSION earthdistance;
- -- CREATE EXTENSION postgis;
- SELECT
- point(139.774508, 35.684040) <-> point(139.786468, 35.549679)AS dist
- , 'point<->point' AS operator
- , 'point' AS data_type
- , 'postgresql' AS lib
- , 'degree' AS unit
- UNION ALL
- SELECT
- point(139.774508, 35.684040) <@> point(139.786468, 35.549679) AS dist
- , 'point<@>point' AS operator
- , 'point' AS data_type
- , 'earthdistance' AS lib
- , 'mile' AS unit
- UNION ALL
- SELECT
- (point(139.774508, 35.684040) <@> point(139.786468, 35.549679))/0.0006214 AS dist
- , '(point<@>point)/0.0006214 ' AS operator
- , 'point' AS data_type
- , 'earthdistance' AS lib
- , 'meter' AS unit
- UNION ALL
- SELECT
- earth_distance( ll_to_earth(35.684040,139.774508),ll_to_earth(35.549679,139.786468))AS dist
- , 'earth_distance(earth,earth)' AS operator
- , 'earth' AS data_type
- , 'earthdistance' AS lib
- , 'meter' AS unit
- UNION ALL
- SELECT
- st_distancesphere(ST_POINT(139.774508, 35.684040), ST_POINT(139.786468, 35.549679))AS dist
- , 'ST_Distance_sphere(geom,geom)' AS operator
- , 'geometry' AS data_type
- , 'PostGIS' AS lib
- , 'meter' AS unit
- UNION ALL
- SELECT
- st_distance(ST_POINT(139.774508, 35.684040)::geography , ST_POINT(139.786468, 35.549679)::geography)AS dist
- , 'ST_Distance(geog,geog)' AS operator
- , 'geography' AS data_type
- , 'PostGIS' AS lib
- , 'meter' AS unit
- UNION ALL
- SELECT
- ST_point(139.774508, 35.684040) <-> ST_point(139.786468, 35.549679)AS dist
- , 'geom<->geom'AS operator
- , 'geometry' AS data_type
- , 'PostGIS' AS lib
- , 'degree' AS unit
- UNION ALL
- SELECT
- ST_point(139.774508, 35.684040)::geography <-> ST_point(139.786468, 35.549679)::geography AS dist
- , 'geog<->geog'AS operator
- , 'geography' AS data_type
- , 'PostGIS' AS lib
- , 'meter' AS unit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement