Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2112 closed defect (fixed)

lw_dist3d_ptarray_poly error

Reported by: pramsey Owned by: nicklas
Priority: medium Milestone: PostGIS 2.0.2
Component: postgis Version: 2.0.x
Keywords: Cc:

Description

In measures3d.c:903, the assignment to move to the next point in the array looks to be reversed,

projp2=projp1;
s2=s1;
p2=p1;

should be

projp1=projp2;
s1=s2;
p1=p2;

Change History (5)

comment:1 by strk, 12 years ago

Indeed, but I wouldn't touch it before having found and added a failing test to the suite.

comment:2 by nicklas, 12 years ago

I will take a look.

Do you have a failing example?

comment:3 by nicklas, 12 years ago

Ok, you are of course right Paul. Quite embarrassing mistake

Here is an example that is failing:

SELECT ST_3DDistance(
 'POLYGON((1 1 1, 5 1 1,5 5 1, 1 5 1,1 1 1))'::geometry,
 'LINESTRING(0 0 2, 0 0 0,5 5 2)'::geometry)

should give 0 but instead gives 0.557086014531155

and the opposite situation:

SELECT ST_3DDistance(
 'POLYGON((1 1 1, 5 1 1,5 5 1, 1 5 1,1 1 1))'::geometry,
 'LINESTRING(0 0 2, 0 0 0,5 5 0)'::geometry)

Where we should get 1 but gets 0.

This affects the test of "if the linestring intersects the polygon". Not the distance-test if they don't intersect. That is why it doesn't always show.

comment:4 by nicklas, 12 years ago

Resolution: fixed
Status: newclosed

Ok,

r10747, trunk r10748, 2.0

I committed regression tests in tickets.sql, and I also committed the modification of measures3d.c. Hope that was ok Paul even if it was your catch.

comment:5 by pramsey, 12 years ago

Thanks Nik, I was hoping you'd take it.

Note: See TracTickets for help on using tickets.