add rivers.sql
setting fixture up.
This commit is contained in:
parent
485c1479ec
commit
3d0adae810
38
Makefile
38
Makefile
@ -1,5 +1,5 @@
|
||||
SOURCE ?= lithuania-latest.osm.pbf
|
||||
WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Žeimena' OR name='Lakaja'
|
||||
OSM ?= lithuania-latest.osm.pbf
|
||||
WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas'
|
||||
#WHERE ?= name like '%'
|
||||
SLIDES = slides-2021-03-29.pdf
|
||||
|
||||
@ -112,7 +112,8 @@ selfcrossing-1-after_1SELECT = wm_debug where name='selfcrossing-1' AND stage='d
|
||||
selfcrossing-1-after_2SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1
|
||||
selfcrossing-1-after_2LINESTYLE = invisible
|
||||
|
||||
.faux_test-integration: tests-integration.sql wm.sql .faux_aggregate-rivers
|
||||
|
||||
.faux_test-integration: tests-integration.sql wm.sql .faux_db
|
||||
./db -f $<
|
||||
touch $@
|
||||
|
||||
@ -122,18 +123,7 @@ selfcrossing-1-after_2LINESTYLE = invisible
|
||||
|
||||
.faux_db: db init.sql
|
||||
./db start
|
||||
./db -f init.sql
|
||||
touch $@
|
||||
|
||||
$(SOURCE):
|
||||
wget http://download.geofabrik.de/europe/$@
|
||||
|
||||
.faux_aggregate-rivers: aggregate-rivers.sql .faux_import-osm Makefile
|
||||
./db -v where="$(WHERE)" -f $<
|
||||
touch $@
|
||||
|
||||
.faux_import-osm: $(SOURCE) .faux_db
|
||||
PGPASSWORD=osm osm2pgsql -c --multi-geometry -H 127.0.0.1 -d osm -U osm $<
|
||||
./db -f init.sql -f rivers.sql
|
||||
touch $@
|
||||
|
||||
################################
|
||||
@ -155,7 +145,7 @@ slides-2021-03-29.pdf: slides-2021-03-29.txt
|
||||
pandoc -t beamer -i $< -o $@
|
||||
|
||||
dump-debug_wm.sql.xz:
|
||||
docker exec -ti wm-mj pg_dump -Uosm osm -t debug_wm | xz -v > $@
|
||||
docker exec -ti wm-mj pg_dump -Uosm osm -t wm_devug | xz -v > $@
|
||||
|
||||
mj-msc-gray.pdf: mj-msc.pdf
|
||||
gs \
|
||||
@ -171,7 +161,7 @@ mj-msc-gray.pdf: mj-msc.pdf
|
||||
.PHONY: clean
|
||||
clean: ## Clean the current working directory
|
||||
-./db stop
|
||||
-rm -r .faux_test .faux_aggregate-rivers .faux_import-osm .faux_db \
|
||||
-rm -r .faux_test .faux_aggregate-rivers .faux_db \
|
||||
version.inc.tex vars.inc.tex version.aux version.fdb_latexmk \
|
||||
_minted-mj-msc \
|
||||
$(shell git ls-files -o mj-msc*) \
|
||||
@ -186,3 +176,17 @@ clean-tables: ## Remove tables created during unit or integration tests
|
||||
.PHONY: help
|
||||
help: ## Print this help message
|
||||
@awk -F':.*?## ' '/^[a-z0-9.-]*: *.*## */{printf "%-18s %s\n",$$1,$$2}' $(MAKEFILE_LIST)
|
||||
|
||||
$(OSM):
|
||||
wget http://download.geofabrik.de/europe/$@
|
||||
|
||||
.PHONY: refresh-rivers
|
||||
refresh-rivers: aggregate-rivers.sql $(OSM) .faux_db ## Refresh rivers.sql from Open Street Maps
|
||||
PGPASSWORD=osm osm2pgsql -c --multi-geometry -H 127.0.0.1 -d osm -U osm $(OSM)
|
||||
./db -v where="$(WHERE)" -f $<
|
||||
(\
|
||||
echo '-- Generated at $(shell TZ=UTC date +"%FT%TZ") on $(shell whoami)@$(shell hostname -f)'; \
|
||||
echo '-- Select: $(WHERE)'; \
|
||||
docker exec -ti wm-mj pg_dump --clean -Uosm osm -t wm_rivers | tr -d '\r' \
|
||||
) > rivers.sql.tmp
|
||||
mv rivers.sql.tmp rivers.sql
|
||||
|
24
layer2img.py
24
layer2img.py
@ -6,14 +6,25 @@ import matplotlib.pyplot as plt
|
||||
|
||||
from matplotlib import rc
|
||||
|
||||
# CMAP = 'Set3' # this is nice too
|
||||
# CMAP = 'Set3' # is nice too
|
||||
CMAP = 'tab20c'
|
||||
|
||||
BOUNDS = ('xmin', 'ymin', 'xmax', 'ymax')
|
||||
INCH = 25.4 # mm
|
||||
BLACK, GREEN, ORANGE, PURPLE = '#000000', '#1b9e77', '#d95f02', '#7570b3'
|
||||
PSQL_CREDS = "host=127.0.0.1 dbname=osm user=osm password=osm"
|
||||
|
||||
|
||||
def plt_size(string):
|
||||
if not string:
|
||||
return None
|
||||
try:
|
||||
w, h = string.split("x")
|
||||
return float(w) / INCH, float(h) / INCH
|
||||
except Exception as e:
|
||||
raise argparse.ArgumentTypeError from e
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Convert geopackage to an image')
|
||||
@ -34,6 +45,11 @@ def parse_args():
|
||||
|
||||
parser.add_argument('-o', '--outfile', metavar='<file>')
|
||||
parser.add_argument('--clip', type=float, nargs=4, metavar=BOUNDS)
|
||||
parser.add_argument(
|
||||
'--size',
|
||||
type=plt_size,
|
||||
help='Figure size in mm (WWxHH)',
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@ -44,19 +60,19 @@ def read_layer(select):
|
||||
sql = "SELECT way FROM %s" % select
|
||||
return geopandas.read_postgis(sql, con=conn, geom_col='way')
|
||||
|
||||
|
||||
def plot_args(color, maybe_cmap, maybe_linestyle):
|
||||
if maybe_cmap:
|
||||
r = {'cmap': CMAP}
|
||||
else:
|
||||
r = {'color': color}
|
||||
|
||||
if maybe_linestyle == 'invisible':
|
||||
r['color'] = (0, 0, 0, 0)
|
||||
elif maybe_linestyle:
|
||||
r['linestyle'] = maybe_linestyle
|
||||
|
||||
return r
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
group1 = read_layer(args.group1_select)
|
||||
@ -69,6 +85,8 @@ def main():
|
||||
rc('text', usetex=True)
|
||||
fig, ax = plt.subplots()
|
||||
fig.set_figwidth(8.27 / args.widthdiv)
|
||||
if args.size:
|
||||
fig.set_size_inches(args.size)
|
||||
if c := args.clip:
|
||||
ax.set_xlim(left=c[0], right=c[2])
|
||||
ax.set_ylim(bottom=c[1], top=c[3])
|
||||
|
15
mj-msc.tex
15
mj-msc.tex
@ -32,6 +32,14 @@
|
||||
\newcommand{\MYTITLE}{Cartographic Generalization of Lines using free software (example of rivers)}
|
||||
\newcommand{\MYAUTHOR}{Motiejus Jakštys}
|
||||
|
||||
\iffalse
|
||||
a4: 210x297mm
|
||||
a5: 148x210mm
|
||||
a6: 105x148xmm
|
||||
a7: 74x105mm
|
||||
a8: 52x74mm
|
||||
\fi
|
||||
|
||||
\title{\MYTITLE}
|
||||
\author{\MYAUTHOR}
|
||||
\date{\VCDescribe}
|
||||
@ -140,9 +148,10 @@ Both algorithms are part of PostGIS, a free-software GIS suite:
|
||||
\href{https://postgis.net/docs/ST_SimplifyVW.html}{PostGIS SimplifyVW}.
|
||||
\end{itemize}
|
||||
|
||||
Since both algorithms produce jagged output lines, it is worthwhile to process
|
||||
those through a widely available Chaikin's line smoothing
|
||||
algorithm \cite{chaikin1974algorithm} via
|
||||
Examples of <TBD Chaikin and others>
|
||||
|
||||
It may be worthwhile to post-process those through a widely available Chaikin's
|
||||
line smoothing algorithm \cite{chaikin1974algorithm} via
|
||||
\href{https://postgis.net/docs/ST_ChaikinSmoothing.html}{PostGIS
|
||||
ChaikinSmoothing}.
|
||||
|
||||
|
53
rivers.sql
Normal file
53
rivers.sql
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user