blob 1c2aa427 (8638B) - Raw
1 \documentclass[a4paper]{article} 2 3 \iffalse 4 \usepackage[L7x,T1]{fontenc} 5 \usepackage[lithuanian]{babel} 6 \else 7 \usepackage[T1]{fontenc} 8 \usepackage[english]{babel} 9 \fi 10 11 \usepackage[utf8]{inputenc} 12 \usepackage{a4wide} 13 \usepackage{csquotes} 14 \usepackage[maxbibnames=99,style=authoryear]{biblatex} 15 \usepackage[pdfusetitle]{hyperref} 16 \usepackage{enumitem} 17 \usepackage[toc,page,title]{appendix} 18 \addbibresource{bib.bib} 19 \usepackage{caption} 20 \usepackage{subcaption} 21 \usepackage{gensymb} 22 \usepackage{varwidth} 23 \usepackage{tabularx} 24 \usepackage{float} 25 \usepackage{tikz} 26 \usepackage{minted} 27 \usetikzlibrary{er,positioning} 28 \definecolor{mypurple}{RGB}{117,112,179} 29 \input{version} 30 31 \newcommand{\DP}{Douglas \& Peucker} 32 \newcommand{\VW}{Visvalingam--Whyatt} 33 \newcommand{\WM}{Wang--M{\"u}ller} 34 35 \newcommand{\MYTITLE}{Cartographic Generalization of Lines using free software (example of rivers)} 36 \newcommand{\MYAUTHOR}{Motiejus Jakštys} 37 38 \title{\MYTITLE} 39 \author{\MYAUTHOR} 40 \date{\VCDescribe} 41 42 \begin{document} 43 44 \begin{titlepage} 45 \begin{center} 46 \includegraphics[width=0.4\textwidth]{vu} 47 48 \huge 49 \textbf{\MYTITLE} \\[4ex] 50 51 \LARGE 52 \textbf{\MYAUTHOR} \\[8ex] 53 54 \vfill 55 56 A thesis presented for the degree of\\ 57 Master in Cartography \\[3ex] 58 59 \large 60 \VCDescribe 61 \end{center} 62 \end{titlepage} 63 64 \begin{abstract} 65 \label{sec:abstract} 66 Current open-source line generalization solutions have their roots in 67 mathematics and geometry, and are not fit for natural objects like rivers 68 and coastlines. This paper discusses our implementation of {\WM} algorithm 69 under and open-source license, explains things that we would had 70 appreciated in the original paper and compares our results to different 71 generalization algorithms. 72 \end{abstract} 73 74 \newpage 75 76 \tableofcontents 77 \listoffigures 78 79 \newpage 80 81 \section{Introduction} 82 \label{sec:introduction} 83 84 When creating small-scale maps, often the detail of the data source is greater 85 than desired for the map. This becomes especially acute for natural features 86 that have many bends, like coastlines, rivers and forest boundaries. 87 88 To create a small-scale map from a large-scale data source, these features need 89 to be generalized: detail should be reduced. However, while doing so, it is 90 important to preserve the "defining" shape of the original feature, otherwise 91 the result will look unrealistic. 92 93 For example, if a river is nearly straight, it should be nearly straight after 94 generalization, otherwise a too straightened river will look like a canal. 95 Conversely, if the river is highly wiggly, the number of bends should be 96 reduced, but not removed. 97 98 Generalization problem for other objects can often be solved by other 99 non-geometric means: 100 101 \begin{itemize} 102 \item Towns and cities can be filtered and generalized by number of 103 inhabitants. 104 \item Roads can be eliminated by the road length, number of lanes, or 105 classification of the road (local, regional, international). 106 \end{itemize} 107 108 Natural line generalization problem can be viewed as having two competing 109 goals: 110 111 \begin{itemize} 112 \item Reduce detail by removing or simplifying "less important" features. 113 \item Retain enough detail, so the original is still recognize-able. 114 \end{itemize} 115 116 Given the discussed complexities, a fine line between under-generalization 117 (leaving object as-is) and over-generalization (making a straight line) must be 118 found. Therein lies the complexity of generalization algorithms: all have 119 different trade-offs. 120 121 \section{Literature review} 122 \label{sec:literature-review} 123 124 A number of cartographic line generalization algorithms have been researched. 125 The "classical" ones are {\DP} and {\VW}. 126 127 \subsection{{\DP} and {\VW}} 128 129 \cite{douglas1973algorithms} and \cite{visvalingam1993line} are "classical" 130 line generalization computer graphics algorithms. They are relatively simple to 131 implement, require few runtime resources. Both of them accept only a single 132 parameter, based on desired scale of the map, which makes them very simple to 133 adjust for different scales. 134 135 Both algorithms are part of PostGIS, a free-software GIS suite: 136 \begin{itemize} 137 \item \cite{douglas1973algorithms} via 138 \href{https://postgis.net/docs/ST_Simplify.html}{PostGIS Simplify}. 139 140 \item \cite{visvalingam1993line} via 141 \href{https://postgis.net/docs/ST_SimplifyVW.html}{PostGIS SimplifyVW}. 142 \end{itemize} 143 144 Since both algorithms produce jagged output lines, it is worthwhile to process 145 those through a widely available \cite{chaikin1974algorithm} smoothing 146 algorithm via \href{https://postgis.net/docs/ST_ChaikinSmoothing.html}{PostGIS 147 ChaikinSmoothing}. 148 149 Even though {\DP} and {\VW} are simple to understand and computationally 150 efficient, they have serious deficiencies for cartographic natural line 151 generalization. 152 153 <TODO: expand on deficiencies> 154 155 \subsection{Modern approaches} 156 157 Due to their simplicity and ubiquity, {\DP} and {\VW} have been established as 158 go-to algorithms for line generalization. During recent years, more modern 159 replacement algorithms have emerged. These fall into roughly two categories: 160 161 \begin{itemize} 162 \item Cartographic knowledge was encoded to an algorithm (bottom-up 163 approach). One among these are \cite{wang1998line}. 164 \item Mathematical shape transformation which yields a more cartographic 165 result. E.g. \cite{jiang2003line}, \cite{dyken2009simultaneous}, 166 \cite{mustafa2006dynamic}, \cite{nollenburg2008morphing}. 167 \end{itemize} 168 169 Authors of most of the aforementioned articles have implemented the 170 generalization algorithm, at least to generate the visuals in the articles. 171 However, I wasn't able to find code for any of those to evaluate with my 172 desired data set, or use as a basis for my own maps. \cite{wang1998line} is 173 available in a commercial product. 174 175 Lack of robust openly available generalization algorithm implementations poses 176 a problem for map creation with free software: there is not a similar 177 high-quality simplification algorithm to create down-scaled maps, so any 178 cartographic work, which uses line generalization as part of its processing, 179 will be of sub-par quality. We believe that availability of high-quality 180 open-source tools is an important foundation for future cartographic 181 experimentation and development, thus it it benefits the cartographic society 182 as a whole. 183 184 \section{Methodology} 185 \label{sec:methodology} 186 187 The original \cite{wang1998line} leaves something to be desired for a practical 188 implementation: it is not straightforward to implement the algorithm from the 189 paper alone. 190 191 In this paper we describe {\WM} in a detail that is more useful for algorithm: 192 each section will be expanded, with more elaborate and exact illustrations for 193 every step of the algorithm. 194 195 \subsection{Automated tests} 196 197 As part of the algorithm realization, an automated test suite has been 198 developed. Shapes to test each function have been hand-crafted and expected 199 results have been manually calculated. The test suite executes parts of the 200 algorithm against a predefined set of geometries, and asserts that the output 201 matches the resulting hand-calculated geometry. 202 203 The full test suite can be executed with a single command, and completes in a 204 few seconds. Having an easily accessible test suite boosts confidence that no 205 unexpected regressions have been added while modifying the algorithm. 206 207 <TODO: expand with a screenshot> 208 209 \section{Description of the implementation} 210 211 \subsection{Definition of a Bend} 212 213 \subsection{Gentle Inflection at End of a Bend} 214 215 \subsection{Self-line Crossing When Cutting a Bend} 216 217 \subsection{Attributes of a Single Bend} 218 219 \subsection{Shape of a Bend} 220 221 \subsection{The Context of a Bend: Isolated and Similar Bends} 222 223 \subsection{Elimination Operator} 224 225 \subsection{Combination Operator} 226 227 \subsection{Exaggeration Operator} 228 229 \section{Program Implementation} 230 231 \section{Results of Experiments} 232 233 \section{Conclusions} 234 \label{sec:conclusions} 235 236 \section{Related Work and future suggestions} 237 \label{sec:related_work} 238 239 \printbibliography 240 241 \begin{appendices} 242 243 \section{Code listings} 244 245 We strongly believe in the ability to reproduce the results is critical for any 246 scientific work. To make it possible for this paper, all source files and 247 accompanying scripts have been attached to the PDF. To re-generate this 248 document and its accompanying graphics, run this script (assuming name of 249 this document is {\tt mj-msc-all.pdf}): 250 251 \inputminted[fontsize=\small]{bash}{extract-and-generate} 252 253 A reasonably up-to-date Linux or OS X system with a working Docker installation 254 is required. 255 256 \end{appendices} 257 \end{document}