Commit 1f13a2d8 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

onland fixes

parent 57250af5
...@@ -91,7 +91,7 @@ class Model(object): ...@@ -91,7 +91,7 @@ class Model(object):
def createOutlet(self,geom): def createOutlet(self,geom):
nrOfParticles = 100 nrOfParticles = 300
center = geom.centroid center = geom.centroid
points = [] points = []
depth = [] depth = []
...@@ -281,20 +281,23 @@ class Model(object): ...@@ -281,20 +281,23 @@ class Model(object):
properties = self.createProperties(1, starttime, multipoint.centroid, [0] * len(multipoint.geoms), [2] * len(multipoint.geoms)) properties = self.createProperties(1, starttime, multipoint.centroid, [0] * len(multipoint.geoms), [2] * len(multipoint.geoms))
features.append(self.createFeature(multipoint, properties)) features.append(self.createFeature(multipoint, properties))
mp = multipoint mp = multipoint
activepoints = []
deactivepoints = [] deactivepoints = []
linestring = geometry.shape(exercisefeature['geometry']) linestring = geometry.shape(exercisefeature['geometry'])
latlngpoints = [[latlng[1], latlng[0]] for latlng in linestring.coords] latlngpoints = [[latlng[1], latlng[0]] for latlng in linestring.coords]
matches = strtree.query(LineString(latlngpoints)) matches = strtree.query(LineString(latlngpoints))
print('matches: '+str(matches)) # print('matches: '+str(matches))
for i, coord in enumerate(linestring.coords): for i, coord in enumerate(linestring.coords):
points = self.centerPoints(coord, mp.centroid, mp.geoms) # start = time.time()
displacedpoints = self.displacePoints(pDist, points) if (len(mp.geoms) > 0):
start = time.time() points = self.centerPoints(coord, mp.centroid, mp.geoms)
activepoints = [] displacedpoints = self.displacePoints(pDist, points)
activepoints, onlandpoints = self.onlandPoints(mp.geoms, displacedpoints, matches) activepoints, onlandpoints = self.onlandPoints(mp.geoms, displacedpoints, matches)
end = time.time() deactivepoints += onlandpoints
print('onland: '+str(end-start)) # print('active: '+str(len(activepoints)))
deactivepoints += onlandpoints # print('onland: '+str(len(onlandpoints)))
# end = time.time()
# print('onland: '+str(end-start))
mp = geometry.MultiPoint(activepoints+deactivepoints) mp = geometry.MultiPoint(activepoints+deactivepoints)
level = [0] * len(mp.geoms) level = [0] * len(mp.geoms)
category = [2] * len(mp.geoms) category = [2] * len(mp.geoms)
...@@ -303,5 +306,8 @@ class Model(object): ...@@ -303,5 +306,8 @@ class Model(object):
# if (i % 10 == 0): # if (i % 10 == 0):
# Cloudtrack.write(featurecollection) # Cloudtrack.write(featurecollection)
# Particletrack.write(featurecollection) # Particletrack.write(featurecollection)
mp = geometry.MultiPoint(activepoints)
print('deactivepoints: '+str(len(deactivepoints)))
return featurecollection return featurecollection
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