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

Regina Obe lr at pcorp.us
Sat Jun 25 14:48:56 PDT 2022


liblwgeom.so is not separate anymore and liblwgeom.h is not installed either. They are all just object libraries, statically linked in all the .sos we expose as needed.

You can take a look at https://trac.osgeo.org/postgis/ticket/4260  and https://github.com/postgis/postgis/pull/348/

where it was removed and back track those changes.

 

By the way  https://postgis.net/docs/ST_ReducePrecision.html is a better alternative to ST_SnapToGrid as it’s much less likely to produce invalid geometries, but as mentioned only available if you have GEOS 3.9+

 

 

Hope that helps,

Regina

 

 

 

From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of pt122 at gmx.net
Sent: Friday, June 24, 2022 5:01 AM
To: postgis-users at lists.osgeo.org
Subject: Re: [postgis-users] Postgis 3.0: How to convert liblwgeom to librttopo?

 

Hi Regina, thank you very much for your valuable and fast reply. What I want to

achive is quite similar to st_snaptogrid(). I'll surely give it a try to replace our function

(developed in 2013) with one or more of these functions you mentioned at some

point in the future. But, for now, I'd like to try to go forward with liblwgeom in the

first place and I am glad for your hint that it is still a usable part of PostGIS 3.x.

 

So, two questions arise:

 

(How) can I build PostGIS via gcc and special flags from source to get the required

liblwgeom.h and liblwgeom.so files?

 

Or is liblwgeom already contained in the "normal" installable package, with some

way to access it?

  

Thank you, Sven

  

Gesendet: Freitag, 24. Juni 2022 um 02:47 Uhr
Von: "Regina Obe" <lr at pcorp.us <mailto:lr at pcorp.us> >
An: "'PostGIS Users Discussion'" <postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org> >
Betreff: Re: [postgis-users] Postgis 3.0: How to convert liblwgeom to librttopo?

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 <mailto:pt122 at gmx.net> 
> Sent: Thursday, June 23, 2022 4:52 PM
> To: postgis-users at lists.osgeo.org <mailto: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 <mailto:postgis-users at lists.osgeo.org> 
> https://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org> 
https://lists.osgeo.org/mailman/listinfo/postgis-users

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20220625/5453e582/attachment.htm>


More information about the postgis-users mailing list