I've been looking for ways to convert PostGIS to GEOS geometries without linking to or dependency on lwgeom/liblwgeom.
The closest thing I can find is a mention of the pointcloud approach here:
For an alternate example of an extension with a lighter dependency on PostGIS, check out pgpointcloud, which has it's own structure for spatial data (a point patch) and exchanges data with PostGIS via well-known-binary. This removes the liblwgeom dependency, which means it's possible to compile and use pgpointcloud without PostGIS installed, which is not entirely uncommon.
But I do not want to reinvent geometry types, and instead want to use what GEOS already have (, which I understand, corresponds to be subset of PostGIS/lwgeom types). So I am thinking about the path
PostGIS geometry ==> (step1. via ST_AsEWKB or its like) EWKB ==> (step2. via GEOSGeomFromWKB_buf) GEOS geometry ==> call geos functions...
But I am not familiar with the code structures of the packages.
What I know so far are:
ST_AsEWKB for step1, but I guess I'll need a C/C++ equivalent.
Some examples reading WKB in step2.
/* WKB input */ g2 = GEOSGeomFromWKB_buf(uptr, size); free(uptr);
Can anyone with the expertise give some pointers to completing the loop? (e.g. about specific pointcloud functions, better work flows, etc.)
(My target environment is a PostgreSQL extension (PostgreSQL 11) with GEOS 3.7 and PostGIS 2.5 as of Jan 2019.)