I'm using PostGIS 2.5.2 on PostgreSQL 10, and I'm trying to build a function which would split a LineString into portions, depending on points positionned close to it. I'm getting a Geometry type (Point) does not match column type (LineString) error, and I can't figure out why. I've stumbled upon this old answer but it's not helping me. Here's where the error comes from :
INSERT INTO portions_lignes(id_parcours, ordre_portion_parcours, id_arret, geom)
VALUES(line_id, prior_point.ordre_arret_parcours, prior_point.id_arret, ST_LineSubstring(linestring, 0, ST_LineLocatePoint(linestring, current_point.geom) / 2));
Where portions_lignes.geom is a LineString geometry type, linestring is also a LineString, and current_point.geom is a Point geometry type.
All geometry types are in SRID 4326, my goal here is just to insert into portions_lignes a particular line_substring (using ST_LineSubstring) from the linestring parameter, which is passed to the function and declared like this :
CREATE OR REPLACE FUNCTION splitLine(
line_id character varying,
linestring geometry(LineString,4326)
)
ST_LineLocatePoint ...returns0asendfraction(i.e. closest point is the start point),ST_LineSubstringreturns aPOINT. – geozelot May 06 '19 at 10:58ST_LineSubstringdocumentation. – Adrien May 06 '19 at 11:05