From 71c2a902a49cd8f3fe18ae3052baf5efac2e182d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 19 May 2021 22:57:47 +0300 Subject: [PATCH] add crossings --- Makefile | 3 +++ layer2img.py | 20 ++++++++++++++++---- mj-msc.tex | 2 ++ tests.sql | 9 ++++++--- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4c12dc2..cac812b 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,9 @@ fig6-self-crossing-before.pdf: layer2img.py Makefile .faux_test --group1-where="name='fig6' AND stage='bbends' AND gen=1" \ --group2-table=wm_visuals \ --group2-where="name='fig6-baseline'" \ + --group3-table=wm_visuals \ + --group3-where="name='fig6-newline'" \ + --group3-linestyle=dashed \ --outfile=$@ fig6-self-crossing-after.pdf: layer2img.py Makefile .faux_test diff --git a/layer2img.py b/layer2img.py index dd110d5..181ec5f 100644 --- a/layer2img.py +++ b/layer2img.py @@ -20,17 +20,20 @@ def parse_args(): parser.add_argument('--group1-table') parser.add_argument('--group1-where') parser.add_argument('--group1-cmap', type=bool) + parser.add_argument('--group1-linestyle') parser.add_argument('--group2-table') parser.add_argument('--group2-where') parser.add_argument('--group2-cmap', type=bool) + parser.add_argument('--group2-linestyle') parser.add_argument('--group3-table') parser.add_argument('--group3-where') parser.add_argument('--group3-cmap', type=bool) + parser.add_argument('--group3-linestyle') parser.add_argument('--widthdiv', - default=1, type=float, help='Size divisor') + default=1, type=float, help='Width divisor') parser.add_argument('-o', '--outfile', metavar='') parser.add_argument('--clip', type=float, nargs=4, metavar=BOUNDS) @@ -46,15 +49,24 @@ def read_layer(table, maybe_where=None): sql += " WHERE %s" % maybe_where 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: + r['linestyle'] = maybe_linestyle + return r def main(): args = parse_args() group1 = read_layer(args.group1_table, args.group1_where) group2 = read_layer(args.group2_table, args.group2_where) group3 = read_layer(args.group3_table, args.group3_where) - c1 = {'cmap': CMAP} if args.group1_cmap else {'color': BLACK} - c2 = {'cmap': CMAP} if args.group2_cmap else {'color': ORANGE} - c3 = {'cmap': CMAP} if args.group3_cmap else {'color': GREEN} + c1 = plot_args(BLACK, args.group1_cmap, args.group1_linestyle) + c2 = plot_args(ORANGE, args.group2_cmap, args.group2_linestyle) + c3 = plot_args(GREEN, args.group3_cmap, args.group3_linestyle) rc('text', usetex=True) fig, ax = plt.subplots() diff --git a/mj-msc.tex b/mj-msc.tex index 9bc44f7..909561f 100644 --- a/mj-msc.tex +++ b/mj-msc.tex @@ -184,6 +184,8 @@ open-source tools is an important foundation for future cartographic experimentation and development, thus it it benefits the cartographic society as a whole. + + \section{Methodology} \label{sec:methodology} diff --git a/tests.sql b/tests.sql index 9268db9..808f6af 100644 --- a/tests.sql +++ b/tests.sql @@ -57,10 +57,13 @@ insert into wm_demo (name, way) select name, ST_SimplifyWM(way, name) from wm_fi drop table if exists wm_visuals; create table wm_visuals (name text, way geometry); do $$ - declare fig6 geometry; + declare fig6b1 geometry; + declare fig6b2 geometry; begin - select way from wm_debug where name='fig6' and stage='bbends' and gen=1 into fig6 limit 1 offset 2; - insert into wm_visuals (name, way) values('fig6-baseline', st_makeline(st_startpoint(fig6), st_endpoint(fig6))); + select way from wm_debug where name='fig6' and stage='bbends' and gen=1 into fig6b1 limit 1 offset 0; + select way from wm_debug where name='fig6' and stage='bbends' and gen=1 into fig6b2 limit 1 offset 2; + insert into wm_visuals (name, way) values('fig6-baseline', st_makeline(st_startpoint(fig6b2), st_endpoint(fig6b2))); + insert into wm_visuals (name, way) values('fig6-newline', st_makeline(st_endpoint(fig6b1), st_endpoint(fig6b2))); end $$ language plpgsql; do $$