| rev | 
   line source | 
| 
jbe@0
 | 
     1 <html><head><title>pgLatLon v0.1 documentation</title></head><body>
 | 
| 
jbe@0
 | 
     2 <h1>pgLatLon v0.1 documentation</h1>
 | 
| 
jbe@0
 | 
     3 
 | 
| 
jbe@0
 | 
     4 <p>pgLatLon is a spatial database extension for the PostgreSQL object-relational
 | 
| 
jbe@0
 | 
     5 database management system providing geographic data types and spatial indexing
 | 
| 
jbe@0
 | 
     6 for the WGS-84 spheroid.</p>
 | 
| 
jbe@0
 | 
     7 
 | 
| 
jbe@0
 | 
     8 <p>While many other spatial databases still use imprecise bounding boxes for many
 | 
| 
jbe@0
 | 
     9 operations, pgLatLon supports more precise geometric calculations for all
 | 
| 
jbe@0
 | 
    10 implemented operators. Efficient indexing of geometric objects is provided
 | 
| 
jbe@2
 | 
    11 using space-filling fractal curves. Optimizations on bit level (including
 | 
| 
jbe@2
 | 
    12 logarithmic compression) allow for a highly memory-efficient non-overlapping
 | 
| 
jbe@2
 | 
    13 index suitable for huge datasets.</p>
 | 
| 
jbe@0
 | 
    14 
 | 
| 
jbe@0
 | 
    15 <p>Unlike competing spatial extensions for PostgreSQL, pgLatLon is available under
 | 
| 
jbe@0
 | 
    16 the permissive MIT/X11 license to avoid problems with viral licenses like the
 | 
| 
jbe@0
 | 
    17 GPLv2/v3.</p>
 | 
| 
jbe@0
 | 
    18 
 | 
| 
jbe@0
 | 
    19 <h2>Installation</h2>
 | 
| 
jbe@0
 | 
    20 
 | 
| 
jbe@0
 | 
    21 <h3>Automatic installation</h3>
 | 
| 
jbe@0
 | 
    22 
 | 
| 
jbe@0
 | 
    23 <p>Prerequisites:</p>
 | 
| 
jbe@0
 | 
    24 
 | 
| 
jbe@0
 | 
    25 <ul>
 | 
| 
jbe@0
 | 
    26 <li>Ensure that the <code>pg_config</code> binary is in your path (shipped with PostgreSQL).</li>
 | 
| 
jbe@0
 | 
    27 <li>Ensure that GNU Make is available (either as <code>make</code> or <code>gmake</code>).</li>
 | 
| 
jbe@0
 | 
    28 </ul>
 | 
| 
jbe@0
 | 
    29 
 | 
| 
jbe@0
 | 
    30 <p>Then simply type:</p>
 | 
| 
jbe@0
 | 
    31 
 | 
| 
jbe@0
 | 
    32 <pre><code>make install
 | 
| 
jbe@0
 | 
    33 </code></pre>
 | 
| 
jbe@0
 | 
    34 
 | 
| 
jbe@0
 | 
    35 <h3>Manual installation</h3>
 | 
| 
jbe@0
 | 
    36 
 | 
| 
jbe@0
 | 
    37 <p>It is also possible to compile and install the extension without GNU Make as
 | 
| 
jbe@0
 | 
    38 follows:</p>
 | 
| 
jbe@0
 | 
    39 
 | 
| 
jbe@6
 | 
    40 <pre><code>cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0002.so latlon-v0002.c
 | 
| 
jbe@6
 | 
    41 cp latlon-v0002.so `pg_config --pkglibdir`
 | 
| 
jbe@0
 | 
    42 cp latlon.control `pg_config --sharedir`/extension/
 | 
| 
jbe@6
 | 
    43 cp latlon--0.1--0.2.sql latlon--0.2.sql `pg_config --sharedir`/extension/
 | 
| 
jbe@0
 | 
    44 </code></pre>
 | 
| 
jbe@0
 | 
    45 
 | 
| 
jbe@0
 | 
    46 <h3>Loading the extension</h3>
 | 
| 
jbe@0
 | 
    47 
 | 
| 
jbe@0
 | 
    48 <p>After installation, you can create a database and load the extension as
 | 
| 
jbe@0
 | 
    49 follows:</p>
 | 
| 
jbe@0
 | 
    50 
 | 
| 
jbe@0
 | 
    51 <pre><code>% createdb test_database
 | 
| 
jbe@0
 | 
    52 % psql test_database
 | 
| 
jbe@0
 | 
    53 psql (9.5.4)
 | 
| 
jbe@0
 | 
    54 Type "help" for help.
 | 
| 
jbe@0
 | 
    55 
 | 
| 
jbe@0
 | 
    56 test_database=# CREATE EXTENSION latlon;
 | 
| 
jbe@0
 | 
    57 </code></pre>
 | 
| 
jbe@0
 | 
    58 
 | 
| 
jbe@0
 | 
    59 <h2>Reference</h2>
 | 
| 
jbe@0
 | 
    60 
 | 
| 
jbe@0
 | 
    61 <h3>1. Types</h3>
 | 
| 
jbe@0
 | 
    62 
 | 
