visualizations
This commit is contained in:
parent
a2f2d62033
commit
31f0a1961f
10
Makefile
10
Makefile
@ -44,7 +44,15 @@ mj-msc-full.pdf: mj-msc.pdf version.tex $(ARCHIVABLES)
|
|||||||
mv .tmp-$@ $@
|
mv .tmp-$@ $@
|
||||||
|
|
||||||
test-figures.pdf: layer2img.py .faux_test
|
test-figures.pdf: layer2img.py .faux_test
|
||||||
python ./layer2img.py --group1-table=wm_figures --group1-arrows=yes --outfile=$@
|
python ./layer2img.py --group1-table=wm_figures --outfile=$@
|
||||||
|
|
||||||
|
fig-definition-of-a-bend.pdf: layer2img.py Makefile .faux_test
|
||||||
|
python ./layer2img.py \
|
||||||
|
--group1-cmap=True \
|
||||||
|
--group1-table=wm_debug \
|
||||||
|
--group1-where="name='fig6' AND stage='bbends-polygon' AND gen=1" \
|
||||||
|
--group2-table=wm_debug --group2-where="name='fig6' AND stage='bbends' AND gen=1" \
|
||||||
|
--outfile=$@
|
||||||
|
|
||||||
.faux_test: tests.sql wm.sql .faux_db
|
.faux_test: tests.sql wm.sql .faux_db
|
||||||
./db -f tests.sql
|
./db -f tests.sql
|
||||||
|
56
layer2img.py
56
layer2img.py
@ -111,20 +111,17 @@ def plt_size(string):
|
|||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Convert geopackage to an image')
|
description='Convert geopackage to an image')
|
||||||
group1 = parser.add_mutually_exclusive_group()
|
parser.add_argument('--group1-table')
|
||||||
group1.add_argument('--group1-infile')
|
parser.add_argument('--group1-where')
|
||||||
group1.add_argument('--group1-table')
|
parser.add_argument('--group1-cmap', type=bool)
|
||||||
parser.add_argument('--group1-arrows', type=bool)
|
|
||||||
|
|
||||||
group2 = parser.add_mutually_exclusive_group()
|
parser.add_argument('--group2-table')
|
||||||
group2.add_argument('--group2-infile', type=str)
|
parser.add_argument('--group2-where')
|
||||||
group2.add_argument('--group2-table', type=str)
|
parser.add_argument('--group2-cmap', type=bool)
|
||||||
parser.add_argument('--group2-arrows', type=bool)
|
|
||||||
|
|
||||||
group3 = parser.add_mutually_exclusive_group()
|
parser.add_argument('--group3-table')
|
||||||
group3.add_argument('--group3-infile', type=str)
|
parser.add_argument('--group3-where')
|
||||||
group3.add_argument('--group3-table', type=str)
|
parser.add_argument('--group3-cmap', type=bool)
|
||||||
parser.add_argument('--group3-arrows', type=bool)
|
|
||||||
|
|
||||||
parser.add_argument('-o', '--outfile', metavar='<file>')
|
parser.add_argument('-o', '--outfile', metavar='<file>')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -133,13 +130,14 @@ def parse_args():
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def read_layer(maybe_table, maybe_file):
|
def read_layer(table, maybe_where=None):
|
||||||
if maybe_table:
|
if not table:
|
||||||
conn = psycopg2.connect(PSQL_CREDS)
|
return
|
||||||
sql = "SELECT way FROM %s" % maybe_table
|
conn = psycopg2.connect(PSQL_CREDS)
|
||||||
return geopandas.read_postgis(sql, con=conn, geom_col='way')
|
sql = "SELECT way FROM %s" % table
|
||||||
elif maybe_file:
|
if maybe_where:
|
||||||
return geopandas.read_file(maybe_file)
|
sql += " WHERE %s" % maybe_where
|
||||||
|
return geopandas.read_postgis(sql, con=conn, geom_col='way')
|
||||||
|
|
||||||
def add_lines(ax, group):
|
def add_lines(ax, group):
|
||||||
for g in group.to_dict()['way'].values():
|
for g in group.to_dict()['way'].values():
|
||||||
@ -150,9 +148,9 @@ def add_lines(ax, group):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
group1 = read_layer(args.group1_table, args.group1_infile)
|
group1 = read_layer(args.group1_table, args.group1_where)
|
||||||
group2 = read_layer(args.group2_table, args.group2_infile)
|
group2 = read_layer(args.group2_table, args.group2_where)
|
||||||
group3 = read_layer(args.group3_table, args.group3_infile)
|
group3 = read_layer(args.group3_table, args.group3_where)
|
||||||
|
|
||||||
rc('text', usetex=True)
|
rc('text', usetex=True)
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
@ -162,15 +160,17 @@ def main():
|
|||||||
ax.set_xlim(left=c[0], right=c[2])
|
ax.set_xlim(left=c[0], right=c[2])
|
||||||
ax.set_ylim(bottom=c[1], top=c[3])
|
ax.set_ylim(bottom=c[1], top=c[3])
|
||||||
|
|
||||||
|
c1 = {'cmap': 'coolwarm'} if args.group1_cmap else {'color': ORANGE}
|
||||||
|
c2 = {'cmap': 'coolwarm'} if args.group2_cmap else {'color': PURPLE}
|
||||||
|
c3 = {'cmap': 'coolwarm'} if args.group3_cmap else {'color': GREEN}
|
||||||
|
|
||||||
if group1 is not None:
|
if group1 is not None:
|
||||||
group1.plot(ax=ax, color=ORANGE)
|
group1.plot(ax=ax, **c1)
|
||||||
args.group1_arrows and add_lines(ax, group1)
|
#args.group1_arrows and add_lines(ax, group1)
|
||||||
if group2 is not None:
|
if group2 is not None:
|
||||||
group2.plot(ax=ax, color=PURPLE)
|
group2.plot(ax=ax, **c2)
|
||||||
args.group2_arrows and add_lines(ax, group1)
|
|
||||||
if group3 is not None:
|
if group3 is not None:
|
||||||
group3.plot(ax=ax, color=GREEN)
|
group3.plot(ax=ax, **c3)
|
||||||
args.group3_arrows and add_lines(ax, group1)
|
|
||||||
|
|
||||||
ax.axis('off')
|
ax.axis('off')
|
||||||
ax.margins(0, 0)
|
ax.margins(0, 0)
|
||||||
|
@ -214,6 +214,8 @@ unexpected bugs have snug in while modifying the algorithm.
|
|||||||
|
|
||||||
\section{Definition of a Bend}
|
\section{Definition of a Bend}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\section{Gentle Inflection at End of a Bend}
|
\section{Gentle Inflection at End of a Bend}
|
||||||
|
|
||||||
\section{Self-line Crossing When Cutting a Bend}
|
\section{Self-line Crossing When Cutting a Bend}
|
||||||
|
38
wm.sql
38
wm.sql
@ -3,7 +3,12 @@ SET plpgsql.extra_errors TO 'all';
|
|||||||
|
|
||||||
-- detect_bends detects bends using the inflection angles. No corrections.
|
-- detect_bends detects bends using the inflection angles. No corrections.
|
||||||
drop function if exists detect_bends;
|
drop function if exists detect_bends;
|
||||||
create function detect_bends(line geometry, dbgname text default null, OUT bends geometry[]) as $$
|
create function detect_bends(
|
||||||
|
line geometry,
|
||||||
|
dbgname text default null,
|
||||||
|
dbgstagenum integer default null,
|
||||||
|
OUT bends geometry[]
|
||||||
|
) as $$
|
||||||
declare
|
declare
|
||||||
pi constant real default radians(180);
|
pi constant real default radians(180);
|
||||||
p geometry;
|
p geometry;
|
||||||
@ -67,6 +72,25 @@ begin
|
|||||||
if (select count(1) >= 2 from st_dumppoints(bend)) then
|
if (select count(1) >= 2 from st_dumppoints(bend)) then
|
||||||
bends = bends || bend;
|
bends = bends || bend;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
if dbgname is not null then
|
||||||
|
for i in 1..array_length(bends, 1) loop
|
||||||
|
insert into wm_debug(stage, name, gen, nbend, way) values(
|
||||||
|
'bbends',
|
||||||
|
dbgname,
|
||||||
|
dbgstagenum,
|
||||||
|
i,
|
||||||
|
bends[i]
|
||||||
|
);
|
||||||
|
insert into wm_debug(stage, name, gen, nbend, way) values(
|
||||||
|
'bbends-polygon',
|
||||||
|
dbgname,
|
||||||
|
dbgstagenum,
|
||||||
|
i,
|
||||||
|
st_makepolygon(st_addpoint(bends[i], st_startpoint(bends[i])))
|
||||||
|
);
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
end
|
end
|
||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
|
||||||
@ -403,17 +427,7 @@ begin
|
|||||||
);
|
);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
bends = detect_bends(lines[i]);
|
bends = detect_bends(lines[i], dbgname, stagenum);
|
||||||
|
|
||||||
if dbgname is not null then
|
|
||||||
insert into wm_debug(stage, name, gen, nbend, way) values(
|
|
||||||
'bbends',
|
|
||||||
dbgname,
|
|
||||||
stagenum,
|
|
||||||
generate_subscripts(bends, 1),
|
|
||||||
unnest(bends)
|
|
||||||
);
|
|
||||||
end if;
|
|
||||||
|
|
||||||
bends = fix_gentle_inflections(bends);
|
bends = fix_gentle_inflections(bends);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user