1

I've been running a scheduled task that contains some SQL code that has been running fine up until a few weeks ago. I don't believe any of the code had changed recently so I went through the debugger and found the following.

The portion of code that fails:

Execute 'create table ab_appl_lines as select gid, disp_num, degrees(st_Azimuth(st_astext(ST_Line_Interpolate_Point(ST_LineMerge(ST_Line_Substring(st_Boundary(the_geom), 0.01, 0.02)), 0.10)), st_astext(ST_Line_Interpolate_Point(ST_LineMerge(ST_Line_Substring(st_Boundary(the_geom), 0.01, 0.02)), 0.2)))) as an_angle,st_Boundary(the_geom) as the_geom from ab_appl where disp_type= ''EZE'' or disp_type= ''REA'' or disp_type= ''VCE'' or disp_type= ''EAS'' or disp_type= ''REC'' or disp_type= ''RDS'' or disp_type= ''RRD'' or disp_type= ''FRD'' or disp_type= ''ROW''or disp_type= ''ISP'' or disp_type= ''DRS'' or disp_type= ''PLA'' or disp_type= ''KRS'' or disp_type= ''LOC'' or disp_type= ''MLL'' or disp_type= ''MLP'' or disp_type= ''MSL'' or disp_type= ''MTS'' or disp_type= ''ROE'' or disp_type= ''PIL'' or disp_type= ''SML'' or disp_type= ''SMC'' or disp_type= ''SME''; alter table ab_appl_lines add primary key(gid);';

The error:

ERROR: line_interpolate_point: 1st arg isnt a line CONTEXT: SQL function "st_line_interpolate_point" statement 2 SQL statement "create table ab_appl_lines as select gid, disp_num, degrees(st_Azimuth(st_astext(ST_Line_Interpolate_Point(ST_LineMerge(ST_Line_Substring(st_Boundary(the_geom), 0.01, 0.02)), 0.10)), st_astext(ST_Line_Interpolate_Point(ST_LineMerge(ST_Line_Substring(st_Boundary(the_geom), 0.01, 0.02)), 0.2)))) as an_angle,st_Boundary(the_geom) as the_geom from ab_appl where disp_type= 'EZE' or disp_type= 'REA' or disp_type= 'VCE' or disp_type= 'EAS' or disp_type= 'REC' or disp_type= 'RDS' or disp_type= 'RRD' or disp_type= 'FRD' or disp_type= 'ROW'or disp_type= 'ISP' or disp_type= 'DRS' or disp_type= 'PLA' or disp_type= 'KRS' or disp_type= 'LOC' or disp_type= 'MLL' or disp_type= 'MLP' or disp_type= 'MSL' or disp_type= 'MTS' or disp_type= 'ROE' or disp_type= 'PIL' or disp_type= 'SML' or disp_type= 'SMC' or disp_type= 'SME'; alter table ab_appl_lines add primary key(gid);" PL/pgSQL function process_create_ab_appl_lines() line 4 at EXECUTE statement

ST_Line_Interpolate_Point takes a linestring and a float as arguments and as far as I can tell that's what I'm passing in the code as ST_Line_Merge? Am I missing something more here?

  • Perhaps there is a new geometry in the table that does not return a linestring from ST_Boundary/ST_Line_Substring/ST_LineMerge. Like an invalid polygon. – user30184 Sep 23 at 17:38
  • As a small test I decided to run the single line of code on some test layers and the error appears to come from the "the_geom" field. It doesn't exist which makes me think the problem is indeed an error with the geometry type... it's just located deeper in the script than I originally though. I believe a table was deleted that is part of an earlier section of the script which creates "the_geom" field. If I can recreate this field I think the code will run. Will post an update later. – AJC Sep 23 at 18:26
0

I believe the problem comes from using the ST_Line_Merge function which can, apart from a LINESTRING, also return a MULTILINESTRING (if the line segments are not adjacent to one another), and that is not compatible with ST_Line_Interpolate_Point which then throws an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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