From: Regina Obe Date: Thu, 10 Nov 2016 04:07:45 +0000 (+0000) Subject: Bug in geography ST_Segmentize X-Git-Tag: 2.4.0alpha~220 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc3437595e88eac7f20b0f3b780a3816cdc912c9;p=postgis Bug in geography ST_Segmentize Closes #3667 for PostGIS 2.4.0 (trunk) Patch provided by Hugo Mercier (Oslandia) git-svn-id: http://svn.osgeo.org/postgis/trunk@15223 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwgeodetic.c b/liblwgeom/lwgeodetic.c index cc1773408..b48a90868 100644 --- a/liblwgeom/lwgeodetic.c +++ b/liblwgeom/lwgeodetic.c @@ -949,6 +949,8 @@ double sphere_direction(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e, do f = (sin(e->lat) - sin(s->lat) * cos(d)) / (sin(d) * cos(s->lat)); if ( FP_EQUALS(f, 1.0) ) heading = 0.0; + else if ( FP_EQUALS(f, -1.0) ) + heading = M_PI; else if ( fabs(f) > 1.0 ) { LWDEBUGF(4, "f = %g", f); diff --git a/regress/geography.sql b/regress/geography.sql index f79b22375..fc0358402 100644 --- a/regress/geography.sql +++ b/regress/geography.sql @@ -117,6 +117,10 @@ SELECT 'segmentize_geography', max(st_distance(d1.geom::geography, d2.geom::geog -- Check that st_segmentize creates segments on the geodesic path SELECT 'segmentize_geography2', st_dwithin(st_pointn(st_segmentize('linestring(1 47,-64 47)'::geography, 3000000)::geometry, 2), 'SRID=4326;POINT(-31.5 51.81)'::geometry, 0.01); +-- #bug 3667 +SELECT 'segmentize_geography_3667', abs(ST_Length(geog) - ST_Length(ST_Segmentize(geog, 30000))) < 0.00001 + FROM (SELECT ST_GeographyFromText('LINESTRING(38.769917 10.780694, 38.769917 9.106194)') As geog) AS f; + -- Clean up spatial_ref_sys DELETE FROM spatial_ref_sys WHERE srid IN (4269,4326); diff --git a/regress/geography_expected b/regress/geography_expected index db6e8a424..cdbb99ae2 100644 --- a/regress/geography_expected +++ b/regress/geography_expected @@ -29,3 +29,4 @@ geog_precision_pazafir|0|0 #2422|1|1068|f|f|1400.230|1396.816|1400.230|1400.230 segmentize_geography|49789 segmentize_geography2|t +segmentize_geography_3667|t