Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
exercisemodel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stw
wt
exercisemodel
Commits
8673d807
Commit
8673d807
authored
Dec 12, 2017
by
Tomas Pettersson
🏸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing displaced points
parent
6082ac97
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
274 deletions
+12
-274
exercisemodel/__init__.py
exercisemodel/__init__.py
+4
-5
exercisemodel/model.py
exercisemodel/model.py
+6
-6
input.json
input.json
+1
-262
output.json
output.json
+1
-1
No files found.
exercisemodel/__init__.py
View file @
8673d807
...
...
@@ -62,11 +62,11 @@ def writeStatus(status):
def
run
():
try
:
# writeStatus
("INITIAL")
print
(
"INITIAL"
)
strtree
=
STRtree
(
pickle
.
load
(
pkg_resources
.
resource_stream
(
__name__
,
'/'
.
join
((
'resources'
,
'strtree.pickle'
)))))
m
=
Model
()()
with
open
(
'input.json'
,
"r"
)
as
inputfile
:
# writeStatus
("PARTIAL")
print
(
"PARTIAL"
)
inputfeaturecollection
=
json
.
load
(
inputfile
)
output
=
{}
multipointoutlet
=
{}
...
...
@@ -87,13 +87,12 @@ def run():
Cloudtrack
.
write
(
outputfeaturecollection
)
Particletrack
.
write
(
outputfeaturecollection
)
# Output.write(outputfeaturecollection)
# writeStatus("COMPLETE")
print
(
"COMPLETE"
)
sys
.
exit
(
0
)
except
Exception
as
error
:
print_exc
()
#
writeStatus("ERROR")
writeStatus
(
"ERROR"
)
sys
.
exit
(
1
)
'''
To run in terminal call with python __init__.py
...
...
exercisemodel/model.py
View file @
8673d807
...
...
@@ -86,7 +86,7 @@ class Model(object):
def
createOutlet
(
self
,
geom
):
nrOfParticles
=
5
00
nrOfParticles
=
1
00
center
=
geom
.
centroid
points
=
[]
depth
=
[]
...
...
@@ -151,9 +151,9 @@ class Model(object):
minoverlap
=
[
float
(
'Inf'
)]
*
len
(
points
)
radius
=
[
0
]
*
len
(
points
)
for
i
in
range
(
len
(
points
)):
radius
[
i
]
=
0.0
3
5
*
random
.
uniform
(
0.1
,
1
)
radius
[
i
]
=
0.0
01
5
*
random
.
uniform
(
0.1
,
1
)
while
(
p
<
len
(
points
)):
pn
=
p
+
1
pn
=
0
while
(
pn
<
len
(
points
)):
dx
=
points
[
p
][
0
]
-
points
[
pn
][
0
]
dy
=
points
[
p
][
1
]
-
points
[
pn
][
1
]
...
...
@@ -215,10 +215,11 @@ class Model(object):
mp
=
multipoint
linestring
=
geometry
.
shape
(
exercisefeature
[
'geometry'
])
for
i
,
coord
in
enumerate
(
linestring
.
coords
):
print
(
mp
.
centroid
)
points
=
self
.
centerPoints
(
coord
,
mp
.
centroid
,
mp
.
geoms
)
#
displacedpoints = self.displacePoints(points)
displacedpoints
=
self
.
displacePoints
(
points
)
# onlandpoints = self.onlandPoints(displacedpoints,strtree)
mp
=
geometry
.
MultiPoint
(
points
)
mp
=
geometry
.
MultiPoint
(
displaced
points
)
level
=
[
0
]
*
len
(
mp
.
geoms
)
category
=
[
2
]
*
len
(
mp
.
geoms
)
properties
=
self
.
createProperties
((
i
+
2
),
time
[
i
],
mp
.
centroid
,
level
,
category
)
...
...
@@ -226,6 +227,5 @@ class Model(object):
if
(
i
%
10
==
0
):
Cloudtrack
.
write
(
featurecollection
)
Particletrack
.
write
(
featurecollection
)
# Output.write(featurecollection)
return
featurecollection
input.json
View file @
8673d807
This diff is collapsed.
Click to expand it.
output.json
View file @
8673d807
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment