douglas-peucker and visvalingam examples

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:48 +03:00 committed by Motiejus Jakštys
parent fd6266698c
commit ddc4af6436
4 changed files with 90 additions and 12 deletions

View File

@ -28,7 +28,11 @@ FIGURES = \
RIVERS = \
salvis-25k \
salvis-50k \
salvis-250k
salvis-250k \
salvis-douglas-64-50k \
salvis-visvalingam-64-50k \
salvis-douglas-64-chaikin-50k \
salvis-visvalingam-64-chaikin-50k
#################################
# The thesis, publishable version
@ -126,6 +130,23 @@ salvis-50k_WIDTHDIV = 2
salvis-250k_1SELECT = wm_visuals where name='salvis'
salvis-250k_WIDTHDIV = 10
#salvis-douglas-64-50k_1SELECT = wm_visuals where name='salvis'
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
.faux_test-rivers: tests-rivers.sql wm.sql Makefile .faux_db
bash db -v scaledwidth=$(SCALEDWIDTH) -f $<
touch $@

View File

@ -24,7 +24,7 @@ def inch(cm):
def parse_args():
parser = argparse.ArgumentParser(
description='Convert a geometry to an image')
parser.add_argument('--group1-select', required=True)
parser.add_argument('--group1-select')
parser.add_argument('--group1-linestyle')
simplify = parser.add_mutually_exclusive_group()
@ -91,9 +91,9 @@ def main():
fig, ax = plt.subplots()
fig.set_figwidth(inch(width))
group1 is not None and group1.plot(ax=ax, **c1)
group2 is not None and group2.plot(ax=ax, **c2)
group3 is not None and group3.plot(ax=ax, **c3)
group1 is not None and group1.plot(ax=ax, linewidth=.75, **c1)
group2 is not None and group2.plot(ax=ax, linewidth=.75, **c2)
group3 is not None and group3.plot(ax=ax, linewidth=.75, **c3)
ax.axis('off')
ax.margins(0, 0)

View File

@ -34,6 +34,8 @@
% does not require minted
\usepackage{verbatim}
\newcommand{\inputcode}[2]{\verbatiminput{#2}}
\usepackage{setspace}
\doublespacing
\fi
\input{version.inc}
@ -192,12 +194,6 @@ thus convenient to analyze for both small and large scale generalization.
\label{fig:salvis-25}
\end{figure}
Same rivers, unprocessed, but with higher density (scales 1:50000 and 1:250000)
are depicted in figure~\ref{fig:salvis-50-250}. Some river features are so
compact that a reasonably thin line depicting the river is overlapping with
itself, creating a thicker line in print. As a result, generalization for this
river for a smaller scale is worthy.
\begin{figure}[h]
\centering
\begin{subfigure}[b]{.49\textwidth}
@ -214,6 +210,50 @@ river for a smaller scale is worthy.
\label{fig:salvis-50-250}
\end{figure}
Same rivers, unprocessed, but with higher density (scales 1:50000 and 1:250000)
are depicted in figure~\onpage{fig:salvis-50-250}. Some river features are so
compact that a reasonably thin line depicting the river is touching itself,
creating a thicker line. As a result, generalization for this river for a
smaller scale is worthy.
\begin{figure}[h]
\centering
\begin{subfigure}[b]{.49\textwidth}
\includegraphics[width=\textwidth]{salvis-douglas-64-50k}
\caption{Using {\DP}}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.49\textwidth}
\includegraphics[width=\textwidth]{salvis-visvalingam-64-50k}
\caption{Using {\VW}}
\end{subfigure}
\caption{Generalized using classical algorithms (1:50000).}
\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,
traditionally, Chaikin's\cite{chaikin1974algorithm} is applied after
generalization, illustrated in
figure~\onpage{fig:salvis-generalized-chaikin-50k}.
\begin{figure}[h]
\centering
\begin{subfigure}[b]{.49\textwidth}
\includegraphics[width=\textwidth]{salvis-douglas-64-chaikin-50k}
\caption{Using {\DP} and Chaikin's}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.49\textwidth}
\includegraphics[width=\textwidth]{salvis-visvalingam-64-chaikin-50k}
\caption{Using {\VW} and Chaikin's}
\end{subfigure}
\caption{Generalized and smoothened river (1:50000).}
\label{fig:salvis-generalized-chaikin-50k}
\end{figure}
\subsubsection{Modern approaches}
Due to their simplicity and ubiquity, {\DP} and {\VW} have been established as

View File

@ -22,7 +22,7 @@ begin
end
$$ language plpgsql;
delete from wm_visuals where name in ('salvis');
delete from wm_visuals where name like 'salvis%';
insert into wm_visuals(name, way) values('salvis', (
select st_intersection(
(select st_union(way) from wm_rivers where name in ('Šalčia', 'Visinčia')),
@ -36,6 +36,23 @@ insert into wm_visuals(name, way) values('salvis', (
)
));
do $$
declare
i integer;
geom1 geometry;
geom2 geometry;
begin
foreach i in array array[16, 64, 256] loop
geom1 = st_simplify((select way from wm_visuals where name='salvis'), i);
geom2 = st_simplifyvw((select way from wm_visuals where name='salvis'), i*i);
insert into wm_visuals(name, way) values
('salvis-douglas-' || i, geom1),
('salvis-douglas-' || i || '-chaikin', st_chaikinsmoothing(geom1, 5)),
('salvis-visvalingam-' || i, geom2),
('salvis-visvalingam-' || i || '-chaikin', st_chaikinsmoothing(geom2, 5));
end loop;
end $$ language plpgsql;
do $$
declare
npoints bigint;