| 
jbe@0
 | 
    63 <p>pgLatLon provides four geographic types: <code>epoint</code>, <code>ebox</code>, <code>ecircle</code>, and
 | 
| 
jbe@0
 | 
    64 <code>ecluster</code>.</p>
 | 
| 
jbe@0
 | 
    65 
 | 
| 
jbe@0
 | 
    66 <h4><code>epoint</code></h4>
 | 
| 
jbe@0
 | 
    67 
 | 
| 
jbe@0
 | 
    68 <p>A point on the earth spheroid (WGS-84).</p>
 | 
| 
jbe@0
 | 
    69 
 | 
| 
jbe@0
 | 
    70 <p>The text input format is <code>'[N|S]<float> [E|W]<float>'</code>, where each float is in
 | 
| 
jbe@0
 | 
    71 degrees. Note the required white space between the latitude and longitude
 | 
| 
jbe@0
 | 
    72 components.  Each floating point number may have a sign, in which case <code>N</code>/<code>S</code>
 | 
| 
jbe@0
 | 
    73 or <code>E</code>/<code>W</code> are switched respectively (e.g. <code>E-5</code> is the same as <code>W5</code>).</p>
 | 
| 
jbe@0
 | 
    74 
 | 
| 
jbe@0
 | 
    75 <p>An <code>epoint</code> may also be created from two floating point numbers by calling
 | 
| 
jbe@0
 | 
    76 <code>epoint(latitude, longitude)</code>, where positive latitudes are used for the
 | 
| 
jbe@0
 | 
    77 northern hemisphere, negative latitudes are used for the southern hemisphere,
 | 
| 
jbe@0
 | 
    78 positive longitudes indicate positions east of the prime meridian, and negative
 | 
| 
jbe@0
 | 
    79 longitudes indicate positions west of the prime meridian.</p>
 | 
| 
jbe@0
 | 
    80 
 | 
| 
jbe@0
 | 
    81 <p>Latitudes exceeding -90 or +90 degrees are truncated to -90 or +90
 | 
| 
jbe@0
 | 
    82 respectively, in which case a warning will be issued. Longitudes exceeding -180
 | 
| 
jbe@0
 | 
    83 or +180 degrees will be converted to values between -180 and +180 (both
 | 
| 
jbe@0
 | 
    84 inclusive) by adding or substracting a multiple of 360 degrees, in which case a
 | 
| 
jbe@0
 | 
    85 notice will be issued.</p>
 | 
| 
jbe@0
 | 
    86 
 | 
| 
jbe@0
 | 
    87 <p>If the latitude is -90 or +90 (south pole or north pole), a longitude value is
 | 
| 
jbe@0
 | 
    88 still stored in the datum, and if a point is on the prime meridian or the
 | 
| 
jbe@0
 | 
    89 180th meridian, the east/west bit is also stored in the datum. In case of the
 | 
| 
jbe@0
 | 
    90 prime meridian, this is done by storing a floating point value of -0 for
 | 
| 
jbe@0
 | 
    91 0 degrees west and a value of +0 for 0 degrees east. In case of the
 | 
| 
jbe@0
 | 
    92 180th meridian, this is done by storing -180 or +180 respectively. The equality
 | 
| 
jbe@0
 | 
    93 operator, however, returns true when the same points on earth are described,
 | 
| 
jbe@0
 | 
    94 i.e. the longitude is ignored for the poles, and 180 degrees west is considered
 | 
| 
jbe@0
 | 
    95 to be equal to 180 degrees east.</p>
 | 
| 
jbe@0
 | 
    96 
 | 
| 
jbe@0
 | 
    97 <h4><code>ebox</code></h4>
 | 
| 
jbe@0
 | 
    98 
 | 
| 
jbe@0
 | 
    99 <p>An area on earth demarcated by a southern and northern latitude, and a western
 | 
| 
jbe@0
 | 
   100 and eastern longitude (all given in WGS-84).</p>
 | 
| 
jbe@0
 | 
   101 
 | 
| 
jbe@0
 | 
   102 <p>The text input format is
 | 
| 
jbe@0
 | 
   103 <code>'{N|S}<float> {E|W}<float> {N|S}<float> {E|W}<float>'</code>, where each float is in
 | 
| 
jbe@0
 | 
   104 degrees. The ordering of the four white-space separated blocks is not
 | 
| 
jbe@0
 | 
   105 significant. To include the 180th meridian, one longitude boundary must be
 | 
| 
jbe@0
 | 
   106 equal to or exceed <code>W180</code> or <code>E180</code>, e.g. <code>'N10 N20 E170 E190'</code>.</p>
 | 
| 
jbe@0
 | 
   107 
 | 
| 
jbe@0
 | 
   108 <p>A special value is the empty area, denoted by the text represenation <code>'empty'</code>.
 | 
| 
jbe@0
 | 
   109 Such an <code>ebox</code> does not contain any point.</p>
 | 
| 
jbe@0
 | 
   110 
 | 
| 
jbe@0
 | 
   111 <p>An <code>ebox</code> may also be created from four floating point numbers by calling
 | 
| 
jbe@0
 | 
   112 <code>ebox(min_latitude, max_latitude, min_longitude, max_longitude)</code>, where
 | 
| 
jbe@0
 | 
   113 positive values are used for north and east, and negative values are used for
 | 
| 
jbe@0
 | 
   114 south and west. If <code>min_latitude</code> is strictly greater than <code>max_latitude</code>, an
 | 
| 
jbe@0
 | 
   115 empty <code>ebox</code> is created. If <code>min_longitude</code> is greater than <code>max_longitude</code> and
 | 
| 
jbe@0
 | 
   116 if both longitudes are between -180 and +180 degrees, then the area oriented in
 | 
| 
jbe@0
 | 
   117 such way that the 180th meridian is included.</p>
 | 
| 
jbe@0
 | 
   118 
 | 
| 
jbe@0
 | 
   119 <p>If the longitude span is less than 120 degrees, an <code>ebox</code> may be alternatively
 | 
| 
jbe@0
 | 
   120 created from two <code>epoints</code> in the following way: <code>ebox(epoint(lat1, lon1),
 | 
| 
jbe@0
 | 
   121 epoint(lat2, lon2))</code>. In this case <code>lat1</code> and <code>lat2</code> as well as <code>lon1</code> and
 | 
| 
jbe@0
 | 
   122 <code>lon2</code> can be swapped without any impact.</p>
 | 
| 
jbe@0
 | 
   123 
 | 
| 
jbe@0
 | 
   124 <h4><code>ecircle</code></h4>
 | 
| 
jbe@0
 | 
   125 
 | 
| 
jbe@0
 | 
   126 <p>An area containing all points not farther away from a given center point
 | 
| 
jbe@0
 | 
   127 (WGS-84) than a given radius.</p>
 | 
| 
jbe@0
 | 
   128 
 | 
| 
jbe@0
 | 
   129 <p>The text input format is <code>'{N|S}<float> {E|W}<float> <float>'</code>, where the first
 | 
| 
jbe@0
 | 
   130 two floats denote the center point in degrees and the third float denotes the
 | 
| 
jbe@0
 | 
   131 radius in meters. A radius equal to minus infinity denotes an empty circle
 | 
| 
jbe@0
 | 
   132 which contains no point at all (despite having a center), while a radius equal
 | 
| 
jbe@0
 | 
   133 to zero denotes a circle that includes a single point.</p>
 | 
| 
jbe@0
 | 
   134 
 | 
| 
jbe@0
 | 
   135 <p>An <code>ecircle</code> may also be created by calling <code>ecircle(epoint(...), radius)</code> or
 | 
| 
jbe@0
 | 
   136 from three floating point numbers by calling <code>ecircle(latitude, longitude,
 | 
| 
jbe@0
 | 
   137 radius)</code>.</p>
 | 
| 
jbe@0
 | 
   138 
 | 
| 
jbe@0
 | 
   139 <h4><code>ecluster</code></h4>
 | 
| 
jbe@0
 | 
   140 
 | 
| 
jbe@0
 | 
   141 <p>A collection of points, paths, polygons, and outlines on the WGS-84 spheroid.
 | 
| 
jbe@0
 | 
   142 Each path, polygon, or outline must cover a longitude range of less than
 | 
| 
jbe@0
 | 
   143 180 degrees to avoid ambiguities.</p>
 | 
| 
jbe@0
 | 
   144 
 | 
| 
jbe@0
 | 
   145 <p>The text input format is a white-space separated list of the following items:</p>
 | 
| 
jbe@0
 | 
   146 
 | 
| 
jbe@0
 | 
   147 <ul>
 | 
| 
jbe@0
 | 
   148 <li><code>point   ({N|S}<float> {E|W}<float>)</code></li>
 | 
| 
jbe@0
 | 
   149 <li><code>path    ({N|S}<float> {E|W}<float> {N|S}<float> {E|W}<float> ...)</code></li>
 | 
| 
jbe@0
 | 
   150 <li><code>outline ({N|S}<float> {E|W}<float> {N|S}<float> {E|W}<float> {N|S}<float> {E|W}<float> ...)</code></li>
 | 
| 
jbe@0
 | 
   151 <li><code>polygon ({N|S}<float> {E|W}<float> {N|S}<float> {E|W}<float> {N|S}<float> {E|W}<float> ...)</code></li>
 | 
| 
jbe@0
 | 
   152 </ul>
 | 
| 
jbe@0
 | 
   153 
 | 
| 
jbe@0
 | 
   154 <p>Paths are open by default (i.e. there is no connection from the last point in
 | 
| 
jbe@0
 | 
   155 the list to the first point in the list). Outlines and polygons, in contrast,
 | 
| 
jbe@0
 | 
   156 are automatically closed (i.e. there is a line segment from the last point in
 | 
| 
jbe@0
 | 
   157 the list to the first point in the list) which means the first point should not
 | 
| 
jbe@0
 | 
   158 be repeated as last point in the list. Polygons are filled, outlines are not.</p>
 | 
| 
jbe@0
 | 
   159 
 | 
| 
jbe@0
 | 
   160 <h3>2. Indices</h3>
 | 
| 
jbe@0
 | 
   161 
 | 
| 
jbe@0
 | 
   162 <p>Two kinds of indices are supported: B-tree and GiST indices.</p>
 | 
| 
jbe@0
 | 
   163 
 | 
| 
jbe@0
 | 
   164 <h4>B-tree indices</h4>
 | 
| 
jbe@0
 | 
   165 
 | 
| 
jbe@0
 | 
   166 <p>A B-tree index can be used for simple equality searches and is supported by the
 | 
| 
jbe@0
 | 
   167 <code>epoint</code>, <code>ebox</code>, and <code>ecircle</code> data types. B-tree indices can not be used for
 | 
| 
jbe@0
 | 
   168 geographic searches.</p>
 | 
| 
jbe@0
 | 
   169 
 | 
| 
jbe@0
 | 
   170 <h4>GiST indices</h4>
 | 
| 
jbe@0
 | 
   171 
 | 
| 
jbe@0
 | 
   172 <p>For geographic searches, GiST indices must be used. The <code>epoint</code>, <code>ecircle</code>,
 | 
| 
jbe@0
 | 
   173 and <code>ecluster</code> data types support GiST indexing. A GiST index for geographic
 | 
| 
jbe@0
 | 
   174 searches can be created as follows:</p>
 | 
| 
jbe@0
 | 
   175 
 | 
| 
jbe@0
 | 
   176 <pre><code>CREATE TABLE tbl (
 | 
| 
jbe@0
 | 
   177         id              serial4         PRIMARY KEY,
 | 
| 
jbe@0
 | 
   178         loc             epoint          NOT NULL );
 | 
| 
jbe@0
 | 
   179 
 | 
| 
jbe@0
 | 
   180 CREATE INDEX name_of_index ON tbl USING gist (loc);
 | 
| 
jbe@0
 | 
   181 </code></pre>
 | 
| 
jbe@0
 | 
   182 
 | 
| 
jbe@0
 | 
   183 <p>GiST indices also support nearest neighbor searches when using the distance
 | 
| 
jbe@0
 | 
   184 operator (<code><-></code>) in the ORDER BY clause.</p>
 | 
| 
jbe@0
 | 
   185 
 | 
| 
jbe@0
 | 
   186 <h4>Indices on other data types (e.g. GeoJSON)</h4>
 | 
| 
jbe@0
 | 
   187 
 | 
| 
jbe@0
 | 
   188 <p>Note that further types can be indexed by using an index on an expression with
 | 
| 
jbe@0
 | 
   189 a conversion function. One conversion function provided by pgLatLon is the
 | 
| 
jbe@0
 | 
   190 <code>GeoJSON_to_ecluster(float8, float8, text)</code> function:</p>
 | 
| 
jbe@0
 | 
   191 
 | 
| 
jbe@0
 | 
   192 <pre><code>CREATE TABLE tbl (
 | 
| 
jbe@0
 | 
   193         id              serial4         PRIMARY KEY,
 | 
| 
jbe@0
 | 
   194         loc             jsonb           NOT NULL );
 | 
| 
jbe@0
 | 
   195 
 | 
| 
jbe@0
 | 
   196 CREATE INDEX name_of_index ON tbl USING gist((GeoJSON_to_ecluster("loc")));
 | 
| 
jbe@0
 | 
   197 </code></pre>
 | 
| 
jbe@0
 | 
   198 
 | 
| 
jbe@0
 | 
   199 <p>When using the conversion function in an expression, the index will be used
 | 
| 
jbe@0
 | 
   200 automatically:</p>
 | 
| 
jbe@0
 | 
   201 
 | 
| 
jbe@0
 | 
   202 <pre><code>SELECT * FROM tbl WHERE GeoJSON_to_ecluster("loc") && 'N50 E10 10000'::ecircle;
 | 
| 
jbe@0
 | 
   203 </code></pre>
 | 
| 
jbe@0
 | 
   204 
 | 
| 
jbe@0
 | 
   205 <h3>3. Operators</h3>
 | 
| 
jbe@0
 | 
   206 
 | 
| 
jbe@0
 | 
   207 <h4>Equality operator <code>=</code></h4>
 | 
| 
jbe@0
 | 
   208 
 | 
| 
jbe@0
 | 
   209 <p>Tests if two geographic objects are equal.</p>
 | 
| 
jbe@0
 | 
   210 
 | 
| 
jbe@0
 | 
   211 <p>The longitude is ignored for the poles, and 180 degrees west is considered to
 | 
| 
jbe@0
 | 
   212 be equal to 180 degrees east.</p>
 | 
| 
jbe@0
 | 
   213 
 | 
| 
jbe@0
 | 
   214 <p>For boxes and circles, two empty objects are considered equal. (Note that a
 | 
| 
jbe@0
 | 
   215 circle is not empty if the radius is zero but only if it is negative infinity,
 | 
| 
jbe@0
 | 
   216 i.e. smaller than zero.) Two circles with a positive infinite radius are also
 | 
| 
jbe@0
 | 
   217 considered equal.</p>
 | 
| 
jbe@0
 | 
   218 
 | 
| 
jbe@0
 | 
   219 <p>Implemented for:</p>
 | 
| 
jbe@0
 | 
   220 
 | 
| 
jbe@0
 | 
   221 <ul>
 | 
| 
jbe@0
 | 
   222 <li><code>epoint = epoint</code></li>
 | 
