纬度经度搜索查询无效

时间:2017-05-20 16:56:26

标签: mysql spatial myisam

我的表格跟随Lat和Longs:

Lat & Longs are... 1.330690209415938,103.92820715904236
Lat & Longs are... 1.3292425419208693,103.92836272716522    
Lat & Longs are... 1.328588258949486,103.9237603917718
Lat & Longs are... 1.3316555440643845,103.92398569732904
Lat & Longs are... 1.3310709803501815,103.9254716411233
Lat & Longs are... 1.3326560728062167,103.91472470015287
Lat & Longs are... 1.3327150654429698,103.91202673316002
Lat & Longs are... 1.3340789345882447,103.87714426964521

当我运行以下查询时,它没有返回任何内容。请帮我。在此先感谢。

SELECT  *
FROM    geomit
WHERE   MBRContains(LineFromText(CONCAT(
        '('
        , 1.330690209415938 + 10 / ( 111.1 / cos(RADIANS(1.330690209415938)))
        , ' '
        , 103.92820715904236 + 10 / 111.1
        , ','
        , 1.330690209415938 - 10 / ( 111.1 / cos(RADIANS(1.330690209415938)))
        , ' '
        , 103.92820715904236 - 10 / 111.1 
        , ')' ))
        ,latlong);

注意:我的创建表脚本是:

CREATE TABLE geomit (
 latitude double,
 longitude double,
 latlong GEOMETRY NOT NULL,
 SPATIAL INDEX(latlong)) ENGINE=MyISAM;

1 个答案:

答案 0 :(得分:0)

是否写入比较线(不是多边形)和点?

也许你需要从这两个点加上另外两个点构建一个矩形而不是一条线?