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-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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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__':
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user