MySQL Forums
Forum List  »  GIS

SELECT * WITH(POLYGON with HOLES) : Error
Posted by: Boni Gopalan
Date: March 14, 2011 03:36AM

The test dataset contains 1000 random rectangles within X  [0,10000], Y  [0,10000]. I would like to query for rectangles within a polygon consisting of an outer ring and a hole within.

SELECT COUNT(*) FROM tile WHERE
within(tile.LOCATION,
GeomFromText(
'POLYGON ((-1 -1, 10000 -1, 10000 10000, -1 10000, -1 -1))'
)
) = 1

Result: 1000 [As expected]

SELECT COUNT(*) FROM tile WHERE
within(tile.LOCATION,
GeomFromText(
'POLYGON ((10 10, 5010 10, 5010 5010, 10 5010, 10 10))'
)
) = 1

Result: 248 [As expected]


SELECT COUNT(*) FROM tile WHERE
within(tile.LOCATION,
GeomFromText(
'POLYGON ((-1 -1, 10000 -1, 10000 10000, -1 10000, -1 -1),(10 10, 5010 10, 5010 5010, 10 5010, 10 10))'
)
) = 1

Result: 1000 [Expected : 752 since 248 falls inside the hole]


If I run

SELECT COUNT(*) FROM tile WHERE
within(tile.LOCATION,
GeomFromText(
'POLYGON ((-1 -1, 10000 -1, 10000 10000, -1 10000, -1 -1)'
)
) = 1
AND
within(tile.LOCATION,
GeomFromText(
'POLYGON ((10 10, 5010 10, 5010 5010, 10 5010, 10 10))'
)
) = 0

Then result is 0

Where as

SELECT COUNT(*) FROM tile WHERE
within(tile.LOCATION,
GeomFromText(
'POLYGON ((-1 -1, 10000 -1, 10000 10000, -1 10000, -1 -1),(10 10, 5010 10, 5010 5010, 10 5010, 10 10))'
)
) = 1
AND
within(tile.LOCATION,
GeomFromText(
'POLYGON ((10 10, 5010 10, 5010 5010, 10 5010, 10 10))'
)
) = 0

Result is 752, exactly what I’d expect!!

Can anyone help me understand this behavior?

Options: ReplyQuote


Subject
Views
Written By
Posted
SELECT * WITH(POLYGON with HOLES) : Error
5314
March 14, 2011 03:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.