Interface crashing with lack of contour data

Added by Richard about 3 years ago

Hi All,

I've run into a problem which causes my mapping app to crash while contouring using the GMT5.1.2 interface.

I have a grid of data points for contouring which span 10 deg in both lat and lon.
Using a gnomonic projection, I inadvertently chose a portion of the globe where no data from my grid exists. When plotting I get the following message:

Error: Input must have at least three input vertices.

This message can be generated in 2 places, line14012 and 14130 of 'triangle.c'. After the message, an exit(status) is executed which kills my app.

Would there be a more graceful way to handle this situation? For example, could the code be modified to return an empty contour set rather than exiting?

Thanks for your time, any help would be much appreciated.

-Rick Carlson


Replies (6)

RE: Interface crashing with lack of contour data - Added by Joaquim about 3 years ago

Richard, thanks for finding and report this. Although triangle.c is an external code we don't want this behavior, which is also fatal for our Matlab, Julia and future Python APIs. I opened issue #764 to keep a track on this.

RE: Interface crashing with lack of contour data - Added by Paul about 3 years ago

Just to be clear, this is happening when you call pscontour? You mention grid but grdcontour does not call triangle. We can certainly add a test to not call the triangulation if there are no data and we would do that on the GMT side. There are lots of calls to exit in triangle.c and most are for fatal things like memory allocation failure deep in the code. Just calling return there may not be helpful. But first let us work on the initial problem.

RE: Interface crashing with lack of contour data - Added by Richard about 3 years ago

Hi Paul,

Yes that's correct, I'm using 'pscontour' to make the plot.
Thanks for looking into this!

-Rick

RE: Interface crashing with lack of contour data - Added by Paul about 3 years ago

I've updated pscontour and triangulate to bail if no data are actually given. In r14861.

RE: Interface crashing with lack of contour data - Added by Richard about 3 years ago

Thanks Paul, I'll give it a try.
-Rick

RE: Interface crashing with lack of contour data - Added by Richard about 3 years ago

Works great Paul, thanks!
-Rick

(1-6/6)