Opened 15 years ago

Closed 15 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 by mloskot, 15 years ago

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 by pracine, 15 years ago

Status: newassigned

comment:3 by pracine, 15 years ago

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 by mloskot, 15 years ago

Related ticket is #351

comment:5 by jorgearevalo, 15 years ago

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 by jorgearevalo, 15 years ago

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

in reply to:  6 comment:7 by jorgearevalo, 15 years ago

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 by jorgearevalo, 15 years ago

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 by jorgearevalo, 15 years ago

Error fixed in r5146.

comment:10 by pracine, 15 years ago

See also 478.

comment:11 by pracine, 15 years ago

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