為了測試或驗證需要,通常需要快速的構建測試數(shù)據(jù)(空間數(shù)據(jù))扫步。
模擬需要生成隨機點范圍
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
生成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