[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0beta1-46-gfd77a4568

git at osgeo.org git at osgeo.org
Fri Nov 26 10:50:10 PST 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  fd77a456835e7fd95f89ec39b1a4a143fdf617ac (commit)
       via  8a73bd724cbd54ca0050976bcc47d273129b02d3 (commit)
       via  c8dff7949a55f2262b81a620f0203153f8b994cf (commit)
       via  2b7c91f54e3499cddf169e19ba0f2778a50c925f (commit)
      from  98d041b06e3dfcdc9ae71bdd82171254d16d0673 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fd77a456835e7fd95f89ec39b1a4a143fdf617ac
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Fri Nov 26 21:49:44 2021 +0300

    Add NEWS for MVT clipping.

diff --git a/NEWS b/NEWS
index bc24932d9..b8da9a44f 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,10 @@ Changes since PostGIS 3.2.0beta1 release:
   * Enhancements *
   - #5018, pgsql2shp basic support for WITH CTE clause (Regina Obe)
   - #5019, address_standardizer: Add support for pcre2 (Paul Ramsey)
+  - ST_AsMVTGeom now uses faster clipping (Aliaksandr Kalenik)
+  - ST_PixelAsCentroids, ST_PixelAsCentroid reimplemented in C (Sergei Shoulbakov)
+
+
 
 PostGIS 3.2.0
 2021/xx/xx
@@ -78,6 +82,7 @@ PostGIS 3.2.0
            (Han Wang, Aliaksandr Kalenik, Darafei Praliaskouski, Giuseppe Broccolo)
   - #4949, Use proj_normalize_for_visualization to hand "axis swap" decisions (Paul Ramsey)
   - ST_PixelAsCentroids, ST_PixelAsCentroid reimplemented on top of a C function (Sergei Shoulbakov)
+  - ST_AsMVTGeom now uses faster clipping (Aliaksandr Kalenik)
 
  * New features*
   - #4923, topology.ValidateTopologyRelation (Sandro Santilli)

commit 8a73bd724cbd54ca0050976bcc47d273129b02d3
Merge: 98d041b06 c8dff7949
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Fri Nov 26 21:45:14 2021 +0300

    Merge 'lwgeom_wagyu: replace wagyu's quick_lr_clip with lwgeom_clip_to_ordinate_range'
    
    Closes https://github.com/postgis/postgis/pull/647


commit c8dff7949a55f2262b81a620f0203153f8b994cf
Merge: b58339cce 2b7c91f54
Author: kalenikaliaksandr <kalenik.aliaksandr at gmail.com>
Date:   Fri Nov 26 21:06:05 2021 +0300

    Merge 2b7c91f54e3499cddf169e19ba0f2778a50c925f into b58339cce2df86cca7d6b5ad97e415836edc9caf


commit 2b7c91f54e3499cddf169e19ba0f2778a50c925f
Author: Aliaksandr Kalenik <kalenik.aliaksandr at gmail.com>
Date:   Mon Nov 22 16:43:55 2021 +0300

    lwgeom_wagyu: replace wagyu's quick_lr_clip with lwgeom_clip_to_ordinate_range

diff --git a/deps/wagyu/lwgeom_wagyu.cpp b/deps/wagyu/lwgeom_wagyu.cpp
index b8a682381..a25a0d189 100644
--- a/deps/wagyu/lwgeom_wagyu.cpp
+++ b/deps/wagyu/lwgeom_wagyu.cpp
@@ -26,7 +26,6 @@
 
 #define USE_WAGYU_INTERRUPT
 #include "mapbox/geometry/wagyu/wagyu.hpp"
-#include "mapbox/geometry/wagyu/quick_clip.hpp"
 
 #include <iterator>
 #include <limits>
@@ -40,20 +39,13 @@ using wagyu_multipolygon = mapbox::geometry::multi_polygon<wagyu_coord_type>;
 using wagyu_linearring = mapbox::geometry::linear_ring<wagyu_coord_type>;
 using vwpolygon = std::vector<wagyu_polygon>;
 using wagyu_point = mapbox::geometry::point<wagyu_coord_type>;
-using wagyu_box = mapbox::geometry::box<wagyu_coord_type>;
 
 static wagyu_linearring
-ptarray_to_wglinearring(const POINTARRAY *pa, const wagyu_box &tile)
+ptarray_to_wglinearring(const POINTARRAY *pa)
 {
 	wagyu_linearring lr;
 	lr.reserve(pa->npoints);
 
-	/* We calculate the bounding box of the point array */
-	wagyu_coord_type min_x = std::numeric_limits<wagyu_coord_type>::max();
-	wagyu_coord_type max_x = std::numeric_limits<wagyu_coord_type>::min();
-	wagyu_coord_type min_y = min_x;
-	wagyu_coord_type max_y = max_x;
-
 	size_t point_size = ptarray_point_size(pa);
 	size_t pa_size = pa->npoints;
 	uint8_t *buffer = pa->serialized_pointlist;
@@ -62,62 +54,48 @@ ptarray_to_wglinearring(const POINTARRAY *pa, const wagyu_box &tile)
 		const wagyu_coord_type x = static_cast<wagyu_coord_type>(*(double*) buffer);
 		const wagyu_coord_type y = static_cast<wagyu_coord_type>(((double*) buffer)[1]);
 		buffer += point_size;
-		min_x = std::min(min_x, x);
-		max_x = std::max(max_x, x);
-		min_y = std::min(min_y, y);
-		max_y = std::max(max_y, y);
 
 		lr.emplace_back(static_cast<wagyu_coord_type>(x), static_cast<wagyu_coord_type>(y));
 	}
 
-	/* Check how many sides of the calculated box are inside the tile */
-	uint32_t sides_in = 0;
-	sides_in += min_x >= tile.min.x && min_x <= tile.max.x;
-	sides_in += max_x >= tile.min.x && max_x <= tile.max.x;
-	sides_in += min_y >= tile.min.y && min_y <= tile.max.y;
-	sides_in += max_y >= tile.min.y && max_y <= tile.max.y;
-
-	/* With 0 sides in, the box it's either outside or covers the tile completely */
-	if ((sides_in == 0) && (min_x > tile.max.x || max_x < tile.min.x || min_y > tile.max.y || max_y < tile.min.y))
-	{
-		/* No overlapping: Return an empty linearring */
-		return wagyu_linearring();
-	}
-
-	if (sides_in != 4)
-	{
-		/* Some edges need to be clipped */
-		return mapbox::geometry::wagyu::quick_clip::quick_lr_clip(lr, tile);
-	}
-
-	/* All points are inside the box */
 	return lr;
 }
 
 static vwpolygon
-lwpoly_to_vwgpoly(const LWPOLY *geom, const wagyu_box &box)
+lwpoly_to_vwgpoly(const LWPOLY *geom, const GBOX *box)
 {
+	LWCOLLECTION *geom_clipped_x = lwgeom_clip_to_ordinate_range((LWGEOM *)geom, 'X', box->xmin, box->xmax, 0);
+	LWCOLLECTION *geom_clipped = lwgeom_clip_to_ordinate_range((LWGEOM *)geom_clipped_x, 'Y', box->ymin, box->ymax, 0);
+
 	vwpolygon vp;
-	for (std::uint32_t i = 0; i < geom->nrings; i++)
+	for (std::uint32_t i = 0; i < geom_clipped->ngeoms; i++)
 	{
-		wagyu_polygon pol;
-		pol.push_back(ptarray_to_wglinearring(geom->rings[i], box));
-
-		/* If it has an inner ring, push it too */
-		i++;
-		if (i != geom->nrings)
+		assert(geom_clipped->geoms[i]->type == POLYGONTYPE);
+		LWPOLY *poly = (LWPOLY *)geom_clipped->geoms[i];
+		for (std::uint32_t ring = 0; ring < poly->nrings; ring++)
 		{
-			pol.push_back(ptarray_to_wglinearring(geom->rings[i], box));
-		}
+			wagyu_polygon pol;
+			pol.push_back(ptarray_to_wglinearring(poly->rings[ring]));
+
+			/* If it has an inner ring, push it too */
+			ring++;
+			if (ring != poly->nrings)
+			{
+				pol.push_back(ptarray_to_wglinearring(poly->rings[ring]));
+			}
 
-		vp.push_back(pol);
+			vp.push_back(pol);
+		}
 	}
 
+	lwgeom_free((LWGEOM *)geom_clipped_x);
+	lwgeom_free((LWGEOM *)geom_clipped);
+
 	return vp;
 }
 
 static vwpolygon
-lwmpoly_to_vwgpoly(const LWMPOLY *geom, const wagyu_box &box)
+lwmpoly_to_vwgpoly(const LWMPOLY *geom, const GBOX *box)
 {
 	vwpolygon vp;
 	for (std::uint32_t i = 0; i < geom->ngeoms; i++)
@@ -139,7 +117,7 @@ lwmpoly_to_vwgpoly(const LWMPOLY *geom, const wagyu_box &box)
  * previous rings)
  */
 static vwpolygon
-lwgeom_to_vwgpoly(const LWGEOM *geom, const wagyu_box &box)
+lwgeom_to_vwgpoly(const LWGEOM *geom, const GBOX *box)
 {
 	switch (geom->type)
 	{
@@ -227,12 +205,8 @@ __lwgeom_wagyu_clip_by_box(const LWGEOM *geom, const GBOX *bbox)
 		return out;
 	}
 
-	wagyu_point box_min(std::min(bbox->xmin, bbox->xmax), std::min(bbox->ymin, bbox->ymax));
-	wagyu_point box_max(std::max(bbox->xmin, bbox->xmax), std::max(bbox->ymin, bbox->ymax));
-	const wagyu_box box(box_min, box_max);
-
 	wagyu_multipolygon solution;
-	vwpolygon vpsubject = lwgeom_to_vwgpoly(geom, box);
+	vwpolygon vpsubject = lwgeom_to_vwgpoly(geom, bbox);
 	if (vpsubject.size() == 0)
 	{
 		LWGEOM *out = lwgeom_construct_empty(MULTIPOLYGONTYPE, geom->srid, 0, 0);
diff --git a/regress/core/mvt.sql b/regress/core/mvt.sql
index a4c29e460..f52d9e3b2 100644
--- a/regress/core/mvt.sql
+++ b/regress/core/mvt.sql
@@ -371,7 +371,7 @@ WITH geometry AS
 	100, 0, true))) as g
 )
 SELECT 'PG57',
-        g = 'POLYGON((0 1,0 100,100 100,100 0,1 0,0 1))' OR g = 'POLYGON((0 0,0 1,0 100,100 100,100 0,0 0))'
+        g = 'POLYGON((0 1,0 100,100 100,100 0,1 0,0 1))' OR g = 'POLYGON((0 0,0 1,0 100,100 100,100 0,0 0))' OR g = 'POLYGON((0 0,0 100,100 100,100 0,0 0))'
 FROM geometry;
 
 -- Geometrycollection test
diff --git a/regress/core/mvt_expected b/regress/core/mvt_expected
index 9b6e5c130..6e72b2be1 100644
--- a/regress/core/mvt_expected
+++ b/regress/core/mvt_expected
@@ -52,7 +52,7 @@ PG42 - OFF|LINESTRING(0 10,0 0,1 0)
 PG43 - ON |MULTIPOLYGON(((0 10,10 10,5 5,0 10)),((0 0,5 5,10 0,0 0)))
 PG43 - OFF|MULTIPOLYGON(((5 5,-1 -1,11 -1,5 5)),((5 5,11 11,-1 11,5 5)))
 PG44|
-PG45|
+PG45|SRID=3857;POLYGON((2803 34,2796 -16,2797 -16,2803 34))
 PG46|SRID=3857;POLYGON((3262 2030,3253 2158,3245 2224,3262 2030))
 PG47|
 PG48|

-----------------------------------------------------------------------

Summary of changes:
 NEWS                        |  5 +++
 deps/wagyu/lwgeom_wagyu.cpp | 78 +++++++++++++++------------------------------
 regress/core/mvt.sql        |  2 +-
 regress/core/mvt_expected   |  2 +-
 4 files changed, 33 insertions(+), 54 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list