#171 closed defect (fixed)
Non-Square Rectangle Should Contain Rectangle
Reported by: | vivahome2 | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | 3.1.0 |
Component: | Core | Version: | 3.0.0 |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
With PostGIS, when I tried something like
ST_Contains(Non-Rectangle-Polygon, Rectangle-Polygon)
It returned false, where Non-Rectangle-Polygon indeed "contained" Rectangle-Polygon
The actual SQL is
SELECT ST_Contains( GeomFromText('POLYGON((0 0,0 11,11 10,10 0,0 0))', -1), GeomFromText('POLYGON((5 5,5 6,6 6,6 5,5 5))', -1) );
The source code of PostGIS where ST_Contains is defined is (I think)
char GEOSrelateContains(Geometry *g1, Geometry*g2) { try { bool result; result = g1->contains(g2); return result; } catch (GEOSException *ge) { NOTICE_MESSAGE(ge->toString().c_str()); delete ge; return 2; } catch (...) { return 2; } }
Note:
See TracTickets
for help on using tickets.
These 3 lines below should be deleted to fix this bug.
source/geom/Geomtry.cpp
The reason why I thought of deleting these 3 lines was:
The 1st argument should be passed as the 2nd argument, and the 2nd argument should be passed as the 1st argument, because it should varify if *this contains *g. Not the other way around.
BUT, predicate::RectangleContains::contains method accepts the 1st argument only being a rectangle. So, passing *this as the 1st argument is not acceptable since *this is not guaranteed as a rectangle; it is just a geometry.