我正在玩PostGIS,我不明白这个请求有什么问题?
WITH ligne AS (SELECT 42 AS id, ST_transform('SRID=4326;LINESTRING(2.232 48.818, 2.246 48.82)'::geometry, 27572) AS geom)
SELECT ST_locate_along_measure(ST_addmeasure(geom, 0, ST_Length(geom)), generate_series(0, ST_length(geom)::int, 50)) FROM ligne;
我收到错误:错误:函数和运算符最多只能占用一个参数
此请求正在运行,但我不明白两者之间的区别:
WITH ligne AS (SELECT 42 AS id, ST_transform('SRID=4326;LINESTRING(2.232 48.818, 2.246 48.82)'::geometry, 27572) AS geom),
ligne3dm AS (SELECT ST_addmeasure(geom, 0, ST_Length(ligne.geom)) as geom FROM ligne),
pas50m AS (SELECT generate_series(0, ST_length(ligne.geom)::int, 50) as pas FROM ligne)
SELECT ROW_NUMBER() OVER () AS id, ST_locate_along_measure(ligne3dm.geom, pas50m.pas) FROM ligne3dm, pas50m;
答案 0 :(得分:1)
解决方案很简单,generate_series返回一个生成器,但ST_Locate_Along_Measure正在等待一个整数。
这将有效:
WITH ligne AS (SELECT 42 AS id, ST_transform('SRID=4326;LINESTRING(2.232 48.818, 2.246 48.82)'::geometry, 27572) AS geom),
generator AS (SELECT generate_series(0, ST_Length(ligne.geom)::int, 50) as pas FROM ligne)
SELECT ST_locate_along_measure(ST_addmeasure(ligne.geom, 0, ST_Length(ligne.geom)), generator.pas) FROM ligne, generator;