0

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)

2 Answers 2

2

No function exists in PostGIS called "x", as the error is telling you.

I am guessing you want to be using the ST_X() and ST_Y() functions, instead.

1
  • I got another problem in the same code. Now its indication "ST_Multi(part_geom) AS the_geom" and returning an error "INSERT has more expressions than target columns". Could you please give me a kind suggestion? Commented Jun 24, 2013 at 22:05
2

I think ST_X(geom) is what you are looking for.

where did you find that x(geom) syntax?

1
  • I got another problem in the same code. Now its indication "ST_Multi(part_geom) AS the_geom" and returning an error "INSERT has more expressions than target columns". Could you please give me a kind suggestion? Commented Jun 24, 2013 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.