Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] [jira] Created: (UDIG-560) Incorrect PostGIS Bounding Envelope

Incorrect PostGIS Bounding Envelope
-----------------------------------

         Key: UDIG-560
         URL: http://jira.codehaus.org/browse/UDIG-560
     Project: uDIG
        Type: Bug
  Components: postgis  
    Versions: UDIG 1.1, UDIG 1.0.1, 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    
 Environment: ALL
 Reporter: Cole Markham
 Assigned to: Jody Garnett 
    Priority: Minor
 Attachments: UDIGPostGISFeatureLocking.java

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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



Back to the top