pgLatLon
diff README.html @ 42:1b9cd45e9e48
Bugfix for type casts to ecluster; New "fair_distance" function
author | jbe |
---|---|
date | Tue Oct 25 18:44:43 2016 +0200 (2016-10-25) |
parents | f1a9a5de9a12 |
children | 10640afbe2ea |
line diff
1.1 --- a/README.html Fri Oct 21 12:57:46 2016 +0200 1.2 +++ b/README.html Tue Oct 25 18:44:43 2016 +0200 1.3 @@ -1,5 +1,5 @@ 1.4 -<html><head><title>pgLatLon v0.8 documentation</title></head><body> 1.5 -<h1>pgLatLon v0.8 documentation</h1> 1.6 +<html><head><title>pgLatLon v0.9 documentation</title></head><body> 1.7 +<h1>pgLatLon v0.9 documentation</h1> 1.8 1.9 <p>pgLatLon is a spatial database extension for the PostgreSQL object-relational 1.10 database management system providing geographic data types and spatial indexing 1.11 @@ -40,8 +40,8 @@ 1.12 <p>It is also possible to compile and install the extension without GNU Make as 1.13 follows:</p> 1.14 1.15 -<pre><code>cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0007.so latlon-v0007.c 1.16 -cp latlon-v0007.so `pg_config --pkglibdir` 1.17 +<pre><code>cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0008.so latlon-v0008.c 1.18 +cp latlon-v0008.so `pg_config --pkglibdir` 1.19 cp latlon.control `pg_config --sharedir`/extension/ 1.20 cp latlon--*.sql `pg_config --sharedir`/extension/ 1.21 </code></pre> 1.22 @@ -486,6 +486,40 @@ 1.23 1.24 <p>Same as <code>epoint(float8, float8)</code> but with arguments reversed.</p> 1.25 1.26 +<h4><code>fair_distance(ecluster, epoint,</code> samples <code>int4 = 10000)</code></h4> 1.27 + 1.28 +<p>When working with user-generated content, users may be tempted to create 1.29 +intentionally oversized objects in order to optimize search results in an 1.30 +unfair manner. The <code>fair_distance</code> function aims to handle this by returning an 1.31 +adjusted distance (i.e. distance increased by a penalty) if a geographic object 1.32 +(the <code>ecluster</code>) consists of more than one point.</p> 1.33 + 1.34 +<p>The first argument to this function is an <code>ecluster</code>, the second argument is a 1.35 +search point (<code>epoint</code>), and the third argument is an interger related to the 1.36 +precision (higher precision will require more computation time).</p> 1.37 + 1.38 +<p>The penalty by which the returned distance is increased fulfills (at least) the 1.39 +following properties:</p> 1.40 + 1.41 +<ul> 1.42 +<li>For search points far away from the <code>ecluster</code> (i.e. distance approaching 1.43 +infinity), the penalty approaches zero (i.e. <code>fair_distance</code> behaves the same 1.44 +as <code>distance</code>).</li> 1.45 +<li>If the <code>ecluster</code> consists of a set of points, the penalty for a search point 1.46 +close to one of that points (closer than half of the minimum distance between 1.47 +each pair of points in the <code>ecluster</code>) is chosen in such a way that the 1.48 +adjusted distance is equal to the distance from the search point to the 1.49 +closest point in the <code>ecluster</code> multiplied by the square root of the count of 1.50 +points in the <code>ecluster</code>.</li> 1.51 +</ul> 1.52 + 1.53 +<p>The function interally uses a Monte Carlo simulation to compute the result. The 1.54 +third parameter (which defaults to 10000) can be used to adjust the number of 1.55 +samples taken. It is ensured that the penalty is always positive, i.e. results 1.56 +returned by the <code>fair_distance</code> function are always equal to or greater than 1.57 +the results returned by the <code>distance</code> function regardless of stochastic 1.58 +effects.</p> 1.59 + 1.60 <h4><code>GeoJSON_to_epoint(jsonb, text)</code></h4> 1.61 1.62 <p>Maps a GeoJSON object of type "Point" or "Feature" (which contains a