0

We have areas table with column named 'position' that stores lattitude and longitude of that area. The column 'position' here is of 'POINT' mysql type.

I read instructions from here and followed the same but I am getting error on following query:

SELECT  *
FROM    areas
WHERE   MBRContains(LineFromText(CONCAT(
    '('
    , 72.836898 + 10 / ( 111.1 / cos(RADIANS(72.836898)))
    , ' '
    , 18.935255 + 10 / 111.1
    , ','
    , 72.836898 - 10 / ( 111.1 / cos(RADIANS(18.935255)))
    , ' '
    , 18.935255 - 10 / 111.1 
    , ')' ))
    ,position);

I am getting Error code: 3037. Invalid GIS data provided to function st_geometryfromtext.

Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98

1 Answers1

0

For your MySQL version you need to use this:

SELECT  *
FROM    areas
WHERE   MBRContains
        (
        LineString
                (
                Point (
                        18.935255 + 10 / ( 111.320 / COS(RADIANS(72.836898))),
                        72.836898 + 10 / 111.133
                ),
                Point (
                        18.935255 - 10 / ( 111.320 / COS(RADIANS(72.836898))),
                        72.836898 - 10 / 111.133
                ) 
        ),
    ,position);
Māris Kiseļovs
  • 16,957
  • 5
  • 41
  • 48