Opened 10 years ago

Closed 10 years ago

#348 closed defect (fixed)

[wktraster] st_raster_envelope & st_raster_to_box2d return different results

Reported by: pracine Owned by: pracine
Priority: high Milestone: WKTRaster 0.1.6
Component: raster Version: master
Keywords: Cc:

Description (last modified by pracine)

SELECT ST_AsText(st_raster_envelope(rast)) FROM mytable
UNION ALL
SELECT ST_AsText(st_raster_to_box2d(rast)) FROM mytable

should return two identical lines.

Change History (11)

comment:1 Changed 10 years ago by mloskot

The difference (WKT Raster Windows build by Regina from 2009-08-10 17:41:12) is as follows:

  • SELECT ST_AsText(st_raster_envelope(rast)) FROM mytable
    POLYGON((-90 90,-72 90,-72 72,-90 72,-90 90))
    
  • SELECT ST_AsText(st_raster_to_box2d(rast)) FROM mytable
    POLYGON((-90 72,-90 90,-72 90,-72 72,-90 72))
    

The two geometries are almost identical. The only difference is which is the first vertex, upper left vs lower left corner.

What does the "should return two identical lines" mean? Which line is the one that should be returned?

comment:2 Changed 10 years ago by pracine

Status: newassigned

comment:3 Changed 10 years ago by pracine

Description: modified (diff)

Reformated the query to make the two lines evident.

This bug appears when the coordinates of the center upper left pixel are very precises i.e. -85.750000033333492

A first problem is that the order is different.

A second problem is that the numbers are also different when the precision is high. I guess this problem is related to the fact that bbox are stored as float4s in PostGIS and our version of ST_Envelope returns the float8s version. I think we should return the float4s bbox. I have to test further though.

comment:4 Changed 10 years ago by mloskot

Related ticket is #351

comment:5 Changed 10 years ago by jorgearevalo

I've changed the name of ST_Raster_Envelope function for ST_ConvexHull, to match the specs: http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking01#Objective0.1.6e-Beingabletointersectvectorandrastertoproducevector.

Commited in r5141

comment:6 Changed 10 years ago by jorgearevalo

I've implemented the ST_Envelope function. The difference with ST_ConvexHull is the affine transformation performed in the case of ST_Envelope function doesn't take into account the rotation (so, only scale + traslation). Is it ok?

New ST_Envelope function committed in r5142

comment:7 in reply to:  6 Changed 10 years ago by jorgearevalo

Replying to jorgearevalo:

I've implemented the ST_Envelope function. The difference with ST_ConvexHull is the affine transformation performed in the case of ST_Envelope function doesn't take into account the rotation (so, only scale + traslation). Is it ok?

New ST_Envelope function committed in r5142

I reply myself to note I should "floor" the raster coordinates on ST_Envelope before constructing the polygon, to add a little buffer around the raster.

comment:8 Changed 10 years ago by jorgearevalo

Ok, this is not correct. I should rotate the raster and the get the min and max coordinates to construct the envelope. I'm sorry, I'll fix it.

comment:9 Changed 10 years ago by jorgearevalo

Error fixed in r5146.

comment:10 Changed 10 years ago by pracine

See also 478.

comment:11 Changed 10 years ago by pracine

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.