开发者社区 > 博文 > 【JUSTQL Reference】UDF介绍之GeoTools
分享
  • 打开微信扫码分享

  • 点击前往QQ分享

  • 点击前往微博分享

  • 点击复制链接

【JUSTQL Reference】UDF介绍之GeoTools

  • 京东城市JUST团队
  • 2021-01-26
  • IP归属:未知
  • 596浏览

1.1.1.1 计算Polygon面积

语法

          ST_getPolygonArea(geometry)

功能

          根据给定的几何对象返回面积(单位为平方公里), st_getPolygonArea(geometry)

input

          geometry: 几何对象

output

          面积 Double,如果传入的为点或者线,面积为0

example

select
st_PolygonArea(
st_geomFromWKT(
'POLYGON (

(114.13797 22.60802,114.13213 22.60813,114.12716 2.61094,114.12928 22.61599,114.13201 22.62031, 114.13797 22.60802))'

)
)

1.1.1.2 获取基于point扩展的MBR

语法

          st_geoHashFromPoint(point, hashLength)

功能

          根据用户传入的pointhash长度返回point所在的geohash格子的GeoHash String, st_geoHashFromPoint(point, hashLength)

input

          point: 查询的点 POINT

           hashLength:指定Geohash的长度 Integer

output

          geoHash String

example

select st_geoHashFromPoint(order_position, 6) from common_table

1.1.1.3 获取表中某一个几何对象列集合构成的MBR

功能

          传入几何对象的合集,返回包裹所有几何对象的MBR, st_getWholeMBR(collect_list(geometry_column))

input

          collect_list(geohash_column): collect_listspark sql内置UDF,获取一列的所有元素集合

          geometry_column为表的geometry列列名

output

          MBR

example

select st_getWholeMBR(collect_list(block)) from polygon_table

1.1.1.4 GeoHash String MBR

语法

          st_mbrFromGeoHash(hashString)

功能

          根据用户传入的GeoHash hash值返回对应的MBR, st_mbrFromGeoHash(hashString)

input

          hashStringgeohash string

output

          MBR

example

select st_mbrFromGeoHash(geohash) from common_table_with_geohash

1.1.1.5 查询point所在的Geohash格子

语法:

st_geoHashFromPoint(point, hashLength)

功能

          根据用户传入的pointhash长度返回point所在的geohash格子的GeoHash String, st_geoHashFromPoint(point, hashLength)

input

          point: 查询的点 POINT,

          hashLength:指定Geohash的长度 Integer

output

          geoHash String

example

select st_geoHashFromPoint(order_position, 6) from common_table

共0条评论