]> granicus.if.org Git - postgis/commitdiff
Bug in geography ST_Segmentize
authorRegina Obe <lr@pcorp.us>
Thu, 10 Nov 2016 04:07:45 +0000 (04:07 +0000)
committerRegina Obe <lr@pcorp.us>
Thu, 10 Nov 2016 04:07:45 +0000 (04:07 +0000)
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

liblwgeom/lwgeodetic.c
regress/geography.sql
regress/geography_expected

index cc1773408ed036aa5f53253464f40fc27402a586..b48a90868ae851757ca2855bcd2f63896345ed98 100644 (file)
@@ -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);
index f79b2237598a770a7954f7b925e5f66cde22a0c5..fc0358402f3add99bcbef9092f2ee20c621c9bb5 100644 (file)
@@ -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);
 
index db6e8a4243d50433b85eec1c5358ee3da5cdfa1e..cdbb99ae22333611751ef150d6ec8b6b8c55b95f 100644 (file)
@@ -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