wm

Wang–Müller line generalization algorithm in PostGIS
Log | Files | Refs | README | LICENSE

README.md (2882B) - Raw


      1 Wang–Müller line generalization algorithm in PostGIS
      2 ----------------------------------------------------
      3 
      4 This is Wang–Müller line generalization algorithm implementation in PostGIS.
      5 Following "Line generalization based on analysis of shape characteristics" by
      6 the same authors, 1998.
      7 
      8 ![line simplification example](https://raw.githubusercontent.com/motiejus/wm/main/salvis.png)
      9 
     10 Status
     11 ------
     12 
     13 The repository is no longer developed and archived. Notable forks:
     14 
     15 - [github.com/openmaplt/wm](https://github.com/openmaplt/wm): seems like they
     16   are seriously continuing the development of the algorithm.
     17 
     18 If you have used this code as a basis and created an improved version, ping me,
     19 I will link it from this README.
     20 
     21 Structure
     22 ---------
     23 
     24 There are 2 main pieces:
     25 
     26 - `wm.sql`, the implementation.
     27 - MSc thesis `mj-msc-full.pdf` with visual examples and known issues.
     28 - A few presentations.
     29 
     30 It contains a few supporting files, notably:
     31 
     32 - `tests.sql` synthetic unit tests.
     33 - `test-rivers.sql` tests with real rivers.
     34 - `Makefile` glues everything together.
     35 - `layer2img.py` converts a PostGIS layer to an embeddable image.
     36 - `aggregate-rivers.sql` combines multiple river objects (linestrings or
     37   multilinestrings) to a single one.
     38 - `init.sql` initializes PostGIS database for running the tests.
     39 - `rivers-*.sql` are national dataset snapshots of rivers (`Makefile`
     40   contains code to update them).
     41 - ... and a few more files necessary to build the paper.
     42 
     43 Running
     44 -------
     45 
     46 `make help` lists the select commands for humans. As of writing:
     47 
     48 ```
     49 # make help
     50 clean              Clean the current working directory
     51 clean-tables       Remove tables created during unit or rivers tests
     52 help               Print this help message
     53 mj-msc-full.pdf    Thesis for publishing
     54 mj-msc-gray.pdf    Gray version, to inspect monochrome output
     55 refresh-rivers     Refresh river data from national datasets
     56 test-rivers        Rivers tests (slow)
     57 test               Unit tests (fast)
     58 ```
     59 
     60 To execute the algorithm, run:
     61 
     62 - `make test` for tests with synthetic data.
     63 - `make test-rivers` for tests with real rivers. You may adjust the rivers and
     64   data source (e.g. use a different country instead of Lithuania) by changing
     65   the `Makefile` and the test files. Left as an exercise for the reader.
     66 
     67 N.B. the `make test-rivers` fails (see `test-rivers.sql`), because with higher
     68 `dhalfcircle` values, the unionized river (`salvis`) is going on top of itself,
     69 making the resulting geometry invalid during the process.
     70 
     71 Building the paper (pdf)
     72 ------------------------
     73 
     74 ```
     75 # make -j mj-msc-full.pdf
     76 ```
     77 
     78 `mj-msc.tex` results in `mj-msc-full.pdf`. This step needs quite a few
     79 or a container: see `Dockerfile` for dependencies or `in-container` to run
     80 it all in the container.
     81 
     82 Credit
     83 ------
     84 
     85 [Nacionalinė Žemės Tarnyba](http://nzt.lt/) for the river data sets.
     86 
     87 License
     88 -------
     89 
     90 GPLv2 or later.