Length not respected in ST_Segmentize

المشرف العام

Administrator
طاقم الإدارة
When segmentizing a geography line in Postgis, the max segment length does not seem to be respected when the line is more than 3000km. The error grows when the length of the line increases.

Below the code to demonstrate it:*) The printLineSegmentLength method logs the length of each segment of the line.*) The select create a geography line, then segmentize it and finally call the printLineSegmentLength method.

SELECT printLineSegmentLength(ST_Segmentize(ST_GeographyFromText('LINESTRING(20 20, 60 60)'), 50000), false);CREATE OR REPLACE FUNCTION printLineSegmentLength(line geography, use_spheroid boolean)RETURNS VOID AS $$DECLARE points geometry_dump[] := array(SELECT ST_DumpPoints(line::geometry)); point_count INTEGER := array_length(points, 1); segmentLength NUMERIC;BEGIN FOR i IN 1..point_count - 1 LOOP segmentLength := ST_Distance(geography(points.geom), geography(points[i + 1].geom), use_spheroid); RAISE INFO 'Length: %, %, %', segmentLength, ST_AsText(points.geom), ST_AsText(points[i + 1].geom); END LOOP;END; $$ LANGUAGE 'plpgsql' IMMUTABLE;When executing this function, usin ST_Distance both with the spheroid or not, the error grows to reach 53263m whereas it shouldn't be more than 50000m.

Changing the length of the segment does not make the error disappear.

Is there anything wrong with my test code?



أكثر...
 
أعلى