fix dimension arithmetic

This commit is contained in:
Motiejus Jakštys 2021-04-18 16:38:03 +03:00
parent 6d4463e7d6
commit da06f6e803
3 changed files with 26 additions and 19 deletions

View File

@ -96,33 +96,34 @@ fig5-gentle-inflection-after_1SELECT = wm_debug where name='fig5' AND stage='cin
fig5-gentle-inflection-after_2SELECT = wm_debug where name='fig5' AND stage='cinflections-polygon' AND gen=1 fig5-gentle-inflection-after_2SELECT = wm_debug where name='fig5' AND stage='cinflections-polygon' AND gen=1
fig5-gentle-inflection-after_2CMAP = 1 fig5-gentle-inflection-after_2CMAP = 1
inflection-1-gentle-inflection-before_SIZE = A5 inflection-1-gentle-inflection-before_WIDTHDIV = 2
inflection-1-gentle-inflection-before_1SELECT = wm_debug where name='inflection-1' AND stage='bbends' AND gen=1 inflection-1-gentle-inflection-before_1SELECT = wm_debug where name='inflection-1' AND stage='bbends' AND gen=1
inflection-1-gentle-inflection-before_2SELECT = wm_debug where name='inflection-1' AND stage='bbends-polygon' AND gen=1 inflection-1-gentle-inflection-before_2SELECT = wm_debug where name='inflection-1' AND stage='bbends-polygon' AND gen=1
inflection-1-gentle-inflection-before_2CMAP = 1 inflection-1-gentle-inflection-before_2CMAP = 1
inflection-1-gentle-inflection-after_SIZE = A5 inflection-1-gentle-inflection-after_WIDTHDIV = 2
inflection-1-gentle-inflection-after_1SELECT = wm_debug where name='inflection-1' AND stage='cinflections' AND gen=1 inflection-1-gentle-inflection-after_1SELECT = wm_debug where name='inflection-1' AND stage='cinflections' AND gen=1
inflection-1-gentle-inflection-after_2SELECT = wm_debug where name='inflection-1' AND stage='cinflections-polygon' AND gen=1 inflection-1-gentle-inflection-after_2SELECT = wm_debug where name='inflection-1' AND stage='cinflections-polygon' AND gen=1
inflection-1-gentle-inflection-after_2CMAP = 1 inflection-1-gentle-inflection-after_2CMAP = 1
fig6-selfcrossing-before_SIZE = A7 fig6-selfcrossing-before_WIDTHDIV = 2
fig6-selfcrossing-before_1SELECT = wm_debug where name='fig6' AND stage='bbends' AND gen=1 fig6-selfcrossing-before_1SELECT = wm_debug where name='fig6' AND stage='bbends' AND gen=1
fig6-selfcrossing-before_2SELECT = wm_visuals where name='fig6-baseline' fig6-selfcrossing-before_2SELECT = wm_visuals where name='fig6-baseline'
fig6-selfcrossing-before_2LINESTYLE = dotted fig6-selfcrossing-before_2LINESTYLE = dotted
fig6-selfcrossing-before_3SELECT = wm_visuals where name='fig6-newline' fig6-selfcrossing-before_3SELECT = wm_visuals where name='fig6-newline'
fig6-selfcrossing-after_SIZE = A7 fig6-selfcrossing-after_WIDTHDIV = 2
fig6-selfcrossing-after_1SELECT = wm_debug where name='fig6' AND stage='dcrossings' AND gen=1 fig6-selfcrossing-after_1SELECT = wm_debug where name='fig6' AND stage='dcrossings' AND gen=1
selfcrossing-1-before_SIZE = A7 selfcrossing-1-before_WIDTHDIV = 2
selfcrossing-1-before_1SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1 selfcrossing-1-before_1SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1
selfcrossing-1-before_2SELECT = wm_visuals where name='selfcrossing-1-baseline' selfcrossing-1-before_2SELECT = wm_visuals where name='selfcrossing-1-baseline'
selfcrossing-1-before_2LINESTYLE = dotted selfcrossing-1-before_2LINESTYLE = dotted
selfcrossing-1-before_3SELECT = wm_visuals where name='selfcrossing-1-newline' selfcrossing-1-before_3SELECT = wm_visuals where name='selfcrossing-1-newline'
selfcrossing-1-after_SIZE = A7 selfcrossing-1-after_WIDTHDIV = 2
selfcrossing-1-after_1SELECT = wm_debug where name='selfcrossing-1' AND stage='dcrossings' AND gen=1 selfcrossing-1-after_1SELECT = wm_debug where name='selfcrossing-1' AND stage='dcrossings' AND gen=1
selfcrossing-1-after_2SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1 selfcrossing-1-after_2SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1
selfcrossing-1-after_2LINESTYLE = invisible selfcrossing-1-after_2LINESTYLE = invisible
.faux_test-rivers: tests-rivers.sql wm.sql .faux_db .faux_test-rivers: tests-rivers.sql wm.sql .faux_db
./db -f $< ./db -f $<
touch $@ touch $@

View File

@ -10,17 +10,20 @@ from matplotlib import rc
CMAP = 'tab20c' CMAP = 'tab20c'
BOUNDS = ('xmin', 'ymin', 'xmax', 'ymax') BOUNDS = ('xmin', 'ymin', 'xmax', 'ymax')
INCH = 25.4 # mm INCH_MM = 25.4 # mm
BLACK, GREEN, ORANGE, PURPLE = '#000000', '#1b9e77', '#d95f02', '#7570b3' BLACK, GREEN, ORANGE, PURPLE = '#000000', '#1b9e77', '#d95f02', '#7570b3'
PSQL_CREDS = "host=127.0.0.1 dbname=osm user=osm password=osm" PSQL_CREDS = "host=127.0.0.1 dbname=osm user=osm password=osm"
# see `NOTICE` in the LaTeX document; this is the width of the main text block.
TEXTWIDTH_CM = 12.12364
TEXTWIDTH_INCH = TEXTWIDTH_CM * 10 / INCH_MM
def plt_size(string): def plt_size(string):
if not string: if not string:
return None return None
try: try:
w, h = string.split("x") w, h = string.split("x")
return float(w) / INCH, float(h) / INCH return float(w) / INCH_MM, float(h) / INCH_MM
except Exception as e: except Exception as e:
raise argparse.ArgumentTypeError from e raise argparse.ArgumentTypeError from e
@ -87,7 +90,8 @@ def main():
if args.size: if args.size:
fig.set_size_inches(args.size) fig.set_size_inches(args.size)
else: else:
fig.set_figwidth(8.27 / args.widthdiv) w = TEXTWIDTH_INCH / args.widthdiv
fig.set_figwidth(TEXTWIDTH_INCH / args.widthdiv)
if c := args.clip: if c := args.clip:
ax.set_xlim(left=c[0], right=c[2]) ax.set_xlim(left=c[0], right=c[2])
ax.set_ylim(bottom=c[1], top=c[3]) ax.set_ylim(bottom=c[1], top=c[3])

View File

@ -81,10 +81,12 @@ Current open-source line generalization solutions have their roots in
\section{Introduction} \section{Introduction}
\label{sec:introduction} \label{sec:introduction}
\begin{itemize} \iffalse
\item Text width in pt: \prntlen{\textwidth} NOTICE: this value should be copied to layer2img.py:TEXTWIDTH, so dimensions
\item Text width in cm: {\printinunitsof{cm}\prntlen{\textwidth}} of inline images are reasonable.
\end{itemize}
Text width in cm: {\printinunitsof{cm}\prntlen{\textwidth}}
\fi
When creating small-scale maps, often the detail of the data source is greater 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 than desired for the map. This becomes especially acute for natural features
@ -357,12 +359,12 @@ when a single vertex is moved outwards the end of the bend.
\begin{figure}[h] \begin{figure}[h]
\centering \centering
\begin{subfigure}[b]{.49\textwidth} \begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{fig5-gentle-inflection-before} \includegraphics[width=\textwidth]{fig5-gentle-inflection-before}
\caption{Before applying the inflection rule} \caption{Before applying the inflection rule}
\end{subfigure} \end{subfigure}
\hfill \hfill
\begin{subfigure}[b]{.49\textwidth} \begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{fig5-gentle-inflection-after} \includegraphics[width=\textwidth]{fig5-gentle-inflection-after}
\caption{After applying the inflection rule} \caption{After applying the inflection rule}
\end{subfigure} \end{subfigure}
@ -425,12 +427,12 @@ following the rules of the article.
\begin{figure}[h] \begin{figure}[h]
\centering \centering
\begin{subfigure}[b]{.4\textwidth} \begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{fig6-selfcrossing-before} \includegraphics[width=\textwidth]{fig6-selfcrossing-before}
\caption{Bend's baseline (dotted) is crossing a neighboring bend} \caption{Bend's baseline (dotted) is crossing a neighboring bend}
\end{subfigure} \end{subfigure}
\hfill \hfill
\begin{subfigure}[b]{.4\textwidth} \begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{fig6-selfcrossing-after} \includegraphics[width=\textwidth]{fig6-selfcrossing-after}
\caption{Self-crossing removed following the algorithm} \caption{Self-crossing removed following the algorithm}
\end{subfigure} \end{subfigure}
@ -445,12 +447,12 @@ figure~\onpage{fig:selfcrossing-1-non-neighbor}.
\begin{figure}[h] \begin{figure}[h]
\centering \centering
\begin{subfigure}[b]{.4\textwidth} \begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{selfcrossing-1-before} \includegraphics[width=\textwidth]{selfcrossing-1-before}
\caption{Bend's baseline (dotted) is crossing a non-neighboring bend} \caption{Bend's baseline (dotted) is crossing a non-neighboring bend}
\end{subfigure} \end{subfigure}
\hfill \hfill
\begin{subfigure}[b]{.4\textwidth} \begin{subfigure}[b]{.45\textwidth}
\includegraphics[width=\textwidth]{selfcrossing-1-after} \includegraphics[width=\textwidth]{selfcrossing-1-after}
\caption{Self-crossing removed following the algorithm} \caption{Self-crossing removed following the algorithm}
\end{subfigure} \end{subfigure}