MySql MBRCONTAINS not accurate

MySQL

I have a table that has 3 column. city_id, city_name and city_geo. city_geo type is geometry. and i have a another table that has a vehiclelog. I want to query if the latitude and longitude from vehiclelog table is inside the city_geo. I can get the result but not so accurate it's also get the Point that near in city_geo. this is my query

        SELECT  v.`City`,v.`Time`,c.`city_name`,v.`Latitude`,v.`Longitude`
        FROM `city` c, `vehiclelog` v
        WHERE c.`city_name`='$c' AND v.`plate`='$p' AND v.`Date` = '$d'
        AND  MBRCONTAINS(c.`city_geo`, POINT(v.`Latitude`, v.`Longitude`))

I plot it on google map to verify the result and i get

enter image description here

as you can see there are markers outside the polygon that are not suppose to include in result I want only the markers inside the polygon or city_geo. Im using MySql v5.0 I also try MBRCONTAINS, MBRCrosses, Contains and Crosses all same result.

Best Answer

MySQL's result seems correct... MBRCONTAINS() tests whether the Minimum Bounding Rectangle of one object contains the other object.

Does the smallest possible rectangle you can draw around the polygon... contain those points? Visually, it certainly appears that it does.

To test whether the polygon, itself (not the MBR) contains the point, the function you want is ST_Contains(), which was introduced in MySQL 5.6.

http://dev.mysql.com/doc/refman/5.6/en/spatial-relation-functions-object-shapes.html