如何通过坐标查找 mysql 中的多面体数据

How to look up multipolygon data in mysql by coordinates

// 맵 데이터
db.Exec(`CREATE TABLE IF NOT EXISTS
    geo_datas(
        id bigint unsigned primary key auto_increment,
        level tinyint unsigned NOT NULL,
        geom multipolygon NOT NULL,
        country_name varchar(30) NOT NULL,
        country_code varchar(10) NOT NULL,
        name varchar(50),
        minx REAL NOT NULL,
        miny REAL NOT NULL,
        maxx REAL NOT NULL,
        maxy REAL NOT NULL
    )
`)

数据是在用上面的代码创建的 table 中创建的。 geom列为multipolygon类型,插入如下数据

MULTIPOLYGON (((5.347486495971623 45.98247528076172, 5.3532729148865315 45.991767883300895, 5.3617901802064125 45.99477386474615, 5.37621974945074 45.99368667602545, 5.380286693572998 45.98820495605469, 5.3969597816467285 45.981689453125, 5.396285533905029 45.97837066650396, 5.378274440765438 45.97423934936529, 5.347486495971623 45.98247528076172)))

之后想获取坐标所属的多边形数据作为地图坐标点类型,尝试了如下

SELECT id
FROM geo_datas
WHERE MBRContains(geom , ST_GeomFromText('Point(37.543238571036824 126.9867128133774)'));

当我执行上面的sql时,它运行持续了201秒。 它返回了 0 个结果。

我的数据是世界数据,结果0是不可能的,不知道为什么returns0.

查询也很慢,不知如何解决,请指教,能否举个简单的例子?

ALTER TABLE geo_datas
    ADD SPATIAL(multipolygon);
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS
    geo_datas(
        id bigint unsigned primary key auto_increment,
        level tinyint unsigned NOT NULL,
        geom multipolygon NOT NULL SRID 0,
        country_name varchar(30) NOT NULL,
        country_code varchar(10) NOT NULL,
        name varchar(50),
        minx REAL NOT NULL,
        miny REAL NOT NULL,
        maxx REAL NOT NULL,
        maxy REAL NOT NULL,
        index idx_level (level),
        index idx_country_code (country_code),
        index idx_country_name (country_name),
        index idx_name (name),
        spatial index (geom)
    )
`)

我更改了 table 上面的代码

    query := "SELECT level, name, country_name, country_code, ST_AsGeoJSON(geom, 20) geom " +
    "FROM geo_datas " +
    "WHERE ST_Contains(geom, ST_GeomFromText('Point(%v %v)')) " +
    "ORDER BY level asc "

如上更改代码后,一切正常。