Skip to content

MySQL GIS常用空间函数.md #2

@iott

Description

@iott

由于之前从未接触过GIS,本文粗浅的记录一些涉及到的函数,便于日后翻阅。

常用函数

MBRIntersects

  • 作用:从数据库中获取完全或部分在此框内的所有多边形
  • 示例:
SELECT * FROM `polygons` 
 WHERE mbrIntersects(ogc_geom,
   GeomFromText('POLYGON((-18 120,-10 120,-10 140,-18 140, -18 120))'));

ST_WITHIN

  • 作用:找出目的地(例如餐馆)是否在范围内。ST_WITHIN(g1, g2): 如果g1在g2的范围内,则返回1,否则返回0
  • 示例:
select ST_WITHIN(ST_GeomFromText('POINT(123.7550476770001 48.29881346700004)'),ST_GeomFromText("POLYGON((123.7550476770001 48.29881346700004,123.754951105 48.29876770200008,123.7547182170001 48.29896478300005,123.7538080500001 48.29853876000006,123.7540577190001 48.29835305800005,123.7537012780001 48.29830251100005,123.753545848 48.29847929300011,123.75315602 48.29836059100005,123.7529432980001 48.29856224300004,123.753799132 48.299119832,123.7543766760001 48.29942498400002,123.7544152390001 48.29945213900005,123.7550476770001 48.29881346700004))"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions