[postgis-users] Postgis 3.0: How to convert liblwgeom to librttopo?

Regina Obe lr at pcorp.us
Thu Jun 23 17:47:22 PDT 2022


liblwgeom is still part of PostGIS but not exposed anymore as a standalone
library and is always statically linked. The reason is it caused too much
headache since we often change it even in micro versions so didn't want
anyone directly relying on it or our own code hooking onto the wrong version
installed in system.

Yes librttopo is a fork and is maintained separate from PostGIS here -
https://git.osgeo.org/gitea/rttopo/librttopo .  

I'm not sure if it has a hard requirement on GEOS.  It definitely has pieces
that use GEOS, so at very least a soft requirement.  It is  a subset of
liblwgeom, that subset that was useful for topology work in particular, but
it probably includes the subset you need.

It's unclear to me what your function does, but some possibly useful
functions to achieve the same goal are:

https://postgis.net/docs/ST_Subdivide.html

https://postgis.net/docs/ST_ClipByBox2D.html

https://postgis.net/docs/ST_SquareGrid.html

https://postgis.net/docs/ST_HexagonGrid.html


Also if you are running GEOS 3.9 (+ PostGIS 3.1+) or higher,  using 
https://postgis.net/docs/ST_ReducePrecision.html (and/or the newer ST_Union,
ST_Intersection, ST_Subdivide) which has reduce precision logic in them
might solve some of your problems) 

Hope that helps,
Regina

> -----Original Message-----
> From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On
Behalf
> Of pt122 at gmx.net
> Sent: Thursday, June 23, 2022 4:52 PM
> To: postgis-users at lists.osgeo.org
> Subject: [postgis-users] Postgis 3.0: How to convert liblwgeom to
librttopo?
> 
> Dear Postgis community, I'm not sure if I'm in the right forum but I want
to
> give it a try. We want to upgrade from PostGIS 2.x to PostGIS 3.x and take
> over a self-written library (.so). This library was compiled with
liblwgeom of
> PostGIS 2.x. liblwgeom seems to be not part of PostGIS 3.x anymore
> (/include/liblwgeom.h is missing for instance).
> 
> According to the comment in https://postgis.net/2019/10/20/postgis-3.0.0/,
> liblwgeom should be replaced with librttopo (which seems to be a fork of
> liblwgeom according to https://github.com/r-spatial/lwgeom/issues/30).
> 
> Our function that makes use of our lib, used for fast scaling, clipping
and
> sorting-out coordinates, looks like:
> 
> CREATE OR REPLACE FUNCTION preprocess(geometry, box2d, ...) RETURNS
> geometry AS 'path/to/lib.so', 'preprocess'
> LANGUAGE c;
> and in the c code are some LWGEOM*, LWMLINE*, LWMPOLY* and lwfree(..)
> calls.
> 
> My questions are:
> 
> - is lwgeom still part of Postgis 3.x? (I still see liblwgeom.h.in as part
of
> postgis-3.2.1.tar.gz, so it seems that is not fully removed yet)
> 
> - if not, what would be a good starting point for conversion?
> 
> - are there any mappings of old and new functions or types available?
> 
> -are there any packages (besides librttopo and librttopo-devel) that must
be
> installed additionally with librttopo (like GEOS or similar)?
> 
> -what are the PostGIS built-in alternatives for scaling and clipping?
> 
> Thank you for any hints, Peter
> 
> (See original post on
> https://gis.stackexchange.com/questions/434369/postgis-3-0-how-to-convert-
> liblwgeom-to-librttopo, but my problem is likely is too specific to ask in
> stackexchange...) _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list