1.ST_AsText:获取几何体对象的 wkt 格式文本描述信息;ST_PointFromText:根据 wkt 信息和 srid 信息构造点类。多边形查询相关SQL:下述SQL可以传入多边形的SQL边界点坐标去匹配表中的坐标找到对应的数据,注意smx is not null and smy is not null条件是为了避免坐标数据存在空值的情况
select qh_code as code, dmgeo.ST_AsText (GEOM) as geojson from T_GEO t where dmgeo.ST_Intersects (dmgeo.ST_POINTFromText('POINT (104.651271 28.718874)' , 4490) = 1, t.geom);
上述SQL得到的结果会是如图所示(具体查询结果根据业务需求进行更改):

2.多边形查询相关SQL:下述SQL可以传入多边形的SQL边界点坐标去匹配表中的坐标找到对应的数据,注意smx is not null and smy is not null条件是为了避免坐标数据存在空值的情况
SELECT * FROM t_data t WHERE dmgeo.ST_Intersects(
dmgeo.ST_POINTFromText('POINT(' || smx || ' ' || smy || ')', 4490), dmgeo.ST_GeomFromText('POLYGON((110 40, 110 50, 120 50, 120 40,110 40))', 4490)
) = 1 and smx is not null and smy is not null;
7613





