diff --git a/doc/geometry.qbk b/doc/geometry.qbk index cfe3b6deb..7ff1d6512 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -113,7 +113,6 @@ Boost.Geometry contains contributions by: * Federico Fern\u00E1ndez (preliminary version of R-tree spatial index) * Karsten Ahnert (patch for cross-track distance) * Mats Taraldsvik (documentation: adapting a legacy model) -* Menelaos Karavelas (on behalf of Oracle: distance, set operations, etc.) [include imports.qbk] diff --git a/doc/reference/status/area_status.qbk b/doc/reference/status/area_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/area_status.qbk +++ b/doc/reference/status/area_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/centroid_status.qbk b/doc/reference/status/centroid_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/centroid_status.qbk +++ b/doc/reference/status/centroid_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/clear_status.qbk b/doc/reference/status/clear_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/clear_status.qbk +++ b/doc/reference/status/clear_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/correct_status.qbk b/doc/reference/status/correct_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/correct_status.qbk +++ b/doc/reference/status/correct_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/covered_by_status.qbk b/doc/reference/status/covered_by_status.qbk index 122666d12..cc550988b 100644 --- a/doc/reference/status/covered_by_status.qbk +++ b/doc/reference/status/covered_by_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/crosses_status.qbk b/doc/reference/status/crosses_status.qbk index 512f4bb78..6b1fe8758 100644 --- a/doc/reference/status/crosses_status.qbk +++ b/doc/reference/status/crosses_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/disjoint_status.qbk b/doc/reference/status/disjoint_status.qbk index f6562c3a3..0760a55f8 100644 --- a/doc/reference/status/disjoint_status.qbk +++ b/doc/reference/status/disjoint_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/distance_status.qbk b/doc/reference/status/distance_status.qbk index 5dbdeba7f..9209452b6 100644 --- a/doc/reference/status/distance_status.qbk +++ b/doc/reference/status/distance_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/envelope_status.qbk b/doc/reference/status/envelope_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/envelope_status.qbk +++ b/doc/reference/status/envelope_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/equals_status.qbk b/doc/reference/status/equals_status.qbk index 9abd11cbc..2628e4483 100644 --- a/doc/reference/status/equals_status.qbk +++ b/doc/reference/status/equals_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/intersects_status.qbk b/doc/reference/status/intersects_status.qbk index f6562c3a3..0760a55f8 100644 --- a/doc/reference/status/intersects_status.qbk +++ b/doc/reference/status/intersects_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/length_status.qbk b/doc/reference/status/length_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/length_status.qbk +++ b/doc/reference/status/length_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/num_points_status.qbk b/doc/reference/status/num_points_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/num_points_status.qbk +++ b/doc/reference/status/num_points_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/overlaps_status.qbk b/doc/reference/status/overlaps_status.qbk index bcb8a672e..8d26c4daf 100644 --- a/doc/reference/status/overlaps_status.qbk +++ b/doc/reference/status/overlaps_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/perimeter_status.qbk b/doc/reference/status/perimeter_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/perimeter_status.qbk +++ b/doc/reference/status/perimeter_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/within_status.qbk b/doc/reference/status/within_status.qbk index 122666d12..cc550988b 100644 --- a/doc/reference/status/within_status.qbk +++ b/doc/reference/status/within_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/src/docutils/tools/implementation_status/implementation_status.cpp b/doc/src/docutils/tools/implementation_status/implementation_status.cpp index 392002d6f..1a3e1e18e 100644 --- a/doc/src/docutils/tools/implementation_status/implementation_status.cpp +++ b/doc/src/docutils/tools/implementation_status/implementation_status.cpp @@ -30,7 +30,8 @@ static const int polygon = 5; static const int multi_point = 6; static const int multi_linestring = 7; static const int multi_polygon = 8; -static const int geometry_count = 9; +static const int variant = 9; +static const int geometry_count = 10; struct compile_bjam { @@ -149,6 +150,7 @@ inline std::string typedef_string(int type, bool clockwise, bool open) out << "bg::model::ring"; break; + case variant : case polygon : out << "bg::model::polygon"; @@ -174,6 +176,7 @@ inline std::string wkt_string(int type) case segment : return "LINESTRING(1 1,2 2)"; case box : return "POLYGON((1 1,2 2))"; case polygon : + case variant : case ring : return "POLYGON((0 0,0 1,1 1,0 0))"; case multi_point : return "MULTIPOINT((1 1),(2 2))"; @@ -196,6 +199,7 @@ inline std::string geometry_string(int type) case multi_point : return "MultiPoint"; case multi_linestring : return "MultiLinestring"; case multi_polygon : return "MultiPolygon"; + case variant : return "Variant"; } return ""; } @@ -235,15 +239,37 @@ int report_library(CompilePolicy& compile_policy, { std::ofstream out("tmp/t.cpp"); + std::string name = "geometry"; + + if (type == variant) + { + name = "source"; + } + + out << "#include " << std::endl; + + if (type == variant) + { + out << "#include " << std::endl; + } + out - << "#include " << std::endl << "template " << std::endl << "inline void test()" << std::endl << "{" << std::endl << " namespace bg = boost::geometry;" << std::endl - << " " << typedef_string(type, clockwise, open) << " geometry;" << std::endl - << " bg::read_wkt(\"" << wkt_string(type) << "\", geometry);" << std::endl; + << " " << typedef_string(type, clockwise, open) << " " << name << ";" << std::endl + << " bg::read_wkt(\"" << wkt_string(type) << "\", " << name << ");" << std::endl; + if (type == variant) + { + out + << " typedef " << typedef_string(polygon, clockwise, open) << " type1;" << std::endl + << " typedef " << typedef_string(box, clockwise, open) << " type2;" << std::endl + << " boost::variant geometry;" << std::endl + << " geometry = source;" + << std::endl; + } if (algo.arity > 1) { diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 106818d67..191866b9a 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/comparable_distance.hpp b/include/boost/geometry/algorithms/comparable_distance.hpp index 4f0563a8a..55b827bd3 100644 --- a/include/boost/geometry/algorithms/comparable_distance.hpp +++ b/include/boost/geometry/algorithms/comparable_distance.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -14,14 +19,43 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP #define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP +#include #include +#include namespace boost { namespace geometry { +// MK::need to add qbk documentation +template +inline typename strategy::distance::services::return_type + < + typename strategy::distance::services::comparable_type + < + Strategy + >::type, + typename point_type::type, + typename point_type::type + >::type +comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2, + Strategy const& strategy) +{ + concept::check(); + concept::check(); + + return distance(geometry1, geometry2, + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy) + ); +} + + + /*! \brief \brief_calc2{comparable distance measurement} \ingroup distance @@ -39,32 +73,22 @@ namespace boost { namespace geometry \qbk{[include reference/algorithms/comparable_distance.qbk]} */ template -inline typename default_distance_result::type comparable_distance( - Geometry1 const& geometry1, Geometry2 const& geometry2) +inline typename default_comparable_distance_result::type +comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2) { concept::check(); concept::check(); - typedef typename point_type::type point1_type; - typedef typename point_type::type point2_type; - - // Define a point-point-distance-strategy - // for either the normal case, either the reversed case - + // Define the default-distance-strategy typedef typename strategy::distance::services::comparable_type < - typename boost::mpl::if_c + typename detail::distance::default_strategy < - geometry::reverse_dispatch - ::type::value, - typename strategy::distance::services::default_strategy - ::type, - typename strategy::distance::services::default_strategy - ::type + Geometry1, Geometry2 >::type - >::type strategy_type; + >::type default_comparable_strategy_type; - return distance(geometry1, geometry2, strategy_type()); + return distance(geometry1, geometry2, default_comparable_strategy_type()); } diff --git a/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp new file mode 100644 index 000000000..5dd69cbcd --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp @@ -0,0 +1,346 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +struct point_to_segment +{ + static inline typename strategy::distance::services::return_type + < + Strategy, + Point, + typename point_type::type + >::type + apply(Point const& point, Segment const& segment, Strategy const& ) + { + typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type segment_strategy; + + typename point_type::type p[2]; + geometry::detail::assign_point_from_index<0>(segment, p[0]); + geometry::detail::assign_point_from_index<1>(segment, p[1]); + return segment_strategy.apply(point, p[0], p[1]); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +// Point-segment version 1, with point-point strategy +template +struct distance +< + Point, Segment, Strategy, + point_tag, segment_tag, strategy_tag_distance_point_point, + false +> : detail::distance::point_to_segment +{}; + + +// Point-line version 1, where point-point strategy is specified +template +struct distance +< + Point, Linestring, Strategy, + point_tag, linestring_tag, strategy_tag_distance_point_point, + false +> +{ + + static inline typename return_type::type>::type + apply(Point const& point, + Linestring const& linestring, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return detail::distance::point_to_range + < + Point, Linestring, closed, ps_strategy_type + >::apply(point, linestring, ps_strategy_type()); + } +}; + + +// Point-ring , where point-point strategy is specified +template +struct distance +< + Point, Ring, Strategy, + point_tag, ring_tag, strategy_tag_distance_point_point, + false +> +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + Ring const& ring, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + std::pair + dc = detail::distance::point_to_ring + < + Point, Ring, + geometry::closure::value, + ps_strategy_type + >::apply(point, ring, ps_strategy_type()); + + return dc.second ? return_type(0) : dc.first; + } +}; + + +// Point-polygon , where point-point strategy is specified +template +struct distance +< + Point, Polygon, Strategy, + point_tag, polygon_tag, strategy_tag_distance_point_point, + false +> +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + Polygon const& polygon, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + std::pair + dc = detail::distance::point_to_polygon + < + Point, Polygon, + geometry::closure::value, + ps_strategy_type + >::apply(point, polygon, ps_strategy_type()); + + return dc.second ? return_type(0) : dc.first; + } +}; + + + + +namespace splitted_dispatch +{ + + +template +< + typename Point, + typename MultiGeometry, + typename MultiGeometryTag, + typename Strategy +> +struct distance_single_to_multi + < + Point, MultiGeometry, Strategy, + point_tag, MultiGeometryTag, + strategy_tag_distance_point_point + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + MultiGeometry const& multigeometry, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return distance_single_to_multi + < + Point, MultiGeometry, ps_strategy_type, + point_tag, MultiGeometryTag, + strategy_tag_distance_point_segment + >::apply(point, multigeometry, ps_strategy_type()); + } +}; + + +template +< + typename Geometry, + typename MultiPoint, + typename GeometryTag, + typename Strategy +> +struct distance_single_to_multi + < + Geometry, MultiPoint, Strategy, + GeometryTag, multi_point_tag, + strategy_tag_distance_point_point + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Geometry const& geometry, + MultiPoint const& multipoint, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + typename point_type::type, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return distance_single_to_multi + < + Geometry, MultiPoint, ps_strategy_type, + GeometryTag, multi_point_tag, + strategy_tag_distance_point_segment + >::apply(geometry, multipoint, ps_strategy_type()); + } +}; + + +template +< + typename MultiPoint, + typename MultiGeometry, + typename MultiGeometryTag, + typename Strategy +> +struct distance_multi_to_multi + < + MultiPoint, MultiGeometry, Strategy, + multi_point_tag, MultiGeometryTag, + strategy_tag_distance_point_point + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiPoint const& multipoint, + MultiGeometry const& multigeometry, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + typename point_type::type, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return distance_multi_to_multi + < + MultiPoint, MultiGeometry, ps_strategy_type, + multi_point_tag, MultiGeometryTag, + strategy_tag_distance_point_segment + >::apply(multipoint, multigeometry, ps_strategy_type()); + } +}; + + +} // namespace splitted_dispatch + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp new file mode 100644 index 000000000..7b032a19c --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp @@ -0,0 +1,59 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BOX_TO_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BOX_TO_BOX_HPP + +#include +#include +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct distance + < + Box1, Box2, Strategy, box_tag, box_tag, + strategy_tag_distance_box_box, false + > +{ + static inline typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type + apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + return strategy.apply(box1, box2); + } +}; + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BOX_TO_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp new file mode 100644 index 000000000..131265c0e --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp @@ -0,0 +1,147 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_DEFAULT_STRATEGIES_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_DEFAULT_STRATEGIES_HPP + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +// Helper metafunction for default strategy retrieval +template +< + typename Geometry1, + typename Geometry2, + typename Tag1 = typename tag_cast + < + typename tag::type, pointlike_tag + >::type, + typename Tag2 = typename tag_cast + < + typename tag::type, pointlike_tag + >::type, + bool Reverse = geometry::reverse_dispatch::type::value +> +struct default_strategy + : strategy::distance::services::default_strategy + < + segment_tag, + typename point_type::type, + typename point_type::type + > +{}; + +template +< + typename Geometry1, + typename Geometry2, + typename Tag1, + typename Tag2 +> +struct default_strategy + : default_strategy +{}; + + +template +struct default_strategy + < + Pointlike1, Pointlike2, + pointlike_tag, pointlike_tag, false + > : strategy::distance::services::default_strategy + < + point_tag, + typename point_type::type, + typename point_type::type + > +{}; + + +template +struct default_strategy + : strategy::distance::services::default_strategy + < + point_tag, + typename point_type::type, + typename point_type::type, + cartesian_tag, + cartesian_tag, + void, + box_tag + > +{}; + + +template +struct default_strategy + : strategy::distance::services::default_strategy + < + box_tag, + typename point_type::type, + typename point_type::type, + cartesian_tag, + cartesian_tag, + void, + box_tag + > +{}; + + + +// Helper metafunction for default point-segment strategy retrieval +template +struct default_ps_strategy + : strategy::distance::services::default_strategy + < + segment_tag, + typename point_type::type, + typename point_type::type, + typename cs_tag::type>::type, + typename cs_tag::type>::type, + Strategy + > +{}; + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_DEFAULT_STRATEGIES_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp new file mode 100644 index 000000000..faa1f20a8 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp @@ -0,0 +1,370 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_TO_GEOMETRY_RTREE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_TO_GEOMETRY_RTREE_HPP + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +template +< + typename RTreePoint, + typename Geometry, + typename Strategy +> +class point_range_to_geometry_rtree +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + RTreePoint, + typename point_type::type + >::type comparable_return_type; + + typedef index::rtree > r_tree; + + // functor to evaluate minimum comparable distance + struct minimum_comparable_distance_evaluator + { + r_tree const& m_r_tree; + comparable_strategy const& m_cstrategy; + bool m_first; + comparable_return_type m_min_cd; + + minimum_comparable_distance_evaluator + (r_tree const& r_tree, comparable_strategy const& cstrategy) + : m_r_tree(r_tree) + , m_cstrategy(cstrategy) + , m_first(true) + , m_min_cd() + {} + + template + inline void operator()(QueryGeometry const& query_geometry) + { + typename r_tree::value_type t_v; + std::size_t n = + m_r_tree.query(index::nearest(query_geometry, 1), &t_v); + + BOOST_ASSERT( n > 0 ); + + comparable_return_type cd = dispatch::distance + < + typename r_tree::value_type, + QueryGeometry, + comparable_strategy + >::apply(t_v, query_geometry, m_cstrategy); + + if ( m_first || cd < m_min_cd ) + { + m_first = false; + m_min_cd = cd; + } + } + }; + + + + // class to choose between for_each_point and for_each_segment + template ::type> + struct for_each_selector + { + typedef dispatch::for_each_segment type; + }; + + template + struct for_each_selector + { + typedef dispatch::for_each_point type; + }; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + RTreePoint, + typename point_type::type + >::type return_type; + + template + static inline return_type apply(PointIterator points_first, + PointIterator points_beyond, + Geometry const& geometry, + Strategy const& strategy) + { + BOOST_ASSERT( points_first != points_beyond ); + + if ( geometry::has_one_element(points_first, points_beyond) ) + { + return dispatch::distance + < + typename std::iterator_traits::value_type, + Geometry, + Strategy + >::apply(*points_first, geometry, strategy); + } + + // create -- packing algorithm + r_tree rt(points_first, points_beyond); + + minimum_comparable_distance_evaluator + functor(rt, + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy)); + + for_each_selector::type::apply(geometry, functor); + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, RTreePoint, Geometry + >::apply(functor.m_min_cd); + } +}; + + + +template +< + typename Geometry1, + typename Geometry2, + typename Strategy +> +class geometry_to_geometry_rtree +{ + // the following works with linear geometries seen as ranges of points + // + // we compute the r-tree for the points of one range and then, + // compute nearest points for the segments of the other, + // ... and ... + // vice versa. + +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy, + bool check_intersection = true) + { + point_iterator first1 = points_begin(geometry1); + point_iterator beyond1 = points_end(geometry1); + point_iterator first2 = points_begin(geometry2); + point_iterator beyond2 = points_end(geometry2); + + if ( geometry::has_one_element(first1, beyond1) ) + { + return dispatch::distance + < + typename point_type::type, + Geometry2, + Strategy + >::apply(*first1, geometry2, strategy); + } + + if ( geometry::has_one_element(first2, beyond2) ) + { + return dispatch::distance + < + typename point_type::type, + Geometry1, + Strategy + >::apply(*first2, geometry1, strategy); + } + + if ( check_intersection && geometry::intersects(geometry1, geometry2) ) + { + return return_type(0); + } + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + comparable_return_type cdist1 = point_range_to_geometry_rtree + < + typename point_type::type, + Geometry2, + comparable_strategy + >::apply(first1, beyond1, geometry2, cstrategy); + + comparable_return_type cdist2 = point_range_to_geometry_rtree + < + typename point_type::type, + Geometry1, + comparable_strategy + >::apply(first2, beyond2, geometry1, cstrategy); + + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Geometry1, Geometry2 + >::apply( (std::min)(cdist1, cdist2) ); + } +}; + + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct distance + < + Linestring1, Linestring2, Strategy, + linestring_tag, linestring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Linestring1, Linestring2, Strategy + > +{}; + + + +template +struct distance + < + Linestring, Polygon, Strategy, + linestring_tag, polygon_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Linestring, Polygon, Strategy + > +{}; + + + +template +struct distance + < + Linestring, Ring, Strategy, + linestring_tag, ring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Linestring, Ring, Strategy + > +{}; + + + +template +struct distance + < + Polygon1, Polygon2, Strategy, + polygon_tag, polygon_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Polygon1, Polygon2, Strategy + > +{}; + + + +template +struct distance + < + Polygon, Ring, Strategy, + polygon_tag, ring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Polygon, Ring, Strategy + > +{}; + + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_TO_GEOMETRY_RTREE_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp b/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp new file mode 100644 index 000000000..1e6e3c77f --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp @@ -0,0 +1,257 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTI_TO_MULTI_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTI_TO_MULTI_HPP + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +template +class distance_multi_to_multi_generic +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Multi1 const& multi1, + Multi2 const& multi2, Strategy const& strategy) + { + comparable_return_type min_cdist = comparable_return_type(); + bool first = true; + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + for(typename range_iterator::type it = boost::begin(multi1); + it != boost::end(multi1); + ++it, first = false) + { + comparable_return_type cdist = + dispatch::splitted_dispatch::distance_single_to_multi + < + typename range_value::type, + Multi2, + comparable_strategy, + typename tag::type>::type, + typename tag::type, + typename strategy::distance::services::tag + < + comparable_strategy + >::type + >::apply(*it, multi2, cstrategy); + if (first || cdist < min_cdist) + { + min_cdist = cdist; + } + if ( geometry::math::equals(min_cdist, 0) ) + { + break; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, + Strategy, + Multi1, + Multi2 + >::apply(min_cdist); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +namespace splitted_dispatch +{ + + +template +< + typename MultiGeometry1, + typename MultiGeometry2, + typename Strategy, + typename Tag1, + typename Tag2, + typename StrategyTag +> +struct distance_multi_to_multi + : not_implemented +{}; + + + +template +< + typename MultiPoint, + typename MultiPolygon, + typename Strategy +> +struct distance_multi_to_multi + < + MultiPoint, MultiPolygon, Strategy, + multi_point_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_multi_generic + < + MultiPoint, MultiPolygon, Strategy + > +{}; + + + +template +< + typename MultiLinestring1, + typename MultiLinestring2, + typename Strategy +> +struct distance_multi_to_multi + < + MultiLinestring1, MultiLinestring2, Strategy, + multi_linestring_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiLinestring1, MultiLinestring2, Strategy + > +{}; + + +template +< + typename MultiLinestring, + typename MultiPolygon, + typename Strategy +> +struct distance_multi_to_multi + < + MultiLinestring, MultiPolygon, Strategy, + multi_linestring_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiLinestring, MultiPolygon, Strategy + > +{}; + + +template +struct distance_multi_to_multi + < + MultiPolygon1, MultiPolygon2, Strategy, + multi_polygon_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiPolygon1, MultiPolygon2, Strategy + > +{}; + + +} // namespace splitted_dispatch + + + + +template +< + typename MultiGeometry1, + typename MultiGeometry2, + typename Strategy, + typename StrategyTag +> +struct distance + < + MultiGeometry1, MultiGeometry2, Strategy, multi_tag, multi_tag, + StrategyTag, false + > : splitted_dispatch::distance_multi_to_multi + < + MultiGeometry1, MultiGeometry2, Strategy, + typename geometry::tag::type, + typename geometry::tag::type, + StrategyTag + > +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTI_TO_MULTI_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp b/include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp new file mode 100644 index 000000000..5a800175c --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp @@ -0,0 +1,182 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_RANGE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_RANGE_HPP + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + +template +struct multipoint_to_multipoint +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiPoint1 const& multipoint1, + MultiPoint2 const& multipoint2, + Strategy const& strategy) + { + if ( boost::size(multipoint1) > boost::size(multipoint2) ) + + { + return multipoint_to_multipoint + < + MultiPoint2, MultiPoint1, Strategy + >::apply(multipoint2, multipoint1, strategy); + } + + return point_range_to_geometry_rtree + < + typename point_type::type, + MultiPoint2, + Strategy + >::apply(points_begin(multipoint1), points_end(multipoint1), + multipoint2, strategy); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +namespace splitted_dispatch +{ + +// specializations of distance_single_to_multi for various geometry combinations + +template +struct distance_single_to_multi + < + Linestring, MultiPoint, Strategy, + linestring_tag, multi_point_tag, + strategy_tag_distance_point_segment + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Linestring const& linestring, + MultiPoint const& multipoint, + Strategy const& strategy) + { + return detail::distance::point_range_to_geometry_rtree + < + typename point_type::type, + Linestring, + Strategy + >::apply(geometry::points_begin(multipoint), + geometry::points_end(multipoint), + linestring, strategy); + + } +}; + + + + +// specializations of distance_multi_to_multi for various geometry combinations + + +template +struct distance_multi_to_multi + < + MultiPoint1, MultiPoint2, Strategy, + multi_point_tag, multi_point_tag, + strategy_tag_distance_point_point + > : detail::distance::multipoint_to_multipoint + < + MultiPoint1, MultiPoint2, Strategy + > +{}; + + + +template +< + typename MultiPoint, + typename MultiLinestring, + typename Strategy +> +struct distance_multi_to_multi + < + MultiPoint, MultiLinestring, Strategy, + multi_point_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiPoint const& multipoint, + MultiLinestring const& multilinestring, + Strategy const& strategy) + { + return detail::distance::point_range_to_geometry_rtree + < + typename point_type::type, + MultiLinestring, + Strategy + >::apply(geometry::points_begin(multipoint), + geometry::points_end(multipoint), + multilinestring, strategy); + + } +}; + +} // namespace splitted_dispatch + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_ALTERNATE_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp new file mode 100644 index 000000000..7b89dcad1 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp @@ -0,0 +1,431 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POINT_TO_GEOMETRY_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POINT_TO_GEOMETRY_HPP + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +struct point_to_point +{ + static inline + typename strategy::distance::services::return_type::type + apply(P1 const& p1, P2 const& p2, Strategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + return strategy.apply(p1, p2); + } +}; + + +template +< + typename Point, + typename Range, + closure_selector Closure, + typename Strategy +> +class point_to_range +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, Point, typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, Range const& range, + Strategy const& strategy) + { + comparable_strategy c_strategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + comparable_return_type const zero = comparable_return_type(0); + + if (boost::size(range) == 0) + { + return zero; + } + + typedef typename closeable_view::type view_type; + + view_type view(range); + + // line of one point: return point distance + typedef typename boost::range_iterator::type iterator_type; + iterator_type it = boost::begin(view); + iterator_type prev = it++; + if (it == boost::end(view)) + { + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Range + >::apply( c_strategy.apply(point, + *boost::begin(view), + *boost::begin(view)) ); + } + + // start with first segment distance + comparable_return_type cd = c_strategy.apply(point, *prev, *it); + + // check if other segments are closer + for (++prev, ++it; it != boost::end(view); ++prev, ++it) + { + comparable_return_type cds = c_strategy.apply(point, *prev, *it); + if (geometry::math::equals(cds, zero)) + { + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Range + >::apply(zero); + } + else if (cds < cd) + { + cd = cds; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Range + >::apply(cd); + } +}; + + +template +< + typename Point, + typename Ring, + closure_selector Closure, + typename Strategy +> +struct point_to_ring +{ + typedef std::pair + < + typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type, + bool + > distance_containment; + + static inline distance_containment apply(Point const& point, + Ring const& ring, + Strategy const& strategy) + { + return distance_containment + ( + point_to_range + < + Point, + Ring, + Closure, + Strategy + >::apply(point, ring, strategy), + geometry::within(point, ring) + ); + } +}; + + + +template +< + typename Point, + typename Polygon, + closure_selector Closure, + typename Strategy +> +class point_to_polygon +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, Point, typename point_type::type + >::type comparable_return_type; + + typedef std::pair + < + comparable_return_type, bool + > comparable_distance_containment; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + typedef std::pair distance_containment; + + static inline distance_containment apply(Point const& point, + Polygon const& polygon, + Strategy const& strategy) + { + comparable_strategy c_strategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + // Check distance to all rings + typedef point_to_ring + < + Point, + typename ring_type::type, + Closure, + comparable_strategy + > per_ring; + + comparable_distance_containment dc = + per_ring::apply(point, exterior_ring(polygon), c_strategy); + + typename interior_return_type::type rings + = interior_rings(polygon); + for (typename boost::range_iterator + < + typename interior_type::type const + >::type it = boost::begin(rings); + it != boost::end(rings); ++it) + { + comparable_distance_containment dcr = + per_ring::apply(point, *it, c_strategy); + if (dcr.first < dc.first) + { + dc.first = dcr.first; + } + // If it was inside, and also inside inner ring, + // turn off the inside-flag, it is outside the polygon + if (dc.second && dcr.second) + { + dc.second = false; + } + } + + return_type rd = strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Polygon + >::apply(dc.first); + + return std::make_pair(rd, dc.second); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +// Point-point +template +struct distance + < + P1, P2, Strategy, + point_tag, point_tag, strategy_tag_distance_point_point, + false + > + : detail::distance::point_to_point +{}; + + +// Point-line version 2, where point-segment strategy is specified +template +struct distance +< + Point, Linestring, Strategy, + point_tag, linestring_tag, strategy_tag_distance_point_segment, + false +> : detail::distance::point_to_range +{}; + + +// Point-ring , where point-segment strategy is specified +template +struct distance +< + Point, Ring, Strategy, + point_tag, ring_tag, strategy_tag_distance_point_segment, + false +> +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + Ring const& ring, + Strategy const& strategy) + { + std::pair + dc = detail::distance::point_to_ring + < + Point, Ring, + geometry::closure::value, + Strategy + >::apply(point, ring, strategy); + + return dc.second ? return_type(0) : dc.first; + } +}; + + +// Point-polygon , where point-segment strategy is specified +template +struct distance +< + Point, Polygon, Strategy, point_tag, polygon_tag, + strategy_tag_distance_point_segment, false +> +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + Polygon const& polygon, + Strategy const& strategy) + { + std::pair + dc = detail::distance::point_to_polygon + < + Point, Polygon, + geometry::closure::value, + Strategy + >::apply(point, polygon, strategy); + + return dc.second ? return_type(0) : dc.first; + } +}; + + +// Point-segment version 2, with point-segment strategy +template +struct distance +< + Point, Segment, Strategy, + point_tag, segment_tag, strategy_tag_distance_point_segment, + false +> +{ + static inline typename return_type::type>::type + apply(Point const& point, + Segment const& segment, + Strategy const& strategy) + { + typename point_type::type p[2]; + geometry::detail::assign_point_from_index<0>(segment, p[0]); + geometry::detail::assign_point_from_index<1>(segment, p[1]); + + boost::ignore_unused_variable_warning(strategy); + return strategy.apply(point, p[0], p[1]); + } +}; + + + +template +struct distance + < + Point, Box, Strategy, point_tag, box_tag, + strategy_tag_distance_point_box, false + > +{ + static inline typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type + apply(Point const& point, Box const& box, Strategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + return strategy.apply(point, box); + } +}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POINT_TO_GEOMETRY_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp new file mode 100644 index 000000000..631cb25d3 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp @@ -0,0 +1,160 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POLYGON_TO_SEGMENT_OR_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POLYGON_TO_SEGMENT_OR_BOX_HPP + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +class polygon_to_segment_or_box +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Polygon const& polygon, + SegmentOrBox const& segment_or_box, + Strategy const& strategy) + { + typedef typename geometry::ring_type::type e_ring; + typedef typename geometry::interior_type::type i_rings; + typedef typename range_value::type i_ring; + + if ( geometry::intersects(polygon, segment_or_box) ) + { + return 0; + } + + e_ring const& ext_ring = geometry::exterior_ring(polygon); + i_rings const& int_rings = geometry::interior_rings(polygon); + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + + comparable_return_type cd_min = range_to_segment_or_box + < + e_ring, SegmentOrBox, comparable_strategy + >::apply(ext_ring, segment_or_box, cstrategy, false); + + typedef typename boost::range_iterator::type iterator_type; + for (iterator_type it = boost::begin(int_rings); + it != boost::end(int_rings); ++it) + { + comparable_return_type cd = range_to_segment_or_box + < + i_ring, SegmentOrBox, comparable_strategy + >::apply(*it, segment_or_box, cstrategy, false); + + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, + Strategy, + Polygon, + SegmentOrBox + >::apply(cd_min); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DETAIL +namespace dispatch +{ + + +template +struct distance + < + Polygon, Segment, Strategy, polygon_tag, segment_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::polygon_to_segment_or_box +{}; + + + +template +struct distance + < + Polygon, Box, Strategy, polygon_tag, box_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::polygon_to_segment_or_box +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POLYGON_TO_SEGMENT_OR_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp new file mode 100644 index 000000000..e1d113ff3 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp @@ -0,0 +1,347 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_SEGMENT_OR_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_SEGMENT_OR_BOX_HPP + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +template +< + typename Range, + typename SegmentOrBox, + typename Strategy +> +class range_to_segment_or_box +{ +private: + typedef typename point_type::type segment_or_box_point; + typedef typename point_type::type range_point; + + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, range_point, segment_or_box_point + >::type comparable_return_type; + + typedef typename strategy::distance::services::tag + < + comparable_strategy + >::type comparable_strategy_tag; + + typedef dispatch::distance + < + segment_or_box_point, Range, comparable_strategy, + point_tag, typename tag::type, + comparable_strategy_tag, false + > comparable_point_to_range; + + // compute distance of a point to a segment or a box + template + < + typename Point, + typename SegOrBoxPoints, + typename ComparableStrategy, + typename Tag + > + struct comparable_distance_point_to_segment_or_box + {}; + + template + < + typename Point, + typename SegmentPoints, + typename ComparableStrategy + > + struct comparable_distance_point_to_segment_or_box + < + Point, SegmentPoints, ComparableStrategy, segment_tag + > + { + static inline + comparable_return_type apply(Point const& point, + SegmentPoints const& segment_points, + ComparableStrategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + return strategy.apply(point, segment_points[0], segment_points[1]); + } + }; + + template + < + typename Point, + typename BoxPoints, + typename ComparableStrategy + > + struct comparable_distance_point_to_segment_or_box + < + Point, BoxPoints, ComparableStrategy, box_tag + > + { + static inline + comparable_return_type apply(Point const& point, + BoxPoints const& box_points, + ComparableStrategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + + comparable_return_type cd_min = + strategy.apply(point, box_points[0], box_points[3]); + + for (unsigned int i = 0; i < 2; ++i) + { + comparable_return_type cd = + strategy.apply(point, box_points[i], box_points[i+1]); + + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + return cd_min; + } + }; + + + // assign the points of a segment or a box to a range + template + < + typename SegOrBox, + typename PointRange, + typename Tag = typename tag::type + > + struct assign_segment_or_box_points + {}; + + + template + struct assign_segment_or_box_points + { + static inline void apply(Segment const& segment, PointRange& range) + { + detail::assign_point_from_index<0>(segment, range[0]); + detail::assign_point_from_index<1>(segment, range[1]); + } + }; + + template + struct assign_segment_or_box_points + { + static inline void apply(Box const& box, PointRange& range) + { + detail::assign_box_corners_oriented(box, range); + } + }; + + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, range_point, segment_or_box_point + >::type return_type; + + static inline return_type + apply(Range const& range, SegmentOrBox const& segment_or_box, + Strategy const& strategy, bool check_intersection = true) + { + if ( check_intersection && geometry::intersects(range, segment_or_box) ) + { + return 0; + } + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + + // get all points of the segment or the box + std::vector + segment_or_box_points(geometry::num_points(segment_or_box)); + + assign_segment_or_box_points + < + + SegmentOrBox, + std::vector + >::apply(segment_or_box, segment_or_box_points); + + // consider all distances from each endpoint of the segment or box + // to the range + typename std::vector::const_iterator it + = segment_or_box_points.begin(); + comparable_return_type cd_min = + comparable_point_to_range::apply(*it, range, cstrategy); + + for (++it; it != segment_or_box_points.end(); ++it) + { + comparable_return_type cd = + comparable_point_to_range::apply(*it, range, cstrategy); + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + // consider all distances of the points in the range to the + // segment or box + typedef typename range_iterator::type iterator_type; + for (iterator_type it = boost::begin(range); it != boost::end(range); ++it) + { + comparable_return_type cd = + comparable_distance_point_to_segment_or_box + < + typename point_type::type, + std::vector, + comparable_strategy, + typename tag::type + >::apply(*it, segment_or_box_points, cstrategy); + + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, + range_point, segment_or_box_point + >::apply(cd_min); + } + + static inline return_type + apply(SegmentOrBox const& segment_or_box, Range const& range, + Strategy const& strategy, bool check_intersection = true) + { + return apply(range, segment_or_box, strategy, check_intersection); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + + +template +struct distance + < + Linestring, Segment, Strategy, linestring_tag, segment_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Linestring, Segment, Strategy + > +{}; + + + + +template +struct distance + < + Segment, Ring, Strategy, segment_tag, ring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Ring, Segment, Strategy + > +{}; + + + + +template +struct distance + < + Linestring, Box, Strategy, linestring_tag, box_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Linestring, Box, Strategy + > +{}; + + + + +template +struct distance + < + Ring, Box, Strategy, ring_tag, box_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Ring, Box, Strategy + > +{}; + + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_SEGMENT_OR_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp new file mode 100644 index 000000000..4a6f23839 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -0,0 +1,576 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +< + typename ReturnType, + typename SegmentPoint, + typename BoxPoint, + typename PPStrategy, + typename PSStrategy +> +class segment_to_box_2D +{ +private: + template + struct cast_to_result + { + template + static inline Result apply(T const& t) + { + return boost::numeric_cast(t); + } + }; + + static inline ReturnType + non_negative_slope_segment(SegmentPoint const& p0, + SegmentPoint const& p1, + BoxPoint const& top_left, + BoxPoint const& top_right, + BoxPoint const& bottom_left, + BoxPoint const& bottom_right, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + typedef cast_to_result cast; + + boost::ignore_unused_variable_warning(pp_strategy); + boost::ignore_unused_variable_warning(ps_strategy); + + // assert that the segment has non-negative slope + BOOST_ASSERT( (math::equals(geometry::get<0>(p0), + geometry::get<0>(p1)) + && geometry::get<1>(p0) < geometry::get<1>(p1)) + || + (geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) <= geometry::get<1>(p1)) + ); + + // p0 lies to the right of the box + if ( geometry::get<0>(p0) >= geometry::get<0>(top_right) ) + { + if ( geometry::get<1>(p0) >= geometry::get<1>(top_right) ) + { + // closest box point is the top-right corner + return cast::apply(pp_strategy.apply(p0, top_right)); + } + else if ( geometry::get<1>(p0) >= geometry::get<1>(bottom_right) ) + { + // distance is realized between p0 and right-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p0)) + - cast::apply(geometry::get<0>(bottom_right)); + return diff * diff; + } + else + { + // distance is realized between the bottom-right + // corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_right, p0, p1)); + } + } + + // p1 lies to the left of the box + if ( geometry::get<0>(p1) <= geometry::get<1>(bottom_left) ) + { + if ( geometry::get<1>(p1) <= geometry::get<1>(bottom_left) ) + { + // closest box point is the bottom-left corner + return cast::apply(pp_strategy.apply(p1, bottom_left)); + } + else if ( geometry::get<1>(p1) <= geometry::get<1>(top_left) ) + { + // distance is realized between p1 and left-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(bottom_left)); + return diff * diff; + } + else + { + // distance is realized between the top-left + // corner of the box and the segment + return cast::apply(ps_strategy.apply(top_left, p0, p1)); + } + } + + // the segment lies below the box + if ( geometry::get<1>(p1) < geometry::get<1>(bottom_left) ) + { + // p1 is below the lower segment of the box + // (and inside its band) + if ( geometry::get<0>(p1) <= geometry::get<0>(bottom_right) ) + { + ReturnType diff = cast::apply(geometry::get<1>(bottom_right)) + - cast::apply(geometry::get<1>(p1)); + return diff * diff; + } + + // p1 is to the right of the box, but p0 is below the box + // in this case the distance is realized between the + // bottom-right corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_right, p0, p1)); + } + + // the segment lies above the box + if ( geometry::get<1>(p0) > geometry::get<1>(top_left) ) + { + // p0 is above the upper segment of the box + // (and inside its band) + if ( geometry::get<0>(p0) >= geometry::get<0>(top_left) ) + { + ReturnType diff = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(top_left)); + return diff * diff; + } + + // p0 is to the left of the box, but p1 is above the box + // in this case the distance is realized between the + // top-left corner of the box and the segment + return cast::apply(ps_strategy.apply(top_left, p0, p1)); + } + + ReturnType diff0 = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_min0 = cast::apply(geometry::get<0>(bottom_left)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_max0 = cast::apply(geometry::get<0>(top_right)) + - cast::apply(geometry::get<0>(p0)); + + ReturnType diff1 = cast::apply(geometry::get<1>(p1)) + - cast::apply(geometry::get<1>(p0)); + ReturnType t_min1 = cast::apply(geometry::get<1>(bottom_left)) + - cast::apply(geometry::get<1>(p0)); + ReturnType t_max1 = cast::apply(geometry::get<1>(top_right)) + - cast::apply(geometry::get<1>(p0)); + + // t_min0 > t_max1 + if ( t_min0 * diff1 > t_max1 * diff0 ) + { + return cast::apply(ps_strategy.apply(top_left, p0, p1)); + } + + // t_min1 > t_max0 + if ( t_min1 * diff0 > t_max0 * diff1 ) + { + return cast::apply(ps_strategy.apply(bottom_right, p0, p1)); + } + + // in all other cases the box and segment intersect, so return 0 + return ReturnType(0); + } + + + static inline ReturnType + negative_slope_segment(SegmentPoint const& p0, + SegmentPoint const& p1, + BoxPoint const& top_left, + BoxPoint const& top_right, + BoxPoint const& bottom_left, + BoxPoint const& bottom_right, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + typedef cast_to_result cast; + + boost::ignore_unused_variable_warning(pp_strategy); + boost::ignore_unused_variable_warning(ps_strategy); + + // assert that the segment has negative slope + BOOST_ASSERT + ( geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) > geometry::get<1>(p1) ); + + // p0 lies to the right of the box + if ( geometry::get<0>(p0) >= geometry::get<0>(top_right) ) + { + if ( geometry::get<1>(p0) <= geometry::get<1>(bottom_right) ) + { + // closest box point is the bottom-right corner + return cast::apply(pp_strategy.apply(p0, bottom_right)); + } + else if ( geometry::get<1>(p0) <= geometry::get<1>(top_right) ) + { + // distance is realized between p0 and right-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p0)) + - cast::apply(geometry::get<0>(bottom_right)); + return diff * diff; + } + else + { + // distance is realized between the top-right + // corner of the box and the segment + return cast::apply(ps_strategy.apply(top_right, p0, p1)); + } + } + + // p1 lies to the left of the box + if ( geometry::get<0>(p1) <= geometry::get<1>(bottom_left) ) + { + if ( geometry::get<1>(p1) >= geometry::get<1>(top_left) ) + { + // closest box point is the top-left corner + return cast::apply(pp_strategy.apply(p1, top_left)); + } + else if ( geometry::get<1>(p1) >= geometry::get<1>(bottom_left) ) + { + // distance is realized between p1 and left-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(bottom_left)); + return diff * diff; + } + else + { + // distance is realized between the bottom-left + // corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_left, p0, p1)); + } + } + + // the segment lies below the box + if ( geometry::get<1>(p0) < geometry::get<1>(bottom_left) ) + { + // p0 is below the lower segment of the box + // (and inside its band) + if ( geometry::get<0>(p0) >= geometry::get<0>(bottom_left) ) + { + ReturnType diff = cast::apply(geometry::get<1>(bottom_left)) + - cast::apply(geometry::get<1>(p0)); + return diff * diff; + } + + // p0 is to the left of the box, but p1 is below the box + // in this case the distance is realized between the + // bottom-left corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_left, p0, p1)); + } + + // the segment lies above the box + if ( geometry::get<1>(p1) > geometry::get<1>(top_right) ) + { + // p1 is above the upper segment of the box + // (and inside its band) + if ( geometry::get<0>(p1) <= geometry::get<0>(top_right) ) + { + ReturnType diff = cast::apply(geometry::get<1>(p1)) + - cast::apply(geometry::get<1>(top_right)); + return diff * diff; + } + + // p1 is to the right of the box, but p0 is above the box + // in this case the distance is realized between the + // top-right corner of the box and the segment + return cast::apply(ps_strategy.apply(top_right, p0, p1)); + } + + ReturnType diff0 = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_min0 = cast::apply(geometry::get<0>(bottom_left)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_max0 = cast::apply(geometry::get<0>(top_right)) + - cast::apply(geometry::get<0>(p0)); + + ReturnType diff1 = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(p1)); + ReturnType t_min1 = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(top_right)); + ReturnType t_max1 = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(bottom_left)); + + // t_max0 < t_max1 + if ( t_max0 * diff1 < t_max1 * diff0 ) + { + return cast::apply(ps_strategy.apply(top_right, p0, p1)); + } + + // t_min0 > t_min1 + if ( t_min0 * diff1 > t_min1 * diff0 ) + { + return cast::apply(ps_strategy.apply(bottom_left, p0, p1)); + } + + // in all other cases the box and segment intersect, so return 0 + return ReturnType(0); + } + +public: + static inline ReturnType apply(SegmentPoint const& p0, + SegmentPoint const& p1, + BoxPoint const& top_left, + BoxPoint const& top_right, + BoxPoint const& bottom_left, + BoxPoint const& bottom_right, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + BOOST_ASSERT( geometry::less()(p0, p1) ); + + if ( geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) > geometry::get<1>(p1) ) + { + return negative_slope_segment(p0, p1, + top_left, top_right, + bottom_left, bottom_right, + pp_strategy, + ps_strategy); + } + + return non_negative_slope_segment(p0, p1, + top_left, top_right, + bottom_left, bottom_right, + pp_strategy, + ps_strategy); + } +}; + + +//========================================================================= +//========================================================================= +//========================================================================= + +template +< + typename Segment, + typename Box, + typename std::size_t Dimension, + typename PPStrategy, + typename PSStrategy +> +class segment_to_box + : not_implemented +{}; + + +template +< + typename Segment, + typename Box, + typename PPStrategy, + typename PSStrategy +> +class segment_to_box +{ +private: + typedef typename point_type::type segment_point; + typedef typename point_type::type box_point; + + typedef typename strategy::distance::services::comparable_type + < + PPStrategy + >::type pp_comparable_strategy; + + typedef typename strategy::distance::services::comparable_type + < + PSStrategy + >::type ps_comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + ps_comparable_strategy, segment_point, box_point + >::type comparable_return_type; +public: + typedef typename strategy::distance::services::return_type + < + PSStrategy, segment_point, box_point + >::type return_type; + + static inline return_type apply(Segment const& segment, + Box const& box, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + segment_point p[2]; + detail::assign_point_from_index<0>(segment, p[0]); + detail::assign_point_from_index<1>(segment, p[1]); + + if ( geometry::equals(p[0], p[1]) ) + { + typedef typename boost::mpl::if_ + < + boost::is_same + < + ps_comparable_strategy, + PSStrategy + >, + typename strategy::distance::services::comparable_type + < + typename detail::distance::default_strategy + < + segment_point, Box + >::type + >::type, + typename detail::distance::default_strategy + < + segment_point, Box + >::type + >::type point_box_strategy_type; + + return dispatch::distance + < + segment_point, + Box, + point_box_strategy_type + >::apply(p[0], box, point_box_strategy_type()); + } + + box_point top_left, top_right, bottom_left, bottom_right; + detail::assign_box_corners(box, bottom_left, bottom_right, + top_left, top_right); + + pp_comparable_strategy c_pp_strategy = + strategy::distance::services::get_comparable + < + PPStrategy + >::apply(pp_strategy); + + ps_comparable_strategy c_ps_strategy = + strategy::distance::services::get_comparable + < + PSStrategy + >::apply(ps_strategy); + + comparable_return_type cd; + + if ( geometry::less()(p[0], p[1]) ) + { + cd = segment_to_box_2D + < + return_type, + segment_point, + box_point, + pp_comparable_strategy, + ps_comparable_strategy + >::apply(p[0], p[1], + top_left, top_right, bottom_left, bottom_right, + c_pp_strategy, + c_ps_strategy); + } + else + { + cd = segment_to_box_2D + < + return_type, + segment_point, + box_point, + pp_comparable_strategy, + ps_comparable_strategy + >::apply(p[1], p[0], + top_left, top_right, bottom_left, bottom_right, + c_pp_strategy, + c_ps_strategy); + } + + return strategy::distance::services::comparable_to_regular + < + ps_comparable_strategy, PSStrategy, Segment, Box + >::apply( cd ); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct distance + < + Segment, Box, Strategy, segment_tag, box_tag, + strategy_tag_distance_point_segment, false + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + + static inline return_type apply(Segment const& segment, + Box const& box, + Strategy const& strategy) + { + assert_dimension_equal(); + + typedef typename detail::distance::default_strategy + < + typename point_type::type, + typename point_type::type + >::type pp_strategy_type; + + return detail::distance::segment_to_box + < + Segment, + Box, + dimension::value, + pp_strategy_type, + Strategy + >::apply(segment, box, pp_strategy_type(), strategy); + } +}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp new file mode 100644 index 000000000..1ae22153c --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp @@ -0,0 +1,131 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_SEGMENT_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_SEGMENT_HPP + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +// compute segment-segment distance +template +class segment_to_segment +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type + apply(Segment1 const& segment1, Segment2 const& segment2, + Strategy const& strategy) + { + if ( geometry::intersects(segment1, segment2) ) + { + return 0; + } + + typename point_type::type p[2]; + detail::assign_point_from_index<0>(segment1, p[0]); + detail::assign_point_from_index<1>(segment1, p[1]); + + typename point_type::type q[2]; + detail::assign_point_from_index<0>(segment2, q[0]); + detail::assign_point_from_index<1>(segment2, q[1]); + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + comparable_return_type d[4]; + d[0] = cstrategy.apply(q[0], p[0], p[1]); + d[1] = cstrategy.apply(q[1], p[0], p[1]); + d[2] = cstrategy.apply(p[0], q[0], q[1]); + d[3] = cstrategy.apply(p[1], q[0], q[1]); + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Segment1, Segment2 + >::apply( *std::min_element(d, d + 4) ); + } +}; + + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + + +// segment-segment +template +struct distance + < + Segment1, Segment2, Strategy, segment_tag, segment_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::segment_to_segment +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_SEGMENT_HPP diff --git a/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp b/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp new file mode 100644 index 000000000..f0c18476d --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp @@ -0,0 +1,489 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SINGLE_TO_MULTI_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SINGLE_TO_MULTI_HPP + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +// includes needed from multi.hpp -- start +#include +#include +#include +#include + +#include +#include +#include + +#include +// includes needed from multi.hpp -- end + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +class distance_single_to_multi_generic +{ +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Geometry const& geometry, + MultiGeometry const& multi, + Strategy const& strategy) + { + comparable_return_type min_cdist = comparable_return_type(); + bool first = true; + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + for (typename range_iterator::type it = boost::begin(multi); + it != boost::end(multi); + ++it, first = false) + { + comparable_return_type cdist = dispatch::distance + < + Geometry, + typename range_value::type, + comparable_strategy + >::apply(geometry, *it, cstrategy); + + if (first || cdist < min_cdist) + { + min_cdist = cdist; + } + if ( geometry::math::equals(min_cdist, 0) ) + { + break; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Geometry, MultiGeometry + >::apply(min_cdist); + } +}; + + + +template +struct distance_multi_to_single_generic +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiGeometry const& multi, + Geometry const& geometry, + Strategy const& strategy) + { + return distance_single_to_multi_generic + < + Geometry, MultiGeometry, Strategy + >::apply(geometry, multi, strategy); + } +}; + + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +namespace splitted_dispatch +{ + + +template +< + typename Geometry, + typename MultiGeometry, + typename Strategy, + typename GeometryTag, + typename MultiGeometryTag, + typename StrategyTag +> +struct distance_single_to_multi + : not_implemented +{}; + + + +template +struct distance_single_to_multi + < + Point, MultiPoint, Strategy, + point_tag, multi_point_tag, + strategy_tag_distance_point_point + > : detail::distance::distance_single_to_multi_generic + < + Point, MultiPoint, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Point, MultiLinestring, Strategy, + point_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_single_to_multi_generic + < + Point, MultiLinestring, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Point, MultiPolygon, Strategy, + point_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_single_to_multi_generic + < + Point, MultiPolygon, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Linestring, MultiLinestring, Strategy, + linestring_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Linestring, MultiLinestring, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Linestring, MultiPolygon, Strategy, + linestring_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Linestring, MultiPolygon, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Polygon, MultiPoint, Strategy, + polygon_tag, multi_point_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_single_to_multi_generic + < + Polygon, MultiPoint, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Polygon, MultiLinestring, Strategy, + polygon_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Polygon, MultiLinestring, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Polygon, MultiPolygon, Strategy, + polygon_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Polygon, MultiPolygon, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + MultiLinestring, Ring, Strategy, + multi_linestring_tag, ring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiLinestring, Ring, Strategy + > +{}; + + +template +struct distance_single_to_multi + < + MultiPolygon, Ring, Strategy, + multi_polygon_tag, ring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiPolygon, Ring, Strategy + > +{}; + + + +template +< + typename MultiGeometry, + typename Geometry, + typename Strategy, + typename MultiGeometryTag, + typename GeometryTag, + typename StrategyTag +> +struct distance_multi_to_single + : not_implemented +{}; + + + +template +< + typename MultiPoint, + typename Segment, + typename Strategy +> +struct distance_multi_to_single + < + MultiPoint, Segment, Strategy, + multi_point_tag, segment_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiPoint, Segment, Strategy + > +{}; + + + +template +< + typename MultiPoint, + typename Box, + typename Strategy +> +struct distance_multi_to_single + < + MultiPoint, Box, Strategy, + multi_point_tag, box_tag, + strategy_tag_distance_point_box + > : detail::distance::distance_multi_to_single_generic + < + MultiPoint, Box, Strategy + > +{}; + + +template +struct distance_multi_to_single + < + MultiLinestring, Segment, Strategy, + multi_linestring_tag, segment_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiLinestring, Segment, Strategy + > +{}; + + + +template +struct distance_multi_to_single + < + MultiLinestring, Box, Strategy, + multi_linestring_tag, box_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiLinestring, Box, Strategy + > +{}; + + + +template +struct distance_multi_to_single + < + MultiPolygon, Segment, Strategy, + multi_polygon_tag, segment_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiPolygon, Segment, Strategy + > +{}; + + + +template +struct distance_multi_to_single + < + MultiPolygon, Box, Strategy, + multi_polygon_tag, box_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiPolygon, Box, Strategy + > +{}; + + +} // namespace splitted_dispatch + + +template +< + typename Geometry, + typename MultiGeometry, + typename Strategy, + typename GeometryTag, + typename StrategyTag +> +struct distance + < + Geometry, MultiGeometry, Strategy, GeometryTag, multi_tag, + StrategyTag, false + > : splitted_dispatch::distance_single_to_multi + < + Geometry, MultiGeometry, Strategy, + GeometryTag, typename tag::type, + StrategyTag + > +{}; + + + +template +< + typename MultiGeometry, + typename Geometry, + typename Strategy, + typename GeometryTag, + typename StrategyTag +> +struct distance + < + MultiGeometry, Geometry, Strategy, multi_tag, GeometryTag, + StrategyTag, false + > : splitted_dispatch::distance_multi_to_single + < + MultiGeometry, Geometry, Strategy, + typename tag::type, GeometryTag, + StrategyTag + > +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SINGLE_TO_MULTI_HPP diff --git a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp index 131154f82..6407706cb 100644 --- a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp @@ -289,7 +289,7 @@ protected: public: template static inline OutputIterator - apply(Linestring const& linestring, Linear const& linear, + apply(Linestring const& linestring, Linear const&, TurnIterator first, TurnIterator beyond, OutputIterator oit) { diff --git a/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp b/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp index 50a14ea24..d71f4ad51 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp @@ -10,8 +10,6 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP -#include - #include diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp new file mode 100644 index 000000000..dd041b0d7 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp @@ -0,0 +1,84 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP + + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace intersection +{ + +template +struct intersection_box_box +{ + template + < + typename Box1, typename Box2, + typename RobustPolicy, + typename BoxOut, + typename Strategy + > + static inline bool apply(Box1 const& box1, + Box2 const& box2, + RobustPolicy const& robust_policy, + BoxOut& box_out, + Strategy const& strategy) + { + typedef typename coordinate_type::type ct; + + ct min1 = get(box1); + ct min2 = get(box2); + ct max1 = get(box1); + ct max2 = get(box2); + + if (max1 < min2 || max2 < min1) + { + return false; + } + // Set dimensions of output coordinate + set(box_out, min1 < min2 ? min2 : min1); + set(box_out, max1 > max2 ? max2 : max1); + + return intersection_box_box + ::apply(box1, box2, robust_policy, box_out, strategy); + } +}; + +template +struct intersection_box_box +{ + template + < + typename Box1, typename Box2, + typename RobustPolicy, + typename BoxOut, + typename Strategy + > + static inline bool apply(Box1 const&, Box2 const&, + RobustPolicy const&, BoxOut&, Strategy const&) + { + return true; + } +}; + + +}} // namespace detail::intersection +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 173639e9a..a13a62745 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -393,14 +393,13 @@ template < typename Linestring, typename Box, typename GeometryOut, - overlay_type OverlayType, bool Reverse1, bool Reverse2, bool ReverseOut > struct intersection_insert < Linestring, Box, GeometryOut, - OverlayType, + overlay_intersection, Reverse1, Reverse2, ReverseOut, linestring_tag, box_tag, linestring_tag, false, true, false diff --git a/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp index db9e91fb6..74b9e0134 100644 --- a/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -85,8 +84,9 @@ struct linear_linear_no_intersections static inline OutputIterator apply(MultiLineString const& multilinestring, OutputIterator oit) { - BOOST_AUTO_TPL(it, boost::begin(multilinestring)); - for (; it != boost::end(multilinestring); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multilinestring); + it != boost::end(multilinestring); ++it) { LineStringOut ls_out; geometry::convert(*it, ls_out); diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp index 8a63e78aa..321a512bf 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -72,8 +71,9 @@ struct copy_points static inline void apply(MultiPointIn const& multi_point_in, OutputIterator& oit) { - BOOST_AUTO_TPL(it, boost::begin(multi_point_in)); - for (; it != boost::end(multi_point_in); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multi_point_in); + it != boost::end(multi_point_in); ++it) { PointOut point_out; geometry::convert(*it, point_out); @@ -185,8 +185,9 @@ struct multipoint_point_point { BOOST_ASSERT( OverlayType == overlay_difference ); - BOOST_AUTO_TPL(it, boost::begin(multipoint)); - for (; it != boost::end(multipoint); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multipoint); + it != boost::end(multipoint); ++it) { action_selector_pl_pl < @@ -220,8 +221,9 @@ struct point_multipoint_point { typedef action_selector_pl_pl action; - BOOST_AUTO_TPL(it, boost::begin(multipoint)); - for (; it != boost::end(multipoint); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multipoint); + it != boost::end(multipoint); ++it) { if ( detail::equals::equals_point_point(*it, point) ) { @@ -268,8 +270,9 @@ struct multipoint_multipoint_point std::sort(points2.begin(), points2.end(), detail::relate::less()); - BOOST_AUTO_TPL(it1, boost::begin(multipoint1)); - for (; it1 != boost::end(multipoint1); ++it1) + for (typename boost::range_iterator::type + it1 = boost::begin(multipoint1); + it1 != boost::end(multipoint1); ++it1) { bool found = std::binary_search(points2.begin(), points2.end(), *it1, detail::relate::less()); diff --git a/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp b/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp index 4f38e3e73..17fbd65dd 100644 --- a/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp +++ b/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp @@ -24,7 +24,7 @@ namespace detail { namespace turns template struct filter_continue_turns { - static inline void apply(Turns& turns) {} + static inline void apply(Turns&) {} }; diff --git a/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp b/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp index 41f52c059..d48736c8f 100644 --- a/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp +++ b/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp @@ -23,7 +23,7 @@ namespace detail { namespace turns template struct remove_duplicate_turns { - static inline void apply(Turns& turns) {} + static inline void apply(Turns&) {} }; diff --git a/include/boost/geometry/algorithms/disjoint.hpp b/include/boost/geometry/algorithms/disjoint.hpp index ac9de681d..7ee61c602 100644 --- a/include/boost/geometry/algorithms/disjoint.hpp +++ b/include/boost/geometry/algorithms/disjoint.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -433,13 +434,25 @@ struct disjoint {}; -// move the following specializations to multi/algorithms/disjoint.hpp? - -template -struct disjoint - : public detail::disjoint::disjoint_linear_areal +template +struct disjoint + : public detail::disjoint::disjoint_linear {}; +template +struct disjoint +{ + static inline bool apply(Polygon const& polygon, + MultiLinestring const& multilinestring) + { + return detail::disjoint::disjoint_linear_areal + < + MultiLinestring, + Polygon + >::apply(multilinestring, polygon); + } +}; + template struct disjoint : public detail::disjoint::disjoint_linear_areal @@ -455,6 +468,11 @@ struct disjoint {}; +template +struct disjoint + : public detail::disjoint::disjoint_linear +{}; + template struct disjoint : public detail::disjoint::disjoint_point_linear diff --git a/include/boost/geometry/algorithms/dispatch/distance.hpp b/include/boost/geometry/algorithms/dispatch/distance.hpp new file mode 100644 index 000000000..58fd59340 --- /dev/null +++ b/include/boost/geometry/algorithms/dispatch/distance.hpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP + + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +using strategy::distance::services::return_type; + + +template +< + typename Geometry1, typename Geometry2, + typename Strategy = typename detail::distance::default_strategy::type, + typename Tag1 = typename tag_cast::type, multi_tag>::type, + typename Tag2 = typename tag_cast::type, multi_tag>::type, + typename StrategyTag = typename strategy::distance::services::tag::type, + bool Reverse = reverse_dispatch::type::value +> +struct distance: not_implemented +{}; + + + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP diff --git a/include/boost/geometry/algorithms/distance.hpp b/include/boost/geometry/algorithms/distance.hpp index 953be2361..36ff3a695 100644 --- a/include/boost/geometry/algorithms/distance.hpp +++ b/include/boost/geometry/algorithms/distance.hpp @@ -20,266 +20,46 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP - #include -#include #include -#include + +#include #include #include -#include +#include #include #include #include -#include #include #include #include -#include -#include +#include -#include -#include +#include + +#include +#include +#include +#include + +#include + +#include namespace boost { namespace geometry { -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace distance -{ - -// To avoid spurious namespaces here: -using strategy::distance::services::return_type; - -template -struct point_to_point -{ - static inline typename return_type::type - apply(P1 const& p1, P2 const& p2, Strategy const& strategy) - { - boost::ignore_unused_variable_warning(strategy); - return strategy.apply(p1, p2); - } -}; - - -template -struct point_to_segment -{ - static inline typename return_type::type>::type - apply(Point const& point, Segment const& segment, Strategy const& ) - { - typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type segment_strategy; - - typename point_type::type p[2]; - geometry::detail::assign_point_from_index<0>(segment, p[0]); - geometry::detail::assign_point_from_index<1>(segment, p[1]); - return segment_strategy.apply(point, p[0], p[1]); - } -}; - - -template -< - typename Point, - typename Range, - closure_selector Closure, - typename PPStrategy, - typename PSStrategy -> -struct point_to_range -{ - typedef typename return_type::type>::type return_type; - - static inline return_type apply(Point const& point, Range const& range, - PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) - { - return_type const zero = return_type(0); - - if (boost::size(range) == 0) - { - return zero; - } - - typedef typename closeable_view::type view_type; - - view_type view(range); - - // line of one point: return point distance - typedef typename boost::range_iterator::type iterator_type; - iterator_type it = boost::begin(view); - iterator_type prev = it++; - if (it == boost::end(view)) - { - return pp_strategy.apply(point, *boost::begin(view)); - } - - // Create comparable (more efficient) strategy - typedef typename strategy::distance::services::comparable_type::type eps_strategy_type; - eps_strategy_type eps_strategy = strategy::distance::services::get_comparable::apply(ps_strategy); - - // start with first segment distance - return_type d = eps_strategy.apply(point, *prev, *it); - return_type rd = ps_strategy.apply(point, *prev, *it); - - // check if other segments are closer - for (++prev, ++it; it != boost::end(view); ++prev, ++it) - { - return_type const ds = eps_strategy.apply(point, *prev, *it); - if (geometry::math::equals(ds, zero)) - { - return ds; - } - else if (ds < d) - { - d = ds; - rd = ps_strategy.apply(point, *prev, *it); - } - } - - return rd; - } -}; - - -template -< - typename Point, - typename Ring, - closure_selector Closure, - typename PPStrategy, - typename PSStrategy -> -struct point_to_ring -{ - typedef std::pair - < - typename return_type::type>::type, bool - > distance_containment; - - static inline distance_containment apply(Point const& point, - Ring const& ring, - PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) - { - return distance_containment - ( - point_to_range - < - Point, - Ring, - Closure, - PPStrategy, - PSStrategy - >::apply(point, ring, pp_strategy, ps_strategy), - geometry::within(point, ring) - ); - } -}; - - - -template -< - typename Point, - typename Polygon, - closure_selector Closure, - typename PPStrategy, - typename PSStrategy -> -struct point_to_polygon -{ - typedef typename return_type::type>::type return_type; - typedef std::pair distance_containment; - - static inline distance_containment apply(Point const& point, - Polygon const& polygon, - PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) - { - // Check distance to all rings - typedef point_to_ring - < - Point, - typename ring_type::type, - Closure, - PPStrategy, - PSStrategy - > per_ring; - - distance_containment dc = per_ring::apply(point, - exterior_ring(polygon), pp_strategy, ps_strategy); - - typename interior_return_type::type rings - = interior_rings(polygon); - for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) - { - distance_containment dcr = per_ring::apply(point, - *it, pp_strategy, ps_strategy); - if (dcr.first < dc.first) - { - dc.first = dcr.first; - } - // If it was inside, and also inside inner ring, - // turn off the inside-flag, it is outside the polygon - if (dc.second && dcr.second) - { - dc.second = false; - } - } - return dc; - } -}; - - -// Helper metafunction for default strategy retrieval -template -struct default_strategy - : strategy::distance::services::default_strategy - < - point_tag, - typename point_type::type, - typename point_type::type - > -{}; - - -}} // namespace detail::distance -#endif // DOXYGEN_NO_DETAIL - #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { -using strategy::distance::services::return_type; - - -template -< - typename Geometry1, typename Geometry2, - typename Strategy = typename detail::distance::default_strategy::type, - typename Tag1 = typename tag_cast::type, multi_tag>::type, - typename Tag2 = typename tag_cast::type, multi_tag>::type, - typename StrategyTag = typename strategy::distance::services::tag::type, - bool Reverse = reverse_dispatch::type::value -> -struct distance: not_implemented -{}; - - // If reversal is needed, perform it template < @@ -316,184 +96,6 @@ struct distance }; -// Point-point -template -struct distance - < - P1, P2, Strategy, - point_tag, point_tag, strategy_tag_distance_point_point, - false - > - : detail::distance::point_to_point -{}; - - -// Point-line version 1, where point-point strategy is specified -template -struct distance -< - Point, Linestring, Strategy, - point_tag, linestring_tag, strategy_tag_distance_point_point, - false -> -{ - - static inline typename return_type::type>::type - apply(Point const& point, - Linestring const& linestring, - Strategy const& strategy) - { - typedef typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type ps_strategy_type; - - return detail::distance::point_to_range - < - Point, Linestring, closed, Strategy, ps_strategy_type - >::apply(point, linestring, strategy, ps_strategy_type()); - } -}; - - -// Point-line version 2, where point-segment strategy is specified -template -struct distance -< - Point, Linestring, Strategy, - point_tag, linestring_tag, strategy_tag_distance_point_segment, - false -> -{ - static inline typename return_type::type>::type - apply(Point const& point, - Linestring const& linestring, - Strategy const& strategy) - { - typedef typename strategy::distance::services::strategy_point_point::type pp_strategy_type; - return detail::distance::point_to_range - < - Point, Linestring, closed, pp_strategy_type, Strategy - >::apply(point, linestring, pp_strategy_type(), strategy); - } -}; - -// Point-ring , where point-segment strategy is specified -template -struct distance -< - Point, Ring, Strategy, - point_tag, ring_tag, strategy_tag_distance_point_point, - false -> -{ - typedef typename return_type::type>::type return_type; - - static inline return_type apply(Point const& point, - Ring const& ring, - Strategy const& strategy) - { - typedef typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type ps_strategy_type; - - std::pair - dc = detail::distance::point_to_ring - < - Point, Ring, - geometry::closure::value, - Strategy, ps_strategy_type - >::apply(point, ring, strategy, ps_strategy_type()); - - return dc.second ? return_type(0) : dc.first; - } -}; - - -// Point-polygon , where point-segment strategy is specified -template -struct distance -< - Point, Polygon, Strategy, - point_tag, polygon_tag, strategy_tag_distance_point_point, - false -> -{ - typedef typename return_type::type>::type return_type; - - static inline return_type apply(Point const& point, - Polygon const& polygon, - Strategy const& strategy) - { - typedef typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type ps_strategy_type; - - std::pair - dc = detail::distance::point_to_polygon - < - Point, Polygon, - geometry::closure::value, - Strategy, ps_strategy_type - >::apply(point, polygon, strategy, ps_strategy_type()); - - return dc.second ? return_type(0) : dc.first; - } -}; - - - -// Point-segment version 1, with point-point strategy -template -struct distance -< - Point, Segment, Strategy, - point_tag, segment_tag, strategy_tag_distance_point_point, - false -> : detail::distance::point_to_segment -{}; - -// Point-segment version 2, with point-segment strategy -template -struct distance -< - Point, Segment, Strategy, - point_tag, segment_tag, strategy_tag_distance_point_segment, - false -> -{ - static inline typename return_type::type>::type - apply(Point const& point, - Segment const& segment, - Strategy const& strategy) - { - - typename point_type::type p[2]; - geometry::detail::assign_point_from_index<0>(segment, p[0]); - geometry::detail::assign_point_from_index<1>(segment, p[1]); - return strategy.apply(point, p[0], p[1]); - } -}; - - - } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH @@ -578,10 +180,29 @@ inline typename default_distance_result::type distance( concept::check(); concept::check(); - return distance(geometry1, geometry2, - typename detail::distance::default_strategy::type()); + typedef typename detail::distance::default_strategy + < + Geometry1, Geometry2 + >::type default_strategy_type; + + return distance(geometry1, geometry2, default_strategy_type()); } }} // namespace boost::geometry + +// the implementation details +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + #endif // BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp index 500cacc9f..ca3bb0682 100644 --- a/include/boost/geometry/algorithms/intersection.hpp +++ b/include/boost/geometry/algorithms/intersection.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -19,68 +20,6 @@ namespace boost { namespace geometry { -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace intersection -{ - -template -struct intersection_box_box -{ - template - < - typename Box1, typename Box2, - typename RobustPolicy, - typename BoxOut, - typename Strategy - > - static inline bool apply(Box1 const& box1, - Box2 const& box2, - RobustPolicy const& robust_policy, - BoxOut& box_out, - Strategy const& strategy) - { - typedef typename coordinate_type::type ct; - - ct min1 = get(box1); - ct min2 = get(box2); - ct max1 = get(box1); - ct max2 = get(box2); - - if (max1 < min2 || max2 < min1) - { - return false; - } - // Set dimensions of output coordinate - set(box_out, min1 < min2 ? min2 : min1); - set(box_out, max1 > max2 ? max2 : max1); - - return intersection_box_box - ::apply(box1, box2, robust_policy, box_out, strategy); - } -}; - -template -struct intersection_box_box -{ - template - < - typename Box1, typename Box2, - typename RobustPolicy, - typename BoxOut, - typename Strategy - > - static inline bool apply(Box1 const&, Box2 const&, - RobustPolicy const&, BoxOut&, Strategy const&) - { - return true; - } -}; - - -}} // namespace detail::intersection -#endif // DOXYGEN_NO_DETAIL - - #ifndef DOXYGEN_NO_DISPATCH namespace dispatch diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp index 841876eb3..c4e44cae1 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp @@ -2,7 +2,7 @@ // // squared distance between point and centroid of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -24,7 +24,7 @@ template < size_t N> struct sum_for_indexable { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, PointIndexable const& i) { @@ -38,7 +38,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -59,7 +59,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_centroid(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp index 07dfcfc0f..214fbf6aa 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp @@ -2,7 +2,7 @@ // // squared distance between point and furthest point of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -26,7 +26,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -49,7 +49,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_far(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp index 5584bf85e..15368a7d2 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp @@ -2,7 +2,7 @@ // // squared distance between point and nearest point of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -23,7 +23,7 @@ template < size_t N> struct sum_for_indexable { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, PointIndexable const& i) { @@ -37,7 +37,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -60,7 +60,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_near(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp index 955d6eb65..ed615c402 100644 --- a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp +++ b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp @@ -11,7 +11,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP -#include +#include +#include #include namespace boost { namespace geometry { namespace index { namespace detail { @@ -25,7 +26,12 @@ inline typename default_content_result::type intersection_content(Box const if ( geometry::intersects(box1, box2) ) { Box box_intersection; - geometry::intersection(box1, box2, box_intersection); + + strategy_intersection_empty dummy; + geometry::detail::intersection::intersection_box_box + < + 0, geometry::dimension::value + >::apply(box1, box2, box_intersection, dummy); return detail::content(box_intersection); } return 0; diff --git a/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp b/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp index 680fb202b..ab6291504 100644 --- a/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp +++ b/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp @@ -2,7 +2,7 @@ // // minmaxdist used in R-tree k nearest neighbors query // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -28,7 +28,7 @@ template < size_t DimensionIndex> struct smallest_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i, result_type const& maxd) { @@ -73,7 +73,7 @@ struct minmaxdist_impl template struct minmaxdist_impl { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, Indexable const& i) { @@ -84,7 +84,7 @@ struct minmaxdist_impl template struct minmaxdist_impl { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, Indexable const& i) { @@ -104,7 +104,7 @@ struct minmaxdist_impl * This is comparable distace. */ template -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type minmaxdist(Point const& pt, Indexable const& i) { return detail::minmaxdist_impl< diff --git a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp index a9e0f3dcb..fe92596ba 100644 --- a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp @@ -2,7 +2,7 @@ // // n-dimensional box-linestring intersection // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -23,6 +23,11 @@ struct path_intersection BOOST_MPL_ASSERT_MSG((false), NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_OR_INDEXABLE, (path_intersection)); }; +// TODO: FP type must be used as a relative distance type! +// and default_distance_result can be some user-defined int type +// BUT! This code is experimental and probably won't be released at all +// since more flexible user-defined-nearest predicate should be added instead + template struct path_intersection { diff --git a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp index a6ad30181..ec7a88f49 100644 --- a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp @@ -2,7 +2,7 @@ // // n-dimensional box-segment intersection // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -110,6 +110,9 @@ struct segment_intersection template static inline bool apply(Indexable const& b, Point const& p0, Point const& p1, RelativeDistance & relative_distance) { + +// TODO: this ASSERT CHECK is wrong for user-defined CoordinateTypes! + static const bool check = !::boost::is_integral::value; BOOST_MPL_ASSERT_MSG(check, RELATIVE_DISTANCE_MUST_BE_FLOATING_POINT_TYPE, (RelativeDistance)); diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index c5c2c4c51..3e057290a 100644 --- a/include/boost/geometry/index/detail/distance_predicates.hpp +++ b/include/boost/geometry/index/detail/distance_predicates.hpp @@ -3,7 +3,7 @@ // Spatial index distance predicates, calculators and checkers // used in nearest query - specialized for envelopes // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -108,11 +108,11 @@ struct calculate_distance< nearest, Indexable, Tag > { typedef detail::relation relation; typedef typename relation::value_type point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest const& p, Indexable const& i, result_type & result) { - result = index::detail::comparable_distance_near(relation::value(p.point_or_relation), i); + result = geometry::comparable_distance(relation::value(p.point_or_relation), i); return true; } }; @@ -121,7 +121,7 @@ template struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> { typedef Point point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest< to_centroid > const& p, Indexable const& i, result_type & result) { @@ -134,7 +134,7 @@ template struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> { typedef Point point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest< to_furthest > const& p, Indexable const& i, result_type & result) { diff --git a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp index 37bc31efa..c903d6ca2 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp @@ -2,7 +2,7 @@ // // R-tree R*-tree insert algorithm implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -45,7 +45,9 @@ public: typedef typename elements_type::value_type element_type; typedef typename geometry::point_type::type point_type; // TODO: awulkiew - change second point_type to the point type of the Indexable? - typedef typename geometry::default_distance_result::type distance_type; + typedef typename + geometry::default_comparable_distance_result::type + comparable_distance_type; elements_type & elements = rtree::elements(n); @@ -63,8 +65,9 @@ public: // fill the container of centers' distances of children from current node's center typedef typename index::detail::rtree::container_from_elements_type< elements_type, - std::pair + std::pair >::type sorted_elements_type; + sorted_elements_type sorted_elements; // If constructor is used instead of resize() MS implementation leaks here sorted_elements.reserve(elements_count); // MAY THROW, STRONG (V, E: alloc, copy) @@ -84,7 +87,7 @@ public: sorted_elements.begin(), sorted_elements.begin() + reinserted_elements_count, sorted_elements.end(), - distances_dsc); // MAY THROW, BASIC (V, E: copy) + distances_dsc); // MAY THROW, BASIC (V, E: copy) // copy elements which will be reinserted result_elements.clear(); diff --git a/include/boost/geometry/index/equal_to.hpp b/include/boost/geometry/index/equal_to.hpp index 8ce5074c3..37e10cb6f 100644 --- a/include/boost/geometry/index/equal_to.hpp +++ b/include/boost/geometry/index/equal_to.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -10,15 +10,14 @@ #define BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP #include +#include -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template struct equals { - static bool apply(Geometry const& g1, Geometry const& g2) + inline static bool apply(Geometry const& g1, Geometry const& g2) { return geometry::equals(g1, g2); } @@ -27,7 +26,7 @@ struct equals template struct equals { - static bool apply(T const& v1, T const& v2) + inline static bool apply(T const& v1, T const& v2) { return v1 == v2; } @@ -57,8 +56,6 @@ struct tuple_equals } }; -} // namespace detail - /*! \brief The function object comparing Values. @@ -67,8 +64,9 @@ The default version handles Values which are Indexables. This template is also specialized for std::pair and boost::tuple<...>. \tparam Value The type of objects which are compared by this function object. +\tparam IsIndexable If true, Values are compared using boost::geometry::equals() functions. */ -template +template ::value> struct equal_to { /*! \brief The type of result returned by function object. */ @@ -81,7 +79,7 @@ struct equal_to \param r Second value. \return true if values are equal. */ - bool operator()(Value const& l, Value const& r) const + inline bool operator()(Value const& l, Value const& r) const { return detail::equals::type>::apply(l ,r); } @@ -97,7 +95,7 @@ It compares pairs' first values, then second values. \tparam T2 The second type. */ template -struct equal_to< std::pair > +struct equal_to, false> { /*! \brief The type of result returned by function object. */ typedef bool result_type; @@ -109,7 +107,7 @@ struct equal_to< std::pair > \param r Second value. \return true if values are equal. */ - bool operator()(std::pair const& l, std::pair const& r) const + inline bool operator()(std::pair const& l, std::pair const& r) const { typedef detail::equals::type> equals1; typedef detail::equals::type> equals2; @@ -126,7 +124,7 @@ It compares all members of the tuple from the first one to the last one. */ template -struct equal_to< boost::tuple > +struct equal_to, false> { typedef boost::tuple value_type; @@ -140,7 +138,7 @@ struct equal_to< boost::tuple > \param r Second value. \return true if values are equal. */ - bool operator()(value_type const& l, value_type const& r) const + inline bool operator()(value_type const& l, value_type const& r) const { return detail::tuple_equals< value_type, 0, boost::tuples::length::value @@ -148,15 +146,13 @@ struct equal_to< boost::tuple > } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template struct std_tuple_equals @@ -182,8 +178,6 @@ struct std_tuple_equals } }; -} // namespace detail - /*! \brief The function object comparing Values. @@ -192,7 +186,7 @@ It's defined if the compiler supports tuples and variadic templates. It compares all members of the tuple from the first one to the last one. */ template -struct equal_to< std::tuple > +struct equal_to, false> { typedef std::tuple value_type; @@ -214,8 +208,42 @@ struct equal_to< std::tuple > } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +namespace boost { namespace geometry { namespace index { + +/*! +\brief The function object comparing Values. + +The default version handles Values which are Indexables, std::pair, boost::tuple<...> +and std::tuple<...> if STD tuples and variadic templates are supported. +All members are compared from left to right, Geometries using boost::geometry::equals() function, +other types using operator==. + +\tparam Value The type of objects which are compared by this function object. +*/ +template +struct equal_to + : detail::equal_to +{ + /*! \brief The type of result returned by function object. */ + typedef typename detail::equal_to::result_type result_type; + + /*! + \brief Compare Values. + + \param l First value. + \param r Second value. + \return true if Values are equal. + */ + inline bool operator()(Value const& l, Value const& r) const + { + return detail::equal_to::operator()(l ,r); + } +}; + +}}} // namespace boost::geometry::index + #endif // BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP diff --git a/include/boost/geometry/index/indexable.hpp b/include/boost/geometry/index/indexable.hpp index 9533fcf9e..7476602f8 100644 --- a/include/boost/geometry/index/indexable.hpp +++ b/include/boost/geometry/index/indexable.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,9 +11,7 @@ #include -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template struct is_indexable_impl { static const bool value = false; }; @@ -31,24 +29,19 @@ struct is_indexable is_indexable_impl::type>::value; }; -} // namespace detail - /*! \brief The function object extracting Indexable from Value. It translates Value object to Indexable object. The default version handles Values which are Indexables. -This template is also specialized for std::pair and boost::tuple. +This template is also specialized for std::pair, boost::tuple +and std::tuple. \tparam Value The Value type which may be translated directly to the Indexable. +\tparam IsIndexable If true, the const reference to Value is returned. */ -template +template ::value> struct indexable { - BOOST_MPL_ASSERT_MSG( - (detail::is_indexable::value), - NOT_VALID_INDEXABLE_TYPE, - (Value) - ); /*! \brief The type of result returned by function object. */ typedef Value const& result_type; @@ -58,7 +51,7 @@ struct indexable \param v The value. \return The indexable. */ - result_type operator()(Value const& v) const + inline result_type operator()(Value const& v) const { return v; } @@ -73,7 +66,7 @@ This specialization translates from std::pair. \tparam T2 The second type. */ template -struct indexable< std::pair > +struct indexable, false> { BOOST_MPL_ASSERT_MSG( (detail::is_indexable::value), @@ -90,7 +83,7 @@ struct indexable< std::pair > \param v The value. \return The indexable. */ - result_type operator()(std::pair const& v) const + inline result_type operator()(std::pair const& v) const { return v.first; } @@ -105,7 +98,7 @@ This specialization translates from boost::tuple. */ template -struct indexable< boost::tuple > +struct indexable, false> { typedef boost::tuple value_type; @@ -124,19 +117,19 @@ struct indexable< boost::tuple > \param v The value. \return The indexable. */ - result_type operator()(value_type const& v) const + inline result_type operator()(value_type const& v) const { return boost::get<0>(v); } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include -namespace boost { namespace geometry { namespace index { +namespace boost { namespace geometry { namespace index { namespace detail { /*! \brief The function object extracting Indexable from Value. @@ -147,7 +140,7 @@ It's defined if the compiler supports tuples and variadic templates. \tparam Indexable The Indexable type. */ template -struct indexable< std::tuple > +struct indexable, false> { typedef std::tuple value_type; @@ -172,8 +165,40 @@ struct indexable< std::tuple > } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +namespace boost { namespace geometry { namespace index { + +/*! +\brief The function object extracting Indexable from Value. + +It translates Value object to Indexable object. By default, it can handle Values which are Indexables, +std::pair, boost::tuple and std::tuple if STD tuples +and variadic templates are supported. + +\tparam Value The Value type which may be translated directly to the Indexable. +*/ +template +struct indexable + : detail::indexable +{ + /*! \brief The type of result returned by function object. It should be const Indexable reference. */ + typedef typename detail::indexable::result_type result_type; + + /*! + \brief Return indexable extracted from the value. + + \param v The value. + \return The indexable. + */ + inline result_type operator()(Value const& v) const + { + return detail::indexable::operator()(v); + } +}; + +}}} // namespace boost::geometry::index + #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 6decfe70f..9e61a3979 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -17,7 +17,45 @@ #include #include -#include +//#include +// START +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//#include +//#include +//#include +//#include +//#include +// END #include diff --git a/include/boost/geometry/iterators/has_one_element.hpp b/include/boost/geometry/iterators/has_one_element.hpp new file mode 100644 index 000000000..2f9acefc1 --- /dev/null +++ b/include/boost/geometry/iterators/has_one_element.hpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ITERATORS_HAS_ONE_ELEMENT_HPP +#define BOOST_GEOMETRY_ITERATORS_HAS_ONE_ELEMENT_HPP + + +namespace boost { namespace geometry +{ + + +// free function to test if an iterator range has a single element +template +inline bool has_one_element(Iterator first, Iterator beyond) +{ + return first != beyond && ++first == beyond; +} + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ITERATORS_HAS_ONE_ELEMENT_HPP diff --git a/include/boost/geometry/multi/algorithms/distance.hpp b/include/boost/geometry/multi/algorithms/distance.hpp index 92352d5fe..4946b6f3e 100644 --- a/include/boost/geometry/multi/algorithms/distance.hpp +++ b/include/boost/geometry/multi/algorithms/distance.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -14,155 +19,9 @@ #ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP #define BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP - -#include -#include - -#include -#include -#include -#include +// this file is intentionally empty (with the exception of the #include below) +// it is used for backward compatinility and may be removed in the future #include -#include -#include - - -namespace boost { namespace geometry -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace distance -{ - - -template -struct distance_single_to_multi - : private dispatch::distance - < - Geometry, - typename range_value::type, - Strategy - > -{ - typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; - - static inline return_type apply(Geometry const& geometry, - MultiGeometry const& multi, - Strategy const& strategy) - { - return_type mindist = return_type(); - bool first = true; - - for(typename range_iterator::type it = boost::begin(multi); - it != boost::end(multi); - ++it, first = false) - { - return_type dist = dispatch::distance - < - Geometry, - typename range_value::type, - Strategy - >::apply(geometry, *it, strategy); - - if (first || dist < mindist) - { - mindist = dist; - } - } - - return mindist; - } -}; - -template -struct distance_multi_to_multi - : private distance_single_to_multi - < - typename range_value::type, - Multi2, - Strategy - > -{ - typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; - - static inline return_type apply(Multi1 const& multi1, - Multi2 const& multi2, Strategy const& strategy) - { - return_type mindist = return_type(); - bool first = true; - - for(typename range_iterator::type it = boost::begin(multi1); - it != boost::end(multi1); - ++it, first = false) - { - return_type dist = distance_single_to_multi - < - typename range_value::type, - Multi2, - Strategy - >::apply(*it, multi2, strategy); - if (first || dist < mindist) - { - mindist = dist; - } - } - - return mindist; - } -}; - - -}} // namespace detail::distance -#endif - - -#ifndef DOXYGEN_NO_DISPATCH -namespace dispatch -{ - -template -< - typename G1, - typename G2, - typename Strategy, - typename SingleGeometryTag -> -struct distance -< - G1, G2, Strategy, - SingleGeometryTag, multi_tag, strategy_tag_distance_point_point, - false -> - : detail::distance::distance_single_to_multi -{}; - -template -struct distance -< - G1, G2, Strategy, - multi_tag, multi_tag, strategy_tag_distance_point_point, - false -> - : detail::distance::distance_multi_to_multi -{}; - -} // namespace dispatch -#endif - - - -}} // namespace boost::geometry - #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP diff --git a/include/boost/geometry/policies/robustness/rescale_policy.hpp b/include/boost/geometry/policies/robustness/rescale_policy.hpp index 570ba8bef..5b3b56697 100644 --- a/include/boost/geometry/policies/robustness/rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/rescale_policy.hpp @@ -16,6 +16,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp b/include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp new file mode 100644 index 000000000..2d13b7a75 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp @@ -0,0 +1,106 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_COMPARABLE_TO_REGULAR_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_COMPARABLE_TO_REGULAR_HPP + + +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + + +template +< + typename ComparableStrategy, + typename Strategy, + typename Geometry1, + typename Geometry2 +> +struct comparable_to_regular + < + ComparableStrategy, Strategy, + Geometry1, Geometry2, + cartesian_tag, cartesian_tag + > +{ + typedef typename return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type calculation_type; + + typedef typename return_type + < + ComparableStrategy, + typename point_type::type, + typename point_type::type + >::type comparable_calculation_type; + + static inline calculation_type apply(comparable_calculation_type const& cd) + { + return sqrt( boost::numeric_cast(cd) ); + } +}; + + + +template +struct comparable_to_regular + < + ComparableStrategy, + ComparableStrategy, + Geometry1, + Geometry2, + cartesian_tag, + cartesian_tag + > +{ + typedef typename return_type + < + ComparableStrategy, + typename point_type::type, + typename point_type::type + >::type comparable_calculation_type; + + static inline comparable_calculation_type + apply(comparable_calculation_type const& cd) + { + return cd; + } +}; + + + + + + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_COMPARABLE_TO_REGULAR_HPP diff --git a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp index 95b13d792..cd86b523f 100644 --- a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp @@ -174,11 +174,6 @@ struct return_type, P, PS> : projected_point::template calculation_type {}; -template -struct strategy_point_point > -{ - typedef Strategy type; -}; template diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp new file mode 100644 index 000000000..d4c94b5c0 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp @@ -0,0 +1,338 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_BOX_BOX_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_BOX_BOX_HPP + + +#include + +#include + +#include + + + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct compute_pythagoras_box_box +{ + template + static inline void apply(Box1 const& box1, Box2 const& box2, T& result) + { + T const b1_min_coord = + boost::numeric_cast(geometry::get(box1)); + T const b1_max_coord = + boost::numeric_cast(geometry::get(box1)); + + T const b2_min_coord = + boost::numeric_cast(geometry::get(box2)); + T const b2_max_coord = + boost::numeric_cast(geometry::get(box2)); + + if ( b1_max_coord < b2_min_coord ) + { + T diff = b2_min_coord - b1_max_coord; + result += diff * diff; + } + if ( b1_min_coord > b2_max_coord ) + { + T diff = b1_min_coord - b2_max_coord; + result += diff * diff; + } + + compute_pythagoras_box_box::apply(box1, box2, result); + } +}; + +template <> +struct compute_pythagoras_box_box<0> +{ + template + static inline void apply(Box1 const&, Box2 const&, T&) + { + } +}; + +} +#endif // DOXYGEN_NO_DETAIL + + +namespace comparable +{ + +/*! +\brief Strategy to calculate comparable distance between two boxes +\ingroup strategies +\tparam Box1 \tparam_first_box +\tparam Box2 \tparam_second_box +\tparam CalculationType \tparam_calculation +*/ +template +class pythagoras_box_box +{ +public : + + template + struct calculation_type + { + typedef typename util::calculation_type::geometric::binary + < + Box1, + Box2, + CalculationType + >::type type; + }; + + template + static inline typename calculation_type::type + apply(Box1 const& box1, Box2 const& box2) + { + BOOST_CONCEPT_ASSERT + ( (concept::ConstPoint::type>) ); + BOOST_CONCEPT_ASSERT + ( (concept::ConstPoint::type>) ); + + // Calculate distance using Pythagoras + // (Leave comment above for Doxygen) + + assert_dimension_equal(); + + typename calculation_type::type result(0); + + detail::compute_pythagoras_box_box + < + dimension::value + >::apply(box1, box2, result); + + return result; + } +}; + +} // namespace comparable + + +/*! +\brief Strategy to calculate the distance between two points or boxes +\ingroup strategies +\tparam CalculationType \tparam_calculation + +\qbk{ +[heading Notes] +[note Can be used for boxes with two\, three or more dimensions] +[heading See also] +[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)] +} + +*/ +template +< + typename CalculationType = void +> +class pythagoras_box_box +{ +public : + + template + struct calculation_type + : util::calculation_type::geometric::binary + < + Box1, + Box2, + CalculationType, + double, + double // promote integer to double + > + {}; + + /*! + \brief applies the distance calculation using pythagoras_box_box + \return the calculated distance (including taking the square root) + \param box1 first box + \param box2 second box + */ + template + static inline typename calculation_type::type + apply(Box1 const& box1, Box2 const& box2) + { + // Don't add std:: for ttmath + // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call + return sqrt + ( + boost::numeric_cast::type> + ( + comparable::pythagoras_box_box + < + CalculationType + >::apply(box1, box2) + ) + ); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + +template +struct tag > +{ + typedef strategy_tag_distance_box_box type; +}; + + +template +struct return_type, Box1, Box2> + : pythagoras_box_box::template calculation_type +{}; + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_box_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_box_box comparable_type; +public : + static inline comparable_type + apply(pythagoras_box_box const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance, Box1, Box2> +{ +private: + typedef typename return_type + < + pythagoras_box_box, Box1, Box2 + >::type return_type; +public: + template + static inline return_type + apply(pythagoras_box_box const& , T const& value) + { + return return_type(value); + } +}; + + +// Specializations for comparable::pythagoras_box_box +template +struct tag > +{ + typedef strategy_tag_distance_box_box type; +}; + + +template +struct return_type, Box1, Box2> + : comparable::pythagoras_box_box + < + CalculationType + >::template calculation_type +{}; + + + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_box_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_box_box comparable_type; +public : + static inline comparable_type apply(comparable_type const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance + < + comparable::pythagoras_box_box, Box1, Box2 + > +{ +private : + typedef typename return_type + < + comparable::pythagoras_box_box, Box1, Box2 + >::type return_type; +public : + template + static inline return_type + apply(comparable::pythagoras_box_box const&, + T const& value) + { + return_type const v = value; + return v * v; + } +}; + + +template +struct default_strategy + < + box_tag, Box1, Box2, cartesian_tag, cartesian_tag, void, box_tag + > +{ + typedef pythagoras_box_box<> type; +}; + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_BOX_BOX_HPP diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp new file mode 100644 index 000000000..304250167 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp @@ -0,0 +1,333 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_POINT_BOX_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_POINT_BOX_HPP + + +#include + +#include + +#include + + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct compute_pythagoras_point_box +{ + template + static inline void apply(Point const& point, Box const& box, T& result) + { + T const p_coord = boost::numeric_cast(geometry::get(point)); + T const b_min_coord = + boost::numeric_cast(geometry::get(box)); + T const b_max_coord = + boost::numeric_cast(geometry::get(box)); + + if ( p_coord < b_min_coord ) + { + T diff = b_min_coord - p_coord; + result += diff * diff; + } + if ( p_coord > b_max_coord ) + { + T diff = p_coord - b_max_coord; + result += diff * diff; + } + + compute_pythagoras_point_box::apply(point, box, result); + } +}; + +template <> +struct compute_pythagoras_point_box<0> +{ + template + static inline void apply(Point const&, Box const&, T&) + { + } +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +namespace comparable +{ + +/*! +\brief Strategy to calculate comparable distance between two points +\ingroup strategies +\tparam Point \tparam_first_point +\tparam Box \tparam_second_box +\tparam CalculationType \tparam_calculation +*/ +template +class pythagoras_point_box +{ +public : + + template + struct calculation_type + { + typedef typename util::calculation_type::geometric::binary + < + Point, Box, CalculationType + >::type type; + }; + + template + static inline typename calculation_type::type + apply(Point const& point, Box const& box) + { + BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); + BOOST_CONCEPT_ASSERT + ( (concept::ConstPoint::type>) ); + + // Calculate distance using Pythagoras + // (Leave comment above for Doxygen) + + assert_dimension_equal(); + + typename calculation_type::type result(0); + + detail::compute_pythagoras_point_box + < + dimension::value + >::apply(point, box, result); + + return result; + } +}; + +} // namespace comparable + + +/*! +\brief Strategy to calculate the distance between two points or boxes +\ingroup strategies +\tparam CalculationType \tparam_calculation + +\qbk{ +[heading Notes] +[note Can be used for points and boxes with two\, three or more dimensions] +[heading See also] +[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)] +} + +*/ +template +< + typename CalculationType = void +> +class pythagoras_point_box +{ +public : + + template + struct calculation_type + : util::calculation_type::geometric::binary + < + Point, + Box, + CalculationType, + double, + double // promote integer to double + > + {}; + + /*! + \brief applies the distance calculation using pythagoras + \return the calculated distance (including taking the square root) + \param point point + \param box box + */ + template + static inline typename calculation_type::type + apply(Point const& point, Box const& box) + { + // Don't add std:: for ttmath + // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call + return sqrt + ( + boost::numeric_cast::type> + ( + comparable::pythagoras_point_box + < + CalculationType + >::apply(point, box) + ) + ); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + +template +struct tag > +{ + typedef strategy_tag_distance_point_box type; +}; + + +template +struct return_type, Point, Box> + : pythagoras_point_box + < + CalculationType + >::template calculation_type +{}; + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_point_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_point_box comparable_type; +public : + static inline comparable_type + apply(pythagoras_point_box const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance, Point, Box> +{ +private : + typedef typename return_type + < + pythagoras_point_box, Point, Box + >::type return_type; +public : + template + static inline return_type + apply(pythagoras_point_box const& , T const& value) + { + return return_type(value); + } +}; + + +// Specializations for comparable::pythagoras_point_box +template +struct tag > +{ + typedef strategy_tag_distance_point_box type; +}; + + +template +struct return_type + < + comparable::pythagoras_point_box, Point, Box + > : comparable::pythagoras_point_box + < + CalculationType + >::template calculation_type +{}; + + + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_point_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_point_box comparable_type; +public : + static inline comparable_type apply(comparable_type const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance + < + comparable::pythagoras_point_box, Point, Box + > +{ +private : + typedef typename return_type + < + comparable::pythagoras_point_box, Point, Box + >::type return_type; +public : + template + static inline return_type + apply(comparable::pythagoras_point_box const& , + T const& value) + { + return_type const v = value; + return v * v; + } +}; + + +template +struct default_strategy +{ + typedef pythagoras_point_box<> type; +}; + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_POINT_BOX_HPP diff --git a/include/boost/geometry/strategies/concepts/distance_concept.hpp b/include/boost/geometry/strategies/concepts/distance_concept.hpp index 5d8cfb690..3d4505bb1 100644 --- a/include/boost/geometry/strategies/concepts/distance_concept.hpp +++ b/include/boost/geometry/strategies/concepts/distance_concept.hpp @@ -135,16 +135,9 @@ private : ApplyMethod, 1 >::type sptype; - // 1) must define meta-function return_type + // must define meta-function return_type typedef typename strategy::distance::services::return_type::type rtype; - // 2) must define underlying point-distance-strategy - typedef typename strategy::distance::services::strategy_point_point::type stype; - BOOST_CONCEPT_ASSERT - ( - (concept::PointDistanceStrategy) - ); - Strategy *str = 0; ptype *p = 0; diff --git a/include/boost/geometry/strategies/default_comparable_distance_result.hpp b/include/boost/geometry/strategies/default_comparable_distance_result.hpp new file mode 100644 index 000000000..601bdbd6a --- /dev/null +++ b/include/boost/geometry/strategies/default_comparable_distance_result.hpp @@ -0,0 +1,58 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_COMPARABLE_DISTANCE_RESULT_HPP +#define BOOST_GEOMETRY_STRATEGIES_DEFAULT_COMPARABLE_DISTANCE_RESULT_HPP + +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + +/*! +\brief Meta-function defining return type of comparable_distance function +\ingroup distance +\note The strategy defines the return-type (so this situation is different + from length, where distance is sqr/sqrt, but length always squared) + */ +template +struct default_comparable_distance_result +{ + typedef typename strategy::distance::services::return_type + < + typename strategy::distance::services::comparable_type + < + typename detail::distance::default_strategy + < + Geometry1, Geometry2 + >::type + >::type, + typename point_type::type, + typename point_type::type + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_COMPARABLE_DISTANCE_RESULT_HPP diff --git a/include/boost/geometry/strategies/default_distance_result.hpp b/include/boost/geometry/strategies/default_distance_result.hpp index 74ce495d3..92b629f6f 100644 --- a/include/boost/geometry/strategies/default_distance_result.hpp +++ b/include/boost/geometry/strategies/default_distance_result.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -19,6 +24,7 @@ #include #include +#include namespace boost { namespace geometry { @@ -34,11 +40,9 @@ struct default_distance_result { typedef typename strategy::distance::services::return_type < - typename strategy::distance::services::default_strategy + typename detail::distance::default_strategy < - point_tag, - typename point_type::type, - typename point_type::type + Geometry1, Geometry2 >::type, typename point_type::type, typename point_type::type diff --git a/include/boost/geometry/strategies/distance.hpp b/include/boost/geometry/strategies/distance.hpp index 4179f8250..2071e86cc 100644 --- a/include/boost/geometry/strategies/distance.hpp +++ b/include/boost/geometry/strategies/distance.hpp @@ -61,8 +61,6 @@ template struct result_from_distance {}; -// For point-segment only: -template struct strategy_point_point {}; // Default strategy @@ -85,7 +83,8 @@ template typename Point2 = Point1, typename CsTag1 = typename cs_tag::type, typename CsTag2 = typename cs_tag::type, - typename UnderlyingStrategy = void + typename UnderlyingStrategy = void, + typename GeometryTag2 = GeometryTag > struct default_strategy { diff --git a/include/boost/geometry/strategies/distance_comparable_to_regular.hpp b/include/boost/geometry/strategies/distance_comparable_to_regular.hpp new file mode 100644 index 000000000..88f51eb15 --- /dev/null +++ b/include/boost/geometry/strategies/distance_comparable_to_regular.hpp @@ -0,0 +1,53 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_TO_REGULAR_HPP +#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_TO_REGULAR_HPP + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + + +template +< + typename ComparableStrategy, + typename Strategy, + typename Geometry1, + typename Geometry2, + typename CsTag1 = typename cs_tag::type, + typename CsTag2 = typename cs_tag::type +> +struct comparable_to_regular + : geometry::not_implemented +{}; + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_TO_REGULAR_HPP diff --git a/include/boost/geometry/strategies/intersection.hpp b/include/boost/geometry/strategies/intersection.hpp index d97baf66d..ef1b676fd 100644 --- a/include/boost/geometry/strategies/intersection.hpp +++ b/include/boost/geometry/strategies/intersection.hpp @@ -82,7 +82,8 @@ public: typedef RobustPolicy rescale_policy_type; }; - +// Version for box_box intersection or other detail calls not needing a strategy +struct strategy_intersection_empty {}; }} // namespace boost::geometry diff --git a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp index 4185a9479..3180fcf5f 100644 --- a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp @@ -250,16 +250,6 @@ public : }; -template -< - typename CalculationType, - typename Strategy -> -struct strategy_point_point > -{ - typedef Strategy type; -}; - /* diff --git a/include/boost/geometry/strategies/strategies.hpp b/include/boost/geometry/strategies/strategies.hpp index 491c1d858..972078d20 100644 --- a/include/boost/geometry/strategies/strategies.hpp +++ b/include/boost/geometry/strategies/strategies.hpp @@ -37,11 +37,14 @@ #include #include #include +#include +#include #include #include #include #include #include +#include #include #include diff --git a/include/boost/geometry/strategies/tags.hpp b/include/boost/geometry/strategies/tags.hpp index 39f2f2303..7589c2107 100644 --- a/include/boost/geometry/strategies/tags.hpp +++ b/include/boost/geometry/strategies/tags.hpp @@ -34,6 +34,8 @@ namespace strategy struct strategy_tag_distance_point_point {}; struct strategy_tag_distance_point_segment {}; +struct strategy_tag_distance_point_box {}; +struct strategy_tag_distance_box_box {}; }} // namespace boost::geometry diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index 52c497af2..63b7fe3c4 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -31,6 +31,12 @@ test-suite boost-geometry-algorithms [ run difference_pl_pl.cpp ] [ run disjoint.cpp ] [ run distance.cpp : : : msvc:/bigobj ] + [ run distance_areal_areal.cpp ] + [ run distance_linear_areal.cpp ] + [ run distance_linear_linear.cpp ] + [ run distance_pointlike_areal.cpp ] + [ run distance_pointlike_linear.cpp ] + [ run distance_pointlike_pointlike.cpp ] [ run envelope.cpp ] [ run equals.cpp ] [ run expand.cpp ] @@ -41,6 +47,7 @@ test-suite boost-geometry-algorithms [ run intersects.cpp : : : msvc:/bigobj ] [ run length.cpp ] [ run make.cpp ] + [ run num_points.cpp ] [ run overlaps.cpp ] [ run perimeter.cpp ] [ run point_on_surface.cpp ] diff --git a/test/algorithms/distance.cpp b/test/algorithms/distance.cpp index 597df4f07..5a2c31aa0 100644 --- a/test/algorithms/distance.cpp +++ b/test/algorithms/distance.cpp @@ -1,9 +1,9 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -13,6 +13,7 @@ // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include @@ -29,6 +30,13 @@ #include #include +// includes for multi-geometries +#include +#include +#include +#include + + BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) @@ -196,6 +204,105 @@ void test_distance_array_as_linestring() } +// code moved from the distance unit test in multi/algorithms -- start +template +void test_distance(std::string const& wkt1, std::string const& wkt2, double expected) +{ + Geometry1 g1; + Geometry2 g2; + bg::read_wkt(wkt1, g1); + bg::read_wkt(wkt2, g2); + typename bg::default_distance_result::type d = bg::distance(g1, g2); + + BOOST_CHECK_CLOSE(d, expected, 0.0001); +} + +template +void test_distance(Strategy const& strategy, std::string const& wkt1, + std::string const& wkt2, double expected) +{ + Geometry1 g1; + Geometry2 g2; + bg::read_wkt(wkt1, g1); + bg::read_wkt(wkt2, g2); + typename bg::default_distance_result::type d = bg::distance(g1, g2, strategy); + + BOOST_CHECK_CLOSE(d, expected, 0.0001); +} + + +template +void test_2d() +{ + typedef bg::model::multi_point

mp; + typedef bg::model::multi_linestring > ml; + test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); + test_distance("POINT(0 0)", "MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", 1.0); + test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "POINT(0 0)", 1.0); + test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "MULTIPOINT((0 0),(1 1))", 0.0); + + // Test with a strategy + bg::strategy::distance::pythagoras<> pyth; + test_distance(pyth, "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + test_distance(pyth, "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pyth, "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); +} + + +template +void test_3d() +{ + typedef bg::model::multi_point

mp; + test_distance("POINT(0 0 0)", "POINT(1 1 1)", sqrt(3.0)); + test_distance("POINT(0 0 0)", "MULTIPOINT((1 1 1),(1 0 0),(0 1 2))", 1.0); + test_distance("MULTIPOINT((1 1 1),(1 0 0),(0 0 2))", "MULTIPOINT((2 2 2),(2 3 4))", sqrt(3.0)); +} + + +template +void test_mixed() +{ + typedef bg::model::multi_point mp1; + typedef bg::model::multi_point mp2; + + test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + + // Test automatic reversal + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + + // Test multi-multi using different point types for each + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); + + // Test with a strategy + using namespace bg::strategy::distance; + + test_distance(pythagoras<>(), "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + + // Most interesting: reversal AND a strategy (note that the stategy must be reversed automatically + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); +} +// code moved from the distance unit test in multi/algorithms -- end + + template @@ -264,10 +371,22 @@ void test_empty_input() bg::model::linestring

line_empty; bg::model::polygon

poly_empty; bg::model::ring

ring_empty; + bg::model::multi_point

mp_empty; + bg::model::multi_linestring > ml_empty; test_empty_input(p, line_empty); test_empty_input(p, poly_empty); test_empty_input(p, ring_empty); + + test_empty_input(p, mp_empty); + test_empty_input(p, ml_empty); + test_empty_input(mp_empty, mp_empty); + + // Test behaviour if one of the inputs is empty + bg::model::multi_point

mp; + mp.push_back(p); + test_empty_input(mp_empty, mp); + test_empty_input(mp, mp_empty); } void test_large_integers() @@ -335,5 +454,23 @@ int test_main(int, char* []) test_empty_input >(); + // below are the test cases moved here from the distance unit test + // in test/multi/algorithms + test_2d >(); + test_2d >(); + test_2d >(); + + test_3d >(); + test_3d >(); + + test_mixed, bg::model::d2::point_xy >(); + +#ifdef HAVE_TTMATH + test_2d >(); + test_mixed, bg::model::d2::point_xy >(); +#endif + + test_empty_input >(); + return 0; } diff --git a/test/algorithms/distance_all.cpp b/test/algorithms/distance_all.cpp new file mode 100644 index 000000000..74a46fffb --- /dev/null +++ b/test/algorithms/distance_all.cpp @@ -0,0 +1,20 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_all +#endif + +#include "distance_pointlike_pointlike.cpp" +#include "distance_pointlike_linear.cpp" +#include "distance_pointlike_areal.cpp" +#include "distance_linear_linear.cpp" +#include "distance_linear_areal.cpp" +#include "distance_areal_areal.cpp" diff --git a/test/algorithms/distance_areal_areal.cpp b/test/algorithms/distance_areal_areal.cpp new file mode 100644 index 000000000..e46e8c54c --- /dev/null +++ b/test/algorithms/distance_areal_areal.cpp @@ -0,0 +1,281 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_areal_areal +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point int_point_type; +typedef bg::model::point point_type; +typedef bg::model::polygon polygon_type; +typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box int_box_type; +typedef bg::model::box box_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::projected_point<> point_segment_strategy; +typedef bg::strategy::distance::pythagoras_box_box<> box_box_strategy; + +//=========================================================================== + +template +void test_distance_polygon_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "polygon/polygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,5 20,5 25,-5 25,-5 20))", + 10, 100, strategy); + + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,-5 5,5 5,5 20,-5 20))", + 0, 0, strategy); + + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,-5 -20,5 -20,5 20,-5 20))", + 0, 0, strategy); + + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + "polygon((-1 -1,0 0,-1 0,-1 -1))", + 4, 16, strategy); +} + +//=========================================================================== + +template +void test_distance_polygon_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "polygon/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + polygon_type, multi_polygon_type + > tester; + + tester::apply("polygon((12 0,14 0,19 0,19.9 -1,12 0))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0.1, 0.01, strategy, true); + + tester::apply("polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multipolygon_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipolygon/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + multi_polygon_type, multi_polygon_type + > tester; + + tester::apply("multipolygon(((12 0,14 0,14 1,12 0)),\ + ((18 0,19 0,19.9 -1,18 0)))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0.1, 0.01, strategy); + + tester::apply("multipolygon(((18 0,19 0,19.9 -1,18 0)),\ + ((12 0,14 0,20.5 0.5,12 0)))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_box_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "box/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries int_tester; + typedef test_distance_of_geometries tester; + + int_tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); + + tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); + + tester::apply(make_box2d(3, 8, 13, 18), + make_box2d(0, 0, 5, 5), + 3, 9, strategy); + + tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 5, 5), + 0, 0, strategy); + + tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 6, 6), + 0, 0, strategy); + + tester::apply(make_box2d(3, 5, 13, 15), + make_box2d(0, 0, 5, 5), + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_polygon_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "polygon/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); + + tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 5, 5), + 0, 0, strategy); + + tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 6, 6), + 0, 0, strategy); + + tester::apply("polygon((10 10,15 5,10 0,5 5,10 10))", + make_box2d(5, 0, 7.5, 2.5), + 0, 0, strategy); + + tester::apply("polygon((10 10,15 5,10 0,5 5,10 10))", + make_box2d(5, 0, 6, 1), + sqrt(4.5), 4.5, strategy); +} + +//=========================================================================== + +template +void test_distance_multipolygon_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipolygon/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 1, 1), + sqrt(2.0), 2, strategy); + + tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 2, 2), + 0, 0, strategy); + + tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 2.5, 2), + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_areal_areal(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::polygon polygon_empty; + bg::model::multi_polygon > multipolygon_empty; + + bg::model::polygon polygon = + from_wkt >("polygon((0 0,1 0,0 1))"); + + // 1st geometry is empty + test_empty_input(polygon_empty, polygon, strategy); + test_empty_input(multipolygon_empty, polygon, strategy); + + // 2nd geometry is empty + test_empty_input(polygon, polygon_empty, strategy); + test_empty_input(polygon, multipolygon_empty, strategy); + + // both geometries are empty + test_empty_input(polygon_empty, polygon_empty, strategy); + test_empty_input(polygon_empty, multipolygon_empty, strategy); + test_empty_input(multipolygon_empty, polygon_empty, strategy); + test_empty_input(multipolygon_empty, multipolygon_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_polygon_polygon ) +{ + test_distance_polygon_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_polygon_multipolygon ) +{ + test_distance_polygon_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipolygon_multipolygon ) +{ + test_distance_multipolygon_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_box_box ) +{ + test_distance_box_box(box_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_polygon_box ) +{ + test_distance_polygon_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipolygon_box ) +{ + test_distance_multipolygon_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_areal_areal ) +{ + test_more_empty_input_areal_areal(point_segment_strategy()); +} diff --git a/test/algorithms/distance_linear_areal.cpp b/test/algorithms/distance_linear_areal.cpp new file mode 100644 index 000000000..e00f3f288 --- /dev/null +++ b/test/algorithms/distance_linear_areal.cpp @@ -0,0 +1,787 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_linear_areal +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::point int_point_type; +typedef bg::model::segment segment_type; +typedef bg::model::segment int_segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_linestring multi_linestring_type; +typedef bg::model::polygon polygon_type; +typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box box_type; +typedef bg::model::box int_box_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; +typedef bg::strategy::distance::projected_point<> point_segment_strategy; + +//=========================================================================== + +template +void test_distance_segment_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/polygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply(make_segment(-1, 20, 1, 20), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); + + tester::apply(make_segment(1, 20, 2, 40), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); + + tester::apply(make_segment(-1, 20, -1, 5), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); + + tester::apply(make_segment(-1, 20, -1, -20), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/polygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("linestring(-1 20,1 20,1 30)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy, true); + + tester::apply("linestring(-1 20,1 20,1 5)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); + + tester::apply("linestring(-1 20,1 20,1 -20)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multilinestring_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/polygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + multi_linestring_type, polygon_type + > tester; + + tester::apply("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy, true); + + tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 5))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); + + tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 -20))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_segment_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + segment_type, multi_polygon_type + > tester; + + tester::apply(make_segment(-1, 20, 1, 20), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30, 2 40,0 22)))", + 2, 4, strategy); + + tester::apply(make_segment(12, 0, 14, 0), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); + + tester::apply(make_segment(12, 0, 20.5, 0.5), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); + + tester::apply(make_segment(12, 0, 50, 0), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + linestring_type, multi_polygon_type + > tester; + + tester::apply("linestring(-1 20,1 20)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30, 2 40,0 22)))", + 2, 4, strategy, true); + + tester::apply("linestring(12 0,14 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy, true); + + tester::apply("linestring(12 0,20.5 0.5)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); + + tester::apply("linestring(12 0,50 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multilinestring_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + multi_linestring_type, multi_polygon_type + > tester; + + tester::apply("multilinestring((12 0,14 0),(19 0,19.9 -1))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10)))", + 0.1, 0.01, strategy, true); + + tester::apply("multilinestring((19 0,19.9 -1),(12 0,20.5 0.5))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_segment_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D segment/box distance tests" << std::endl; +#endif + typedef int_box_type B; + typedef segment_type S; + typedef int_segment_type IS; + + typedef test_distance_of_geometries tester; + typedef test_distance_of_geometries itester; + + // segments that intersect the box + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 0.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 1.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.5, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 1.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 0, 0, 2), + 0, 0, strategy); + + // segment that has closest point on box boundary + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(4, 0.5, 5, 0.75), + 3, 9, strategy); + + // segment that has closest point on box corner + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(4, 0, 0, 4), + sqrt(2), 2, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 0, -4), + sqrt(8), 8, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-8, 4, 4, -8), + sqrt(8), 8, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 0, 4), + 1.5 * sqrt(2), 4.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 1, 5), + 1.5 * sqrt(2), 4.5, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 3, 1), + 0.5 * sqrt(2), 0.5, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 2, 2), + 0, 0, strategy); + + // horizontal segments + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -1, -1, -1), + sqrt(2), 2, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -1, 0, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, -1, 0.5, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.75, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 1.25, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -1, 2, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, -1, 3, -1), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -1, 2, -1), + 1, 1, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0, -1, 0), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0, 0, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 0, 0.5, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0, 0.75, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0, 1.25, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0, 2, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 0, 3, 0), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0, 2, 0), + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.5, -1, 0.5), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 0, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 0.5, 0.5, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.75, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 1.25, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 2, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 0.5, 3, 0.5), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.5, 2, 0.5), + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 1, -1, 1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 1, 0, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 1, 0.5, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 0.75, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 1.25, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 2, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 1, 3, 1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 1, 2, 1), + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 3, -1, 3), + sqrt(5), 5, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 3, 0, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 3, 0.5, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 0.75, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 1.25, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 3, 2, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 3, 3, 3), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 3, 2, 3), + 2, 4, strategy); + + // vertical segments + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, -1, -1), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -1, -1, 0), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -0.5, -1, 0.5), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, -1, 0.75), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, -1, 1.25), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 1, -1, 2), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 2, -1, 3), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, -1, 2), + 1, 1, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 0, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -1, 0, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -0.5, 0, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 0.5, 0, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 0.5, 0, 1.25), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 1, 0, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 2, 0, 3), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 0, 2), + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 0.5, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.5, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -0.5, 0.5, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.5, 1.25), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 0.5, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 2, 0.5, 3), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 0.5, 2), + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -2, 1, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -1, 1, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -0.5, 1, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 1, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 1, 1.25), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 1, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 2, 1, 3), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -2, 1, 2), + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -2, 3, -1), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -1, 3, 0), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -0.5, 3, 0.5), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 0.5, 3, 0.75), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 0.5, 3, 1.25), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 1, 3, 2), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 2, 3, 3), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -2, 3, 2), + 2, 4, strategy); + + // positive slope + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1, -1), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0, -0.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0.5, -0.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 1, -0.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 2, 0), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 1), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 0), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 0.5), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 1), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0, 2), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 1, 4), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 2, 4), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 3), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 3, 4), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 3, 3), + 0, 0, strategy); + + // negative slope + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1, -3), + sqrt(8), 8, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-3, -1, 0, -4), + sqrt(8), 8, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.75, -1.5, 0.5), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 1.5, -1.5, 0.5), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 2, 0.75, 1.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 2, 0.75, 1.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 2, 2, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 3, 3, 0), + sqrt(0.5), 0.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 4, 4, -1), + sqrt(0.5), 0.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 4, 0, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 5, -1, 4), + sqrt(10), 10, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -1, 4, -4), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 2, 2, 1), + sqrt(0.5), 0.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 2, -3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0, -3), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0.5, -3.5), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0.5, -3.5), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 2.5, 2), + sqrt(2.45), 2.45, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1.5, 1.5, -1.5), + 0, 0, strategy); + + // test degenerate segment + tester::apply(make_box2d(0, 0, 2, 2), + make_segment(4, 1, 4, 1), + 2, 4, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + // linestrings that intersect the box + tester::apply("linestring(-1 0.5,0.5 0.75)", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + tester::apply("linestring(-1 0.5,1.5 0.75)", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + + // linestring that has closest point on box boundary + tester::apply("linestring(4 0.5,5 0.75)", + make_box2d(0, 0, 1, 1), + 3, 9, strategy); + + // linestring that has closest point on box corner + tester::apply("linestring(4 0,0 4)", + make_box2d(0, 0, 1, 1), + sqrt(2), 2, strategy); +} + +//=========================================================================== + +template +void test_distance_multilinestring_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + // multilinestring that intersects the box + tester::apply("multilinestring((-1 0.5,0.5 0.75),(4 0.5,5 0.75))", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + + // multilinestring that has closest point on box boundary + tester::apply("multilinestring((4 0.5,5 0.75))", + make_box2d(0, 0, 1, 1), + 3, 9, strategy); + + // multilinestring that has closest point on box corner + tester::apply("multilinestring((5 0,0 5),(4 0,0 4))", + make_box2d(0, 0, 1, 1), + sqrt(2), 2, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_linear_areal(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::linestring line_empty; + bg::model::polygon polygon_empty; + bg::model::multi_linestring > multiline_empty; + bg::model::multi_polygon > multipolygon_empty; + + bg::model::linestring line = + from_wkt >("linestring(0 0,1 1)"); + + bg::model::polygon polygon = + from_wkt >("polygon((0 0,1 0,0 1))"); + + // 1st geometry is empty + test_empty_input(line_empty, polygon, strategy); + test_empty_input(multiline_empty, polygon, strategy); + + // 2nd geometry is empty + test_empty_input(line, polygon_empty, strategy); + test_empty_input(line, multipolygon_empty, strategy); + + // both geometries are empty + test_empty_input(line_empty, polygon_empty, strategy); + test_empty_input(line_empty, multipolygon_empty, strategy); + test_empty_input(multiline_empty, polygon_empty, strategy); + test_empty_input(multiline_empty, multipolygon_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_segment_polygon ) +{ + test_distance_segment_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_polygon ) +{ + test_distance_linestring_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_polygon ) +{ + test_distance_multilinestring_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_multipolygon ) +{ + test_distance_segment_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_multipolygon ) +{ + test_distance_linestring_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_multipolygon ) +{ + test_distance_multilinestring_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_box ) +{ + test_distance_segment_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_box ) +{ + test_distance_linestring_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_box ) +{ + test_distance_multilinestring_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_linear_areal ) +{ + test_more_empty_input_linear_areal(point_segment_strategy()); +} diff --git a/test/algorithms/distance_linear_linear.cpp b/test/algorithms/distance_linear_linear.cpp new file mode 100644 index 000000000..5faeca69a --- /dev/null +++ b/test/algorithms/distance_linear_linear.cpp @@ -0,0 +1,280 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_linear_linear +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::segment segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_linestring multi_linestring_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::projected_point<> point_segment_strategy; + +//=========================================================================== + +template +void test_distance_segment_segment(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/segment distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply(make_segment(0, 0, 10, 0), + make_segment(4, 2, 4, 0.5), + return_type(0.5), return_type(0.25), strategy); + + tester::apply(make_segment(0, 0, 10, 0), + make_segment(4, 2, 4, -0.5), + return_type(0), return_type(0), strategy); + + tester::apply(make_segment(0, 0, 10, 0), + make_segment(4, 2, 0, 0), + return_type(0), return_type(0), strategy); + + tester::apply(make_segment(0, 0, 10, 0), + make_segment(-2, 3, 1, 2), + return_type(2), return_type(4), strategy); +} + +//=========================================================================== + +template +void test_distance_segment_linestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/linestring distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply(make_segment(-1, -1, -2, -2), + "linestring(2 1,1 2,4 0)", + sqrt(12.5), 12.5, strategy); + + tester::apply(make_segment(1, 1, 2, 2), + "linestring(2 1,1 2,4 0)", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_linestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/linestring distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + linestring_type, linestring_type + > tester; + + // It is not obvious that linestrings with only one point are valid + tester::apply("linestring(1 1)", "linestring(2 1)", + 1, 1, strategy); + + tester::apply("linestring(1 1,3 1)", "linestring(2 1)", + 0, 0, strategy); + + tester::apply("linestring(1 1)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); + + tester::apply("linestring(1 1,1 1)", "linestring(2 1,2 1)", + 1, 1, strategy); + + tester::apply("linestring(1 1,1 1,1 1)", "linestring(2 1,2 1,2 1,2 1)", + 1, 1, strategy); + + tester::apply("linestring(1 1,3 1)", "linestring(2 1,2 1)", + 0, 0, strategy); + + tester::apply("linestring(1 1,1 1)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); + + tester::apply("linestring(1 1,3 1)", "linestring(2 1, 4 1)", + 0, 0, strategy); + + tester::apply("linestring(1 1,2 2,3 3)", "linestring(2 1,1 2,4 0)", + 0, 0, strategy); + + tester::apply("linestring(1 1,2 2,3 3)", "linestring(1 0,2 -1,4 0)", + 1, 1, strategy); + + tester::apply("linestring(1 1,2 2,3 3)", + "linestring(1 -10,2 0,2.1 -10,4 0)", + sqrt(2.0), 2, strategy); + + tester::apply("linestring(1 1,2 2,3 3)", + "linestring(1 -10,2 1.9,2.1 -10,4 0)", + sqrt(0.005), 0.005, strategy); + + tester::apply("linestring(1 1,1 2)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); +} + +//=========================================================================== + +template +void test_distance_segment_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/multilinestring distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + segment_type, multi_linestring_type + > tester; + + tester::apply(make_segment(-1, -1, -2, -2), + "multilinestring((2 1,1 2),(4 0,4 10))", + sqrt(12.5), 12.5, strategy); + + tester::apply(make_segment(1, 1, 2, 2), + "multilinestring((2 1,1 2),(4 0,4 10))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/multilinestring distance tests" << std::endl; +#endif + + typedef test_distance_of_geometries + < + linestring_type, multi_linestring_type + > tester; + + tester::apply("linestring(1 1,2 2,3 3)", + "multilinestring((2 1,1 2,4 0),(1 -10,2 1.9,2.1 -10,4 0))", + 0, 0, strategy, true); + + tester::apply("linestring(1 1,2 2,3 3)", + "multilinestring((1 -10,2 0,2.1 -10,4 0),(1 -10,2 1.9,2.1 -10,4 0))", + sqrt(0.005), 0.005, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multilinestring_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/multilinestring distance tests" << std::endl; +#endif + + typedef test_distance_of_geometries + < + multi_linestring_type, multi_linestring_type + > tester; + + tester::apply("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 7))", + 0, 0, strategy); + + tester::apply("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 0.9))", + sqrt(0.005), 0.005, strategy); + + tester::apply("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11.1 0,11.1 0.9))", + sqrt(0.02), 0.02, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_linear_linear(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::linestring line_empty; + bg::model::multi_linestring > multiline_empty; + + bg::model::linestring line = + from_wkt >("linestring(0 0,1 1)"); + + // 1st geometry is empty + test_empty_input(line_empty, line, strategy); + test_empty_input(multiline_empty, line, strategy); + + // 2nd geometry is empty + test_empty_input(line, line_empty, strategy); + test_empty_input(line, multiline_empty, strategy); + + // both geometries are empty + test_empty_input(line_empty, line_empty, strategy); + test_empty_input(line_empty, multiline_empty, strategy); + test_empty_input(multiline_empty, multiline_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_segment_segment ) +{ + test_distance_segment_segment(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_linestring ) +{ + test_distance_segment_linestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_linestring ) +{ + test_distance_linestring_linestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_multilinestring ) +{ + test_distance_segment_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_multilinestring ) +{ + test_distance_linestring_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_multilinestring ) +{ + test_distance_multilinestring_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_linear_linear ) +{ + test_more_empty_input_linear_linear(point_segment_strategy()); +} diff --git a/test/algorithms/distance_pointlike_areal.cpp b/test/algorithms/distance_pointlike_areal.cpp new file mode 100644 index 000000000..f8d68f30a --- /dev/null +++ b/test/algorithms/distance_pointlike_areal.cpp @@ -0,0 +1,575 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_pointlike_areal +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::multi_point multi_point_type; +typedef bg::model::point point_type_3d; +typedef bg::model::multi_point multi_point_type_3d; +typedef bg::model::polygon polygon_type; +typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box box_type; +typedef bg::model::box box_type_3d; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; +typedef bg::strategy::distance::projected_point<> point_segment_strategy; +typedef bg::strategy::distance::pythagoras_point_box<> point_box_strategy; + +//=========================================================================== + +template +void test_distance_point_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/polygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("point(0 -20)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); + + tester::apply("point(12 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 2, 4, strategy); + + tester::apply("point(0 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); + + tester::apply("point(0 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + 5, 25, strategy); +} + +//=========================================================================== + +template +void test_distance_point_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("point(0 -20)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30,2 40,0 22)))", + 10, 100, strategy); + + tester::apply("point(12 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); + + tester::apply("point(0 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); + + tester::apply("point(0 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ + ((100 0,101 0,101 1,100 1,100 0)))", + 5, 25, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/polygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("multipoint(0 -20,0 -15)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 5, 25, strategy); + + tester::apply("multipoint(16 0,12 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 2, 4, strategy); + + tester::apply("multipoint(0 0,5 5,4 4)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); + + tester::apply("multipoint(0 0,2 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + 3, 9, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/multipolygon distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + multi_point_type, multi_polygon_type + > tester; + + tester::apply("multipoint(0 -20,0 -15)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30,2 40,0 22)))", + 5, 25, strategy); + + tester::apply("multipoint(16 0,12 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); + + tester::apply("multipoint(0 0,4 4,5 5)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); + + tester::apply("multipoint(0 0,2 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ + ((100 0,101 0,101 1,100 1,100 0)))", + 3, 9, strategy); +} + +//=========================================================================== + +template +void test_distance_point_box_2d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D point/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + // point inside box + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 0)", 0, 0, strategy); + + // points on box corners + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-1 -1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-1 1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(1 -1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(1 1)", 0, 0, strategy); + + // points on box boundary edges + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 -1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-1 0)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(1 0)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 1)", 0, 0, strategy); + + // points outside box + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 4)", 3, 9, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0.5 4)", 3, 9, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-0.5 5)", 4, 16, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(3 0.25)", 2, 4, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-3 -0.25)", 2, 4, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(3 5)", sqrt(20), 20, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-5 -4)", 5, 25, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(2 -2)", sqrt(2), 2, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-3 4)", sqrt(13), 13, strategy); +} + +//=========================================================================== + +template +void test_distance_point_box_different_point_types(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D point/box distance tests with different points" + << std::endl; +#endif + typedef point_type double_point; + typedef box_type double_box; + typedef bg::model::point int_point; + typedef bg::model::box int_box; + + test_distance_of_geometries + < + int_point, int_box + >::apply("point(0 0)", + make_box2d(1, 1, 2, 2), + sqrt(2), 2, strategy); + + test_distance_of_geometries + < + double_point, int_box + >::apply("point(0.5 0)", + make_box2d(1, -1, 2, 1), + 0.5, 0.25, strategy); + + test_distance_of_geometries + < + double_point, double_box + >::apply("point(1.5 0)", + make_box2d(1, -1, 2, 1), + 0, 0, strategy); + + test_distance_of_geometries + < + double_point, int_box + >::apply("point(1.5 0)", + make_box2d(1, -1, 2, 1), + 0, 0, strategy); + + test_distance_of_geometries + < + int_point, double_box + >::apply("point(1 0)", + make_box2d(0.5, -1, 1.5, 1), + 0, 0, strategy); + + test_distance_of_geometries + < + int_point, double_box + >::apply("point(0 0)", + make_box2d(0.5, -1, 1.5, 1), + 0.5, 0.25, strategy); +} + +//=========================================================================== + +template +void test_distance_point_box_3d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "3D point/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + // point inside box + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 0)", 0, 0, strategy); + + // points on box corners + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 1)", 0, 0, strategy); + + // points on box boundary edges + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 1)", 0, 0, strategy); + + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 1)", 0, 0, strategy); + + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 0)", 0, 0, strategy); + + // point on box faces + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 0)", 0, 0, strategy); + + // points outside box -- closer to box corners + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 -3 -4)", sqrt(14), 14, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 -3 3)", 3, 9, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 5 -2)", sqrt(18), 18, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 5 3)", sqrt(21), 21, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 -6 -3)", sqrt(38), 38, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 -6 4)", sqrt(43), 43, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 7 -2)", sqrt(46), 46, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 7 8)", sqrt(94), 94, strategy); + + + // points closer to box facets + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 10)", 9, 81, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 -5)", 4, 16, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 7 0)", 6, 36, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -6 0)", 5, 25, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 0 0)", 3, 9, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-3 0 0)", 2, 4, strategy); + + // points closer to box edges + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -4 -5)", 5, 25, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -3 6)", sqrt(29), 29, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 2 -7)", sqrt(37), 37, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 8 7)", sqrt(85), 85, strategy); + + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-4 0 -4)", sqrt(18), 18, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-3 0 5)", sqrt(20), 20, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(2 0 -6)", sqrt(26), 26, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(8 0 6)", sqrt(74), 74, strategy); + + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-5 -5 0)", sqrt(32), 32, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-4 6 0)", sqrt(34), 34, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(3 -7 0)", sqrt(40), 40, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(9 7 0)", 10, 100, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_box_2d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D multipoint/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + // at least one point inside the box + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(0 0,-1 -1,20 20)", + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(1 1,-1 -1,20 20)", + 0, 0, strategy); + + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(1 1,2 2,3 3)", + 0, 0, strategy); + + // all points outside the box + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(-1 -1,20 20)", + sqrt(2), 2, strategy); + + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(5 13, 50 50)", + 3, 9, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_box_3d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "3D multipoint/box distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + box_type_3d, multi_point_type_3d + > tester; + + // at least one point inside the box + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(0 0 0,-1 -1 -1,20 20 20)", + 0, 0, strategy); + + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(1 1 1,-1 -1 -1,20 20 20)", + 0, 0, strategy); + + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(1 1 1,2 2 2,3 3 3)", + 0, 0, strategy); + + // all points outside the box + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(-1 -1 -1,20 20 20)", + sqrt(3), 3, strategy); + + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(5 5 13,50 50 50)", + 3, 9, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_pointlike_areal(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::multi_point multipoint_empty; + bg::model::polygon polygon_empty; + bg::model::multi_polygon > multipolygon_empty; + + Point point = from_wkt("point(0 0)"); + bg::model::polygon polygon = + from_wkt >("polygon((0 0,1 0,0 1))"); + + // 1st geometry is empty + test_empty_input(multipoint_empty, polygon, strategy); + + // 2nd geometry is empty + test_empty_input(point, polygon_empty, strategy); + test_empty_input(point, multipolygon_empty, strategy); + + // both geometries are empty + test_empty_input(multipoint_empty, polygon_empty, strategy); + test_empty_input(multipoint_empty, multipolygon_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_point_polygon ) +{ + test_distance_point_polygon(point_point_strategy()); // back-compatibility + test_distance_point_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_multipolygon ) +{ + test_distance_point_multipolygon(point_point_strategy()); // back-compatibility + test_distance_point_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_polygon ) +{ + test_distance_multipoint_polygon(point_point_strategy()); // back-compatibility + test_distance_multipoint_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_multipolygon ) +{ + test_distance_multipoint_multipolygon(point_point_strategy()); // back-compatibility + test_distance_multipoint_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_box_2d ) +{ + point_box_strategy pb_strategy; + + test_distance_point_box_2d(pb_strategy); + test_distance_point_box_different_point_types(pb_strategy); +} + +BOOST_AUTO_TEST_CASE( test_all_point_box_3d ) +{ + test_distance_point_box_3d(point_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_box_2d ) +{ + test_distance_multipoint_box_2d(point_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_box_3d ) +{ + test_distance_multipoint_box_3d(point_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_areal ) +{ + test_more_empty_input_pointlike_areal + < + point_type + >(point_segment_strategy()); +} diff --git a/test/algorithms/distance_pointlike_linear.cpp b/test/algorithms/distance_pointlike_linear.cpp new file mode 100644 index 000000000..9a56f0460 --- /dev/null +++ b/test/algorithms/distance_pointlike_linear.cpp @@ -0,0 +1,264 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_pointlike_linear +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::multi_point multi_point_type; +typedef bg::model::segment segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_linestring multi_linestring_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; +typedef bg::strategy::distance::projected_point<> point_segment_strategy; + + +//=========================================================================== + + +template +void test_distance_point_segment(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/segment distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("point(0 0)", "segment(2 0,3 0)", 2, 4, strategy); + tester::apply("point(2.5 3)", "segment(2 0,3 0)", 3, 9, strategy); + tester::apply("point(2 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester::apply("point(3 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester::apply("point(2.5 0)", "segment(2 0,3 0)", 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_point_linestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/linestring distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("point(0 0)", "linestring(2 0)", 2, 4, strategy); + tester::apply("point(0 0)", "linestring(2 0,3 0)", 2, 4, strategy); + tester::apply("point(2.5 3)", "linestring(2 0,3 0)", 3, 9, strategy); + tester::apply("point(2 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester::apply("point(3 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester::apply("point(2.5 0)", "linestring(2 0,3 0)", 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_point_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/multilinestring distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + point_type, multi_linestring_type + > tester; + + tester::apply("point(0 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 2, 4, strategy); + tester::apply("point(2.5 3)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 3, 9, strategy); + tester::apply("point(2 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); + tester::apply("point(3 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); + tester::apply("point(2.5 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_multipoint(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/multipoint distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + linestring_type, multi_point_type + > tester; + + tester::apply("linestring(2 0,0 2,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + 0, 0, strategy); + tester::apply("linestring(4 0,0 4,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + sqrt(2.0), 2, strategy); + tester::apply("linestring(1 1,2 2,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + 0, 0, strategy); + tester::apply("linestring(3 3,4 4,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + sqrt(8.0), 8, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/multilinestring distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + multi_point_type, multi_linestring_type + > tester; + + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((2 0,0 2),(2 2,3 3))", + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((3 0,0 3),(4 4,5 5))", + 0.5 * sqrt(2.0), 0.5, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((4 4,5 5),(1 1,2 2))", + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((3 3,4 4),(4 4,5 5))", + sqrt(8.0), 8, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_segment(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/segment distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(2, 0, 0, 2), + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(4, 0, 0, 4), + sqrt(2.0), 2, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(1, 1, 2, 2), + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(3, 3, 4, 4), + sqrt(8.0), 8, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_pointlike_linear(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::linestring line_empty; + bg::model::multi_point multipoint_empty; + bg::model::multi_linestring > multiline_empty; + + Point point = from_wkt("point(0 0)"); + bg::model::linestring line = + from_wkt >("linestring(0 0,1 1)"); + + // 1st geometry is empty + test_empty_input(multipoint_empty, line, strategy); + + // 2nd geometry is empty + test_empty_input(point, line_empty, strategy); + test_empty_input(point, multiline_empty, strategy); + + // both geometries are empty + test_empty_input(multipoint_empty, line_empty, strategy); + test_empty_input(multipoint_empty, multiline_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + + +//=========================================================================== +//=========================================================================== +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_point_segment ) +{ + test_distance_point_segment(point_point_strategy()); // back-compatibility + test_distance_point_segment(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_linestring ) +{ + test_distance_point_linestring(point_point_strategy()); // back-compatibility + test_distance_point_linestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_multilinestring ) +{ + test_distance_point_multilinestring(point_point_strategy()); // back-compatibility + test_distance_point_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_multipoint ) +{ + test_distance_linestring_multipoint(point_point_strategy()); // back-compatibility + test_distance_linestring_multipoint(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_multilinestring ) +{ + test_distance_multipoint_multilinestring(point_point_strategy()); // back-compatibility + test_distance_multipoint_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_segment ) +{ + test_distance_multipoint_segment(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_linear ) +{ + test_more_empty_input_pointlike_linear + < + point_type + >(point_segment_strategy()); +} diff --git a/test/algorithms/distance_pointlike_pointlike.cpp b/test/algorithms/distance_pointlike_pointlike.cpp new file mode 100644 index 000000000..83116ed73 --- /dev/null +++ b/test/algorithms/distance_pointlike_pointlike.cpp @@ -0,0 +1,143 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_pointlike_pointlike +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::multi_point multi_point_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; + +//=========================================================================== + +template +void test_distance_point_point(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/point distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("point(1 1)", + "point(0 0)", + sqrt(2.0), 2, strategy); + tester::apply("point(1 1)", + "point(1 1)", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_point_multipoint(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/multipoint distance tests" << std::endl; +#endif + typedef test_distance_of_geometries tester; + + tester::apply("point(1 1)", + "multipoint(1 1,2 1,2 2,1 2)", + 0, 0, strategy); + tester::apply("point(1 1)", + "multipoint(2 2,2 3,3 2,3 3)", + sqrt(2.0), 2, strategy); + tester::apply("point(3 0)", + "multipoint(2 2,2 4,4 2,4 4)", + sqrt(5.0), 5, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_multipoint(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/multipoint distance tests" << std::endl; +#endif + typedef test_distance_of_geometries + < + multi_point_type, multi_point_type + > tester; + + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multipoint(1 1,2 1,2 2,1 2)", + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multipoint(2 2,2 3,3 2,3 3)", + sqrt(2.0), 2, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_pointlike_pointlike(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::multi_point multipoint_empty; + + Point point = from_wkt("point(0 0)"); + + // 1st geometry is empty + test_empty_input(multipoint_empty, point, strategy); + + // 2nd geometry is empty + test_empty_input(point, multipoint_empty, strategy); + + // both geometries are empty + test_empty_input(multipoint_empty, multipoint_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_point_point ) +{ + test_distance_point_point(point_point_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_multipoint ) +{ + test_distance_point_multipoint(point_point_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_multipoint ) +{ + test_distance_multipoint_multipoint(point_point_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_pointlike ) +{ + test_more_empty_input_pointlike_pointlike + < + point_type + >(point_point_strategy()); +} diff --git a/test/algorithms/from_wkt.hpp b/test/algorithms/from_wkt.hpp index 13d646356..5c78afdea 100644 --- a/test/algorithms/from_wkt.hpp +++ b/test/algorithms/from_wkt.hpp @@ -1,14 +1,27 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Tests + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + #ifndef BOOST_GEOMETRY_TEST_FROM_WKT_HPP #define BOOST_GEOMETRY_TEST_FROM_WKT_HPP #include +#include template -Geometry from_wkt(std::string const& wkt) +inline Geometry from_wkt(std::string const& wkt) { - Geometry res; - boost::geometry::read_wkt(wkt, res); - return res; + Geometry result; + boost::geometry::read_wkt(wkt, result); + return result; } #endif // BOOST_GEOMETRY_TEST_FROM_WKT_HPP diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp new file mode 100644 index 000000000..3abeed449 --- /dev/null +++ b/test/algorithms/num_points.cpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_num_points +#endif + +#include +#include + +#include +#include +#include +#include + +#include +#include + +template +inline void test_num_points(std::string const& wkt, std::size_t expected) +{ + namespace bg = boost::geometry; + Geometry geometry; + boost::geometry::read_wkt(wkt, geometry); + std::size_t detected = bg::num_points(geometry); + BOOST_CHECK_EQUAL(expected, detected); + detected = bg::num_points(geometry, false); + BOOST_CHECK_EQUAL(expected, detected); + detected = bg::num_points(geometry, true); +} + +BOOST_AUTO_TEST_CASE( test_num_points_closed ) +{ + namespace bg = boost::geometry; + typedef bg::model::point point; + typedef bg::model::linestring linestring; + typedef bg::model::segment segment; + typedef bg::model::box box; + typedef bg::model::ring ring; + typedef bg::model::polygon polygon; + typedef bg::model::multi_point multi_point; + typedef bg::model::multi_linestring multi_linestring; + typedef bg::model::multi_polygon multi_polygon; + + test_num_points("POINT(0 0)", 1u); + test_num_points("LINESTRING(0 0,1 1)", 2u); + test_num_points("LINESTRING(0 0,1 1)", 2u); + test_num_points("POLYGON((0 0,10 10))", 4u); + test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 4u); + test_num_points("POLYGON((0 0,10 10,0 10,0 0))", 4u); + test_num_points("POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", 10u); + test_num_points("MULTIPOINT((0 0),(1 1))", 2u); + test_num_points("MULTILINESTRING((0 0,1 1),(2 2,3 3,4 4))", 5u); + test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 9u); +} + diff --git a/test/algorithms/test_distance_common.hpp b/test/algorithms/test_distance_common.hpp new file mode 100644 index 000000000..826811cda --- /dev/null +++ b/test/algorithms/test_distance_common.hpp @@ -0,0 +1,538 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_TEST_DISTANCE_COMMON_HPP +#define BOOST_GEOMETRY_TEST_DISTANCE_COMMON_HPP + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include "from_wkt.hpp" + +#include + + +#ifndef BOOST_GEOMETRY_TEST_DISTANCE_HPP + +namespace bg = ::boost::geometry; + +// function copied from BG's test_distance.hpp + +template +void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2) +{ + try + { + bg::distance(geometry1, geometry2); + } + catch(bg::empty_input_exception const& ) + { + return; + } + BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); +} +#endif // BOOST_GEOMETRY_TEST_DISTANCE_HPP + + + +//======================================================================== +//======================================================================== +//======================================================================== + + +// create geometries -- START +template +Segment make_segment(double x1, double y1, double x2, double y2) +{ + typename bg::point_type::type p(x1, y1), q(x2, y2); + return Segment(p, q); +} + + +template +Box make_box2d(double xmin, double ymin, double xmax, double ymax) +{ + typedef typename bg::point_type::type BoxPoint; + + return Box(BoxPoint(xmin, ymin), BoxPoint(xmax, ymax)); +} + +template +Box make_box3d(double xmin, double ymin, double zmin, + double xmax, double ymax, double zmax) +{ + typedef typename bg::point_type::type BoxPoint; + + return Box(BoxPoint(xmin, ymin, zmin), BoxPoint(xmax, ymax, zmax)); +} +// create geometries -- END + + +//======================================================================== +//======================================================================== +//======================================================================== + + +#ifdef GEOMETRY_TEST_DEBUG +// pretty print geometry -- START +template +struct pretty_print_geometry_dispatch +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + os << bg::wkt(geometry); + return os; + } +}; + +template +struct pretty_print_geometry_dispatch +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + os << "SEGMENT" << bg::dsv(geometry); + return os; + } +}; + +template +struct pretty_print_geometry_dispatch +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + os << "BOX" << bg::dsv(geometry); + return os; + } +}; + + +template +struct pretty_print_geometry +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + return pretty_print_geometry_dispatch + < + Geometry, typename bg::tag::type + >::apply(geometry, os); + } +}; +// pretty print geometry -- END +#endif // GEOMETRY_TEST_DEBUG + + + + +//======================================================================== + + +template +struct check_equal +{ + static inline void apply(T const& value1, T const& value2) + { + BOOST_CHECK( value1 == value2 ); + } +}; + +template <> +struct check_equal +{ + static inline void apply(double value1, double value2) + { + BOOST_CHECK_CLOSE( value1, value2, 0.0001 ); + } +}; + + +//======================================================================== + +template +< + typename Geometry1, typename Geometry2, + int id1 = bg::geometry_id::value, + int id2 = bg::geometry_id::value +> +struct test_distance_of_geometries + : public test_distance_of_geometries +{}; + + +template +struct test_distance_of_geometries +{ + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(std::string const& wkt1, + std::string const& wkt2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) + { + Geometry1 geometry1 = from_wkt(wkt1); + Geometry2 geometry2 = from_wkt(wkt2); + + apply(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(Geometry1 const& geometry1, + std::string const& wkt2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) + { + Geometry2 geometry2 = from_wkt(wkt2); + + apply(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(std::string const& wkt1, + Geometry2 const& geometry2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) + { + Geometry1 geometry1 = from_wkt(wkt1); + + apply(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) + { +#ifdef GEOMETRY_TEST_DEBUG + typedef pretty_print_geometry PPG1; + typedef pretty_print_geometry PPG2; + PPG1::apply(geometry1, std::cout); + std::cout << " - "; + PPG2::apply(geometry2, std::cout); + std::cout << std::endl; +#endif + typedef typename bg::default_distance_result + < + Geometry1, Geometry2 + >::type default_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + Strategy, Geometry1, Geometry2 + >::type distance_result_from_strategy; + + static const bool same_regular = boost::is_same + < + default_distance_result, + distance_result_from_strategy + >::type::value; + + BOOST_CHECK( same_regular ); + + + typedef typename bg::default_comparable_distance_result + < + Geometry1, Geometry2 + >::type default_comparable_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + typename bg::strategy::distance::services::comparable_type + < + Strategy + >::type, + Geometry1, + Geometry2 + >::type comparable_distance_result_from_strategy; + + static const bool same_comparable = boost::is_same + < + default_comparable_distance_result, + comparable_distance_result_from_strategy + >::type::value; + + BOOST_CHECK( same_comparable ); + + + // check distance with default strategy + default_distance_result dist_def = bg::distance(geometry1, geometry2); + + check_equal + < + default_distance_result + >::apply(dist_def, expected_distance); + + + // check distance with passed strategy + distance_result_from_strategy dist = + bg::distance(geometry1, geometry2, strategy); + + check_equal + < + default_distance_result + >::apply(dist, expected_distance); + + + // check comparable distance with default strategy + default_comparable_distance_result cdist_def = + bg::comparable_distance(geometry1, geometry2); + + check_equal + < + default_comparable_distance_result + >::apply(cdist_def, expected_comparable_distance); + + + // check comparable distance with passed strategy + comparable_distance_result_from_strategy cdist = + bg::comparable_distance(geometry1, geometry2, strategy); + + check_equal + < + default_comparable_distance_result + >::apply(cdist, expected_comparable_distance); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << string_from_type::type>::name() + << string_from_type::type>::name() + << " -> " + << string_from_type::name() + << string_from_type::name() + << std::endl; + std::cout << "distance (default strategy) = " << dist_def << " ; " + << "distance (passed strategy) = " << dist << " ; " + << "comp. distance (default strategy) = " + << cdist_def << " ; " + << "comp. distance (passed strategy) = " + << cdist << std::endl; + + if ( !test_reversed ) + { + std::cout << std::endl; + } +#endif + + if ( test_reversed ) + { + // check distance with default strategy + dist_def = bg::distance(geometry2, geometry1); + + check_equal + < + default_distance_result + >::apply(dist_def, expected_distance); + + + // check distance with given strategy + dist = bg::distance(geometry2, geometry1, strategy); + + check_equal + < + default_distance_result + >::apply(dist, expected_distance); + + + // check comparable distance with default strategy + cdist_def = bg::comparable_distance(geometry2, geometry1); + + check_equal + < + default_comparable_distance_result + >::apply(cdist_def, expected_comparable_distance); + + // check comparable distance with given strategy + cdist = bg::comparable_distance(geometry2, geometry1, strategy); + + check_equal + < + default_comparable_distance_result + >::apply(cdist, expected_comparable_distance); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "distance[reversed args] (def. startegy) = " + << dist_def << " ; " + << "distance[reversed args] (passed startegy) = " + << dist << " ; " + << "comp. distance[reversed args] (def. strategy) = " + << cdist_def << " ; " + << "comp. distance[reversed args] (passed strategy) = " + << cdist << std::endl; + std::cout << std::endl; +#endif + } + } +}; + + +//======================================================================== +//======================================================================== + +template +struct test_distance_of_geometries +< + Geometry1, Geometry2, + 92 /* segment */, 3 /* polygon */ +> + : public test_distance_of_geometries +{ + typedef test_distance_of_geometries base; + + typedef typename bg::ring_type::type ring_type; + + template + < + typename Segment, + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(Segment const& segment, + std::string const& wkt, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy) + { + Geometry2 geometry = from_wkt(wkt); + apply(segment, + geometry, + expected_distance, + expected_comparable_distance, + strategy); + } + + + template + < + typename Segment, + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(Segment const& segment, + Geometry2 const& geometry, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy) + { + base::apply(segment, geometry, expected_distance, + expected_comparable_distance, strategy); + if ( bg::num_interior_rings(geometry) == 0 ) { +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "... testing also exterior ring ..." << std::endl; +#endif + test_distance_of_geometries + < + Segment, ring_type + >::apply(segment, + bg::exterior_ring(geometry), + expected_distance, + expected_comparable_distance, + strategy); + } + } +}; + + +//======================================================================== + + +template +void test_empty_input(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) +{ + try + { + bg::distance(geometry1, geometry2, strategy); + } + catch(bg::empty_input_exception const& ) + { + return; + } + BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); + + try + { + bg::distance(geometry2, geometry1, strategy); + } + catch(bg::empty_input_exception const& ) + { + return; + } + BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); +} + +#endif // BOOST_GEOMETRY_TEST_DISTANCE_COMMON_HPP diff --git a/test/algorithms/test_set_ops_linear_linear.hpp b/test/algorithms/test_set_ops_linear_linear.hpp index 51d9d5794..c3ff6757d 100644 --- a/test/algorithms/test_set_ops_linear_linear.hpp +++ b/test/algorithms/test_set_ops_linear_linear.hpp @@ -92,7 +92,7 @@ struct multilinestring_equals template struct unique { - void operator()(MultiLinestring& mls) + void operator()(MultiLinestring&) { } }; diff --git a/test/geometry_test_common.hpp b/test/geometry_test_common.hpp index fdaec1e57..37b8d053d 100644 --- a/test/geometry_test_common.hpp +++ b/test/geometry_test_common.hpp @@ -34,6 +34,7 @@ #include +#include // Include some always-included-for-testing files #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST) @@ -83,52 +84,6 @@ namespace bg = boost::geometry; -template -struct string_from_type {}; - -template <> struct string_from_type -{ static std::string name() { return "v"; } }; - -template <> struct string_from_type -{ static std::string name() { return "f"; } }; - -template <> struct string_from_type -{ static std::string name() { return "d"; } }; - -template <> struct string_from_type -{ static std::string name() { return "e"; } }; - -template <> struct string_from_type -{ static std::string name() { return "s"; } }; - -template <> struct string_from_type -{ static std::string name() { return "i"; } }; - -template <> struct string_from_type -{ static std::string name() { return "l"; } }; - -#if defined(HAVE_TTMATH) - template <> struct string_from_type - { static std::string name() { return "t"; } }; -#endif - -#if defined(BOOST_RATIONAL_HPP) -template struct string_from_type > -{ static std::string name() { return "r"; } }; -#endif - - -#if defined(HAVE_GMP) - template <> struct string_from_type - { static std::string name() { return "g"; } }; -#endif - -#if defined(HAVE_CLN) - template <> struct string_from_type - { static std::string name() { return "c"; } }; -#endif - - template inline T1 if_typed_tt(T1 value_tt, T2 value) { diff --git a/test/multi/algorithms/Jamfile.v2 b/test/multi/algorithms/Jamfile.v2 index 5708300cb..ef1d6b2c8 100644 --- a/test/multi/algorithms/Jamfile.v2 +++ b/test/multi/algorithms/Jamfile.v2 @@ -1,8 +1,8 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -# Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -# Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. # # Use, modification and distribution is subject to the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -19,7 +19,6 @@ test-suite boost-geometry-multi-algorithms [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run multi_disjoint.cpp ] - [ run multi_distance.cpp ] [ run multi_envelope.cpp ] [ run multi_equals.cpp ] [ run multi_for_each.cpp ] diff --git a/test/multi/algorithms/multi_distance.cpp b/test/multi/algorithms/multi_distance.cpp deleted file mode 100644 index 0c932474a..000000000 --- a/test/multi/algorithms/multi_distance.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Use, modification and distribution is subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - - -#include - -#include - -#include -#include - -#include - - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) -BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) - - -template -void test_distance(std::string const& wkt1, std::string const& wkt2, double expected) -{ - Geometry1 g1; - Geometry2 g2; - bg::read_wkt(wkt1, g1); - bg::read_wkt(wkt2, g2); - typename bg::default_distance_result::type d = bg::distance(g1, g2); - - BOOST_CHECK_CLOSE(d, expected, 0.0001); -} - -template -void test_distance(Strategy const& strategy, std::string const& wkt1, - std::string const& wkt2, double expected) -{ - Geometry1 g1; - Geometry2 g2; - bg::read_wkt(wkt1, g1); - bg::read_wkt(wkt2, g2); - typename bg::default_distance_result::type d = bg::distance(g1, g2, strategy); - - BOOST_CHECK_CLOSE(d, expected, 0.0001); -} - - -template -void test_2d() -{ - typedef bg::model::multi_point

mp; - typedef bg::model::multi_linestring > ml; - test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); - test_distance("POINT(0 0)", "MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", 1.0); - test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "POINT(0 0)", 1.0); - test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "MULTIPOINT((0 0),(1 1))", 0.0); - - // Test with a strategy - bg::strategy::distance::pythagoras<> pyth; - test_distance(pyth, "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - test_distance(pyth, "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pyth, "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); -} - - -template -void test_3d() -{ - typedef bg::model::multi_point

mp; - test_distance("POINT(0 0 0)", "POINT(1 1 1)", sqrt(3.0)); - test_distance("POINT(0 0 0)", "MULTIPOINT((1 1 1),(1 0 0),(0 1 2))", 1.0); - test_distance("MULTIPOINT((1 1 1),(1 0 0),(0 0 2))", "MULTIPOINT((2 2 2),(2 3 4))", sqrt(3.0)); -} - - -template -void test_mixed() -{ - typedef bg::model::multi_point mp1; - typedef bg::model::multi_point mp2; - - test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - - // Test automatic reversal - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - - // Test multi-multi using different point types for each - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); - - // Test with a strategy - using namespace bg::strategy::distance; - - test_distance(pythagoras<>(), "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - - // Most interesting: reversal AND a strategy (note that the stategy must be reversed automatically - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); -} - -template -void test_empty_input() -{ - P p; - bg::model::multi_point

mp_empty; - bg::model::multi_linestring > ml_empty; - - test_empty_input(p, mp_empty); - test_empty_input(p, ml_empty); - test_empty_input(mp_empty, mp_empty); - - // Test behaviour if one of the inputs is empty - bg::model::multi_point

mp; - mp.push_back(p); - test_empty_input(mp_empty, mp); - test_empty_input(mp, mp_empty); -} - - -int test_main( int , char* [] ) -{ - test_2d >(); - test_2d >(); - test_2d >(); - - test_3d >(); - test_3d >(); - - test_mixed, bg::model::d2::point_xy >(); - -#ifdef HAVE_TTMATH - test_2d >(); - test_mixed, bg::model::d2::point_xy >(); -#endif - - test_empty_input >(); - - return 0; -} diff --git a/test/strategies/Jamfile.v2 b/test/strategies/Jamfile.v2 index 9475f6a5d..e994e46f0 100644 --- a/test/strategies/Jamfile.v2 +++ b/test/strategies/Jamfile.v2 @@ -1,8 +1,13 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -# Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -# Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +# +# This file was modified by Oracle on 2014. +# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # # Use, modification and distribution is subject to the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,6 +16,7 @@ test-suite boost-geometry-strategies : [ run cross_track.cpp ] + [ run distance_default_result.cpp ] [ run haversine.cpp ] [ run projected_point.cpp ] [ run pythagoras.cpp ] diff --git a/test/strategies/distance_default_result.cpp b/test/strategies/distance_default_result.cpp new file mode 100644 index 000000000..40315d207 --- /dev/null +++ b/test/strategies/distance_default_result.cpp @@ -0,0 +1,270 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_default_result +#endif + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#if defined(HAVE_TTMATH) +#include +#endif + +namespace bg = ::boost::geometry; + + +template +struct assert_equal_types +{ + assert_equal_types() + { + static const bool are_same = + boost::is_same::type::value; + + BOOST_MPL_ASSERT_MSG((are_same), + WRONG_DEFAULT_DISTANCE_RESULT, + (types)); + } +}; + +//========================================================================= + +template +< + typename Geometry1, + typename Geometry2, + typename ExpectedResult, + typename ExpectedComparableResult +> +inline void test_distance_result() +{ + typedef typename bg::default_distance_result + < + Geometry1, Geometry2 + >::type result12; + + typedef typename bg::default_distance_result + < + Geometry2, Geometry1 + >::type result21; + + typedef typename bg::default_comparable_distance_result + < + Geometry1, Geometry2 + >::type comparable_result12; + + typedef typename bg::default_comparable_distance_result + < + Geometry2, Geometry1 + >::type comparable_result21; + + assert_equal_types(); + assert_equal_types(); + assert_equal_types(); + assert_equal_types(); +} + +//========================================================================= + +template +< + typename CoordinateType1, + typename CoordinateType2, + std::size_t Dimension, + typename CoordinateSystem, + typename ExpectedResult, + typename ExpectedComparableResult = ExpectedResult +> +struct test_distance_result_segment +{ + test_distance_result_segment() + { + typedef typename bg::model::point + < + CoordinateType1, Dimension, CoordinateSystem + > point1; + + typedef typename bg::model::point + < + CoordinateType2, Dimension, CoordinateSystem + > point2; + + typedef typename bg::model::segment segment1; + typedef typename bg::model::segment segment2; + + test_distance_result + < + point1, point2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point1, segment2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point2, segment1, ExpectedResult, ExpectedComparableResult + >(); + } +}; + +//========================================================================= + +template +< + typename CoordinateType1, + typename CoordinateType2, + std::size_t Dimension, + typename ExpectedResult, + typename ExpectedComparableResult = ExpectedResult +> +struct test_distance_result_box +{ + test_distance_result_box() + { + typedef typename bg::model::point + < + CoordinateType1, Dimension, bg::cs::cartesian + > point1; + + typedef typename bg::model::point + < + CoordinateType2, Dimension, bg::cs::cartesian + > point2; + + typedef typename bg::model::box box1; + typedef typename bg::model::box box2; + + test_distance_result + < + point1, box2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point2, box1, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + box1, box2, ExpectedResult, ExpectedComparableResult + >(); + } +}; + +//========================================================================= + +template +inline void test_segment_all() +{ +#if defined(HAVE_TTMATH) + typedef ttmath_big tt; + typedef bg::util::detail::default_integral::type default_integral; +#endif + typedef typename boost::mpl::if_ + < + typename boost::is_same::type, + double, + float + >::type float_return_type; + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + +#if defined(HAVE_TTMATH) + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); +#endif +} + +//========================================================================= + +template +inline void test_box_all() +{ +#if defined(HAVE_TTMATH) + typedef ttmath_big tt; +#endif + typedef bg::util::detail::default_integral::type default_integral; + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + +#if defined(HAVE_TTMATH) + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); +#endif +} + +//========================================================================= + +BOOST_AUTO_TEST_CASE( test_point_point_or_point_segment ) +{ + test_segment_all<2, bg::cs::cartesian>(); + test_segment_all<3, bg::cs::cartesian>(); + test_segment_all<4, bg::cs::cartesian>(); + test_segment_all<2, bg::cs::spherical_equatorial >(); +} + +BOOST_AUTO_TEST_CASE( test_point_box_or_box ) +{ + test_box_all<2>(); + test_box_all<3>(); + test_box_all<4>(); +} diff --git a/test/string_from_type.hpp b/test/string_from_type.hpp new file mode 100644 index 000000000..b564c2359 --- /dev/null +++ b/test/string_from_type.hpp @@ -0,0 +1,82 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef GEOMETRY_TEST_STRING_FROM_TYPE_HPP +#define GEOMETRY_TEST_STRING_FROM_TYPE_HPP + + +#if defined(HAVE_TTMATH) +# include +#endif + +#if defined(HAVE_CLN) || defined(HAVE_GMP) +# include +#endif + + +#if defined(HAVE_GMP) +# include +#endif +#if defined(HAVE_CLN) +# include +#endif + + + +template +struct string_from_type {}; + +template <> struct string_from_type +{ static std::string name() { return "v"; } }; + +template <> struct string_from_type +{ static std::string name() { return "f"; } }; + +template <> struct string_from_type +{ static std::string name() { return "d"; } }; + +template <> struct string_from_type +{ static std::string name() { return "e"; } }; + +template <> struct string_from_type +{ static std::string name() { return "s"; } }; + +template <> struct string_from_type +{ static std::string name() { return "i"; } }; + +template <> struct string_from_type +{ static std::string name() { return "l"; } }; + +#if defined(HAVE_TTMATH) + template <> struct string_from_type + { static std::string name() { return "t"; } }; +#endif + +#if defined(BOOST_RATIONAL_HPP) +template struct string_from_type > +{ static std::string name() { return "r"; } }; +#endif + + +#if defined(HAVE_GMP) +template <> struct string_from_type +{ static std::string name() { return "g"; } }; +#endif + +#if defined(HAVE_CLN) +template <> struct string_from_type +{ static std::string name() { return "c"; } }; +#endif + + +#endif // GEOMETRY_TEST_STRING_FROM_TYPE_HPP diff --git a/test/to_svg.hpp b/test/to_svg.hpp index 54891b7bf..9f7c37749 100644 --- a/test/to_svg.hpp +++ b/test/to_svg.hpp @@ -29,7 +29,7 @@ #include template -inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = false) +inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool /*enrich*/ = false) { // turn points in orange, + enrichment/traversal info typedef typename bg::coordinate_type::type coordinate_type; @@ -196,7 +196,7 @@ struct to_svg_assign_policy }; template -inline void to_svg(G const& g, std::string const& filename, bool sort = true) +inline void to_svg(G const& g, std::string const& filename, bool /*sort*/ = true) { namespace bg = boost::geometry;