fix sinewave generator
This commit is contained in:
parent
996b03fb93
commit
94f0e54ea6
@ -3,7 +3,8 @@ GEN = $(addsuffix .pdf, \
|
|||||||
$(addprefix zeimena-douglas-,$(TOLERANCES)) \
|
$(addprefix zeimena-douglas-,$(TOLERANCES)) \
|
||||||
$(addprefix zeimena-visvalingam-,$(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 $<
|
latexmk -g -pdf $<
|
||||||
|
|
||||||
define algo2img
|
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
|
./layer2img.py --table=$(1)_$(2)_$(3) --size=52x74 --outfile $(1)-$(2)-$(3).pdf
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
$(eval $(call algo2img,sinewave,douglas,100))
|
||||||
$(foreach t,$(TOLERANCES),$(eval $(call algo2img,zeimena,douglas,$(t))))
|
$(foreach t,$(TOLERANCES),$(eval $(call algo2img,zeimena,douglas,$(t))))
|
||||||
$(foreach t,$(TOLERANCES),$(eval $(call algo2img,zeimena,visvalingam,$(t))))
|
$(foreach t,$(TOLERANCES),$(eval $(call algo2img,zeimena,visvalingam,$(t))))
|
||||||
|
|
||||||
sinewave.json: sinewave.py
|
sinewave.gpkg: sinewave.py
|
||||||
./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 stop; rm -fr db
|
||||||
./managedb init
|
./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" 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 $@
|
touch $@
|
||||||
|
|
||||||
REF = $(shell git describe --tags)
|
REF = $(shell git describe --tags)
|
||||||
|
@ -7,8 +7,8 @@ CREATE TABLE :tbl (
|
|||||||
|
|
||||||
INSERT INTO :tbl (geom) (
|
INSERT INTO :tbl (geom) (
|
||||||
SELECT
|
SELECT
|
||||||
ST_Simplify (ST_LineMerge (ST_Union (geom)),
|
ST_Multi (ST_Simplify (ST_LineMerge (ST_Union (geom)),
|
||||||
:tolerance) AS geoms
|
:tolerance)) AS geoms
|
||||||
FROM
|
FROM
|
||||||
:src);
|
:src);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from math import pi
|
|||||||
from pyproj import CRS
|
from pyproj import CRS
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
from shapely.geometry import LineString
|
from shapely.geometry import LineString, MultiLineString
|
||||||
|
|
||||||
INTERVAL = 0.1
|
INTERVAL = 0.1
|
||||||
TAIL_LEN = 4
|
TAIL_LEN = 4
|
||||||
@ -17,11 +17,12 @@ def main():
|
|||||||
amplitude = (np.sin(sin_range * pi / 2) + 1)*2
|
amplitude = (np.sin(sin_range * pi / 2) + 1)*2
|
||||||
y = np.concatenate([TAILS, amplitude, TAILS])
|
y = np.concatenate([TAILS, amplitude, TAILS])
|
||||||
x = np.arange(-TAIL_LEN - pi/4, SINE_LEN + TAIL_LEN, INTERVAL)
|
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 = gpd.GeoDataFrame(crs=CRS(3346))
|
||||||
df['geometry'] = None
|
df['geometry'] = None
|
||||||
df.loc[0, 'geometry'] = geom
|
df.loc[0, 'geometry'] = geom
|
||||||
df.to_file("sinewave.json", driver='GeoJSON')
|
df.to_file("sinewave.gpkg", driver='GPKG')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -7,8 +7,8 @@ CREATE TABLE :tbl (
|
|||||||
|
|
||||||
INSERT INTO :tbl (geom) (
|
INSERT INTO :tbl (geom) (
|
||||||
SELECT
|
SELECT
|
||||||
ST_SimplifyVW (ST_LineMerge (ST_Union (geom)),
|
ST_Multi (ST_SimplifyVW (ST_LineMerge (ST_Union (geom)),
|
||||||
:tolerance * :tolerance) AS geoms
|
:tolerance * :tolerance)) AS geoms
|
||||||
FROM
|
FROM
|
||||||
:src);
|
:src);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user