[postgis-devel] Update of the integration of MobilityDB and PostGIS 3

Esteban Zimanyi esteban.zimanyi at ulb.be
Tue Aug 31 01:37:18 PDT 2021


Dear all

Following the recommendations we received at the PostGIS Dev meeting this
August 20, 2021, we were able to include the liblwgeom source files from
PostGIS 3.1.3 inside MobilityDB. The build, which works for both PostGIS
2.5.5 and 3.1, is in the branch
https://github.com/MobilityDB/MobilityDB/commits/towards-postgis3
The tests on Github Actions were done with version 3.1.1 (which is the one
packaged for Linux with PostgreSQL 13), while we did the tests on our
machines with version 3.1.3.

The source files of the PostGIS directories liblwgeom, libpgcommon, and
ryu, in addition to the two files postgis_config.h and postgis_revision.h
were copied into the directory MobilityDB/postgis. Minimal changes were
done to these files, basically removing static keywords for the functions
getSRSbySRID, getSRIDbySRS, and circ_tree_distance_tree_internal so that
they can be called by MobilityDB. Furthermore, we replicated some of the
configuration PostGIS performs in order to produce the right
postgis_config.h according to the machine characteristics at hand, for
example for setting the machine endian or the version of the required
libraries such as GEOS.

The basic idea of the build is that if a PostGIS version less than 3.0 is
found, then library liblwgeom.so is loaded. Otherwise, the directory
MobilityDB/postgis is added to the build.

We needed to modify the MobilityDB regression tests to cope with changes in
PostGIS from versions 2.5.5 to 3.1.3. There are mainly two types of
modifications. The first one concerns a very small floating point precision
difference across versions, as shown in the following extract of diff file

 SELECT ST_AsText(trajectory(tnpoint 'Npoint(1, 0.5)@2000-01-01'));
-                 st_astext
---------------------------------------------
- POINT(48.71866291282778 77.76407051015086)
+                st_astext
+------------------------------------------
+ POINT(48.7186629128278 77.7640705101509)
 (1 row)

The reason is that PostGIS 3 started using the ryu library to output
coordinate values. We had similar differences between PostgreSQL version 12
and 13 and we solved those problem with the setPrecision functions
https://docs.mobilitydb.com/MobilityDB/develop/ch04s05.html#box_setPrecision
https://docs.mobilitydb.com/MobilityDB/develop/ch05s06.html#tpoint_setPrecision
We extended the setPrecision function for geometry/geography so that for
example, the test above

SELECT ST_AsText(trajectory(tnpoint 'Npoint(1, 0.5)@2000-01-01'));

was replaced by

SELECT ST_AsText(setPrecision(trajectory(tnpoint 'Npoint(1,
0.5)@2000-01-01'), 6));

We are aware that functions ST_AsText and ST_AsEWKT have an optional
parameter specifying the number of decimals to be output, but this is
available only since PostGIS version 3 and we needed a solution that also
works for PostGIS 2.5.

Another type of difference concerns discrepancies in the result of some
PostGIS functions from version 2.5.5 to version 3.1. In order to solve the
discrepancies we "commented out" the results of some tests, while keeping
their execution for testing robustness and keeping coverage values.

More precisely, since the result of the function lwgeom_hash for
geographies (which is used for B-Tree comparison of temporal values)
changed in PostGIS 3, we replaced the tests such as

SELECT tgeogpoint 'Point(1.5 1.5)@2000-01-01' < tgeogpoint 'Point(2.5
2.5)@2000-01-01';

by

SELECT 1 WHERE tgeogpoint 'Point(1.5 1.5)@2000-01-01' < tgeogpoint
'Point(2.5 2.5)@2000-01-01' IS NOT NULL;

Similarly, since the result of the ST_Azimuth function changed in PostGIS
3, we replaced the tests such as

SELECT round(degrees(azimuth(tgeogpoint '[Point(1.5 1.5)@2000-01-01,
Point(2.5 2.5)@2000-01-02]')), 6);

by

SELECT 1 WHERE round(degrees(azimuth(tgeogpoint '[Point(1.5
1.5)@2000-01-01, Point(2.5 2.5)@2000-01-02]')), 6) IS NOT NULL;

We are ready to release a new MobilityDB beta version with these changes
but before that we need to discuss with the PostGIS development team about
the license implications. The current license for MobilityDB is as follows

/*****************************************************************************
 *
 * This MobilityDB code is provided under The PostgreSQL License.
 *
 * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
 * contributors
 *
 * MobilityDB includes portions of PostGIS version 3 source code
 * released under the GNU General Public License (GPLv2 or later).
 * Copyright (c) 2001-2021, PosGIS contributors
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without a written
 * agreement is hereby granted, provided that the above copyright notice and
 * this paragraph and the following two paragraphs appear in all copies.
 *
 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY
FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
INCLUDING
 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION,
 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON
 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 *****************************************************************************/

We propose to modify this license as follows

/*****************************************************************************
 *
 * This MobilityDB code is provided under The PostgreSQL License.
 *
 * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
 * contributors
 *
 * MobilityDB includes portions of PostGIS version 3 source code released
 * under the GNU General Public License (GPLv2 or later).
 * Copyright (c) 2001-2021, PostGIS contributors
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without a written
 * [...]
 *
 *****************************************************************************/

Could you please confirm that everything is OK with this license
modification ?

Many thanks again to Vicky Vergara and Regina Obe who made this possible.

Regards

Esteban
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20210831/dd66b345/attachment-0001.html>


More information about the postgis-devel mailing list