[SCM] PostGIS branch stable-3.6 updated. 3.6.4-3-g923c06385
git at osgeo.org
git at osgeo.org
Tue Jun 9 11:20:26 PDT 2026
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, stable-3.6 has been updated
via 923c0638576b8916829233557224fe77a1a1e570 (commit)
via 265a9edd2b6e5bd72944910d61eb9754827451d7 (commit)
from cb20046039b693e42ca608aa21a9e774e0ec8fe2 (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 923c0638576b8916829233557224fe77a1a1e570
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Jun 9 10:59:25 2026 -0700
News entry for #5989
diff --git a/NEWS b/NEWS
index 95691e8cc..51a185b62 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,7 @@ PostGIS 3.6.5
* Fixes *
--
+- #5989, CurvePolygon distance corner case (Paul Ramsey)
PostGIS 3.6.4
commit 265a9edd2b6e5bd72944910d61eb9754827451d7
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Jun 9 00:19:54 2026 +0000
Fix CurvePolygon distance issue, references #5989
diff --git a/liblwgeom/cunit/cu_measures.c b/liblwgeom/cunit/cu_measures.c
index c95bf21e1..5cb4b6d81 100644
--- a/liblwgeom/cunit/cu_measures.c
+++ b/liblwgeom/cunit/cu_measures.c
@@ -235,6 +235,12 @@ static void test_mindistance2d_tolerance(void)
DIST2DTEST(
"CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0, -1 5, 0 10), (0 10, -10 10, -10 0, 0 0)))",
"POINT(-0.5 5)", 0.5, default_accepted_error);
+
+ /* Ticket 5989 reopened: multi-arc COMPOUNDCURVE with large Finnish coordinates */
+ DIST2DTEST(
+ "MULTISURFACE(CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(25493681.3085 6678739.6419,25493637.8256 6678776.2541,25493599.9716 6678818.6604),(25493599.9716 6678818.6604,25493583.8816 6678839.494,25493590.9591 6678844.9594,25493566.9698 6678851.9051,25493526.5793 6678861.0985,25493487.3853 6678868.2546,25493447.392 6678871.7846,25493429.5033 6678876.6846,25493435.0147 6678857.4594,25493454.9254 6678821.6192,25493452.4867 6678816.1292,25493402.3226 6678828.2153,25493354.7526 6678837.8291,25493349.0217 6678838.9873,25493310.914 6678843.6926,25493306.3784 6678859.9295,25493294.1011 6678858.7864,25493169.9028 6678847.2212,25493127.549 6678843.2773,25493057.8888 6678834.6763,25493017.4547 6678826.7261,25492928.2395 6678821.5524,25492909.1067 6678795.0681,25492946.9544 6678794.8193,25492967.1292 6678794.6866,25493010.8878 6678795.9163,25493111.5564 6678804.3109,25493113.4069 6678799.5694,25493134.2375 6678806.0729),CIRCULARSTRING(25493134.2375 6678806.0729,25493223.038 6678812.0533,25493311
.4919 6678802.1948,25493317.3589 6678800.9679,25493323.2107 6678799.6707),(25493323.2107 6678799.6707,25493362.6615 6678792.3924,25493364.6948 6678785.173,25493375.0512 6678781.6008,25493404.9736 6678771.2798),CIRCULARSTRING(25493404.9736 6678771.2798,25493486.8049 6678737.6728,25493566.8862 6678700.0859),(25493566.8862 6678700.0859,25493574.903 6678714.0761,25493600.2214 6678702.8803,25493654.1114 6678670.2493,25493669.7219 6678659.2147,25493677.0288 6678653.353,25493684.6468 6678648.4119,25493724.0447 6678623.7638,25493800.1925 6678583.5847,25493805.6261 6678586.1292,25493811.9258 6678582.3016,25493812.8413 6678583.0522,25493846.581 6678558.6541,25493884.2653 6678531.6272,25493900.9168 6678580.1258,25493830.7852 6678630.9518,25493789.0848 6678661.2736,25493746.1612 6678692.485,25493686.5413 6678735.8369,25493681.3085 6678739.6419))))",
+ "POLYGON ((25492929.752797972 6678919.124091367,25493008.675235115 6678876.783133076,25493098.02917443 6678854.33589699,25493139.669701554 6678977.913508233,25493122.946292613 6679011.427315322,25493050.53388224 6679068.791126598,25493140.33593199 6679140.958135231,25492931.688606273 6679401.2946243705,25492799.289171 6679295.949040241,25492651.5177725 6679115.144800108,25492929.752797972 6678919.124091367))",
+ 14.5, 1.0);
}
static void
diff --git a/liblwgeom/measures.c b/liblwgeom/measures.c
index 458e82978..30d596d4f 100644
--- a/liblwgeom/measures.c
+++ b/liblwgeom/measures.c
@@ -1392,17 +1392,33 @@ lw_dist2d_seg_arc(const POINT2D *A1,
{
double length_A; /* length of the segment A */
POINT2D E, F; /* points of intersection of edge A and circle(B) */
- double dist_D_EF; /* distance from D to E or F (same distance both ways) */
+ double dist_D_EF; /* distance from D_line to E or F (same distance both ways) */
+ POINT2D D_line; /* foot of perpendicular from C to the infinite line through A1-A2 */
+ double dist_C_D_line; /* distance from C to the infinite line */
+ double t;
- dist_D_EF = sqrt(radius_C * radius_C - dist_C_D * dist_C_D);
length_A = sqrt((A2->x - A1->x) * (A2->x - A1->x) + (A2->y - A1->y) * (A2->y - A1->y));
+ /*
+ * D (from lw_dist2d_pt_seg) is clamped to the segment, but we need the
+ * foot of the perpendicular on the *infinite* line to correctly compute
+ * circle-line intersections E and F. Using the clamped endpoint gives wrong
+ * intersection points when the perpendicular falls outside the segment.
+ */
+ t = ((C.x - A1->x) * (A2->x - A1->x) + (C.y - A1->y) * (A2->y - A1->y))
+ / (length_A * length_A);
+ D_line.x = A1->x + t * (A2->x - A1->x);
+ D_line.y = A1->y + t * (A2->y - A1->y);
+ dist_C_D_line = sqrt((C.x - D_line.x) * (C.x - D_line.x) + (C.y - D_line.y) * (C.y - D_line.y));
+
+ dist_D_EF = sqrt(radius_C * radius_C - dist_C_D_line * dist_C_D_line);
+
/* Point of intersection E */
- E.x = D.x - (A2->x - A1->x) * dist_D_EF / length_A;
- E.y = D.y - (A2->y - A1->y) * dist_D_EF / length_A;
+ E.x = D_line.x - (A2->x - A1->x) * dist_D_EF / length_A;
+ E.y = D_line.y - (A2->y - A1->y) * dist_D_EF / length_A;
/* Point of intersection F */
- F.x = D.x + (A2->x - A1->x) * dist_D_EF / length_A;
- F.y = D.y + (A2->y - A1->y) * dist_D_EF / length_A;
+ F.x = D_line.x + (A2->x - A1->x) * dist_D_EF / length_A;
+ F.y = D_line.y + (A2->y - A1->y) * dist_D_EF / length_A;
/* If E is within A and within B then it's an intersection point */
pt_in_arc = lw_pt_in_arc(&E, B1, B2, B3);
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 +-
liblwgeom/cunit/cu_measures.c | 6 ++++++
liblwgeom/measures.c | 28 ++++++++++++++++++++++------
3 files changed, 29 insertions(+), 7 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list