引擎内置多种创建对象的方法,具体如下:
1.1.1.1 创建点对象
1.1.1.1.1 st_makePoint(double1,
double2)
•
select st_makePoint(120.22, 20.33) as udf_point
•
假设我们有一张表,coordinate_table:
pt_longitude |
pt_latitude |
111.11 |
22.11 |
111.22 |
22.22 |
111.33 |
22.33 |
我们可以使用这个udf接收表中的每行经纬度数据并转化为Point
select
st_makePoint(pt_longitude, pt_latitude) as udf_point
from coordinate_table
传入参数所在表的列名以及表名,返回的则是一列多行的表格:
udf_point |
POINT(111.11, 22.11) |
POINT(111.22, 22.22) |
POINT(111.33, 22.33) |
1.1.1.1.2 st_pointFromGeoJson(geoJson)
功能
•
input
•
output
•
example
select
st_pointFromGeoJson(
'{"type":"FeatureCollection",
"features":[
{"type":"Feature",
"properties":{"direction":"forward"},
"geometry":{
"type":"Point",
"coordinates":[105.380859375,31.57853542647338]
}}]}'
)
1.1.1.1.3 st_makePointFromWKT(wktString)
功能
•
input
•
•
output
•
example
select
st_makePointFromWkt('POINT(114.134488 22.614742)')
1.1.1.2 创建线对象
1.1.1.2.1 st_lineFromGeoJson(geoJson)
功能
•
input
•
output
•
example
select
st_lineFromGeoJson(
'{"type":"Feature",
"properties":{},
"geometry":{
"type":"LineString",
"coordinates":[[105.6005859375,30.65681556429287],
[107.95166015624999,31.98944183792288],
[109.3798828125,30.031055426540206],
[107.7978515625,29.935895213372444]]
}}'
)
1.1.1.2.2 st_makeLine(collect_list(pt_column))
功能
•
input
•
•
output
•
example
select
st_makeLine(collect_list(poi_point)) from
poi_table
1.1.1.2.3 st_lineFromPointSeries(column_name,
seperator, coordinateFormat)
功能
•
input
•
•
•
•
output
•
example
LOAD hdfs
:'/just_test/sdline/reading'
to
just:sdlineTableName
Config
{
oid:"0",
--此处将索引为第三列的coordinates数据转换为LineString传入表的GEOM列中
geom:"st_lineFromPointSeries(3, ';','lat lng')",
time:"to_timestamp(2)",
crowd_number:"1"
}
separator ','
1.1.1.3 创建面对象
语法
•
功能
•
input
•
output
•
example
select
st_polygonFromGeoJson(
'{"type":"Feature",
"properties":{},
"geometry":{
"type":"Polygon",
"coordinates":[
[[106.10595703125,33.33970700424026],
[106.32568359375,32.41706632846282],
[108.03955078125,32.2313896627376],
[108.25927734375,33.15594830078649],
[106.10595703125,33.33970700424026]]]
}}'
)
1.1.1.4 创建矩形对象
1.1.1.4.1 st_makeRectangleFromCoord(lng1,lat1,lng2,lat2)
功能
•
input
•
•
•
•
•
为长方形的左下点和右上点,无视顺序
output
•
example
select
st_makeRectangleFromCoord(111.11, 22.22, 113.33, 22.33)
1.1.1.4.2 st_makeMBR(lng1,lat1,lng2,lat2)
功能
•
input
•
•
•
•
•
为长方形的左下点和右上点,无视顺序
output
•
example
select st_makeMBR(111.11, 22.22,
113.33, 22.33)
1.1.1.4.3 st_makeBBox(lng_min,
lat_min, lng_max, lat_max)
1.1.1.5 创建圆
1.1.1.5.1 st_makeCircleFromCoord(lng,lat,radius)
功能
•
input
•
•
•
output
•
example
select
st_makeCircleFromCoord(114.134488, 22.614742, 500.0)
1.1.1.5.2 st_makeCircle(center,
radius)
功能
•
input
•
•
output
•
example
select
st_makeCircle(st_makePoint(114.134488, 22.614742), 500.0)
1.1.1.6 创建轨迹对象
1.1.1.6.1
st_makeTrajectory(wktString)
功能
•
input
•
output
•
一条轨迹点的时间为随机生成的轨迹
example
select
st_makeTrajectory(
'LINESTRING (106.6416
26.632, 106.641 26.635,106.7091 26.5898)'
)
1.1.1.7 创建路网对象
1.1.1.7.1 st_makeRoadNetwork(collect_list(item))
功能
•
input
•
output
•
example
select
st_makeRoadNetwork(collect_list(item)) from
longgang_rn
1.1.1.8 获取几何对象对应的buffer
1.1.1.8.1 st_makeTrajBuffer(traj_column,
radius)
功能
•
input
•
•
output
•
example
select st_makeTrajBuffer(item,
2000.0) from guiyang
1.1.1.8.2 st_makeBuffer(geometry,
radius)
功能
•
input
•
•
output
•
example
select
st_makeBuffer(st_makePoint(110,20), 500.0)
1.1.1.8.3 st_makeBufferFromWKT
功能
•
input
•
•
output
•
example
select
st_makeBuffer('POINT(114.134488 22.614742)', 500.0)
1.1.1.9 创建最小凹包
1.1.1.9.1 st_makeConcaveHull
(collect_list(geometry_column))
功能
•
input
•
•
output
•
example
select
st_makeConcaveHull(collect_list(block)) from
polygon_table