wm/README.md

87 lines
2.6 KiB
Markdown
Raw Normal View History

2021-05-19 22:57:49 +03:00
WangMüller algorithm in PostGIS
--------------------------------
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
the same author, 1998.
Status
------
It mostly works. Read `mj-msc-full.pdf` for visual examples and possible
gotchas.
2021-05-19 22:57:49 +03:00
Structure
---------
2021-05-19 23:09:05 +03:00
There are be 2 deliverables:
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
- `wm.sql`, the implementation.
2021-05-19 22:57:49 +03:00
- paper `mj-msc-full.pdf`, a MSc thesis, explaining it.
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
mj-msc-full.pdf Thesis for publishing
test Unit tests (fast)
test-rivers Rivers tests (slow)
clean Clean the current working directory
clean-tables Remove tables created during unit or rivers tests
help Print this help message
wc Character and page count
refresh-rivers Refresh rivers-*.sql from Open Street Maps
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,
making the resulting geometry invalid.
2021-05-19 22:57:49 +03:00
Building the paper (pdf)
------------------------
2021-05-19 22:57:49 +03:00
```
2021-05-19 22:57:49 +03:00
# make -j$(nproc) mj-msc-full.pdf
2021-05-19 22:57:49 +03:00
```
2021-05-19 22:57:49 +03:00
`mj-msc.tex` results in `mj-msc-full.pdf`, which will be at some point
2021-05-19 23:09:05 +03:00
published to this repo. It needs quite a few dependencies, including a
functioning Docker environment, postgresql client, geopandas, pygments,
osm2pgsql, poppler, and a "quite extensive" LaTeX installation. Tested on
Debian 11.
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
Contributing
------------
2021-05-19 23:09:05 +03:00
This repository is frozen and will not accept contributions. Please fork it.
If fork has improved the algorithm substantially, feel free to ping me, I will
link to it in this README.
2021-05-19 22:57:49 +03:00
2021-05-19 22:57:49 +03:00
License
-------
2021-05-19 23:09:05 +03:00
GPLv2 or later.