Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. /**
  2. * PostgreSQL distance calcuration functions and operators.
  3. **/
  4.  
  5. -- CREATE EXTENSION cube;
  6. -- CREATE EXTENSION earthdistance;
  7. -- CREATE EXTENSION postgis;
  8.  
  9.  
  10. SELECT
  11. point(139.774508, 35.684040) <-> point(139.786468, 35.549679)AS dist
  12. , 'point<->point' AS operator
  13. , 'point' AS data_type
  14. , 'postgresql' AS lib
  15. , 'degree' AS unit
  16.  
  17. UNION ALL
  18.  
  19. SELECT
  20. point(139.774508, 35.684040) <@> point(139.786468, 35.549679) AS dist
  21. , 'point<@>point' AS operator
  22. , 'point' AS data_type
  23. , 'earthdistance' AS lib
  24. , 'mile' AS unit
  25.  
  26. UNION ALL
  27.  
  28. SELECT
  29. (point(139.774508, 35.684040) <@> point(139.786468, 35.549679))/0.0006214 AS dist
  30. , '(point<@>point)/0.0006214 ' AS operator
  31. , 'point' AS data_type
  32. , 'earthdistance' AS lib
  33. , 'meter' AS unit
  34.  
  35. UNION ALL
  36.  
  37. SELECT
  38. earth_distance( ll_to_earth(35.684040,139.774508),ll_to_earth(35.549679,139.786468))AS dist
  39. , 'earth_distance(earth,earth)' AS operator
  40. , 'earth' AS data_type
  41. , 'earthdistance' AS lib
  42. , 'meter' AS unit
  43.  
  44. UNION ALL
  45.  
  46. SELECT
  47. st_distancesphere(ST_POINT(139.774508, 35.684040), ST_POINT(139.786468, 35.549679))AS dist
  48. , 'ST_Distance_sphere(geom,geom)' AS operator
  49. , 'geometry' AS data_type
  50. , 'PostGIS' AS lib
  51. , 'meter' AS unit
  52.  
  53. UNION ALL
  54.  
  55. SELECT
  56. st_distance(ST_POINT(139.774508, 35.684040)::geography , ST_POINT(139.786468, 35.549679)::geography)AS dist
  57. , 'ST_Distance(geog,geog)' AS operator
  58. , 'geography' AS data_type
  59. , 'PostGIS' AS lib
  60. , 'meter' AS unit
  61.  
  62. UNION ALL
  63.  
  64. SELECT
  65. ST_point(139.774508, 35.684040) <-> ST_point(139.786468, 35.549679)AS dist
  66. , 'geom<->geom'AS operator
  67. , 'geometry' AS data_type
  68. , 'PostGIS' AS lib
  69. , 'degree' AS unit
  70.  
  71. UNION ALL
  72.  
  73. SELECT
  74. ST_point(139.774508, 35.684040)::geography <-> ST_point(139.786468, 35.549679)::geography AS dist
  75. , 'geog<->geog'AS operator
  76. , 'geography' AS data_type
  77. , 'PostGIS' AS lib
  78. , 'meter' AS unit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement