This commit is contained in:
Motiejus Jakštys 2020-06-18 11:05:13 +03:00
parent 0fddb49a8c
commit d585b47714
3 changed files with 48 additions and 28 deletions

View File

@ -1,8 +1,8 @@
CROSSING = 622916 6109267 626066 6111487 # xmin ymin xmax ymax CROSSING = 622916 6109267 626066 6111487 # xmin ymin xmax ymax
ZEIMENA_TOLERANCES = 128 256 512 1024 2048 4096 ZEIMENA_TOLERANCES = 128 256 512 1024 2048 4096
SINEWAVE_TOLERANCES = 2 16 32 SINEWAVE_TOLERANCES = 2 16 32
CROSSING_TOLERANCES = 64 128 256 CROSSING_TOLERANCES = 128 256 512
CHAIKIN_CROSSING_TOLERANCES = 128 256 CHAIKIN_CROSSING_TOLERANCES = 128 256 512
SINEWAVE_SIZE = 120x48 SINEWAVE_SIZE = 120x48
GEN1 = $(addsuffix .pdf, \ GEN1 = $(addsuffix .pdf, \
$(addprefix sinewave2_douglas_,$(SINEWAVE_TOLERANCES)) \ $(addprefix sinewave2_douglas_,$(SINEWAVE_TOLERANCES)) \

View File

@ -7,7 +7,7 @@ CREATE TABLE :tbl (
INSERT INTO :tbl (geom) ( INSERT INTO :tbl (geom) (
SELECT SELECT
ST_ChaikinSmoothing (geom, 3) AS geoms ST_ChaikinSmoothing (geom, 5) AS geoms
FROM FROM
:src); :src);

View File

@ -33,7 +33,7 @@
\newcommand{\WM}{Wang--M{\"u}ller} \newcommand{\WM}{Wang--M{\"u}ller}
\title{ \title{
Cartografic Generalization of Lines using free software \\ Cartographic Generalization of Lines using free software \\
(example of rivers) \\ \vspace{4mm} (example of rivers) \\ \vspace{4mm}
} }
@ -185,6 +185,9 @@ version will help explain some of the deficiencies in the reviewed algorithms.
\label{fig:crossing} \label{fig:crossing}
\end{figure} \end{figure}
\section{Comparison algorithms and parameters}
\label{sec:algs-and-params}
To visually evaluate the Žeimena sample, examples for {\DP} and {\VW} To visually evaluate the Žeimena sample, examples for {\DP} and {\VW}
were created using the following parameters: were created using the following parameters:
@ -193,16 +196,22 @@ were created using the following parameters:
\item {\VW} tolerance: $vwtolerance = tolerance ^ 2$\label{itm:2}. \item {\VW} tolerance: $vwtolerance = tolerance ^ 2$\label{itm:2}.
\end{enumerate} \end{enumerate}
Parameter~\ref{itm:2} requires explanation. Tolerance for {\DP} is specified in Tolerance squared, i.e. the parameter~\ref{itm:2} requires explanation.
linear units, in this case, meters. Tolerance for {\VW} is specified in area Tolerance for {\DP} is specified in linear units, in this case, meters.
units $m^2$. As author was not able to locate formal comparisons between the Tolerance for {\VW} is specified in area units $m^2$. As author was not able to
two (i.e. how to calculate one tolerance value from the other, so the results locate formal comparisons between the two (i.e. how to calculate one tolerance
are comparable?), {\DP} tolerance was arbitrarily squared and fed to {\VW}. To value from the other, so the results are comparable?), {\DP} tolerance was
author's eye, this provides comparable and reasonable results, though could be arbitrarily squared and fed to {\VW}. To author's eye, this provides comparable
researched. and reasonable results, though could be researched.
Chaikin's smoothing algorithm was generated using $nIterations = 5$. That
number was chosen for better visual appeal at the expense of computational
power. Smaller number iterations would cause retain visible angles, whereas
larger number of iterations, like 5 (PostGIS supports values from 1 to 5),
causes the resulting lines to be very smooth.
As can be observed in table~\ref{tab:comparison-zeimena} on As can be observed in table~\ref{tab:comparison-zeimena} on
page~\pageref{tab:comparison-zeimena}, both simplication algorithms convert page~\pageref{tab:comparison-zeimena}, both simplification algorithms convert
bends to chopped lines. This is especially visible in tolerances 256 and 512. bends to chopped lines. This is especially visible in tolerances 256 and 512.
In a more robust simplification algorithm, the larger tolerance, the larger the In a more robust simplification algorithm, the larger tolerance, the larger the
bends on the original map should be retained. bends on the original map should be retained.
@ -211,8 +220,8 @@ bends on the original map should be retained.
\renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}} \renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}}
\begin{tabularx}{\textwidth}{ p{2.1cm} | X | X | } \begin{tabularx}{\textwidth}{ p{2.1cm} | X | X | }
Tolerance DP/VW & Tolerance DP/VW &
Douglas \& Peucker & {\DP} &
Visvalingam-Whyatt \tabularnewline \hline {\VW} \tabularnewline \hline
128/16384 & 128/16384 &
\includegraphics[width=\linewidth]{zeimena_douglas_128} & \includegraphics[width=\linewidth]{zeimena_douglas_128} &
@ -244,7 +253,7 @@ bends on the original map should be retained.
To ease the discussion on shapes in the resulting output, it is useful to To ease the discussion on shapes in the resulting output, it is useful to
define what a "blunt bend" is: it is a river bent that looks like a cutout from define what a "blunt bend" is: it is a river bent that looks like a cutout from
a large circle, ilustrated in figure~\ref{fig:blunt-bent}. a large circle, illustrated in figure~\ref{fig:blunt-bent}.
\begin{figure}[h] \begin{figure}[h]
\centering \centering
@ -266,12 +275,8 @@ table~\ref{tab:comparison-crossing} on page~\pageref{tab:comparison-crossing}.
\renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}} \renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}}
\begin{tabularx}{\textwidth}{ p{2.1cm} | X | X | } \begin{tabularx}{\textwidth}{ p{2.1cm} | X | X | }
Tolerance DP/VW & Tolerance DP/VW &
Douglas \& Peucker & {\DP} &
Visvalingam-Whyatt \tabularnewline \hline {\VW} \tabularnewline \hline
64/4096 &
\includegraphics[width=\linewidth]{overlaid_zeimena_douglas_64} &
\includegraphics[width=\linewidth]{overlaid_zeimena_visvalingam_64} \tabularnewline \hline
128/16384 & 128/16384 &
\includegraphics[width=\linewidth]{overlaid_zeimena_douglas_128} & \includegraphics[width=\linewidth]{overlaid_zeimena_douglas_128} &
@ -281,6 +286,10 @@ table~\ref{tab:comparison-crossing} on page~\pageref{tab:comparison-crossing}.
\includegraphics[width=\linewidth]{overlaid_zeimena_douglas_256} & \includegraphics[width=\linewidth]{overlaid_zeimena_douglas_256} &
\includegraphics[width=\linewidth]{overlaid_zeimena_visvalingam_256} \tabularnewline \hline \includegraphics[width=\linewidth]{overlaid_zeimena_visvalingam_256} \tabularnewline \hline
512/262144 &
\includegraphics[width=\linewidth]{overlaid_zeimena_douglas_512} &
\includegraphics[width=\linewidth]{overlaid_zeimena_visvalingam_512} \tabularnewline \hline
\end{tabularx} \end{tabularx}
\caption{{\DP} and {\VW} on river crossing area} \caption{{\DP} and {\VW} on river crossing area}
\label{tab:comparison-crossing} \label{tab:comparison-crossing}
@ -288,15 +297,15 @@ table~\ref{tab:comparison-crossing} on page~\pageref{tab:comparison-crossing}.
As the reader may observe, the output lines, especially with higher tolerances, As the reader may observe, the output lines, especially with higher tolerances,
are jaggy. Higher-tolerance jaggy outputs from {\VW} and {\DP}, passed through are jaggy. Higher-tolerance jaggy outputs from {\VW} and {\DP}, passed through
Chaikin with 3 iterations, are displayed in table~\ref{tab:chaikin-crossing} on Chaikin with 5 iterations, are displayed in table~\ref{tab:chaikin-crossing} on
page~\pageref{tab:chaikin-crossing}. page~\pageref{tab:chaikin-crossing}.
\begin{figure}[h] \begin{figure}[h]
\renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}} \renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}}
\begin{tabularx}{\textwidth}{ p{2.1cm} | X | X | } \begin{tabularx}{\textwidth}{ p{2.1cm} | X | X | }
Tolerance DP/VW & Tolerance DP/VW &
Douglas \& Peucker + Chaikin(3) & {\DP} + Chaikin(5) &
Visvalingam-Whyatt + Chaikin(3) \tabularnewline \hline {\VW} + Chaikin(5) \tabularnewline \hline
128/16384 & 128/16384 &
\includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_douglas_128} & \includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_douglas_128} &
@ -306,12 +315,16 @@ page~\pageref{tab:chaikin-crossing}.
\includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_douglas_256} & \includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_douglas_256} &
\includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_visvalingam_256} \tabularnewline \hline \includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_visvalingam_256} \tabularnewline \hline
512/262144 &
\includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_douglas_512} &
\includegraphics[width=\linewidth]{overlaid_chaikin_zeimena_visvalingam_512} \tabularnewline \hline
\end{tabularx} \end{tabularx}
\caption{Chaikin-smoothened {\DP} and {\VW} on river crossing area} \caption{Chaikin-smoothened {\DP} and {\VW} on river crossing area}
\label{tab:chaikin-crossing} \label{tab:chaikin-crossing}
\end{figure} \end{figure}
There is another issue on the wishlist beyond jaggyness and loss of large bents There is another issue on the wishlist beyond jaggedness and loss of large bents
-- combining close bends to larger ones. -- combining close bends to larger ones.
\subsection{Combining bends} \subsection{Combining bends}
@ -340,8 +353,8 @@ page~\pageref{tab:comparison-sinewave2}.
\renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}} \renewcommand{\tabularxcolumn}[1]{>{\center\small}m{#1}}
\begin{tabularx}{\textwidth}{ p{1.5cm} | X | X | } \begin{tabularx}{\textwidth}{ p{1.5cm} | X | X | }
Tolerance DP/VW & Tolerance DP/VW &
Douglas \& Peucker & {\DP} &
Visvalingam-Whyatt \tabularnewline \hline {\VW} \tabularnewline \hline
2/4 & 2/4 &
\includegraphics[width=\linewidth]{overlaid_sinewave2_douglas_2} & \includegraphics[width=\linewidth]{overlaid_sinewave2_douglas_2} &
@ -384,7 +397,7 @@ algorithms {\DP} and {\VW}, and now can enumerate the shortcomings:
\item Resulting generalized lines look jaggy and, when zoomed in, \item Resulting generalized lines look jaggy and, when zoomed in,
unpleasant to the eye. unpleasant to the eye.
\item Blunt bends are generalized to straight lines, even though sometimes \item Blunt bends are generalized to straight lines, even though sometimes
they should remain blunt bends (or even exhagerated bends). they should remain blunt bends (or even exaggerated bends).
\item Consecutive small bends should be normalized into a larger bend. \item Consecutive small bends should be normalized into a larger bend.
\end{itemize} \end{itemize}
@ -453,6 +466,13 @@ Transforms a layer ({\tt :src}) to {\VW} using $tolerance^2$ tolerance into
{\tt :tbl} table. {\tt :tbl} table.
\inputminted[fontsize=\small]{sql}{visvalingam.sql} \inputminted[fontsize=\small]{sql}{visvalingam.sql}
\subsection{chaikin.sql}
Smoothens a layer ({\tt :src}) using Chaikin's algorithm using $nIterations =
5$ into {\tt :tbl} table. The parameters are explained in
section~\ref{sec:algs-and-params} on page~\pageref{sec:algs-and-params}.
\inputminted[fontsize=\small]{sql}{chaikin.sql}
\subsection{fig2layer.py} \subsection{fig2layer.py}
Creates figures (square, sine wave) as geopackage files. Creates figures (square, sine wave) as geopackage files.
\inputminted[fontsize=\small]{python}{fig2layer.py} \inputminted[fontsize=\small]{python}{fig2layer.py}