2020-05-26 11:39:05 +03:00
|
|
|
#!/usr/bin/python
|
2020-05-26 11:56:58 +03:00
|
|
|
from math import pi
|
2020-05-26 11:39:05 +03:00
|
|
|
from pyproj import CRS
|
|
|
|
import numpy as np
|
|
|
|
import geopandas as gpd
|
|
|
|
from shapely.geometry import LineString
|
|
|
|
|
2020-05-26 11:56:58 +03:00
|
|
|
INTERVAL = 0.1
|
2020-05-26 11:39:05 +03:00
|
|
|
TAIL_LEN = 4
|
|
|
|
SINE_LEN = 7
|
|
|
|
|
2020-05-26 11:56:58 +03:00
|
|
|
TAILS = np.zeros(int(TAIL_LEN / INTERVAL))
|
|
|
|
|
2020-05-26 11:39:05 +03:00
|
|
|
|
|
|
|
def main():
|
2020-05-26 11:56:58 +03:00
|
|
|
sin_range = np.arange(-pi/4, SINE_LEN, INTERVAL)
|
2020-05-26 12:11:41 +03:00
|
|
|
amplitude = (np.sin(sin_range * pi / 2) + 1)*2
|
2020-05-26 11:56:58 +03:00
|
|
|
y = np.concatenate([TAILS, amplitude, TAILS])
|
|
|
|
x = np.arange(-TAIL_LEN - pi/4, SINE_LEN + TAIL_LEN, INTERVAL)
|
2020-05-26 11:39:05 +03:00
|
|
|
geom = LineString(zip(x, y))
|
|
|
|
df = gpd.GeoDataFrame(crs=CRS(3346))
|
|
|
|
df['geometry'] = None
|
|
|
|
df.loc[0, 'geometry'] = geom
|
|
|
|
df.to_file("sinewave.json", driver='GeoJSON')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|