wm/README.md

87 lines
2.7 KiB
Markdown
Raw 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)
2021-05-28 06:24:23 +03:00
Status & Structure
------------------
2021-05-19 22:57:49 +03:00
2021-05-28 06:24:23 +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:23 +03:00
- MSc thesis `mj-msc-full.pdf` with visual examples and known issues.
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 22:57:49 +03:00
Contributing
------------
2021-05-20 22:08:30 +03:00
This repository does not accept contributoins. Please fork it. If a fork has
improved the algorithm substantially, you are welcome to ping me, I will link
to it in this README.
2021-05-19 22:57:49 +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.