Wang–Müller line simplification algorithm in PostGIS
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Motiejus Jakštys ebafd19680 update README w.r.t. notable fork again 2 years ago
.gitignore postgis and postgresql logos 3 years ago
COPYING Add license 3 years ago
Dockerfile clean up files 3 years ago
Makefile re-add; add a notable fork 2 years ago update README w.r.t. notable fork again 2 years ago
aggregate-rivers.sql also import GDR50 and GDR250 3 years ago
amalgamate1.png amalgamation 3 years ago
bib.bib acknowledgments 3 years ago
db support in-container make 3 years ago
extract-and-generate gentler remove 3 years ago
gdr2pgsql also import GDR50 and GDR250 3 years ago
github-wm.png add github screenshot 3 years ago
in-container [in-container] fix directories 3 years ago
init.sql use smaller number of rivers during development 3 years ago more consistent figure names 3 years ago
mj-msc-full.pdf stamp 3 years ago
mj-msc.tex update links to listings 3 years ago
openmap-wm-bad.png test harness 3 years ago
openmap-wm-good.png test harness 3 years ago
osi-logo.pdf a few more figures 3 years ago
postgis-logo.png postgis and postgresql logos 3 years ago
postgresql-logo.pdf postgis and postgresql logos 3 years ago
rivers-10.sql update all rivers from the new data source 3 years ago
rivers-50.sql update all rivers from the new data source 3 years ago
rivers-250.sql update all rivers from the new data source 3 years ago
salvis.png add salvis.png and README 3 years ago
slides-2021-03-29.txt remove demo 3 years ago
slides-2021-06-02.pdf Add final MSc thesis presentation 3 years ago
slides-2021-06-02.tex language 3 years ago
test-rivers.sql update README and docs 3 years ago
test.sql fix remaining bugs. gone from debug mode. 3 years ago
vars.awk test harness 3 years ago
visuals.sql default intersect_patience is 50 3 years ago
vu.pdf add generated vu.pdf 3 years ago
wang125-2.png more pics 3 years ago
wang125.png add wang125 3 years ago
wm.sql default intersect_patience is 50 3 years ago

WangMüller line generalization algorithm in PostGIS

This is WangMüller line generalization algorithm implementation in PostGIS. Following "Line generalization based on analysis of shape characteristics" by the same authors, 1998.

line simplification example


The repository is no longer developed and archived. Notable forks:

If you have used this code as a basis and created an improved version, ping me, I will link it from this README.


There are 2 main pieces:

  • wm.sql, the implementation.
  • MSc thesis mj-msc-full.pdf with visual examples and known issues.
  • A few presentations.

It contains a few supporting files, notably:

  • tests.sql synthetic unit tests.
  • test-rivers.sql tests with real rivers.
  • Makefile glues everything together.
  • converts a PostGIS layer to an embeddable image.
  • aggregate-rivers.sql combines multiple river objects (linestrings or multilinestrings) to a single one.
  • init.sql initializes PostGIS database for running the tests.
  • rivers-*.sql are national dataset snapshots of rivers (Makefile contains code to update them).
  • ... and a few more files necessary to build the paper.


make help lists the select commands for humans. As of writing:

# make help
clean              Clean the current working directory
clean-tables       Remove tables created during unit or rivers tests
help               Print this help message
mj-msc-full.pdf    Thesis for publishing
mj-msc-gray.pdf    Gray version, to inspect monochrome output
refresh-rivers     Refresh river data from national datasets
test-rivers        Rivers tests (slow)
test               Unit tests (fast)

To execute the algorithm, run:

  • make test for tests with synthetic data.
  • make test-rivers for tests with real rivers. You may adjust the rivers and data source (e.g. use a different country instead of Lithuania) by changing the Makefile and the test files. Left as an exercise for the reader.

N.B. the make test-rivers fails (see test-rivers.sql), because with higher dhalfcircle values, the unionized river (salvis) is going on top of itself, making the resulting geometry invalid during the process.

Building the paper (pdf)

# make -j mj-msc-full.pdf

mj-msc.tex results in mj-msc-full.pdf. This step needs quite a few or a container: see Dockerfile for dependencies or in-container to run it all in the container.


Nacionalinė Žemės Tarnyba for the river data sets.


GPLv2 or later.