# HG changeset patch # User jbe # Date 1473696052 -7200 # Node ID 8a8d6dc44337d9803e6c0ca8c6eaf10c3246dd47 # Parent bd166e5e02cbad41abd65789d7656bad931e76e1 Changed/fixed behavior of "contains" operator regarding perimeters; Added "contains" operator for ebox type; Minor changes in README diff -r bd166e5e02cb -r 8a8d6dc44337 GNUmakefile --- a/GNUmakefile Fri Sep 09 23:44:28 2016 +0200 +++ b/GNUmakefile Mon Sep 12 18:00:52 2016 +0200 @@ -1,5 +1,5 @@ EXTENSION = latlon -DATA = latlon--0.3--0.4.sql latlon--0.4.sql latlon--0.5.sql +DATA = latlon--0.3--0.4.sql latlon--0.4.sql latlon--0.4--0.5.sql latlon--0.5.sql MODULES = latlon-v0004 latlon-v0005 PG_CONFIG = pg_config diff -r bd166e5e02cb -r 8a8d6dc44337 README.html --- a/README.html Fri Sep 09 23:44:28 2016 +0200 +++ b/README.html Mon Sep 12 18:00:52 2016 +0200 @@ -1,5 +1,5 @@ -
pgLatLon is a spatial database extension for the PostgreSQL object-relational database management system providing geographic data types and spatial indexing @@ -40,8 +40,8 @@
It is also possible to compile and install the extension without GNU Make as follows:
-cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0003.so latlon-v0003.c
-cp latlon-v0003.so `pg_config --pkglibdir`
+cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0005.so latlon-v0005.c
+cp latlon-v0005.so `pg_config --pkglibdir`
cp latlon.control `pg_config --sharedir`/extension/
cp latlon--*.sql `pg_config --sharedir`/extension/
@@ -285,8 +285,8 @@
ecluster && ecluster
-The &&
operator is commutative, i.e. a && b
is the same as b && a
. Each
-commutation is supported as well.
+The &&
operator is commutative, i.e. "a && b
" is the same as "b && a
".
+Each commutation is supported as well.
Lossy overlap operator &&+
@@ -302,7 +302,7 @@
ecluster &&+ ecluster
-The &&+
operator is commutative, i.e. a &&+ b
is the same as b &&+ a
.
+
The &&+
operator is commutative, i.e. "a &&+ b
" is the same as "b &&+ a
".
Each commutation is supported as well.
Where two data types support both the &&
and the &&+
operator, the &&+
@@ -315,14 +315,21 @@
ebox @> epoint
(alias for &&
)
+ebox @> ebox
ebox @> ecluster
ecluster @> epoint
(alias for &&
)
ecluster @> ebox
ecluster @> ecluster
-The commutator of @>
("contains") is <@
("is contained in"), i.e. a @> b
-is the same as b <@ a
.
+The commutator of @>
("contains") is <@
("is contained in"), i.e.
+"a @> b
" is the same as "b <@ a
".
+
+Whether the perimeter of an object is taken into account is undefined and may
+differ between the left and the right hand side of the operator. The current
+implementation returns true only if an object is contained completely within
+the other object, not touching its perimeter, paths, outlines, or any singular
+points.
Distance operator <->
@@ -342,7 +349,7 @@
ecluster <-> ecluster
-The <->
operator is commutative, i.e. a <-> b
is the same as b <-> a
.
+
The <->
operator is commutative, i.e. "a <-> b
" is the same as "b <-> a
".
Each commutation is supported as well.
For short distances, the result is very accurate (i.e. respects the dimensions
diff -r bd166e5e02cb -r 8a8d6dc44337 README.mkd
--- a/README.mkd Fri Sep 09 23:44:28 2016 +0200
+++ b/README.mkd Mon Sep 12 18:00:52 2016 +0200
@@ -1,4 +1,4 @@
-pgLatLon v0.4 documentation
+pgLatLon v0.5 documentation
===========================
pgLatLon is a spatial database extension for the PostgreSQL object-relational
@@ -39,8 +39,8 @@
It is also possible to compile and install the extension without GNU Make as
follows:
- cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0003.so latlon-v0003.c
- cp latlon-v0003.so `pg_config --pkglibdir`
+ cc -Wall -O2 -fPIC -shared -I `pg_config --includedir-server` -o latlon-v0005.so latlon-v0005.c
+ cp latlon-v0005.so `pg_config --pkglibdir`
cp latlon.control `pg_config --sharedir`/extension/
cp latlon--*.sql `pg_config --sharedir`/extension/
@@ -274,8 +274,8 @@
* `ecircle && ecluster`
* `ecluster && ecluster`
-The `&&` operator is commutative, i.e. `a && b` is the same as `b && a`. Each
-commutation is supported as well.
+The `&&` operator is commutative, i.e. "`a && b`" is the same as "`b && a`".
+Each commutation is supported as well.
#### Lossy overlap operator `&&+`
@@ -289,7 +289,7 @@
* `ecircle &&+ ecluster`
* `ecluster &&+ ecluster`
-The `&&+` operator is commutative, i.e. `a &&+ b` is the same as `b &&+ a`.
+The `&&+` operator is commutative, i.e. "`a &&+ b`" is the same as "`b &&+ a`".
Each commutation is supported as well.
Where two data types support both the `&&` and the `&&+` operator, the `&&+`
@@ -301,13 +301,20 @@
the operator. Currently implemented for:
* `ebox @> epoint` (alias for `&&`)
+* `ebox @> ebox`
* `ebox @> ecluster`
* `ecluster @> epoint` (alias for `&&`)
* `ecluster @> ebox`
* `ecluster @> ecluster`
-The commutator of `@>` ("contains") is `<@` ("is contained in"), i.e. `a @> b`
-is the same as `b <@ a`.
+The commutator of `@>` ("contains") is `<@` ("is contained in"), i.e.
+"`a @> b`" is the same as "`b <@ a`".
+
+Whether the perimeter of an object is taken into account is undefined and may
+differ between the left and the right hand side of the operator. The current
+implementation returns true only if an object is contained completely within
+the other object, not touching its perimeter, paths, outlines, or any singular
+points.
#### Distance operator `<->`
@@ -325,7 +332,7 @@
* `ecircle <-> ecluster`
* `ecluster <-> ecluster`
-The `<->` operator is commutative, i.e. `a <-> b` is the same as `b <-> a`.
+The `<->` operator is commutative, i.e. "`a <-> b`" is the same as "`b <-> a`".
Each commutation is supported as well.
For short distances, the result is very accurate (i.e. respects the dimensions
diff -r bd166e5e02cb -r 8a8d6dc44337 latlon--0.4--0.5.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/latlon--0.4--0.5.sql Mon Sep 12 18:00:52 2016 +0200
@@ -0,0 +1,457 @@
+
+CREATE OR REPLACE FUNCTION ekey_point_in_dummy(cstring)
+ RETURNS ekey_point
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_notimpl';
+
+CREATE OR REPLACE FUNCTION ekey_point_out_dummy(ekey_point)
+ RETURNS cstring
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_notimpl';
+
+CREATE OR REPLACE FUNCTION ekey_area_in_dummy(cstring)
+ RETURNS ekey_area
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_notimpl';
+
+CREATE OR REPLACE FUNCTION ekey_area_out_dummy(ekey_area)
+ RETURNS cstring
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_notimpl';
+
+CREATE OR REPLACE FUNCTION epoint_in(cstring)
+ RETURNS epoint
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_in';
+
+CREATE OR REPLACE FUNCTION ebox_in(cstring)
+ RETURNS ebox
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_in';
+
+CREATE OR REPLACE FUNCTION ecircle_in(cstring)
+ RETURNS ecircle
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_in';
+
+CREATE OR REPLACE FUNCTION ecluster_in(cstring)
+ RETURNS ecluster
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecluster_in';
+
+CREATE OR REPLACE FUNCTION epoint_out(epoint)
+ RETURNS cstring
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_out';
+
+CREATE OR REPLACE FUNCTION ebox_out(ebox)
+ RETURNS cstring
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_out';
+
+CREATE OR REPLACE FUNCTION ecircle_out(ecircle)
+ RETURNS cstring
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_out';
+
+CREATE OR REPLACE FUNCTION ecluster_out(ecluster)
+ RETURNS cstring
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecluster_out';
+
+CREATE OR REPLACE FUNCTION epoint_recv(internal)
+ RETURNS epoint
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_recv';
+
+CREATE OR REPLACE FUNCTION ebox_recv(internal)
+ RETURNS ebox
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_recv';
+
+CREATE OR REPLACE FUNCTION ecircle_recv(internal)
+ RETURNS ecircle
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_recv';
+
+CREATE OR REPLACE FUNCTION epoint_send(epoint)
+ RETURNS bytea
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_send';
+
+CREATE OR REPLACE FUNCTION ebox_send(ebox)
+ RETURNS bytea
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_send';
+
+CREATE OR REPLACE FUNCTION ecircle_send(ecircle)
+ RETURNS bytea
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_send';
+
+CREATE OR REPLACE FUNCTION epoint_btree_lt(epoint, epoint)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_lt';
+
+CREATE OR REPLACE FUNCTION epoint_btree_le(epoint, epoint)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_le';
+
+CREATE OR REPLACE FUNCTION epoint_btree_eq(epoint, epoint)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_eq';
+
+CREATE OR REPLACE FUNCTION epoint_btree_ne(epoint, epoint)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_ne';
+
+CREATE OR REPLACE FUNCTION epoint_btree_ge(epoint, epoint)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_ge';
+
+CREATE OR REPLACE FUNCTION epoint_btree_gt(epoint, epoint)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_gt';
+
+CREATE OR REPLACE FUNCTION epoint_btree_cmp(epoint, epoint)
+ RETURNS int4
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_epoint_cmp';
+
+CREATE OR REPLACE FUNCTION ebox_btree_lt(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_lt';
+
+CREATE OR REPLACE FUNCTION ebox_btree_le(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_le';
+
+CREATE OR REPLACE FUNCTION ebox_btree_eq(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_eq';
+
+CREATE OR REPLACE FUNCTION ebox_btree_ne(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_ne';
+
+CREATE OR REPLACE FUNCTION ebox_btree_ge(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_ge';
+
+CREATE OR REPLACE FUNCTION ebox_btree_gt(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_gt';
+
+CREATE OR REPLACE FUNCTION ebox_btree_cmp(ebox, ebox)
+ RETURNS int4
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ebox_cmp';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_lt(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_lt';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_le(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_le';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_eq(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_eq';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_ne(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_ne';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_ge(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_ge';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_gt(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_gt';
+
+CREATE OR REPLACE FUNCTION ecircle_btree_cmp(ecircle, ecircle)
+ RETURNS int4
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_btree_ecircle_cmp';
+
+CREATE OR REPLACE FUNCTION cast_epoint_to_ebox(epoint)
+ RETURNS ebox
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_to_ebox';
+
+CREATE OR REPLACE FUNCTION cast_epoint_to_ecircle(epoint)
+ RETURNS ecircle
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_to_ecircle';
+
+CREATE OR REPLACE FUNCTION cast_epoint_to_ecluster(epoint)
+ RETURNS ecluster
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_to_ecluster';
+
+CREATE OR REPLACE FUNCTION cast_ebox_to_ecluster(ebox)
+ RETURNS ecluster
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_to_ecluster';
+
+CREATE OR REPLACE FUNCTION epoint(float8, float8)
+ RETURNS epoint
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_create_epoint';
+
+CREATE OR REPLACE FUNCTION empty_ebox()
+ RETURNS ebox
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_create_empty_ebox';
+
+CREATE OR REPLACE FUNCTION ebox(float8, float8, float8, float8)
+ RETURNS ebox
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_create_ebox';
+
+CREATE OR REPLACE FUNCTION ebox(epoint, epoint)
+ RETURNS ebox
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_create_ebox_from_epoints';
+
+CREATE OR REPLACE FUNCTION ecircle(float8, float8, float8)
+ RETURNS ecircle
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_create_ecircle';
+
+CREATE OR REPLACE FUNCTION ecircle(epoint, float8)
+ RETURNS ecircle
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_create_ecircle_from_epoint';
+
+CREATE OR REPLACE FUNCTION latitude(epoint)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_lat';
+
+CREATE OR REPLACE FUNCTION longitude(epoint)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_lon';
+
+CREATE OR REPLACE FUNCTION min_latitude(ebox)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_lat_min';
+
+CREATE OR REPLACE FUNCTION max_latitude(ebox)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_lat_max';
+
+CREATE OR REPLACE FUNCTION min_longitude(ebox)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_lon_min';
+
+CREATE OR REPLACE FUNCTION max_longitude(ebox)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_lon_max';
+
+CREATE OR REPLACE FUNCTION center(ecircle)
+ RETURNS epoint
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_center';
+
+CREATE OR REPLACE FUNCTION radius(ecircle)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_radius';
+
+CREATE OR REPLACE FUNCTION epoint_ebox_overlap_proc(epoint, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_ebox_overlap';
+
+CREATE OR REPLACE FUNCTION epoint_ecircle_overlap_proc(epoint, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_ecircle_overlap';
+
+CREATE OR REPLACE FUNCTION epoint_ecluster_overlap_proc(epoint, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_ecluster_overlap';
+
+CREATE OR REPLACE FUNCTION epoint_ecluster_may_overlap_proc(epoint, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_ecluster_may_overlap';
+
+CREATE OR REPLACE FUNCTION ebox_overlap_proc(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_overlap';
+
+CREATE OR REPLACE FUNCTION ebox_ecircle_may_overlap_proc(ebox, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_ecircle_may_overlap';
+
+CREATE OR REPLACE FUNCTION ebox_ecluster_may_overlap_proc(ebox, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ebox_ecluster_may_overlap';
+
+CREATE OR REPLACE FUNCTION ecircle_overlap_proc(ecircle, ecircle)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_overlap';
+
+CREATE OR REPLACE FUNCTION ecircle_ecluster_overlap_proc(ecircle, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_ecluster_overlap';
+
+CREATE OR REPLACE FUNCTION ecircle_ecluster_may_overlap_proc(ecircle, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_ecluster_may_overlap';
+
+CREATE OR REPLACE FUNCTION ecluster_overlap_proc(ecluster, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecluster_overlap';
+
+CREATE OR REPLACE FUNCTION ecluster_may_overlap_proc(ecluster, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecluster_may_overlap';
+
+CREATE OR REPLACE FUNCTION ecluster_contains_proc(ecluster, ecluster)
+ RETURNS boolean
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecluster_contains';
+
+CREATE OR REPLACE FUNCTION epoint_distance_proc(epoint, epoint)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_distance';
+
+CREATE OR REPLACE FUNCTION epoint_ecircle_distance_proc(epoint, ecircle)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_ecircle_distance';
+
+CREATE OR REPLACE FUNCTION epoint_ecluster_distance_proc(epoint, ecluster)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_epoint_ecluster_distance';
+
+CREATE OR REPLACE FUNCTION ecircle_distance_proc(ecircle, ecircle)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_distance';
+
+CREATE OR REPLACE FUNCTION ecircle_ecluster_distance_proc(ecircle, ecluster)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecircle_ecluster_distance';
+
+CREATE OR REPLACE FUNCTION ecluster_distance_proc(ecluster, ecluster)
+ RETURNS float8
+ LANGUAGE C IMMUTABLE STRICT
+ AS '$libdir/latlon-v0005', 'pgl_ecluster_distance';
+
+CREATE FUNCTION ebox_contains_castwrap(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE sql IMMUTABLE AS 'SELECT $1::ecluster @> $2::ecluster';
+
+CREATE OPERATOR @> (
+ leftarg = ebox,
+ rightarg = ebox,
+ procedure = ebox_contains_castwrap,
+ commutator = <@,
+ restrict = areasel,
+ join = areajoinsel
+);
+
+CREATE FUNCTION ebox_contains_swapped_castwrap(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE sql IMMUTABLE AS 'SELECT $2::ecluster @> $1::ecluster';
+
+CREATE OPERATOR <@ (
+ leftarg = ebox,
+ rightarg = ebox,
+ procedure = ebox_contains_swapped_castwrap,
+ commutator = @>,
+ restrict = areasel,
+ join = areajoinsel
+);
+
+CREATE OR REPLACE FUNCTION pgl_gist_consistent(internal, internal, smallint, oid, internal)
+ RETURNS boolean
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_consistent';
+
+CREATE OR REPLACE FUNCTION pgl_gist_union(internal, internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_union';
+
+CREATE OR REPLACE FUNCTION pgl_gist_compress_epoint(internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_compress_epoint';
+
+CREATE OR REPLACE FUNCTION pgl_gist_compress_ecircle(internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_compress_ecircle';
+
+CREATE OR REPLACE FUNCTION pgl_gist_compress_ecluster(internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_compress_ecluster';
+
+CREATE OR REPLACE FUNCTION pgl_gist_decompress(internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_decompress';
+
+CREATE OR REPLACE FUNCTION pgl_gist_penalty(internal, internal, internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_penalty';
+
+CREATE OR REPLACE FUNCTION pgl_gist_picksplit(internal, internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_picksplit';
+
+CREATE OR REPLACE FUNCTION pgl_gist_same(internal, internal, internal)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_same';
+
+CREATE OR REPLACE FUNCTION pgl_gist_distance(internal, internal, smallint, oid)
+ RETURNS internal
+ LANGUAGE C STRICT
+ AS '$libdir/latlon-v0005', 'pgl_gist_distance';
+
diff -r bd166e5e02cb -r 8a8d6dc44337 latlon--0.5.sql
--- a/latlon--0.5.sql Fri Sep 09 23:44:28 2016 +0200
+++ b/latlon--0.5.sql Mon Sep 12 18:00:52 2016 +0200
@@ -1134,6 +1134,32 @@
join = areajoinsel
);
+CREATE FUNCTION ebox_contains_castwrap(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE sql IMMUTABLE AS 'SELECT $1::ecluster @> $2::ecluster';
+
+CREATE OPERATOR @> (
+ leftarg = ebox,
+ rightarg = ebox,
+ procedure = ebox_contains_castwrap,
+ commutator = <@,
+ restrict = areasel,
+ join = areajoinsel
+);
+
+CREATE FUNCTION ebox_contains_swapped_castwrap(ebox, ebox)
+ RETURNS boolean
+ LANGUAGE sql IMMUTABLE AS 'SELECT $2::ecluster @> $1::ecluster';
+
+CREATE OPERATOR <@ (
+ leftarg = ebox,
+ rightarg = ebox,
+ procedure = ebox_contains_swapped_castwrap,
+ commutator = @>,
+ restrict = areasel,
+ join = areajoinsel
+);
+
CREATE FUNCTION ebox_ecluster_contains_castwrap(ebox, ecluster)
RETURNS boolean
LANGUAGE sql IMMUTABLE AS 'SELECT $1::ecluster @> $2';
diff -r bd166e5e02cb -r 8a8d6dc44337 latlon-v0005.c
--- a/latlon-v0005.c Fri Sep 09 23:44:28 2016 +0200
+++ b/latlon-v0005.c Mon Sep 12 18:00:52 2016 +0200
@@ -489,7 +489,13 @@
}
/* check if point is inside cluster */
-static bool pgl_point_in_cluster(pgl_point *point, pgl_cluster *cluster) {
+/* (if point is on perimeter, then true is returned if and only if
+ strict == false) */
+static bool pgl_point_in_cluster(
+ pgl_point *point,
+ pgl_cluster *cluster,
+ bool strict
+) {
int i, j, k; /* i: entry, j: point in entry, k: next point in entry */
int entrytype; /* type of entry */
int npoints; /* number of points in entry */
@@ -504,8 +510,11 @@
int counter = 0; /* counter for intersections east of point */
/* iterate over all entries */
for (i=0; inentries; i++) {
- /* get properties of entry */
+ /* get type of entry */
entrytype = cluster->entries[i].entrytype;
+ /* skip all entries but polygons if perimeters are excluded */
+ if (strict && entrytype != PGL_ENTRY_POLYGON) continue;
+ /* get points of entry */
npoints = cluster->entries[i].npoints;
points = PGL_ENTRY_POINTS(cluster, i);
/* determine east/west orientation of first point of entry and calculate
@@ -521,8 +530,8 @@
else if (lon_dir > 0 && lon0 < lon_break) lon0 = pgl_round(lon0 + 360);
/* iterate over all edges and vertices */
for (j=0; j lon_break) lon2 = pgl_round(lon2 - 360);
else if (lon_dir > 0 && lon2 < lon_break) lon2 = pgl_round(lon2 + 360);
- /* return true if point is on horizontal (west to east) edge of polygon */
+ /* return if point is on horizontal (west to east) edge of polygon */
if (
lat0 == lat1 && lat0 == lat2 &&
( (lon0 >= lon1 && lon0 <= lon2) || (lon0 >= lon2 && lon0 <= lon1) )
- ) return true;
+ ) return !strict;
/* check if edge crosses east/west line of point */
if ((lat1 < lat0 && lat2 >= lat0) || (lat2 < lat0 && lat1 >= lat0)) {
/* calculate longitude of intersection */
lon = (lon1 * (lat2-lat0) + lon2 * (lat0-lat1)) / (lat2-lat1);
- /* return true if intersection goes (approximately) through point */
- if (pgl_round(lon) == lon0) return true;
+ /* return if intersection goes (approximately) through point */
+ if (pgl_round(lon) == lon0) return !strict;
/* count intersection if east of point and entry is polygon*/
if (entrytype == PGL_ENTRY_POLYGON && lon > lon0) counter++;
}
@@ -569,8 +578,9 @@
return counter & 1;
}
-/* check if all points of the second cluster are inside the first cluster */
-static inline bool pgl_all_cluster_points_in_cluster(
+/* check if all points of the second cluster are strictly inside the first
+ cluster */
+static inline bool pgl_all_cluster_points_strictly_in_cluster(
pgl_cluster *outer, pgl_cluster *inner
) {
int i, j; /* i: entry, j: point in entry */
@@ -584,7 +594,7 @@
/* iterate over all points in entry of "inner" cluster */
for (j=0; jnentries; i++) {
/* get properties of entry */
@@ -2343,7 +2349,7 @@
cluster->bounding.center.lat, cluster->bounding.center.lon
) > cluster->bounding.radius
) retval = false;
- else retval = pgl_point_in_cluster(point, cluster);
+ else retval = pgl_point_in_cluster(point, cluster, false);
PG_FREE_IF_COPY(cluster, 1);
PG_RETURN_BOOL(retval);
}
diff -r bd166e5e02cb -r 8a8d6dc44337 latlon.control
--- a/latlon.control Fri Sep 09 23:44:28 2016 +0200
+++ b/latlon.control Mon Sep 12 18:00:52 2016 +0200
@@ -1,3 +1,3 @@
comment = 'Geographic data types and spatial indexing for the WGS-84 spheroid'
-default_version = '0.4'
+default_version = '0.5'
relocatable = true