Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: UDIG 0.9, UDIG 1.0.RC1, UDIG 1.0.RC3, UDIG 1.0.RC4, UDIG 1.0.RC5, UDIG 1.0.RC6, UDIG 1.0.0, UDIG 1.0.1, UDIG 1.1.M0
-
Fix Version/s: UDIG 1.0.1
-
Component/s: database
-
Labels:None
-
Environment:ALL
Description
The calculation of the bounding envelope is incorrect. The problem is in the plugin
net.refractions.udig.catalog.postgis
in the class net.refractions.udig.catalog.internal.postgis.UDIGPostGISFeatureLocking
in the method getEntireEnvelope().
The envelope returned by JTS is correct, however expanding the envelope is not correct. Multiplying the min and max coordinates by 1.2 and expanding the envelope to include these new points will only work if the envelope is at the origin. The following code snippet fixes the problem:
[CODE]
envelope = geometryReader.read(wkt).getEnvelopeInternal();
// *** This doesn't work like you think it should ***
//expand by 1.2 to make sure we get the entire bounds
// envelope.expandToInclude(1.2*envelope.getMinX(),1.2*envelope.getMinY());
// envelope.expandToInclude(1.2*envelope.getMaxX(),1.2*envelope.getMaxY());
// *** This is what you really want to do ***
// expand the bounds by 20% (10% in each direction)
double minX = envelope.getMinX();
double minY = envelope.getMinY();
double maxX = envelope.getMaxX();
double maxY = envelope.getMaxY();
double deltaX = (maxX - minX)*0.1;
double deltaY = (maxY - minY)*0.1;
envelope.expandToInclude(minX - deltaX, minY - deltaY);
envelope.expandToInclude(maxX + deltaX, maxY + deltaY);
[/CODE]
Expanding the envelope by 10% in each direction should guarantee that the entire layer is contained in the bounds. The same error also affects the approximated envelope. The attached file fixes both problems.