| 
jbe@0
 | 
   223 <li><code>ebox = ebox</code></li>
 | 
| 
jbe@0
 | 
   224 <li><code>ecircle = ecircle</code></li>
 | 
| 
jbe@0
 | 
   225 </ul>
 | 
| 
jbe@0
 | 
   226 
 | 
| 
jbe@0
 | 
   227 <p>The negation is the inequality operator (<code><></code> or <code>!=</code>).</p>
 | 
| 
jbe@0
 | 
   228 
 | 
| 
jbe@0
 | 
   229 <h4>Linear ordering operators <code><<<</code>, <code><<<=</code>, <code>>>>=</code>, <code>>>></code></h4>
 | 
| 
jbe@0
 | 
   230 
 | 
| 
jbe@0
 | 
   231 <p>These operators create an arbitrary (but well-defined) linear ordering of
 | 
| 
jbe@0
 | 
   232 geographic objects, which is used internally for B-tree indexing and merge
 | 
| 
jbe@0
 | 
   233 joins. These operators will usually not be used by an application programmer.</p>
 | 
| 
jbe@0
 | 
   234 
 | 
| 
jbe@0
 | 
   235 <h4>Overlap operator <code>&&</code></h4>
 | 
| 
jbe@0
 | 
   236 
 | 
| 
jbe@0
 | 
   237 <p>Tests if two geographic objects have at least one point in common. Currently
 | 
| 
jbe@0
 | 
   238 implemented for:</p>
 | 
| 
jbe@0
 | 
   239 
 | 
| 
jbe@0
 | 
   240 <ul>
 | 
| 
jbe@0
 | 
   241 <li><code>epoint && ebox</code></li>
 | 
| 
jbe@0
 | 
   242 <li><code>epoint && ecircle</code></li>
 | 
| 
jbe@0
 | 
   243 <li><code>epoint && ecluster</code></li>
 | 
| 
jbe@0
 | 
   244 <li><code>ebox && ebox</code></li>
 | 
| 
jbe@0
 | 
   245 <li><code>ecircle && ecircle</code></li>
 | 
| 
jbe@0
 | 
   246 <li><code>ecircle && ecluster</code></li>
 | 
| 
jbe@0
 | 
   247 </ul>
 | 
| 
jbe@0
 | 
   248 
 | 
| 
jbe@0
 | 
   249 <p>The <code>&&</code> operator is commutative, i.e. <code>a && b</code> is the same as <code>b && a</code>. Each
 | 
| 
jbe@0
 | 
   250 commutation is supported as well.</p>
 | 
| 
jbe@0
 | 
   251 
 | 
| 
jbe@0
 | 
   252 <h4>Distance operator <code><-></code></h4>
 | 
| 
jbe@0
 | 
   253 
 | 
| 
jbe@0
 | 
   254 <p>Calculates the shortest distance between two geographic objects in meters (zero
 | 
| 
jbe@0
 | 
   255 if the objects are overlapping). Currently implemented for:</p>
 | 
| 
jbe@0
 | 
   256 
 | 
| 
jbe@0
 | 
   257 <ul>
 | 
| 
jbe@0
 | 
   258 <li><code>epoint <-> epoint</code></li>
 | 
| 
jbe@0
 | 
   259 <li><code>epoint <-> ecircle</code></li>
 | 
| 
jbe@0
 | 
   260 <li><code>epoint <-> ecluster</code></li>
 | 
| 
jbe@0
 | 
   261 <li><code>ecircle <-> ecircle</code></li>
 | 
| 
jbe@0
 | 
   262 <li><code>ecircle <-> ecluster</code></li>
 | 
| 
jbe@0
 | 
   263 </ul>
 | 
| 
jbe@0
 | 
   264 
 | 
| 
jbe@0
 | 
   265 <p>The <code><-></code> operator is commutative, i.e. <code>a <-> b</code> is the same as <code>b <-> a</code>.
 | 
| 
jbe@0
 | 
   266 Each commutation is supported as well.</p>
 | 
| 
jbe@0
 | 
   267 
 | 
| 
jbe@0
 | 
   268 <p>For short distances, the result is very accurate (i.e. respects the dimensions
 | 
| 
jbe@0
 | 
   269 of the WGS-84 spheroid). For longer distances in the order of magnitude of
 | 
| 
jbe@0
 | 
   270 earth's radius or greater, the value is only approximate (but the error is
 | 
| 
jbe@0
 | 
   271 still less than 0.2% as long as no polygons with very long edges are involved).</p>
 | 
| 
jbe@0
 | 
   272 
 | 
| 
jbe@0
 | 
   273 <p>The functions <code>distance(epoint, epoint)</code> and <code>distance(ecluster, epoint)</code> can
 | 
| 
jbe@0
 | 
   274 be used as an alias for this operator.</p>
 | 
| 
jbe@0
 | 
   275 
 | 
| 
jbe@0
 | 
   276 <p>Note: In case of radial searches with a fixed radius, this operator should
 | 
| 
jbe@0
 | 
   277 not be used. Instead, an <code>ecircle</code> should be created and used in combination
 | 
| 
jbe@0
 | 
   278 with the overlap operator (<code>&&</code>). Alternatively, the functions
 | 
| 
jbe@0
 | 
   279 <code>distance_within(epoint, epoint, float8)</code> or <code>distance_within(ecluster, epoint,
 | 
| 
jbe@0
 | 
   280 float8)</code> can be used for fixed-radius searches.</p>
 | 
| 
jbe@0
 | 
   281 
 | 
| 
jbe@0
 | 
   282 <h3>4. Functions</h3>
 | 
| 
jbe@0
 | 
   283 
 | 
| 
jbe@0
 | 
   284 <h4><code>center(circle)</code></h4>
 | 
| 
jbe@0
 | 
   285 
 | 
| 
jbe@0
 | 
   286 <p>Returns the center of an <code>ecircle</code> as an <code>epoint</code>.</p>
 | 
| 
jbe@0
 | 
   287 
 | 
| 
jbe@0
 | 
   288 <h4><code>distance(epoint, epoint)</code></h4>
 | 
| 
jbe@0
 | 
   289 
 | 
| 
jbe@0
 | 
   290 <p>Calculates the distance between two <code>epoint</code> datums in meters. This function is
 | 
| 
jbe@0
 | 
   291 an alias for the distance operator <code><-></code>.</p>
 | 
| 
jbe@0
 | 
   292 
 | 
| 
jbe@0
 | 
   293 <p>Note: In case of radial searches with a fixed radius, this function should not be
 | 
| 
jbe@0
 | 
   294 used. Use <code>distance_within(epoint, epoint, float8)</code> instead.</p>
 | 
| 
jbe@0
 | 
   295 
 | 
| 
jbe@0
 | 
   296 <h4><code>distance(ecluster, epoint)</code></h4>
 | 
| 
jbe@0
 | 
   297 
 | 
| 
jbe@0
 | 
   298 <p>Calculates the distance from an <code>ecluster</code> to an <code>epoint</code> in meters. This
 | 
| 
jbe@0
 | 
   299 function is an alias for the distance operator <code><-></code>.</p>
 | 
| 
jbe@0
 | 
   300 
 | 
| 
jbe@0
 | 
   301 <p>Note: In case of radial searches with a fixed radius, this function should not be
 | 
| 
jbe@0
 | 
   302 used. Use <code>distance_within(epoint, epoint, float8)</code> instead.</p>
 | 
| 
jbe@0
 | 
   303 
 | 
| 
jbe@0
 | 
   304 <h4><code>distance_within(</code>variable <code>epoint,</code> fixed <code>epoint,</code> radius <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   305 
 | 
| 
jbe@0
 | 
   306 <p>Checks if the distance between two <code>epoint</code> datums is not greater than a given
 | 
| 
jbe@0
 | 
   307 value (search radius).</p>
 | 
| 
jbe@0
 | 
   308 
 | 
| 
jbe@0
 | 
   309 <p>Note: In case of radial searches with a fixed radius, the first argument must
 | 
| 
jbe@0
 | 
   310 be used for the table column, while the second argument must be used for the
 | 
| 
jbe@0
 | 
   311 search center. Otherwise an existing index cannot be used.</p>
 | 
| 
jbe@0
 | 
   312 
 | 
| 
jbe@0
 | 
   313 <h4><code>distance_within(</code>variable <code>ecluster,</code> fixed <code>epoint,</code> radius <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   314 
 | 
| 
jbe@0
 | 
   315 <p>Checks if the distance from an <code>ecluster</code> to an <code>epoint</code> is not greater than a
 | 
| 
jbe@0
 | 
   316 given value (search radius).</p>
 | 
| 
jbe@0
 | 
   317 
 | 
| 
jbe@0
 | 
   318 <h4><code>ebox(</code>latmin <code>float8,</code> latmax <code>float8,</code> lonmin <code>float8,</code> lonmax <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   319 
 | 
| 
jbe@0
 | 
   320 <p>Creates a new <code>ebox</code> with the given boundaries.
 | 
| 
jbe@0
 | 
   321 See "1. Types", subsection <code>ebox</code> for details.</p>
 | 
| 
jbe@0
 | 
   322 
 | 
| 
jbe@0
 | 
   323 <h4><code>ebox(epoint, epoint)</code></h4>
 | 
| 
jbe@0
 | 
   324 
 | 
| 
jbe@0
 | 
   325 <p>Creates a new <code>ebox</code>. This function may only be used if the longitude
 | 
| 
jbe@0
 | 
   326 difference is less than or equal to 120 degrees.
 | 
| 
jbe@0
 | 
   327 See "1. Types", subsection <code>ebox</code> for details.</p>
 | 
| 
jbe@0
 | 
   328 
 | 
| 
jbe@0
 | 
   329 <h4><code>ecircle(epoint, float8)</code></h4>
 | 
| 
jbe@0
 | 
   330 
 | 
| 
jbe@0
 | 
   331 <p>Creates an <code>ecircle</code> with the given center point and radius.</p>
 | 
| 
jbe@0
 | 
   332 
 | 
| 
jbe@0
 | 
   333 <h4><code>ecircle(</code>latitude <code>float8,</code> longitude <code>float8,</code> radius <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   334 
 | 
| 
jbe@0
 | 
   335 <p>Creates an <code>ecircle</code> with the given center point and radius.</p>
 | 
| 
jbe@0
 | 
   336 
 | 
| 
jbe@0
 | 
   337 <h4><code>ecluster_concat(ecluster, ecluster)</code></h4>
 | 
| 
jbe@0
 | 
   338 
 | 
| 
jbe@0
 | 
   339 <p>Combines two clusters to form a new <code>ecluster</code> by uniting all entries of both
 | 
| 
jbe@0
 | 
   340 clusters. Note that two overlapping areas of polygons annihilate each other
 | 
| 
jbe@0
 | 
   341 (which may be used to create polygons with holes).</p>
 | 
| 
jbe@0
 | 
   342 
 | 
| 
jbe@0
 | 
   343 <h4><code>ecluster_concat(ecluster[])</code></h4>
 | 
| 
jbe@0
 | 
   344 
 | 
| 
jbe@0
 | 
   345 <p>Creates a new <code>ecluster</code> that unites all entries of all clusters in the passed
 | 
| 
jbe@0
 | 
   346 array. Note that two overlapping areas of polygons annihilate each other (which
 | 
| 
jbe@0
 | 
   347 may be used to create polygons with holes).</p>
 | 
| 
jbe@0
 | 
   348 
 | 
| 
jbe@0
 | 
   349 <h4><code>ecluster_create_multipoint(epoint[])</code></h4>
 | 
| 
jbe@0
 | 
   350 
 | 
| 
jbe@0
 | 
   351 <p>Creates a new <code>ecluster</code> which contains multiple points.</p>
 | 
| 
jbe@0
 | 
   352 
 | 
| 
jbe@0
 | 
   353 <h4><code>ecluster_create_outline(epoint[])</code></h4>
 | 
| 
jbe@0
 | 
   354 
 | 
| 
jbe@0
 | 
   355 <p>Creates a new <code>ecluster</code> that is an outline given by the passed points.</p>
 | 
| 
jbe@0
 | 
   356 
 | 
| 
jbe@0
 | 
   357 <h4><code>ecluster_create_path(epoint[])</code></h4>
 | 
| 
jbe@0
 | 
   358 
 | 
| 
jbe@0
 | 
   359 <p>Creates a new <code>ecluster</code> that is a path given by the passed points.</p>
 | 
| 
jbe@0
 | 
   360 
 | 
| 
jbe@0
 | 
   361 <h4><code>ecluster_create_polygon(epoint[])</code></h4>
 | 
| 
jbe@0
 | 
   362 
 | 
| 
jbe@0
 | 
   363 <p>Creates a new <code>ecluster</code> that is a polygon given by the passed points.</p>
 | 
| 
jbe@0
 | 
   364 
 | 
| 
jbe@0
 | 
   365 <h4><code>ecluster_extract_outlines(ecluster)</code></h4>
 | 
| 
jbe@0
 | 
   366 
 | 
| 
jbe@0
 | 
   367 <p>Set-returning function that returns the outlines of an <code>ecluster</code> as <code>epoint[]</code>
 | 
| 
jbe@0
 | 
   368 rows.</p>
 | 
| 
jbe@0
 | 
   369 
 | 
| 
jbe@0
 | 
   370 <h4><code>ecluster_extract_paths(ecluster)</code></h4>
 | 
| 
jbe@0
 | 
   371 
 | 
| 
jbe@0
 | 
   372 <p>Set-returning function that returns the paths of an <code>ecluster</code> as <code>epoint[]</code>
 | 
| 
jbe@0
 | 
   373 rows.</p>
 | 
| 
jbe@0
 | 
   374 
 | 
| 
jbe@0
 | 
   375 <h4><code>ecluster_extract_points(ecluster)</code></h4>
 | 
| 
jbe@0
 | 
   376 
 | 
| 
jbe@0
 | 
   377 <p>Set-returning function that returns the points of an <code>ecluster</code> as <code>epoint</code>
 | 
| 
jbe@0
 | 
   378 rows.</p>
 | 
| 
jbe@0
 | 
   379 
 | 
| 
jbe@0
 | 
   380 <h4><code>ecluster_extract_polygons(ecluster)</code></h4>
 | 
| 
jbe@0
 | 
   381 
 | 
| 
jbe@0
 | 
   382 <p>Set-returning function that returns the polygons of an <code>ecluster</code> as <code>epoint[]</code>
 | 
| 
jbe@0
 | 
   383 rows.</p>
 | 
| 
jbe@0
 | 
   384 
 | 
| 
jbe@0
 | 
   385 <h4><code>empty_ebox</code>()</h4>
 | 
| 
jbe@0
 | 
   386 
 | 
| 
jbe@0
 | 
   387 <p>Returns the empty <code>ebox</code>.
 | 
| 
jbe@0
 | 
   388 See "1. Types", subsection <code>ebox</code> for details.</p>
 | 
| 
jbe@0
 | 
   389 
 | 
| 
jbe@0
 | 
   390 <h4><code>epoint(</code>latitude <code>float8,</code> longitude <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   391 
 | 
| 
jbe@0
 | 
   392 <p>Returns an <code>epoint</code> with the given latitude and longitude.</p>
 | 
| 
jbe@0
 | 
   393 
 | 
| 
jbe@0
 | 
   394 <h4><code>epoint_latlon(</code>latitude <code>float8,</code> longitude <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   395 
 | 
| 
jbe@0
 | 
   396 <p>Alias for <code>epoint(float8, float8)</code>.</p>
 | 
| 
jbe@0
 | 
   397 
 | 
| 
jbe@0
 | 
   398 <h4><code>epoint_lonlat(</code>longitude <code>float8,</code> latitude <code>float8)</code></h4>
 | 
| 
jbe@0
 | 
   399 
 | 
| 
jbe@0
 | 
   400 <p>Same as <code>epoint(float8, float8)</code> but with arguments reversed.</p>
 | 
| 
jbe@0
 | 
   401 
 | 
| 
jbe@0
 | 
   402 <h4><code>GeoJSON_to_epoint(jsonb, text)</code></h4>
 | 
| 
jbe@0
 | 
   403 
 | 
| 
jbe@0
 | 
   404 <p>Maps a GeoJSON object of type "Point" or "Feature" (which contains a
 | 
| 
jbe@0
 | 
   405 "Point") to an <code>epoint</code> datum. For any other JSON objects, NULL is returned.</p>
 | 
| 
jbe@0
 | 
   406 
 | 
| 
jbe@0
 | 
   407 <p>The second parameter (which defaults to <code>epoint_lonlat</code>) may be set to a name
 | 
| 
jbe@0
 | 
   408 of a conversion function that transforms two coordinates (two <code>float8</code>
 | 
| 
jbe@0
 | 
   409 parameters) to an <code>epoint</code>.</p>
 | 
| 
jbe@0
 | 
   410 
 | 
| 
jbe@0
 | 
   411 <h4><code>GeoJSON_to_ecluster(jsonb, text)</code></h4>
 | 
| 
jbe@0
 | 
   412 
 | 
| 
jbe@0
 | 
   413 <p>Maps a (valid) GeoJSON object to an <code>ecluster</code>. Note that this function
 | 
| 
jbe@0
 | 
   414 does not check whether the JSONB object is a valid GeoJSON object.</p>
 | 
| 
jbe@0
 | 
   415 
 | 
| 
jbe@0
 | 
   416 <p>The second parameter (which defaults to <code>epoint_lonlat</code>) may be set to a name
 | 
| 
jbe@0
 | 
   417 of a conversion function that transforms two coordinates (two <code>float8</code>
 | 
| 
jbe@0
 | 
   418 parameters) to an <code>epoint</code>.</p>
 | 
| 
jbe@0
 | 
   419 
 | 
| 
jbe@0
 | 
   420 <h4><code>max_latitude(ebox)</code></h4>
 | 
| 
jbe@0
 | 
   421 
 | 
| 
jbe@0
 | 
   422 <p>Returns the northern boundary of a given <code>ebox</code> in degrees between -90 and +90.</p>
 | 
| 
jbe@0
 | 
   423 
 | 
| 
jbe@0
 | 
   424 <h4><code>max_longitude(ebox)</code></h4>
 | 
| 
jbe@0
 | 
   425 
 | 
| 
jbe@0
 | 
   426 <p>Returns the eastern boundary of a given <code>ebox</code> in degrees between -180 and +180
 | 
| 
jbe@0
 | 
   427 (both inclusive).</p>
 | 
| 
jbe@0
 | 
   428 
 | 
| 
jbe@0
 | 
   429 <h4><code>min_latitude(ebox)</code></h4>
 | 
| 
jbe@0
 | 
   430 
 | 
| 
jbe@0
 | 
   431 <p>Returns the southern boundary of a given <code>ebox</code> in degrees between -90 and +90.</p>
 | 
| 
jbe@0
 | 
   432 
 | 
| 
jbe@0
 | 
   433 <h4><code>min_longitude(ebox)</code></h4>
 | 
| 
jbe@0
 | 
   434 
 | 
| 
jbe@0
 | 
   435 <p>Returns the western boundary of a given <code>ebox</code> in degrees between -180 and +180
 | 
| 
jbe@0
 | 
   436 (both inclusive).</p>
 | 
| 
jbe@0
 | 
   437 
 | 
| 
jbe@0
 | 
   438 <h4><code>latitude(epoint)</code></h4>
 | 
| 
jbe@0
 | 
   439 
 | 
| 
jbe@0
 | 
   440 <p>Returns the latitude value of an <code>epoint</code> in degrees between -90 and +90.</p>
 | 
| 
jbe@0
 | 
   441 
 | 
| 
jbe@0
 | 
   442 <h4><code>longitude(epoint)</code></h4>
 | 
| 
jbe@0
 | 
   443 
 | 
| 
jbe@0
 | 
   444 <p>Returns the longitude value of an <code>epoint</code> in degrees between -180 and +180
 | 
| 
jbe@0
 | 
   445 (both inclusive).</p>
 | 
| 
jbe@0
 | 
   446 
 | 
| 
jbe@0
 | 
   447 <h4><code>radius(ecircle)</code></h4>
 | 
| 
jbe@0
 | 
   448 
 | 
| 
jbe@0
 | 
   449 <p>Returns the radius of an <code>ecircle</code> in meters.</p>
 | 
| 
jbe@0
 | 
   450 </body></html>
 |