zoom quadrants

main
Motiejus Jakštys 2021-05-19 22:57:48 +03:00 committed by Motiejus Jakštys
parent a64246b102
commit 9e7b263750
5 changed files with 84 additions and 11 deletions

View File

@ -32,7 +32,9 @@ RIVERS = \
salvis-douglas-64-50k \
salvis-visvalingam-64-50k \
salvis-douglas-64-chaikin-50k \
salvis-visvalingam-64-chaikin-50k
salvis-visvalingam-64-chaikin-50k \
salvis-overlaid-douglas-64-chaikin-50k \
salvis-overlaid-visvalingam-64-chaikin-50k
#################################
# The thesis, publishable version
@ -76,6 +78,7 @@ define FIG_template
$(1).pdf: layer2img.py Makefile $(2)
python ./layer2img.py --outfile=$(1).pdf \
$$(if $$($(1)_WIDTHDIV),--widthdiv=$$($(1)_WIDTHDIV)) \
$$(if $$($(1)_QUADRANT),--quadrant=$$($(1)_QUADRANT)) \
$$(foreach i,1 2 3, \
$$(if $$($(1)_$$(i)SELECT),--group$$(i)-select="$$($(1)_$$(i)SELECT)") \
$$(if $$($(1)_$$(i)LINESTYLE),--group$$(i)-linestyle="$$($(1)_$$(i)LINESTYLE)") \
@ -134,18 +137,25 @@ salvis-250k_WIDTHDIV = 10
salvis-douglas-64-50k_2SELECT = wm_visuals where name='salvis-douglas-64'
salvis-douglas-64-50k_WIDTHDIV = 2
#salvis-visvalingam-64-50k_1SELECT = wm_visuals where name='salvis'
salvis-visvalingam-64-50k_2SELECT = wm_visuals where name='salvis-visvalingam-64'
salvis-visvalingam-64-50k_WIDTHDIV = 2
#salvis-douglas-64-chaikin-50k_1SELECT = wm_visuals where name='salvis'
salvis-douglas-64-chaikin-50k_2SELECT = wm_visuals where name='salvis-douglas-64-chaikin'
salvis-douglas-64-chaikin-50k_WIDTHDIV = 2
#salvis-visvalingam-64-chaikin-50k_1SELECT = wm_visuals where name='salvis'
salvis-visvalingam-64-chaikin-50k_2SELECT = wm_visuals where name='salvis-visvalingam-64-chaikin'
salvis-visvalingam-64-chaikin-50k_WIDTHDIV = 2
salvis-overlaid-douglas-64-chaikin-50k_1SELECT = wm_visuals where name='salvis'
salvis-overlaid-douglas-64-chaikin-50k_2SELECT = wm_visuals where name='salvis-douglas-64-chaikin'
salvis-overlaid-douglas-64-chaikin-50k_WIDTHDIV = 2
salvis-overlaid-douglas-64-chaikin-50k_QUADRANT = 4
salvis-overlaid-visvalingam-64-chaikin-50k_1SELECT = wm_visuals where name='salvis'
salvis-overlaid-visvalingam-64-chaikin-50k_2SELECT = wm_visuals where name='salvis-visvalingam-64-chaikin'
salvis-overlaid-visvalingam-64-chaikin-50k_WIDTHDIV = 2
salvis-overlaid-visvalingam-64-chaikin-50k_QUADRANT = 4
.faux_test-rivers: tests-rivers.sql wm.sql Makefile .faux_db
bash db -v scaledwidth=$(SCALEDWIDTH) -f $<

View File

@ -174,7 +174,7 @@
title={Handbuch der Lehre von der Verteilung der Primzahlen},
journal={Monatshefte f{\"u}r Mathematik und Physik},
year={1911},
month={Dec},
month={12},
day={01},
volume={22},
number={1},

View File

@ -48,17 +48,22 @@ def parse_args():
parser.add_argument('--widthdiv',
default=1, type=float, help='Width divisor')
parser.add_argument('--quadrant', type=int, choices=(1,2,3,4))
parser.add_argument('-o', '--outfile', metavar='<file>')
return parser.parse_args()
def read_layer(select, width):
def read_layer(select, width, maybe_quadrant):
if not select:
return
way = "way"
if maybe_quadrant:
way = "wm_quadrant(way, {})".format(maybe_quadrant)
conn = psycopg2.connect(PSQL_CREDS)
sql = "SELECT {way} as way1 FROM {select}".format(way=way, select=select)
print(sql)
return geopandas.read_postgis(sql, con=conn, geom_col='way1')
@ -80,9 +85,9 @@ def plot_args(geom, color, maybe_linestyle):
def main():
args = parse_args()
width = TEXTWIDTH_CM / args.widthdiv
group1 = read_layer(args.group1_select, width)
group2 = read_layer(args.group2_select, width)
group3 = read_layer(args.group3_select, width)
group1 = read_layer(args.group1_select, width, args.quadrant)
group2 = read_layer(args.group2_select, width, args.quadrant)
group3 = read_layer(args.group3_select, width, args.quadrant)
c1 = plot_args(group1, BLACK, args.group1_linestyle)
c2 = plot_args(group2, ORANGE, args.group2_linestyle)
c3 = plot_args(group3, GREEN, args.group3_linestyle)

View File

@ -231,7 +231,6 @@ smaller scale is worthy.
\label{fig:salvis-generalized-50k}
\end{figure}
Figure~\onpage{fig:salvis-generalized-50k} illustrates the same river bend, but
generalized using {\DP} and {\VW} algorithms. The resulting lines are jagged,
thus the resulting line looks unlike a real river. To smoothen the jaggedness,
@ -254,6 +253,21 @@ figure~\onpage{fig:salvis-generalized-chaikin-50k}.
\label{fig:salvis-generalized-chaikin-50k}
\end{figure}
\begin{figure}[h]
\centering
\begin{subfigure}[b]{.49\textwidth}
\includegraphics[width=\textwidth]{salvis-overlaid-douglas-64-chaikin-50k}
\caption{Original and {\DP} + Chaikin's}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.49\textwidth}
\includegraphics[width=\textwidth]{salvis-overlaid-visvalingam-64-chaikin-50k}
\caption{Original and {\VW} + Chaikin's}
\end{subfigure}
\caption{Generalized and smoothened river (1:50000) and the original one overlaid.}
\label{fig:salvis-overlaid-generalized-chaikin-50k}
\end{figure}
There are a few problems with {\VW} and {\DP} immediately visible in
figure~\onpage{fig:salvis-generalized-chaikin-50k}:

View File

@ -1,6 +1,6 @@
\i wm.sql
-- wm_envelope clips a geometry by a bounding box around a given object,
-- wm_bbox clips a geometry by a bounding box around a given object,
-- matching dimensions of A-class paper (1 by sqrt(2).
drop function if exists wm_bbox;
create function wm_bbox(
@ -22,6 +22,50 @@ begin
end
$$ language plpgsql;
-- wm_quadrant divides the given geometry to 4 rectangles
-- and returns the requested quadrant following cartesian
-- convention:
-- +----------+
-- | II | I |
--- +----------+
-- | III | IV |
-- +-----+----+
-- matching dimensions of A-class paper (1 by sqrt(2).
drop function if exists wm_quadrant;
create function wm_quadrant(
geom geometry,
quadrant integer
) returns geometry as $$
declare
xmin float;
xmax float;
ymin float;
ymax float;
begin
xmin = st_xmin(geom);
xmax = st_xmax(geom);
ymin = st_ymin(geom);
ymax = st_ymax(geom);
if quadrant = 1 or quadrant = 2 then
ymin = (ymin + ymax)/2;
else
ymax = (ymin + ymax)/2;
end if;
if quadrant = 2 or quadrant = 3 then
xmax = (xmin + xmax)/2;
else
xmin = (xmin + xmax)/2;
end if;
return st_intersection(
geom,
st_makeenvelope(xmin, ymin, xmax, ymax, st_srid(geom))
);
end $$ language plpgsql;
delete from wm_visuals where name like 'salvis%';
insert into wm_visuals(name, way) values('salvis', (
select st_intersection(