<div dir="ltr">I'm using GEOS with the C API - I am trying to do something that as far as I can tell from the documentation should be possible but I've tried every call I think might do it and cannot get it to work:<br><br>I have a GEOS_POLYGON (or GEOS_MULTIPOLYGON) in one GEOSGeometry object and a GEOS_LINESTRING (or GEOS_MULTILINESTRING) in another, and I want to merge them into a single GEOS_GEOMETRYCOLLECTION object containing both lines and polygons.<br><br>What's the right way to do this?<br><br>The example I'm testing with is that I take a polygon and create a set of overlapping lines to hatch it. I can clip the lines using the polygon to create the hatching pattern OK, but I can't add the polygon to those lines to include the outline. (I'd also rather leave the polygon as a polygon and not be forced to downgrade it to a set of lines in order to add it to the compound object.)<br><br>For the moment I'm working around the problem by drawing the hatch pattern and the outline separately, but ultimately I need to union them into a single object.<br><br>I'll try to include an image with this post of what the result should look like.<br><br>The top-level code for the test is in  <a href="http://gtoal.com/src/polygon/testnew.c">http://gtoal.com/src/polygon/testnew.c</a> and the code for the hatching is in <a href="http://gtoal.com/src/polygon/polygon-package.c">http://gtoal.com/src/polygon/polygon-package.c</a>   (  see void Hatch(Polygon g, double gap, double rot)  )<br><br>I would have expected the "Union()" procedure in the latter file to have done what I wanted, but it didn't - I tried creating a "Merge()" procedure instead in a desperate effort to force the two objects into a single collection, but like all the attempts before it, it did not work. Most efforts ended up with only one of the two input objects being present in the output object. (That version of Merge() was but the last of many, the methods I tried getting more esoteric with each attempt, starting from the basic "<span style="color:rgb(0,0,0);white-space:pre-wrap">c = GEOSUnion(a, b);" </span>)<br><br>Hopefully this is a newbie error with a simple solution!  I'ld appreciate any suggestions.<br><br>thanks,<br><br>Graham<div>PS  what I'm working on is an interface to the polygon code that will make it easier to use with some code that drives my CNC cutter.</div><div><br></div><div><img src="cid:ii_ld256b580" alt="poly.png" width="228" height="230"></div></div>