I am using the following postgis query for updating a pgrouting table from my custom road data. In the x(ST_StartPoint(part_geom)) as x1,
line its returning an error mentioned
ERROR: function x(geometry) does not exist
INSERT INTO public.roads_r (
SELECT DISTINCT ON (the_geom)
nextval('public.roads_r_gid_seq') AS gid,
gid AS parent_gid,
name,
no,
type,
NULL as source,
NULL as target,
ST_Length(part_geom, true) as cost,
ST_Length(part_geom, true) as reverse_cost,
x(ST_StartPoint(part_geom)) as x1,
y(ST_StartPoint(part_geom)) as y1,
x(ST_EndPoint(part_geom)) as x2,
y(ST_EndPoint(part_geom)) as y2,
NULL as to_cost,
NULL as rule,
ST_Multi(part_geom) AS the_geom
FROM (
SELECT
a.gid,
a.geom,
(ST_Dump(ST_Union(b.geom))).geom AS part_geom,
a.road_name as name,
a.road_no as no,
a.road_type as type
FROM public.roads as a, public.roads as b
WHERE ST_Intersects(a.geom, b.geom)
GROUP BY a.gid, a.geom, a.road_name, a.road_no, a.road_type
) AS res
WHERE ST_Contains(geom, part_geom) = true OR ST_Contains(ST_Buffer(geom, 0.00001), part_geom) = true)
Best Answer
No function exists in PostGIS called "x", as the error is telling you.
I am guessing you want to be using the
ST_X()
andST_Y()
functions, instead.