Commit 8673d807 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

testing displaced points

parent 6082ac97
...@@ -62,11 +62,11 @@ def writeStatus(status): ...@@ -62,11 +62,11 @@ def writeStatus(status):
def run(): def run():
try: try:
# writeStatus("INITIAL") print("INITIAL")
strtree = STRtree(pickle.load(pkg_resources.resource_stream(__name__, '/'.join(('resources', 'strtree.pickle'))))) strtree = STRtree(pickle.load(pkg_resources.resource_stream(__name__, '/'.join(('resources', 'strtree.pickle')))))
m = Model()() m = Model()()
with open('input.json',"r") as inputfile: with open('input.json',"r") as inputfile:
# writeStatus("PARTIAL") print("PARTIAL")
inputfeaturecollection = json.load(inputfile) inputfeaturecollection = json.load(inputfile)
output = {} output = {}
multipointoutlet = {} multipointoutlet = {}
...@@ -87,13 +87,12 @@ def run(): ...@@ -87,13 +87,12 @@ def run():
Cloudtrack.write(outputfeaturecollection) Cloudtrack.write(outputfeaturecollection)
Particletrack.write(outputfeaturecollection) Particletrack.write(outputfeaturecollection)
# Output.write(outputfeaturecollection) print("COMPLETE")
# writeStatus("COMPLETE")
sys.exit(0) sys.exit(0)
except Exception as error: except Exception as error:
print_exc() print_exc()
# writeStatus("ERROR") writeStatus("ERROR")
sys.exit(1) sys.exit(1)
''' '''
To run in terminal call with python __init__.py To run in terminal call with python __init__.py
......
...@@ -86,7 +86,7 @@ class Model(object): ...@@ -86,7 +86,7 @@ class Model(object):
def createOutlet(self,geom): def createOutlet(self,geom):
nrOfParticles = 500 nrOfParticles = 100
center = geom.centroid center = geom.centroid
points = [] points = []
depth = [] depth = []
...@@ -151,9 +151,9 @@ class Model(object): ...@@ -151,9 +151,9 @@ class Model(object):
minoverlap = [float('Inf')] * len(points) minoverlap = [float('Inf')] * len(points)
radius = [0] * len(points) radius = [0] * len(points)
for i in range(len(points)): for i in range(len(points)):
radius[i] = 0.035 * random.uniform(0.1, 1) radius[i] = 0.0015 * random.uniform(0.1, 1)
while (p < len(points)): while (p < len(points)):
pn = p + 1 pn = 0
while (pn < len(points)): while (pn < len(points)):
dx = points[p][0] - points[pn][0] dx = points[p][0] - points[pn][0]
dy = points[p][1] - points[pn][1] dy = points[p][1] - points[pn][1]
...@@ -215,10 +215,11 @@ class Model(object): ...@@ -215,10 +215,11 @@ class Model(object):
mp = multipoint mp = multipoint
linestring = geometry.shape(exercisefeature['geometry']) linestring = geometry.shape(exercisefeature['geometry'])
for i, coord in enumerate(linestring.coords): for i, coord in enumerate(linestring.coords):
print(mp.centroid)
points = self.centerPoints(coord, mp.centroid, mp.geoms) points = self.centerPoints(coord, mp.centroid, mp.geoms)
# displacedpoints = self.displacePoints(points) displacedpoints = self.displacePoints(points)
# onlandpoints = self.onlandPoints(displacedpoints,strtree) # onlandpoints = self.onlandPoints(displacedpoints,strtree)
mp = geometry.MultiPoint(points) mp = geometry.MultiPoint(displacedpoints)
level = [0] * len(mp.geoms) level = [0] * len(mp.geoms)
category = [2] * len(mp.geoms) category = [2] * len(mp.geoms)
properties = self.createProperties((i+2), time[i], mp.centroid, level, category) properties = self.createProperties((i+2), time[i], mp.centroid, level, category)
...@@ -226,6 +227,5 @@ class Model(object): ...@@ -226,6 +227,5 @@ class Model(object):
if (i % 10 == 0): if (i % 10 == 0):
Cloudtrack.write(featurecollection) Cloudtrack.write(featurecollection)
Particletrack.write(featurecollection) Particletrack.write(featurecollection)
# Output.write(featurecollection)
return featurecollection return featurecollection
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment