0
votes

Using the simple table below, I'm trying to select the 'latlng POINT' that is within the POLYGON given. But the return is always empty, what am I missing?

CREATE TABLE mypoi (
   id int not null auto_increment,
  latlng POINT not null,
  primary key(id)
)ENGINE=MyISM;

INSERT INTO mypoi VALUES
(1 ,  POINT( 39.274, -94.4233  )),
(2 , POINT( 39.5, -94.3483  ));

SELECT id, x(latlng), y(latlng)
FROM mypoi
WHERE MBRContains(GeomFromText('POLYGON((39.48025, -94.73566 , 39.48025, -94.09021 , 39.09122, -94.09021 , 39.09122, -94.73566))'),latlng);
1

1 Answers

0
votes

WKT polygons are closed by including the original point at the end of the sequence of points. They also have each point separated by a comma (i.e. x1 y1, x2 y2, ..., x1 y1). There are just some formatting issues in the polygon text.

SELECT id, x(latlng), y(latlng)
FROM mypoi
WHERE MBRContains(GeomFromText('POLYGON((39.48025 -94.73566, 39.48025 -94.09021, 39.09122 -94.09021, 39.09122 -94.73566, 39.48025 -94.73566))'),latlng);