wm/README.md

91 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2021-05-19 23:44:13 +03:00
WangMüller line generalization algorithm in PostGIS
----------------------------------------------------
2021-05-19 22:57:49 +03:00
2021-05-19 23:09:05 +03:00
This is WangMüller line generalization algorithm implementation in PostGIS.
Following "Line generalization based on analysis of shape characteristics" by
2021-05-20 22:08:30 +03:00
the same authors, 1998.
2021-05-19 23:09:05 +03:00
2021-05-19 23:36:30 +03:00
![line simplification example](https://raw.githubusercontent.com/motiejus/wm/main/salvis.png)
Status
------
2021-08-10 17:45:34 +03:00
The repository is no longer developed and archived. Notable forks:
- [github.com/openmaplt/wm](https://github.com/openmaplt/wm): seems like they
are seriously continuing the development of the algorithm.
2021-08-10 17:45:34 +03:00
If you have used this code as a basis and created an improved version, ping me,
I will link it from this README.
Structure
---------
2021-05-19 22:57:49 +03:00
2021-05-28 06:24:51 +03:00
There are 2 main pieces:
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
- `wm.sql`, the implementation.
2021-05-28 06:24:51 +03:00
- MSc thesis `mj-msc-full.pdf` with visual examples and known issues.
- A few presentations.
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
It contains a few supporting files, notably:
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
- `tests.sql` synthetic unit tests.
- `test-rivers.sql` tests with real rivers.
- `Makefile` glues everything together.
2021-05-19 22:57:49 +03:00
- `layer2img.py` converts a PostGIS layer to an embeddable image.
2021-05-19 22:57:49 +03:00
- `aggregate-rivers.sql` combines multiple river objects (linestrings or
multilinestrings) to a single one.
2021-05-19 22:57:49 +03:00
- `init.sql` initializes PostGIS database for running the tests.
- `rivers-*.sql` are national dataset snapshots of rivers (`Makefile`
2021-05-19 22:57:49 +03:00
contains code to update them).
2021-05-19 22:57:49 +03:00
- ... and a few more files necessary to build the paper.
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
Running
-------
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
`make help` lists the select commands for humans. As of writing:
2021-05-19 22:57:49 +03:00
```
2021-05-19 22:57:49 +03:00
# make help
2021-05-19 22:57:49 +03:00
clean Clean the current working directory
clean-tables Remove tables created during unit or rivers tests
help Print this help message
2021-05-20 22:14:54 +03:00
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)
2021-05-19 22:57:49 +03:00
```
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
2021-05-19 22:57:49 +03:00
the `Makefile` and the test files. Left as an exercise for the reader.
2021-05-19 22:57:49 +03:00
2021-05-19 23:09:05 +03:00
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,
2021-05-20 22:08:30 +03:00
making the resulting geometry invalid during the process.
2021-05-19 23:09:05 +03:00
2021-05-19 22:57:49 +03:00
Building the paper (pdf)
------------------------
2021-05-19 22:57:49 +03:00
```
2021-05-20 22:08:30 +03:00
# make -j mj-msc-full.pdf
2021-05-19 22:57:49 +03:00
```
2021-05-20 22:08:30 +03:00
`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.
2021-05-19 23:46:29 +03:00
2021-05-19 23:34:53 +03:00
Credit
------
[Nacionalinė Žemės Tarnyba](http://nzt.lt/) for the river data sets.
2021-05-19 22:57:49 +03:00
License
-------
2021-05-19 23:09:05 +03:00
GPLv2 or later.