better sine wave

This commit is contained in:
Motiejus Jakštys 2020-05-26 18:33:03 +03:00
parent 56090d23e3
commit b73f71eb82
4 changed files with 25 additions and 25 deletions

View File

@ -1,6 +1,6 @@
CROSSING=622916.858 6109272.561 626066.858 6111492.561 # xmin ymin xmax ymax
ZEIMENA_TOLERANCES = 100 125 250 500 1000 2000 4000
SINEWAVE_TOLERANCES = 1 2 3 4
SINEWAVE_TOLERANCES = 1 20 30 40
GEN = $(addsuffix .pdf, \
$(addprefix sinewave-douglas-,$(SINEWAVE_TOLERANCES)) \
$(addprefix sinewave-visvalingam-,$(SINEWAVE_TOLERANCES)) \
@ -22,17 +22,17 @@ crossing-$(1)-$(2)-%.pdf: layer2img.py db/.faux_$(1)-$(2)-%
endef
define gpkg2pdf
$(2): $(1)
./layer2img.py $(3) --infile=$(1) --outfile $(2)
$(2).pdf: $(1).gpkg
./layer2img.py $(3) --infile=$(1).gpkg --outfile $(2).pdf
endef
$(eval $(call algo2img,sinewave,douglas,52x12))
$(eval $(call algo2img,sinewave,visvalingam,52x12))
$(eval $(call algo2img,zeimena,douglas,52x74))
$(eval $(call algo2img,zeimena,visvalingam,52x74))
$(eval $(call gpkg2pdf,sinewave.gpkg,sinewave.pdf,--size=52x15))
$(eval $(call gpkg2pdf,zeimena.gpkg,zeimena.pdf,--size=148x210 --rect $(CROSSING)))
$(eval $(call gpkg2pdf,zeimena.gpkg,crossing.pdf,--size=105x74 --clip $(CROSSING)))
$(eval $(call gpkg2pdf,sinewave,sinewave,--size=52x15))
$(eval $(call gpkg2pdf,zeimena,zeimena,--size=148x210 --rect $(CROSSING)))
$(eval $(call gpkg2pdf,zeimena,crossing,--size=105x74 --clip $(CROSSING)))
sinewave.gpkg: sinewave.py
./sinewave.py

View File

@ -12,7 +12,6 @@ INCH = 25.4 # mm
def plt_size(string):
if not string:
# using default matplotlib dimensions
return None
try:
w, h = string.split("x")
@ -48,6 +47,7 @@ def main():
else:
f = geopandas.read_file(args.infile)
fig, ax = plt.subplots()
if args.size:
fig.set_size_inches(args.size)
f.plot(ax=ax)
if c := args.clip:

View File

@ -265,17 +265,17 @@ page~\pageref{tab:comparison-sinewave}.
\includegraphics[width=\linewidth]{sinewave-douglas-1} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-1} \tabularnewline \hline
2/4 &
\includegraphics[width=\linewidth]{sinewave-douglas-2} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-2} \tabularnewline \hline
20/400 &
\includegraphics[width=\linewidth]{sinewave-douglas-20} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-20} \tabularnewline \hline
3/9 &
\includegraphics[width=\linewidth]{sinewave-douglas-3} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-3} \tabularnewline \hline
30/900 &
\includegraphics[width=\linewidth]{sinewave-douglas-30} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-30} \tabularnewline \hline
4/16 &
\includegraphics[width=\linewidth]{sinewave-douglas-4} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-4} \tabularnewline \hline
40/1600 &
\includegraphics[width=\linewidth]{sinewave-douglas-40} &
\includegraphics[width=\linewidth]{sinewave-visvalingam-40} \tabularnewline \hline
\end{tabularx}
\caption{{\DP} and {\VW} on example wave}

View File

@ -6,7 +6,7 @@ import geopandas as gpd
from shapely.geometry import LineString, MultiLineString
INTERVAL = 0.1
TAIL_LEN = 10
TAIL_LEN = 7
SINE_LEN = 7
TAILS = np.zeros(int(TAIL_LEN / INTERVAL))
@ -17,7 +17,7 @@ def main():
amplitude = (np.sin(sin_range * pi / 2) + 1)*2
y = np.concatenate([TAILS, amplitude, TAILS])
x = np.arange(-TAIL_LEN - pi/4, SINE_LEN + TAIL_LEN, INTERVAL)
lines = LineString(zip(x, y))
lines = LineString(zip(x*10, y*10))
geom = MultiLineString([lines])
df = gpd.GeoDataFrame(crs=CRS(3346))
df['geometry'] = None