postgis feature : pgsql2shp symbol map (1/2)

A new feature has been implemented for PostGIS to be used with Humanitarian OpenStreetMap. The proposed patch was written for version 2.0 and backported to version1.5.

howto contribute

Vincent Picavet says postgis is very open to contributions as long as :

If these conditions are met, the patch must be added the relevant ticket in the postgis trac and posted on the development mailing list for discussion and testing. Once a consensus is reach (it happens most of the time) one of the commiters will commit the patch to the trunk.
If it turns out that the patch is not a trivial functionality, it is better to develop it against the 2.0 trunk, where most of the development is currently focused. In any case, describing the functionality on the list to get early feedback is the best way to make sure the patch is relevant.
A user identifier must be created on and can then be used on the postgis trac.

pgsql2shp tests in trunk

A minimal patch to add tests for the pgsql2shp source files was announced to the mailing list.
The tests are only run if the –with-gui configure flag is given, which requires the following packages to be installed:

apt-get install pkg-config libgtk2.0-dev

If the tests are interrupted unexpectedly, the database is not removed and will prevent further runs of make check. It can be dropped with:

loic@rodo1:~/trunk$ psql postgres
psql (8.4.7)
Type "help" for help.

postgres=# drop database postgis_reg;
drop database postgis_reg;
postgres=# \q

pgsql2shp symbol map

The desired functionality is, as described by Rodolphe Quiedeville, When using pgsql2shp with table fields name longer than 10 digits pgsql2shp truncate and generate a 10 digits fields name. It will be very useful to add an option on pgsql2shp that define a filename witch contains a 2 fields that associate a 10 digits fields name to the longer fields name.. It was introduced in a trac ticket and announced to the development mailing list for discussion.
A few discussions happened on the IRC channel ( but the developpers were unfortunately not present at the time. The 2.0 code was checked out

svn co

and compiled

./configure --with-gui
make -j8

In order for the tests to run, a new postgres user must exist under the name ${USERNAME} and have enough privilege to create the database in which the tests will be conducted.The tests themselves are run with:

make check
make -C loader/cunit check

An attempt was made to trace the regression tests from the 1.5 version. The idea was primarily to replace the unit tests that do not exist in 1.5 for the loader directory, but this direction was abandonned when the cunit tests were discovered in the 2.0 codebase.

postgis-1.5.1/regress$ USE_VERSION=84 bash -x ./run_test --nocreate loader/Point

The proposed patch needs work but the tests show it works and if it is accepted on principle, there should be only cosmetic changes to apply.

checking for memory corruption

The tests are run with valgrind to validate that there is no memory corruption.

trunk/loader/cunit$ valgrind cu_tester
==23014== Memcheck, a memory error detector
==23014== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==23014== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==23014== Command: cu_tester

     CUnit - A Unit testing framework for C - Version 2.1-0

Suite: GUI Shapefile Loader File List Test
  Test: test_append_file() ... passed
  Test: test_find_file() ... passed
  Test: test_traversal() ... passed
  Test: test_remove_first() ... passed
  Test: test_remove_last() ... passed
  Test: test_remove_middle() ... passed
  Test: test_find_index() ... passed
Suite: Shapefile Loader File pgsql2shp Test
  Test: test_ShpDumperCreate() ... passed
  Test: test_ShpDumperGeoMapRead() ... passed

--Run Summary: Type      Total     Ran  Passed  Failed
               suites        2       2     n/a       0
               tests         9       9       9       0
               asserts     132     132     132       0
==23014== HEAP SUMMARY:
==23014==     in use at exit: 2,558 bytes in 194 blocks
==23014==   total heap usage: 254 allocs, 60 frees, 8,683 bytes allocated
==23014== LEAK SUMMARY:
==23014==    definitely lost: 964 bytes in 113 blocks
==23014==    indirectly lost: 1,594 bytes in 81 blocks
==23014==      possibly lost: 0 bytes in 0 blocks
==23014==    still reachable: 0 bytes in 0 blocks
==23014==         suppressed: 0 bytes in 0 blocks
==23014== Rerun with --leak-check=full to see details of leaked memory
==23014== For counts of detected and suppressed errors, rerun with: -v
==23014== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)

backporting to 1.5

The 2.0 release is still 3 month away and Humanitarian OpenStreetMap requires a patch against 1.5. A backport was added to the ticket and it was made into a dedicated debian package that can be installed from


or recompiled from source at:


The corresponding changelog entry shows:

postgis (1.5.1-6~hot) unstable; urgency=low

  * backport
    into patches/osgeo-885.dpatch

 -- Loic Dachary (  Sun, 27 Mar 2011 19:10:27 +0200
This entry was posted in openstreetmap. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>