Ticket #348 (closed defect: fixed)

Opened 2 years ago

Last modified 22 months ago

[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: trunk
Keywords: Cc:

Description (last modified by pracine) (diff)

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

  Changed 2 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?

  Changed 2 years ago by pracine

  • status changed from new to assigned

  Changed 2 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.

  Changed 2 years ago by mloskot

Related ticket is #351

  Changed 2 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

follow-up: ↓ 7   Changed 2 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

in reply to: ↑ 6   Changed 2 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.

  Changed 2 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.

  Changed 2 years ago by jorgearevalo

Error fixed in r5146.

  Changed 23 months ago by pracine

See also 478.

  Changed 22 months ago by pracine

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.