gooderp18绿色标准版
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

93 rindas
10KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.13. earthdistance</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="dict-xsyn.html" title="F.12. dict_xsyn" /><link rel="next" href="file-fdw.html" title="F.14. file_fdw" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.13. earthdistance</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="dict-xsyn.html" title="F.12. dict_xsyn">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="file-fdw.html" title="F.14. file_fdw">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="EARTHDISTANCE"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.13. earthdistance</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="earthdistance.html#id-1.11.7.22.7">F.13.1. Cube-Based Earth Distances</a></span></dt><dt><span class="sect2"><a href="earthdistance.html#id-1.11.7.22.8">F.13.2. Point-Based Earth Distances</a></span></dt></dl></div><a id="id-1.11.7.22.2" class="indexterm"></a><p>
  3. The <code class="filename">earthdistance</code> module provides two different approaches to
  4. calculating great circle distances on the surface of the Earth. The one
  5. described first depends on the <code class="filename">cube</code> module.
  6. The second one is based on the built-in <code class="type">point</code> data type,
  7. using longitude and latitude for the coordinates.
  8. </p><p>
  9. In this module, the Earth is assumed to be perfectly spherical.
  10. (If that's too inaccurate for you, you might want to look at the
  11. <span class="application"><a class="ulink" href="https://postgis.net/" target="_top">PostGIS</a></span>
  12. project.)
  13. </p><p>
  14. The <code class="filename">cube</code> module must be installed
  15. before <code class="filename">earthdistance</code> can be installed
  16. (although you can use the <code class="literal">CASCADE</code> option
  17. of <code class="command">CREATE EXTENSION</code> to install both in one command).
  18. </p><div class="caution"><h3 class="title">Caution</h3><p>
  19. It is strongly recommended that <code class="filename">earthdistance</code>
  20. and <code class="filename">cube</code> be installed in the same schema, and that
  21. that schema be one for which CREATE privilege has not been and will not
  22. be granted to any untrusted users.
  23. Otherwise there are installation-time security hazards
  24. if <code class="filename">earthdistance</code>'s schema contains objects defined
  25. by a hostile user.
  26. Furthermore, when using <code class="filename">earthdistance</code>'s functions
  27. after installation, the entire search path should contain only trusted
  28. schemas.
  29. </p></div><div class="sect2" id="id-1.11.7.22.7"><div class="titlepage"><div><div><h3 class="title">F.13.1. Cube-Based Earth Distances</h3></div></div></div><p>
  30. Data is stored in cubes that are points (both corners are the same) using 3
  31. coordinates representing the x, y, and z distance from the center of the
  32. Earth. A domain <code class="type">earth</code> over <code class="type">cube</code> is provided, which
  33. includes constraint checks that the value meets these restrictions and
  34. is reasonably close to the actual surface of the Earth.
  35. </p><p>
  36. The radius of the Earth is obtained from the <code class="function">earth()</code>
  37. function. It is given in meters. But by changing this one function you can
  38. change the module to use some other units, or to use a different value of
  39. the radius that you feel is more appropriate.
  40. </p><p>
  41. This package has applications to astronomical databases as well.
  42. Astronomers will probably want to change <code class="function">earth()</code> to return a
  43. radius of <code class="literal">180/pi()</code> so that distances are in degrees.
  44. </p><p>
  45. Functions are provided to support input in latitude and longitude (in
  46. degrees), to support output of latitude and longitude, to calculate
  47. the great circle distance between two points and to easily specify a
  48. bounding box usable for index searches.
  49. </p><p>
  50. The provided functions are shown
  51. in <a class="xref" href="earthdistance.html#EARTHDISTANCE-CUBE-FUNCTIONS" title="Table F.5. Cube-Based Earthdistance Functions">Table F.5</a>.
  52. </p><div class="table" id="EARTHDISTANCE-CUBE-FUNCTIONS"><p class="title"><strong>Table F.5. Cube-Based Earthdistance Functions</strong></p><div class="table-contents"><table class="table" summary="Cube-Based Earthdistance Functions" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Function</th><th>Returns</th><th>Description</th></tr></thead><tbody><tr><td><code class="function">earth()</code><a id="id-1.11.7.22.7.7.2.2.1.1.2" class="indexterm"></a></td><td><code class="type">float8</code></td><td>Returns the assumed radius of the Earth.</td></tr><tr><td><code class="function">sec_to_gc(float8)</code><a id="id-1.11.7.22.7.7.2.2.2.1.2" class="indexterm"></a></td><td><code class="type">float8</code></td><td>Converts the normal straight line
  53. (secant) distance between two points on the surface of the Earth
  54. to the great circle distance between them.
  55. </td></tr><tr><td><code class="function">gc_to_sec(float8)</code><a id="id-1.11.7.22.7.7.2.2.3.1.2" class="indexterm"></a></td><td><code class="type">float8</code></td><td>Converts the great circle distance between two points on the
  56. surface of the Earth to the normal straight line (secant) distance
  57. between them.
  58. </td></tr><tr><td><code class="function">ll_to_earth(float8, float8)</code><a id="id-1.11.7.22.7.7.2.2.4.1.2" class="indexterm"></a></td><td><code class="type">earth</code></td><td>Returns the location of a point on the surface of the Earth given
  59. its latitude (argument 1) and longitude (argument 2) in degrees.
  60. </td></tr><tr><td><code class="function">latitude(earth)</code><a id="id-1.11.7.22.7.7.2.2.5.1.2" class="indexterm"></a></td><td><code class="type">float8</code></td><td>Returns the latitude in degrees of a point on the surface of the
  61. Earth.
  62. </td></tr><tr><td><code class="function">longitude(earth)</code><a id="id-1.11.7.22.7.7.2.2.6.1.2" class="indexterm"></a></td><td><code class="type">float8</code></td><td>Returns the longitude in degrees of a point on the surface of the
  63. Earth.
  64. </td></tr><tr><td><code class="function">earth_distance(earth, earth)</code><a id="id-1.11.7.22.7.7.2.2.7.1.2" class="indexterm"></a></td><td><code class="type">float8</code></td><td>Returns the great circle distance between two points on the
  65. surface of the Earth.
  66. </td></tr><tr><td><code class="function">earth_box(earth, float8)</code><a id="id-1.11.7.22.7.7.2.2.8.1.2" class="indexterm"></a></td><td><code class="type">cube</code></td><td>Returns a box suitable for an indexed search using the cube
  67. <code class="literal">@&gt;</code>
  68. operator for points within a given great circle distance of a location.
  69. Some points in this box are further than the specified great circle
  70. distance from the location, so a second check using
  71. <code class="function">earth_distance</code> should be included in the query.
  72. </td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="id-1.11.7.22.8"><div class="titlepage"><div><div><h3 class="title">F.13.2. Point-Based Earth Distances</h3></div></div></div><p>
  73. The second part of the module relies on representing Earth locations as
  74. values of type <code class="type">point</code>, in which the first component is taken to
  75. represent longitude in degrees, and the second component is taken to
  76. represent latitude in degrees. Points are taken as (longitude, latitude)
  77. and not vice versa because longitude is closer to the intuitive idea of
  78. x-axis and latitude to y-axis.
  79. </p><p>
  80. A single operator is provided, shown
  81. in <a class="xref" href="earthdistance.html#EARTHDISTANCE-POINT-OPERATORS" title="Table F.6. Point-Based Earthdistance Operators">Table F.6</a>.
  82. </p><div class="table" id="EARTHDISTANCE-POINT-OPERATORS"><p class="title"><strong>Table F.6. Point-Based Earthdistance Operators</strong></p><div class="table-contents"><table class="table" summary="Point-Based Earthdistance Operators" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Operator</th><th>Returns</th><th>Description</th></tr></thead><tbody><tr><td><code class="type">point</code> <code class="literal">&lt;@&gt;</code> <code class="type">point</code></td><td><code class="type">float8</code></td><td>Gives the distance in statute miles between
  83. two points on the Earth's surface.
  84. </td></tr></tbody></table></div></div><br class="table-break" /><p>
  85. Note that unlike the <code class="type">cube</code>-based part of the module, units
  86. are hardwired here: changing the <code class="function">earth()</code> function will
  87. not affect the results of this operator.
  88. </p><p>
  89. One disadvantage of the longitude/latitude representation is that
  90. you need to be careful about the edge conditions near the poles
  91. and near +/- 180 degrees of longitude. The <code class="type">cube</code>-based
  92. representation avoids these discontinuities.
  93. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dict-xsyn.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="file-fdw.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.12. dict_xsyn </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> F.14. file_fdw</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1