2021-04-13 04:49:27 +03:00
|
|
|
\documentclass[a4paper]{article}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
|
|
|
\usepackage[T1]{fontenc}
|
|
|
|
\usepackage[english]{babel}
|
|
|
|
\usepackage[utf8]{inputenc}
|
2021-04-18 16:15:37 +03:00
|
|
|
%\usepackage{a4wide}
|
2021-04-13 05:08:32 +03:00
|
|
|
\usepackage [autostyle, english=american]{csquotes}
|
2021-04-12 16:58:44 +03:00
|
|
|
\MakeOuterQuote{"}
|
2021-04-13 08:31:01 +03:00
|
|
|
\usepackage[maxbibnames=99,style=numeric,sorting=none]{biblatex}
|
|
|
|
\addbibresource{bib.bib}
|
2021-03-30 17:37:13 +03:00
|
|
|
\usepackage[pdfusetitle]{hyperref}
|
|
|
|
\usepackage{enumitem}
|
|
|
|
\usepackage[toc,page,title]{appendix}
|
|
|
|
\usepackage{caption}
|
|
|
|
\usepackage{subcaption}
|
|
|
|
\usepackage{gensymb}
|
2021-04-13 05:20:37 +03:00
|
|
|
\usepackage{units}
|
2021-03-30 17:37:13 +03:00
|
|
|
\usepackage{varwidth}
|
|
|
|
\usepackage{tabularx}
|
|
|
|
\usepackage{float}
|
|
|
|
\usepackage{tikz}
|
|
|
|
\usepackage{minted}
|
2021-04-13 10:05:52 +03:00
|
|
|
\usepackage{fancyvrb}
|
2021-04-13 04:26:19 +03:00
|
|
|
\input{version.inc}
|
|
|
|
\input{vars.inc}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-18 16:27:19 +03:00
|
|
|
% for layout debugging
|
|
|
|
\usepackage{layouts}
|
|
|
|
|
2021-04-12 12:00:17 +03:00
|
|
|
\newcommand{\onpage}[1]{\ref{#1} on page~\pageref{#1}}
|
2021-04-13 09:12:06 +03:00
|
|
|
\newcommand{\titlecite}[1]{\citetitle{#1} \cite{#1}}
|
2021-03-30 17:37:13 +03:00
|
|
|
\newcommand{\DP}{Douglas \& Peucker}
|
|
|
|
\newcommand{\VW}{Visvalingam--Whyatt}
|
|
|
|
\newcommand{\WM}{Wang--M{\"u}ller}
|
2021-04-01 15:46:34 +03:00
|
|
|
\newcommand{\MYTITLE}{Cartographic Generalization of Lines using free software (example of rivers)}
|
|
|
|
\newcommand{\MYAUTHOR}{Motiejus Jakštys}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-01 15:46:34 +03:00
|
|
|
\title{\MYTITLE}
|
|
|
|
\author{\MYAUTHOR}
|
|
|
|
\date{\VCDescribe}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
|
|
|
\begin{document}
|
2021-04-01 15:46:34 +03:00
|
|
|
|
|
|
|
\begin{titlepage}
|
|
|
|
\begin{center}
|
|
|
|
\includegraphics[width=0.4\textwidth]{vu}
|
|
|
|
|
|
|
|
\huge
|
|
|
|
\textbf{\MYTITLE} \\[4ex]
|
|
|
|
|
|
|
|
\LARGE
|
|
|
|
\textbf{\MYAUTHOR} \\[8ex]
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
A thesis presented for the degree of\\
|
|
|
|
Master in Cartography \\[3ex]
|
|
|
|
|
|
|
|
\large
|
|
|
|
\VCDescribe
|
|
|
|
\end{center}
|
|
|
|
\end{titlepage}
|
|
|
|
|
2021-03-30 17:37:13 +03:00
|
|
|
\begin{abstract}
|
|
|
|
\label{sec:abstract}
|
|
|
|
Current open-source line generalization solutions have their roots in
|
|
|
|
mathematics and geometry, and are not fit for natural objects like rivers
|
2021-04-01 09:42:08 +03:00
|
|
|
and coastlines. This paper discusses our implementation of {\WM} algorithm
|
2021-03-30 17:37:13 +03:00
|
|
|
under and open-source license, explains things that we would had
|
|
|
|
appreciated in the original paper and compares our results to different
|
|
|
|
generalization algorithms.
|
|
|
|
\end{abstract}
|
|
|
|
|
|
|
|
\newpage
|
|
|
|
|
|
|
|
\tableofcontents
|
|
|
|
\listoffigures
|
|
|
|
|
|
|
|
\newpage
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Introduction}
|
2021-03-30 17:37:13 +03:00
|
|
|
\label{sec:introduction}
|
|
|
|
|
2021-04-18 16:38:03 +03:00
|
|
|
\iffalse
|
|
|
|
NOTICE: this value should be copied to layer2img.py:TEXTWIDTH, so dimensions
|
|
|
|
of inline images are reasonable.
|
|
|
|
|
2021-04-18 18:11:21 +03:00
|
|
|
textwidth in cm: {\printinunitsof{cm}\prntlen{\textwidth}}
|
2021-04-18 16:38:03 +03:00
|
|
|
\fi
|
2021-04-18 16:27:19 +03:00
|
|
|
|
2021-04-01 09:42:08 +03:00
|
|
|
When creating small-scale maps, often the detail of the data source is greater
|
|
|
|
than desired for the map. This becomes especially acute for natural features
|
|
|
|
that have many bends, like coastlines, rivers and forest boundaries.
|
|
|
|
|
|
|
|
To create a small-scale map from a large-scale data source, these features need
|
|
|
|
to be generalized: detail should be reduced. However, while doing so, it is
|
|
|
|
important to preserve the "defining" shape of the original feature, otherwise
|
|
|
|
the result will look unrealistic.
|
|
|
|
|
|
|
|
For example, if a river is nearly straight, it should be nearly straight after
|
|
|
|
generalization, otherwise a too straightened river will look like a canal.
|
|
|
|
Conversely, if the river is highly wiggly, the number of bends should be
|
|
|
|
reduced, but not removed.
|
|
|
|
|
|
|
|
Generalization problem for other objects can often be solved by other
|
|
|
|
non-geometric means:
|
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
\item Towns and cities can be filtered and generalized by number of
|
|
|
|
inhabitants.
|
|
|
|
\item Roads can be eliminated by the road length, number of lanes, or
|
|
|
|
classification of the road (local, regional, international).
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
Natural line generalization problem can be viewed as having two competing
|
|
|
|
goals:
|
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
\item Reduce detail by removing or simplifying "less important" features.
|
|
|
|
\item Retain enough detail, so the original is still recognize-able.
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
Given the discussed complexities, a fine line between under-generalization
|
|
|
|
(leaving object as-is) and over-generalization (making a straight line) must be
|
|
|
|
found. Therein lies the complexity of generalization algorithms: all have
|
|
|
|
different trade-offs.
|
|
|
|
|
2021-04-16 07:28:17 +03:00
|
|
|
\section{Literature review and problematic}
|
2021-04-01 09:42:08 +03:00
|
|
|
\label{sec:literature-review}
|
|
|
|
|
|
|
|
A number of cartographic line generalization algorithms have been researched.
|
|
|
|
The "classical" ones are {\DP} and {\VW}.
|
|
|
|
|
2021-04-17 16:16:27 +03:00
|
|
|
\subsection{Available algorithms}
|
|
|
|
|
|
|
|
\subsubsection{{\DP}, {\VW} and Chaikin's}
|
2021-04-01 09:42:08 +03:00
|
|
|
|
2021-04-13 08:31:01 +03:00
|
|
|
{\DP} \cite{douglas1973algorithms} and {\VW} \cite{visvalingam1993line} are
|
|
|
|
"classical" line generalization computer graphics algorithms. They are
|
|
|
|
relatively simple to implement, require few runtime resources. Both of them
|
|
|
|
accept only a single parameter, based on desired scale of the map, which makes
|
|
|
|
them very simple to adjust for different scales.
|
2021-04-01 09:42:08 +03:00
|
|
|
|
2021-04-01 15:32:16 +03:00
|
|
|
Both algorithms are part of PostGIS, a free-software GIS suite:
|
|
|
|
\begin{itemize}
|
2021-04-13 08:31:01 +03:00
|
|
|
\item {\DP} via
|
2021-04-01 15:32:16 +03:00
|
|
|
\href{https://postgis.net/docs/ST_Simplify.html}{PostGIS Simplify}.
|
2021-04-01 09:42:08 +03:00
|
|
|
|
2021-04-13 08:31:01 +03:00
|
|
|
\item {\VW} via
|
2021-04-01 15:32:16 +03:00
|
|
|
\href{https://postgis.net/docs/ST_SimplifyVW.html}{PostGIS SimplifyVW}.
|
|
|
|
\end{itemize}
|
2021-04-01 09:42:08 +03:00
|
|
|
|
2021-04-17 21:52:08 +03:00
|
|
|
Examples of <TBD Chaikin and others>
|
|
|
|
|
|
|
|
It may be worthwhile to post-process those through a widely available Chaikin's
|
|
|
|
line smoothing algorithm \cite{chaikin1974algorithm} via
|
2021-04-13 08:31:01 +03:00
|
|
|
\href{https://postgis.net/docs/ST_ChaikinSmoothing.html}{PostGIS
|
2021-04-01 15:32:16 +03:00
|
|
|
ChaikinSmoothing}.
|
2021-04-01 09:42:08 +03:00
|
|
|
|
2021-04-01 15:32:16 +03:00
|
|
|
|
2021-04-17 16:16:27 +03:00
|
|
|
\subsubsection{Modern approaches}
|
2021-04-01 15:32:16 +03:00
|
|
|
|
|
|
|
Due to their simplicity and ubiquity, {\DP} and {\VW} have been established as
|
2021-04-01 19:30:20 +03:00
|
|
|
go-to algorithms for line generalization. During recent years, alternatives
|
|
|
|
have emerged. These modern replacements fall into roughly two categories:
|
2021-04-01 09:42:08 +03:00
|
|
|
|
2021-03-30 17:37:13 +03:00
|
|
|
\begin{itemize}
|
2021-04-13 09:12:06 +03:00
|
|
|
|
2021-03-30 17:37:13 +03:00
|
|
|
\item Cartographic knowledge was encoded to an algorithm (bottom-up
|
2021-04-13 09:12:06 +03:00
|
|
|
approach). One among these are \titlecite{wang1998line}, also known
|
|
|
|
as {\WM}'s algorithm.
|
|
|
|
|
2021-04-01 09:42:08 +03:00
|
|
|
\item Mathematical shape transformation which yields a more cartographic
|
2021-04-13 09:12:06 +03:00
|
|
|
result. E.g. \titlecite{jiang2003line},
|
|
|
|
\titlecite{dyken2009simultaneous}, \titlecite{mustafa2006dynamic},
|
|
|
|
\titlecite{nollenburg2008morphing}.
|
|
|
|
|
2021-03-30 17:37:13 +03:00
|
|
|
\end{itemize}
|
|
|
|
|
2021-04-01 15:32:16 +03:00
|
|
|
Authors of most of the aforementioned articles have implemented the
|
|
|
|
generalization algorithm, at least to generate the visuals in the articles.
|
|
|
|
However, I wasn't able to find code for any of those to evaluate with my
|
2021-04-13 09:12:06 +03:00
|
|
|
desired data set, or use as a basis for my own maps. {\WM} \cite{wang1998line}
|
|
|
|
is available in a commercial product.
|
2021-04-01 15:32:16 +03:00
|
|
|
|
2021-04-01 16:13:29 +03:00
|
|
|
Lack of robust openly available generalization algorithm implementations poses
|
|
|
|
a problem for map creation with free software: there is not a similar
|
2021-04-01 15:32:16 +03:00
|
|
|
high-quality simplification algorithm to create down-scaled maps, so any
|
|
|
|
cartographic work, which uses line generalization as part of its processing,
|
|
|
|
will be of sub-par quality. We believe that availability of high-quality
|
|
|
|
open-source tools is an important foundation for future cartographic
|
|
|
|
experimentation and development, thus it it benefits the cartographic society
|
|
|
|
as a whole.
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-17 16:16:27 +03:00
|
|
|
\subsection{Problematic with generalization of rivers}
|
2021-04-13 10:36:47 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Methodology}
|
2021-04-01 09:42:08 +03:00
|
|
|
\label{sec:methodology}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-13 09:12:06 +03:00
|
|
|
The original {\WM}'s algorithm \cite{wang1998line} leaves something to be
|
|
|
|
desired for a practical implementation: it is not straightforward to implement
|
|
|
|
the algorithm from the paper alone.
|
2021-04-01 16:24:47 +03:00
|
|
|
|
2021-04-12 13:33:51 +03:00
|
|
|
Explanations in this document are meant to expand, rather than substitute, the
|
2021-04-13 09:12:06 +03:00
|
|
|
original description in {\WM}. Therefore familiarity with the original paper is
|
|
|
|
assumed, and, for some sections, having it close-by is necessary to
|
|
|
|
meaningfully follow this document.
|
2021-04-12 13:33:51 +03:00
|
|
|
|
2021-04-01 16:24:47 +03:00
|
|
|
In this paper we describe {\WM} in a detail that is more useful for algorithm:
|
|
|
|
each section will be expanded, with more elaborate and exact illustrations for
|
|
|
|
every step of the algorithm.
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-12 12:00:17 +03:00
|
|
|
Algorithms discussed in this paper assume Euclidean geometry.
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Vocabulary and terminology}
|
2021-04-12 13:33:51 +03:00
|
|
|
|
|
|
|
This section defines vocabulary and terms as defined in the rest of the paper.
|
|
|
|
|
|
|
|
\begin{description}
|
|
|
|
|
|
|
|
\item[Vertex] is a point on a plane, can be expressed by a pair of $(x,y)$
|
|
|
|
coordinates.
|
|
|
|
|
|
|
|
\item[Line Segment (or Segment)] joins two vertices by a straight line. A
|
|
|
|
segment can be expressed by two coordinate pairs: $(x_1, y_1)$ and
|
2021-04-12 17:09:01 +03:00
|
|
|
$(x_2, y_2)$. Line Segment and Segment are used interchangeably
|
|
|
|
throughout the paper.
|
2021-04-12 13:33:51 +03:00
|
|
|
|
|
|
|
\item[Line] represents a single linear feature in the real world. For
|
|
|
|
example, a river or a coastline. {\tt LINESTRING} in GIS terms.
|
|
|
|
|
|
|
|
Geometrically, A line is a series of connected line segments, or,
|
|
|
|
equivalently, a series of connected vertices. Each vertex connects to
|
|
|
|
two other vertices, except those vertices at either ends of the line:
|
|
|
|
these two connect to a single other vertex.
|
|
|
|
|
2021-04-12 19:19:10 +03:00
|
|
|
\item[Bend] is a subset of a line that humans perceive as a curve. The
|
|
|
|
geometric definition is complex and is discussed in
|
|
|
|
section~\onpage{sec:definition-of-a-bend}.
|
2021-04-12 14:14:35 +03:00
|
|
|
|
2021-04-13 09:20:50 +03:00
|
|
|
\item[Baseline] is a line between bend's first and last vertex.
|
|
|
|
|
2021-04-13 10:05:52 +03:00
|
|
|
\item[Sum of inner angles] TBD.
|
|
|
|
|
2021-04-12 13:33:51 +03:00
|
|
|
\end{description}
|
|
|
|
|
2021-04-13 05:08:32 +03:00
|
|
|
\subsection{Radians and Degrees}
|
|
|
|
|
|
|
|
This document contains a few constant angles expressed in radians.
|
2021-04-13 05:20:37 +03:00
|
|
|
Table~\ref{table:radians} summarizes some of the values used in this document
|
|
|
|
and the implementation.
|
2021-04-13 05:08:32 +03:00
|
|
|
|
|
|
|
\begin{table}[h]
|
2021-04-13 05:20:37 +03:00
|
|
|
\centering
|
2021-04-13 05:08:32 +03:00
|
|
|
\begin{tabular}{|c|c|c|c|c|c|c|}
|
|
|
|
\hline
|
2021-04-13 20:51:38 +03:00
|
|
|
Degrees & $30^\circ$ & $45^\circ$ & $90^\circ$ & $180^\circ$ & $360^\circ$ \\
|
2021-04-13 05:08:32 +03:00
|
|
|
\hline
|
2021-04-13 08:31:01 +03:00
|
|
|
Radians & $\nicefrac{\pi}{6}$ & $\nicefrac{\pi}{4}$ & $\nicefrac{\pi}{2}$ & $\pi$ & $2\pi$ \\
|
2021-04-13 05:08:32 +03:00
|
|
|
\hline
|
|
|
|
\end{tabular}
|
2021-04-13 05:20:37 +03:00
|
|
|
\caption{Popular degree and radian values}
|
|
|
|
\label{table:radians}
|
2021-04-13 05:08:32 +03:00
|
|
|
\end{table}
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Automated tests}
|
2021-04-12 12:04:56 +03:00
|
|
|
\label{sec:automated-tests}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-01 16:24:47 +03:00
|
|
|
As part of the algorithm realization, an automated test suite has been
|
|
|
|
developed. Shapes to test each function have been hand-crafted and expected
|
|
|
|
results have been manually calculated. The test suite executes parts of the
|
|
|
|
algorithm against a predefined set of geometries, and asserts that the output
|
|
|
|
matches the resulting hand-calculated geometry.
|
|
|
|
|
2021-04-12 12:00:17 +03:00
|
|
|
The full set of test geometries is visualized in
|
|
|
|
figure~\onpage{fig:test-figures}. The figure includes arrows depicting line
|
|
|
|
direction.
|
2021-04-01 20:54:20 +03:00
|
|
|
|
2021-04-12 14:14:35 +03:00
|
|
|
\begin{figure}[h]
|
2021-04-01 19:30:20 +03:00
|
|
|
\centering
|
2021-04-18 18:11:21 +03:00
|
|
|
\includegraphics[width=\textwidth]{test-figures}
|
2021-04-03 12:46:45 +03:00
|
|
|
\caption{Line geometries for automated test cases}
|
2021-04-01 19:30:20 +03:00
|
|
|
\label{fig:test-figures}
|
|
|
|
\end{figure}
|
2021-04-01 16:24:47 +03:00
|
|
|
|
2021-04-01 20:44:22 +03:00
|
|
|
The full test suite can be executed with a single command, and completes in a
|
|
|
|
few seconds. Having an easily accessible test suite boosts confidence that no
|
2021-04-03 12:37:59 +03:00
|
|
|
unexpected bugs have snug in while modifying the algorithm.
|
2021-04-01 20:44:22 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Description of the implementation}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 08:31:01 +03:00
|
|
|
Like alluded in section~\onpage{sec:introduction}, {\WM} paper skims over
|
|
|
|
certain details, which are important to implement the algorithm. This section
|
|
|
|
goes through each algorithm stage, illustrating the intermediate steps and
|
|
|
|
explaining the author's desiderata for a more detailed description.
|
2021-04-11 20:39:38 +03:00
|
|
|
|
2021-04-12 12:04:56 +03:00
|
|
|
Illustrations of the following sections are extracted from the automated test
|
|
|
|
cases, which were written during the algorithm implementation (as discussed in
|
|
|
|
section~\onpage{sec:automated-tests}).
|
2021-04-11 20:39:38 +03:00
|
|
|
|
2021-04-12 12:04:56 +03:00
|
|
|
Lines in illustrations are black, and bends are heavily colored after
|
|
|
|
converting them to polygons. Bends are converted to polygons (for illustration
|
|
|
|
purposes) using the following algorithm:
|
2021-04-12 10:26:20 +03:00
|
|
|
|
|
|
|
\begin{itemize}
|
2021-04-12 12:04:56 +03:00
|
|
|
\item Join the first and last vertices of the bend, creating a polygon.
|
|
|
|
\item Color the polygons using distinct colors.
|
2021-04-12 10:26:20 +03:00
|
|
|
\end{itemize}
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Definition of a Bend}
|
2021-04-12 12:00:17 +03:00
|
|
|
\label{sec:definition-of-a-bend}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-12 17:09:01 +03:00
|
|
|
The original article describes a bend as:
|
2021-04-12 16:58:44 +03:00
|
|
|
|
2021-04-14 17:28:45 +03:00
|
|
|
\begin{displaycquote}{wang1998line}
|
2021-04-12 16:58:44 +03:00
|
|
|
A bend can be defined as that part of a line which contains a number of
|
|
|
|
subsequent vertices, with the inflection angles on all vertices included in
|
|
|
|
the bend being either positive or negative and the inflection of the bend's
|
|
|
|
two end vertices being in opposite signs.
|
2021-04-14 17:28:45 +03:00
|
|
|
\end{displaycquote}
|
2021-04-12 16:58:44 +03:00
|
|
|
|
2021-04-12 17:09:01 +03:00
|
|
|
While it gives a good intuitive understanding of what the bend is, this section
|
|
|
|
provides more technical details. Here are some non-obvious characteristics that
|
|
|
|
are necessary when writing code to detect the bends:
|
2021-04-12 16:58:44 +03:00
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
\item End segments of each line should also belong to bends. That way, all
|
|
|
|
segments belong to 1 or 2 bends.
|
|
|
|
|
|
|
|
\item First and last segments of each bend (except for the two end-line
|
|
|
|
segments) is also the first vertex of the next bend.
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
Properties above may be apparent when looking at illustrations at this article
|
|
|
|
or reading here, but they are nowhere as such when looking at the original
|
|
|
|
article.
|
2021-04-10 19:40:04 +03:00
|
|
|
|
2021-04-12 17:09:01 +03:00
|
|
|
Figure~\ref{fig:fig8-definition-of-a-bend} illustrates article's Figure 8,
|
|
|
|
but with bends colored as polygons: each color is a distinctive bend.
|
|
|
|
|
|
|
|
\begin{figure}[h]
|
|
|
|
\centering
|
2021-04-18 18:11:21 +03:00
|
|
|
\includegraphics[width=\textwidth]{fig8-definition-of-a-bend}
|
2021-04-12 17:09:01 +03:00
|
|
|
\caption{Originally Figure 8: detected bends are highlighted}
|
|
|
|
\label{fig:fig8-definition-of-a-bend}
|
|
|
|
\end{figure}
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Gentle Inflection at End of a Bend}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-12 16:58:44 +03:00
|
|
|
The gist of the section is in the original article:
|
|
|
|
|
2021-04-14 17:28:45 +03:00
|
|
|
\begin{displaycquote}{wang1998line}
|
2021-04-12 16:58:44 +03:00
|
|
|
But if the inflection that marks the end of a bend is quite small, people
|
|
|
|
would not recognize this as the bend point of a bend
|
2021-04-14 17:28:45 +03:00
|
|
|
\end{displaycquote}
|
2021-04-12 16:58:44 +03:00
|
|
|
|
2021-04-12 13:33:51 +03:00
|
|
|
Figure~\ref{fig:fig5-gentle-inflection} visualizes original paper's Figure 5,
|
|
|
|
when a single vertex is moved outwards the end of the bend.
|
|
|
|
|
|
|
|
\begin{figure}[h]
|
|
|
|
\centering
|
2021-04-18 16:38:03 +03:00
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-12 13:33:51 +03:00
|
|
|
\includegraphics[width=\textwidth]{fig5-gentle-inflection-before}
|
|
|
|
\caption{Before applying the inflection rule}
|
|
|
|
\end{subfigure}
|
|
|
|
\hfill
|
2021-04-18 16:38:03 +03:00
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-12 13:33:51 +03:00
|
|
|
\includegraphics[width=\textwidth]{fig5-gentle-inflection-after}
|
|
|
|
\caption{After applying the inflection rule}
|
|
|
|
\end{subfigure}
|
2021-04-12 17:09:01 +03:00
|
|
|
\caption{Originally Figure 5: gentle inflections at the ends of the bend}
|
2021-04-12 13:33:51 +03:00
|
|
|
\label{fig:fig5-gentle-inflection}
|
|
|
|
\end{figure}
|
|
|
|
|
2021-04-12 16:58:44 +03:00
|
|
|
The illustration for this section was clear, but insufficient: it does not
|
|
|
|
specify how many vertices should be included when calculating the end-of-bend
|
|
|
|
inflection. We chose the iterative approach --- as long as the angle is "right"
|
2021-04-12 14:14:35 +03:00
|
|
|
and the distance is decreasing, the algorithm should keep re-assigning vertices
|
|
|
|
to different bends; practically not having an upper bound on the number of
|
|
|
|
iterations.
|
2021-04-12 10:10:39 +03:00
|
|
|
|
2021-04-12 16:58:44 +03:00
|
|
|
To prove that the algorithm implementation is correct for multiple vertices,
|
|
|
|
additional example was created, and illustrated in
|
|
|
|
figure~\ref{fig:inflection-1-gentle-inflection}: the rule re-assigns two
|
|
|
|
vertices to the next bend instead of one.
|
2021-04-12 13:33:51 +03:00
|
|
|
|
2021-04-12 10:10:39 +03:00
|
|
|
\begin{figure}[h]
|
|
|
|
\centering
|
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-12 13:33:51 +03:00
|
|
|
\includegraphics[width=\textwidth]{inflection-1-gentle-inflection-before}
|
2021-04-12 10:10:39 +03:00
|
|
|
\caption{Before applying the inflection rule}
|
|
|
|
\end{subfigure}
|
|
|
|
\hfill
|
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-12 13:33:51 +03:00
|
|
|
\includegraphics[width=\textwidth]{inflection-1-gentle-inflection-after}
|
2021-04-12 10:10:39 +03:00
|
|
|
\caption{After applying the inflection rule}
|
|
|
|
\end{subfigure}
|
2021-04-12 20:14:27 +03:00
|
|
|
\caption{Gentle inflection at the end of the bend when multiple vertices is moved}
|
2021-04-12 13:33:51 +03:00
|
|
|
\label{fig:inflection-1-gentle-inflection}
|
2021-04-12 10:10:39 +03:00
|
|
|
\end{figure}
|
|
|
|
|
2021-04-12 20:14:27 +03:00
|
|
|
To find and fix the gentle bends' inflections requires to run the algorithm in
|
|
|
|
both directions; if implemented as documented, the steps will fail to match
|
2021-04-13 20:51:38 +03:00
|
|
|
some bends that should be mutated. This implementation does it in the following
|
|
|
|
way:
|
2021-04-12 20:14:27 +03:00
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
\item Run the algorithm from beginning to the end.
|
|
|
|
\item \label{rev1} Reverse the line and each bend.
|
|
|
|
\item Run the algorithm again.
|
|
|
|
\item \label{rev2} Reverse the line and each bend.
|
|
|
|
\item Return result.
|
|
|
|
\end{enumerate}
|
|
|
|
|
2021-04-13 04:26:19 +03:00
|
|
|
The current implementation is the most straightforward, but not optimal:
|
2021-04-12 20:14:27 +03:00
|
|
|
reversing of lines and bends could be avoided by walking backwards the lines.
|
2021-04-13 04:49:27 +03:00
|
|
|
In this case, steps \ref{rev1} and \ref{rev2} could be spared, thus saving
|
|
|
|
memory and computation time.
|
2021-04-12 13:33:51 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
The "quite small angle" was arbitrarily chosen to $\smallAngle$.
|
2021-04-13 04:26:19 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Self-line Crossing When Cutting a Bend}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 09:20:50 +03:00
|
|
|
When bend's baseline crosses another bend, it is called self-crossing. This is
|
2021-04-13 09:53:44 +03:00
|
|
|
undesirable in the upcoming operators, and self-crossings should be removed
|
|
|
|
following the rules of the article.
|
|
|
|
|
|
|
|
\begin{figure}[h]
|
|
|
|
\centering
|
2021-04-18 16:38:03 +03:00
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-17 17:19:41 +03:00
|
|
|
\includegraphics[width=\textwidth]{fig6-selfcrossing-before}
|
2021-04-17 20:42:59 +03:00
|
|
|
\caption{Bend's baseline (dotted) is crossing a neighboring bend}
|
2021-04-13 09:53:44 +03:00
|
|
|
\end{subfigure}
|
|
|
|
\hfill
|
2021-04-18 16:38:03 +03:00
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-17 17:19:41 +03:00
|
|
|
\includegraphics[width=\textwidth]{fig6-selfcrossing-after}
|
2021-04-17 20:42:59 +03:00
|
|
|
\caption{Self-crossing removed following the algorithm}
|
2021-04-13 09:53:44 +03:00
|
|
|
\end{subfigure}
|
2021-04-17 20:42:59 +03:00
|
|
|
\caption{Originally Figure 6: simple case of self-line crossing}
|
2021-04-17 17:19:41 +03:00
|
|
|
\label{fig:fig6-selfcrossing}
|
2021-04-13 09:53:44 +03:00
|
|
|
\end{figure}
|
2021-04-13 09:20:50 +03:00
|
|
|
|
2021-04-13 10:05:52 +03:00
|
|
|
The self-line-crossing may happen not by the neighboring bend, but by any other
|
2021-04-13 10:58:03 +03:00
|
|
|
bend in the line. For example, the baseline of the bend $(A, B)$ may cross
|
2021-04-17 17:19:41 +03:00
|
|
|
different bends in between, as depicted in
|
|
|
|
figure~\onpage{fig:selfcrossing-1-non-neighbor}.
|
|
|
|
|
|
|
|
\begin{figure}[h]
|
|
|
|
\centering
|
2021-04-18 16:38:03 +03:00
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-17 17:19:41 +03:00
|
|
|
\includegraphics[width=\textwidth]{selfcrossing-1-before}
|
2021-04-17 20:42:59 +03:00
|
|
|
\caption{Bend's baseline (dotted) is crossing a non-neighboring bend}
|
2021-04-17 17:19:41 +03:00
|
|
|
\end{subfigure}
|
|
|
|
\hfill
|
2021-04-18 16:38:03 +03:00
|
|
|
\begin{subfigure}[b]{.45\textwidth}
|
2021-04-17 17:36:32 +03:00
|
|
|
\includegraphics[width=\textwidth]{selfcrossing-1-after}
|
2021-04-17 20:42:59 +03:00
|
|
|
\caption{Self-crossing removed following the algorithm}
|
2021-04-17 17:36:32 +03:00
|
|
|
\end{subfigure}
|
2021-04-17 17:19:41 +03:00
|
|
|
\caption{Self-crossing with non-neighboring bend}
|
|
|
|
\label{fig:selfcrossing-1-non-neighbor}
|
|
|
|
\end{figure}
|
|
|
|
|
2021-04-17 20:42:59 +03:00
|
|
|
Naively implemented, checking every bend with every bend is costs $O(n^2)$. In
|
|
|
|
other words, the time it takes to run the algorithm grows quadratically with
|
|
|
|
the with the number of vertices.
|
2021-04-13 10:05:52 +03:00
|
|
|
|
|
|
|
It is possible to optimize this step and skip checking some of the bends. Only
|
|
|
|
bends whose sum of inner angles is $\pi$ can ever self-cross. If the value is
|
|
|
|
less than $\pi$, it cannot cross other bends. That way, only a fraction of
|
|
|
|
bends need to be checked.
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Attributes of a Single Bend}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-18 16:27:19 +03:00
|
|
|
|
|
|
|
|
2021-04-14 16:48:11 +03:00
|
|
|
\textsc{Compactness Index} is "the ratio of the area of the polygon over the
|
2021-04-14 10:46:56 +03:00
|
|
|
circle whose circumference length is the same as the length of the
|
2021-04-14 17:29:52 +03:00
|
|
|
circumference of the polygon" \cite{wang1998line}. Given a bend, its
|
|
|
|
compactness index is calculated as follows:
|
2021-04-14 10:46:56 +03:00
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
|
2021-04-14 11:49:52 +03:00
|
|
|
\item Construct a polygon by joining first and last vertices of the bend.
|
2021-04-14 10:46:56 +03:00
|
|
|
|
2021-04-14 11:49:52 +03:00
|
|
|
\item Calculate area of the polygon $P$.
|
2021-04-14 10:46:56 +03:00
|
|
|
|
2021-04-14 11:49:52 +03:00
|
|
|
\item Calculate perimeter of the polygon $u$. The same value is the
|
|
|
|
circumference of the circle.
|
2021-04-14 10:46:56 +03:00
|
|
|
|
2021-04-14 11:49:52 +03:00
|
|
|
\item Given circle's perimeter $u$, circle's area $A$ is:
|
2021-04-14 10:46:56 +03:00
|
|
|
|
|
|
|
\[
|
|
|
|
A = \frac{u^2}{4\pi}
|
|
|
|
\]
|
|
|
|
|
|
|
|
\item Compactness index is $\nicefrac{P}{A}$:
|
|
|
|
|
|
|
|
\[
|
2021-04-14 11:49:52 +03:00
|
|
|
cmp = \frac{P}{A} = \frac{P}{ \frac{u^2}{4\pi} } = \frac{4\pi P}{u^2}
|
2021-04-14 10:46:56 +03:00
|
|
|
\]
|
|
|
|
|
|
|
|
\end{enumerate}
|
|
|
|
|
2021-04-14 16:48:11 +03:00
|
|
|
Other than that, once this section is implemented, each bend will have a list
|
|
|
|
of properties, upon which actions later will be performed.
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Shape of a Bend}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-14 16:48:11 +03:00
|
|
|
This section introduces \textsc{adjusted size}, which trivially derives from
|
|
|
|
\textsc{compactness index} $cmp$ and shape's area $A$:
|
|
|
|
|
|
|
|
\[
|
|
|
|
adjsize = \frac{0.75 A}{cmp}
|
|
|
|
\]
|
|
|
|
|
|
|
|
Adjusted size becomes necessary later to compare bends with each other, and
|
|
|
|
find out similar ones.
|
|
|
|
|
2021-04-14 17:28:45 +03:00
|
|
|
\subsection{Isolated Bend}
|
|
|
|
|
2021-04-14 20:03:34 +03:00
|
|
|
Bend itself and its "isolation" can be described by \textsc{average curvature},
|
2021-04-14 17:28:45 +03:00
|
|
|
which is \textcquote{wang1998line}{geometrically defined as the ratio of
|
|
|
|
inflection over the length of a curve.}
|
|
|
|
|
2021-04-14 20:03:34 +03:00
|
|
|
Two conditions must be true to claim that a bend is isolated:
|
|
|
|
|
|
|
|
\begin{enumerate}
|
|
|
|
\item \textsc{average curvature} of neighboring bends, should be larger
|
|
|
|
than the "candidate" bend's curvature; this implementation arbitrarily
|
|
|
|
chose $\isolationThreshold$.
|
|
|
|
|
|
|
|
\item Bends on both sides of the "candidate" should be longer than a
|
|
|
|
certain value. This implementation does not (yet) define such a
|
|
|
|
constraint and will only follow the average curvature constraint above.
|
|
|
|
\end{enumerate}
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{The Context of a Bend: Isolated and Similar Bends}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-14 16:48:11 +03:00
|
|
|
To find out whether two bends are similar, they are compared by 3 components:
|
|
|
|
|
|
|
|
\begin{enumerate}
|
2021-04-14 17:32:00 +03:00
|
|
|
\item \textsc{adjusted size}
|
|
|
|
\item \textsc{compactness index}
|
2021-04-14 16:48:11 +03:00
|
|
|
\item Baseline length
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
These 3 components represent a point in the 3-dimensional space, and Euclidean
|
|
|
|
distance $d$ between those is calculated to differentiate between bends $p$ and
|
|
|
|
$q$:
|
|
|
|
|
|
|
|
\[
|
2021-04-14 17:28:45 +03:00
|
|
|
d(p,q) = \sqrt{(adjsize_p-adjsize_q)^2 +
|
|
|
|
(cmp_p-cmp_q)^2 +
|
|
|
|
(baseline_p-baseline_q)^2}
|
2021-04-14 16:48:11 +03:00
|
|
|
\]
|
2021-04-14 17:28:45 +03:00
|
|
|
|
2021-04-14 20:03:34 +03:00
|
|
|
The more similar the bends are, the smaller the distance $d$.
|
2021-04-14 16:48:11 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Elimination Operator}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Combination Operator}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\subsection{Exaggeration Operator}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Program Implementation}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Results of Experiments}
|
2021-04-01 16:13:29 +03:00
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Conclusions}
|
2021-03-30 17:37:13 +03:00
|
|
|
\label{sec:conclusions}
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Related Work and future suggestions}
|
2021-03-30 17:37:13 +03:00
|
|
|
\label{sec:related_work}
|
|
|
|
|
|
|
|
\printbibliography
|
|
|
|
|
|
|
|
\begin{appendices}
|
|
|
|
|
2021-04-13 04:49:27 +03:00
|
|
|
\section{Code listings}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-13 09:20:50 +03:00
|
|
|
\subsection{Reproducing the generalizations in this paper}
|
|
|
|
|
2021-04-01 16:13:29 +03:00
|
|
|
We strongly believe in the ability to reproduce the results is critical for any
|
|
|
|
scientific work. To make it possible for this paper, all source files and
|
2021-04-01 17:27:49 +03:00
|
|
|
accompanying scripts have been attached to the PDF. To re-generate this
|
|
|
|
document and its accompanying graphics, run this script (assuming name of
|
2021-04-02 06:22:10 +03:00
|
|
|
this document is {\tt mj-msc-full.pdf}):
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-03-31 15:12:42 +03:00
|
|
|
\inputminted[fontsize=\small]{bash}{extract-and-generate}
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-02 06:27:32 +03:00
|
|
|
This was tested on Linux Debian 11 with upstream packages only.
|
2021-03-30 17:37:13 +03:00
|
|
|
|
2021-04-14 20:16:39 +03:00
|
|
|
\subsection{Algorithm code listings}
|
|
|
|
\inputminted[fontsize=\small]{postgresql}{wm.sql}
|
2021-04-13 09:20:50 +03:00
|
|
|
|
2021-03-30 17:37:13 +03:00
|
|
|
\end{appendices}
|
|
|
|
\end{document}
|