为了测试或验证需要,通常需要快速的构建测试数据(空间数据)。
模拟需要生成随机点范围
SELECT ST_SetSRID(ST_MakeBox2D(ST_Point(119.7342, 29.9602),ST_Point(120.6181 ,30.5581)),4326) geom;
空间范围
生成2000个点
SELECT
(
ST_Dump (
ST_GeneratePoints (kl.geom, 2000)
)).geom AS geom,md5((random()*random())::text) as id,random()*1000 as val
FROM
(
SELECT
ST_SetSRID (
ST_MakeBox2D (
ST_Point (119.7342, 29.9602),
ST_Point (120.6181, 30.5581)
),
4326
) geom
) kl
2000个点
生成20w个点
SELECT
(
ST_Dump (
ST_GeneratePoints (kl.geom, 200000)
)).geom AS geom,md5((random()*random())::text) as id,random()*1000 as val
FROM
(
SELECT
ST_SetSRID (
ST_MakeBox2D (
ST_Point (119.7342, 29.9602),
ST_Point (120.6181, 30.5581)
),
4326
) geom
) kl
20W个点
网友评论