simpler WHERE clauses
This commit is contained in:
parent
71c2a902a4
commit
d4b89b4253
47
Makefile
47
Makefile
@ -64,74 +64,59 @@ mj-msc-full.pdf: mj-msc.pdf version.inc.tex $(ARCHIVABLES)
|
||||
mv .tmp-$@ $@
|
||||
|
||||
test-figures.pdf: layer2img.py .faux_test
|
||||
python ./layer2img.py --group1-table=wm_figures --outfile=$@
|
||||
python ./layer2img.py --group1-select=wm_figures --outfile=$@
|
||||
|
||||
fig8-definition-of-a-bend.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--group1-table=wm_debug \
|
||||
--group1-where="name='fig8' AND stage='bbends' AND gen=1" \
|
||||
--group1-select="wm_debug where name='fig8' AND stage='bbends' AND gen=1" \
|
||||
--group2-cmap=1 \
|
||||
--group2-table=wm_debug \
|
||||
--group2-where="name='fig8' AND stage='bbends-polygon' AND gen=1" \
|
||||
--group2-select="wm_debug where name='fig8' AND stage='bbends-polygon' AND gen=1" \
|
||||
--outfile=$@
|
||||
|
||||
fig5-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--widthdiv=2 \
|
||||
--group1-table=wm_debug \
|
||||
--group1-where="name='fig5' AND stage='bbends' AND gen=1" \
|
||||
--group1-select="wm_debug where name='fig5' AND stage='bbends' AND gen=1" \
|
||||
--group2-cmap=1 \
|
||||
--group2-table=wm_debug \
|
||||
--group2-where="name='fig5' AND stage='bbends-polygon' AND gen=1" \
|
||||
--group2-select="wm_debug where name='fig5' AND stage='bbends-polygon' AND gen=1" \
|
||||
--outfile=$@
|
||||
|
||||
fig5-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--widthdiv=2 \
|
||||
--group1-table=wm_debug \
|
||||
--group1-where="name='fig5' AND stage='cinflections' AND gen=1" \
|
||||
--group1-select="wm_debug where name='fig5' AND stage='cinflections' AND gen=1" \
|
||||
--group2-select="wm_debug where name='fig5' AND stage='cinflections-polygon' AND gen=1" \
|
||||
--group2-cmap=1 \
|
||||
--group2-table=wm_debug \
|
||||
--group2-where="name='fig5' AND stage='cinflections-polygon' AND gen=1" \
|
||||
--outfile=$@
|
||||
|
||||
inflection-1-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--widthdiv=2 \
|
||||
--group1-table=wm_debug \
|
||||
--group1-where="name='inflection-1' AND stage='bbends' AND gen=1" \
|
||||
--group1-select="wm_debug where name='inflection-1' AND stage='bbends' AND gen=1" \
|
||||
--group2-select="wm_debug where name='inflection-1' AND stage='bbends-polygon' AND gen=1" \
|
||||
--group2-cmap=1 \
|
||||
--group2-table=wm_debug \
|
||||
--group2-where="name='inflection-1' AND stage='bbends-polygon' AND gen=1" \
|
||||
--outfile=$@
|
||||
|
||||
inflection-1-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--widthdiv=2 \
|
||||
--group1-table=wm_debug \
|
||||
--group1-where="name='inflection-1' AND stage='cinflections' AND gen=1" \
|
||||
--group1-select="wm_debug where name='inflection-1' AND stage='cinflections' AND gen=1" \
|
||||
--group2-select="wm_debug where name='inflection-1' AND stage='cinflections-polygon' AND gen=1" \
|
||||
--group2-cmap=1 \
|
||||
--group2-table=wm_debug \
|
||||
--group2-where="name='inflection-1' AND stage='cinflections-polygon' AND gen=1" \
|
||||
--outfile=$@
|
||||
|
||||
fig6-self-crossing-before.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--widthdiv=4 \
|
||||
--group1-table=wm_debug \
|
||||
--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 \
|
||||
--group1-select="wm_debug where name='fig6' AND stage='bbends' AND gen=1" \
|
||||
--group2-select="wm_visuals where name='fig6-baseline'" --group2-linestyle=dashed \
|
||||
--group3-select="wm_visuals where name='fig6-newline'" --group3-linestyle=dashed \
|
||||
--outfile=$@
|
||||
|
||||
fig6-self-crossing-after.pdf: layer2img.py Makefile .faux_test
|
||||
python ./layer2img.py \
|
||||
--widthdiv=4 \
|
||||
--group1-table=wm_debug \
|
||||
--group1-where="name='fig6' AND stage='dcrossings' AND gen=1" \
|
||||
--widthdiv=3 \
|
||||
--group1-select="wm_debug where name='fig6' AND stage='dcrossings' AND gen=1" \
|
||||
--outfile=$@
|
||||
|
||||
.faux_test: tests.sql wm.sql .faux_db
|
||||
|
23
layer2img.py
23
layer2img.py
@ -17,18 +17,15 @@ PSQL_CREDS = "host=127.0.0.1 dbname=osm user=osm password=osm"
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Convert geopackage to an image')
|
||||
parser.add_argument('--group1-table')
|
||||
parser.add_argument('--group1-where')
|
||||
parser.add_argument('--group1-select', required=True)
|
||||
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-select')
|
||||
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-select')
|
||||
parser.add_argument('--group3-cmap', type=bool)
|
||||
parser.add_argument('--group3-linestyle')
|
||||
|
||||
@ -40,13 +37,11 @@ def parse_args():
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def read_layer(table, maybe_where=None):
|
||||
if not table:
|
||||
def read_layer(select):
|
||||
if not select:
|
||||
return
|
||||
conn = psycopg2.connect(PSQL_CREDS)
|
||||
sql = "SELECT way FROM %s" % table
|
||||
if maybe_where:
|
||||
sql += " WHERE %s" % maybe_where
|
||||
sql = "SELECT way FROM %s" % select
|
||||
return geopandas.read_postgis(sql, con=conn, geom_col='way')
|
||||
|
||||
def plot_args(color, maybe_cmap, maybe_linestyle):
|
||||
@ -61,9 +56,9 @@ def plot_args(color, maybe_cmap, maybe_linestyle):
|
||||
|
||||
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)
|
||||
group1 = read_layer(args.group1_select)
|
||||
group2 = read_layer(args.group2_select)
|
||||
group3 = read_layer(args.group3_select)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user