我在gis.stackexchange上问了这个问题(但是因为我的实际问题似乎比GIS更像是一个DB问题,我在这里试试运气).以下是关于gis.stackexchange的问题:https://gis.stackexchange.com/questions/256535/postgis-2-3-splitting-multiline-by-points
我有一个触发器,当我插入一个新行来插入我的表中的分割线组时,我会循环,但由于某种原因我没有得到想要的结果,因为在示例中我只得到三行中的两行.我做错了什么?
这里是触发器功能的代码:
CREATE OR REPLACE FUNCTION public.split_cable()
RETURNS trigger AS
$BODY$
DECLARE compte integer;
DECLARE i integer := 2;
BEGIN
compte = (SELECT count(*) FROM boite WHERE st_intersects(boite.geom, new.geom));
WHILE i < compte LOOP
WITH brs AS (SELECT row_number() over(), boite.geom FROM boite, cable2
WHERE st_intersects(boite.geom, new.geom)
-- here the ORDER BY serve to get the "boite" objects in a specific order
ORDER BY st_linelocatepoint(st_linemerge(new.geom),boite.geom)),
brs2 AS (SELECT st_union(geom) AS geom FROM brs),
cables AS (SELECT (st_dump(st_split(new.geom, …Run Code Online (Sandbox Code Playgroud)