From 94f0e54ea6f9f8fcc1fb014f2f492a099ef110ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 26 May 2020 12:28:32 +0300 Subject: [PATCH] fix sinewave generator --- II/Referatas/Makefile | 10 ++++++---- II/Referatas/douglas.sql | 4 ++-- II/Referatas/sinewave.py | 7 ++++--- II/Referatas/visvalingam.sql | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/II/Referatas/Makefile b/II/Referatas/Makefile index ff198a9..8d3c417 100644 --- a/II/Referatas/Makefile +++ b/II/Referatas/Makefile @@ -3,7 +3,8 @@ GEN = $(addsuffix .pdf, \ $(addprefix zeimena-douglas-,$(TOLERANCES)) \ $(addprefix zeimena-visvalingam-,$(TOLERANCES))) -mj-referatas.pdf: mj-referatas.tex version.tex bib.bib zeimena-pretty.pdf $(GEN) +mj-referatas.pdf: mj-referatas.tex version.tex bib.bib zeimena-pretty.pdf \ + sinewave-douglas-100.pdf $(GEN) latexmk -g -pdf $< define algo2img @@ -15,17 +16,18 @@ $(1)-$(2)-$(3).pdf: layer2img.py db/.faux_$(1)-$(2)-$(3) ./layer2img.py --table=$(1)_$(2)_$(3) --size=52x74 --outfile $(1)-$(2)-$(3).pdf endef +$(eval $(call algo2img,sinewave,douglas,100)) $(foreach t,$(TOLERANCES),$(eval $(call algo2img,zeimena,douglas,$(t)))) $(foreach t,$(TOLERANCES),$(eval $(call algo2img,zeimena,visvalingam,$(t)))) -sinewave.json: sinewave.py +sinewave.gpkg: sinewave.py ./sinewave.py -db/.faux_ready: zeimena.gpkg sinewave.json managedb +db/.faux_ready: zeimena.gpkg sinewave.gpkg managedb -./managedb stop; rm -fr db ./managedb init ogr2ogr -f PostgreSQL "PG:host=127.0.0.1 user=osm dbname=osm" zeimena.gpkg - ogr2ogr -f PostgreSQL "PG:host=127.0.0.1 user=osm dbname=osm" sinewave.json + ogr2ogr -f PostgreSQL "PG:host=127.0.0.1 user=osm dbname=osm" sinewave.gpkg touch $@ REF = $(shell git describe --tags) diff --git a/II/Referatas/douglas.sql b/II/Referatas/douglas.sql index ef997e2..6d4a8bb 100644 --- a/II/Referatas/douglas.sql +++ b/II/Referatas/douglas.sql @@ -7,8 +7,8 @@ CREATE TABLE :tbl ( INSERT INTO :tbl (geom) ( SELECT - ST_Simplify (ST_LineMerge (ST_Union (geom)), - :tolerance) AS geoms + ST_Multi (ST_Simplify (ST_LineMerge (ST_Union (geom)), + :tolerance)) AS geoms FROM :src); diff --git a/II/Referatas/sinewave.py b/II/Referatas/sinewave.py index e718d90..8a4923b 100755 --- a/II/Referatas/sinewave.py +++ b/II/Referatas/sinewave.py @@ -3,7 +3,7 @@ from math import pi from pyproj import CRS import numpy as np import geopandas as gpd -from shapely.geometry import LineString +from shapely.geometry import LineString, MultiLineString INTERVAL = 0.1 TAIL_LEN = 4 @@ -17,11 +17,12 @@ 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) - geom = LineString(zip(x, y)) + lines = LineString(zip(x, y)) + geom = MultiLineString([lines]) df = gpd.GeoDataFrame(crs=CRS(3346)) df['geometry'] = None df.loc[0, 'geometry'] = geom - df.to_file("sinewave.json", driver='GeoJSON') + df.to_file("sinewave.gpkg", driver='GPKG') if __name__ == '__main__': diff --git a/II/Referatas/visvalingam.sql b/II/Referatas/visvalingam.sql index 340ce1d..31668cb 100644 --- a/II/Referatas/visvalingam.sql +++ b/II/Referatas/visvalingam.sql @@ -7,8 +7,8 @@ CREATE TABLE :tbl ( INSERT INTO :tbl (geom) ( SELECT - ST_SimplifyVW (ST_LineMerge (ST_Union (geom)), - :tolerance * :tolerance) AS geoms + ST_Multi (ST_SimplifyVW (ST_LineMerge (ST_Union (geom)), + :tolerance * :tolerance)) AS geoms FROM :src);