Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
aqdl
geoblobs
osmaug_pkg
Commits
7e553997
Commit
7e553997
authored
Jan 27, 2022
by
Jean-Marie Lepioufle
Browse files
typo + upgrade version
parent
eacc202d
Changes
5
Hide whitespace changes
Inline
Side-by-side
osmaug/collosm.py
View file @
7e553997
...
...
@@ -3,6 +3,7 @@ import json
from
osmaug.combine.collosm_main
import
collosm_function
import
random
import
string
import
os
def
get_random_alphanumeric_string
(
length
):
letters_and_digits
=
string
.
ascii_letters
+
string
.
digits
...
...
@@ -17,6 +18,7 @@ def main():
parser
.
add_argument
(
"-w"
,
help
=
"path of the workdir"
)
parser
.
add_argument
(
"-c"
,
help
=
"json configuration file providing the whole set of parameter"
)
parser
.
add_argument
(
"-s"
,
help
=
"json sessions file providing keys about outcomes from aqdl modules"
)
args
=
parser
.
parse_args
()
if
not
os
.
path
.
exists
(
args
.
w
):
raise
ValueError
(
"path "
+
args
.
w
+
" does not exist"
)
with
open
(
os
.
path
.
join
(
args
.
w
,
"config"
,
args
.
c
),
encoding
=
'utf8'
)
as
f
:
...
...
@@ -25,12 +27,13 @@ def main():
get_session_config
=
json
.
load
(
f
)
key
=
get_random_alphanumeric_string
(
20
)
collosm_config
[
'sessiondir'
]
=
os
.
path
.
join
(
args
.
w
,
"session"
,
key
)
collosm_config
[
"tabdir"
]
=
os
.
path
.
join
(
args
.
w
,
'session'
,
get_session_config
[
'aqmet'
])
collosm_config
[
"tiledir"
]
=
os
.
path
.
join
(
args
.
w
,
'session'
,
get_session_config
[
'osmaug_getosm'
])
os
.
makedirs
(
collosm_config
[
'sessiondir'
],
exist_ok
=
True
)
collosm_config
[
"tabdir"
]
=
os
.
path
.
join
(
args
.
w
,
'session'
,
get_session_config
[
'aqmet'
][
0
])
collosm_config
[
"tiledir"
]
=
os
.
path
.
join
(
args
.
w
,
'session'
,
get_session_config
[
'osmaug_getosm'
][
0
])
collosm_function
(
collosm_config
)
print
(
"Combining OSM pictures augmentation to dataset completed."
)
#save updated sessions file
get_session_config
[
'osmaug_collosm'
]
=
key
get_session_config
[
'osmaug_collosm'
]
=
[
key
]
with
open
(
os
.
path
.
join
(
args
.
w
,
"config"
,
args
.
s
),
'w'
,
encoding
=
'utf8'
)
as
f_sessions
:
json
.
dump
(
get_session_config
,
f_sessions
)
...
...
osmaug/combine/collosm_main.py
View file @
7e553997
...
...
@@ -12,10 +12,14 @@ def collosm_function(params: Dict):
tiledir
=
os
.
path
.
join
(
params
[
'tiledir'
],
'tile'
)
tabdir
=
os
.
path
.
join
(
params
[
'tabdir'
],
'tab'
)
resdir
=
os
.
path
.
join
(
params
[
'sessiondir'
])
res_data_dir
=
os
.
path
.
join
(
resdir
,
'tab'
)
res_img_dir
=
os
.
path
.
join
(
resdir
,
'img'
)
if
not
os
.
path
.
exists
(
resdir
):
os
.
mkdir
(
resdir
)
res_data_dir
=
os
.
path
.
join
(
resdir
,
'tab'
)
if
not
os
.
path
.
exists
(
res_data_dir
):
os
.
mkdir
(
res_data_dir
)
res_img_dir
=
os
.
path
.
join
(
resdir
,
'img'
)
if
not
os
.
path
.
exists
(
res_img_dir
):
os
.
mkdir
(
res_img_dir
)
df
=
pd
.
read_csv
(
os
.
path
.
join
(
tabdir
,
'dataset.csv'
),
sep
=
','
)
df
[
'ID'
]
=
df
[
'ID'
].
apply
(
str
)
tile
=
pd
.
DataFrame
.
from_dict
(
params
[
'tile'
],
orient
=
'columns'
)
...
...
osmaug/getosm.py
View file @
7e553997
import
argparse
import
json
from
osmaug.osm.getosm_main
import
getosm_
mai
n
from
osmaug.osm.getosm_main
import
getosm_
functio
n
import
random
import
string
import
os
def
get_random_alphanumeric_string
(
length
):
letters_and_digits
=
string
.
ascii_letters
+
string
.
digits
...
...
@@ -17,6 +18,7 @@ def main():
parser
.
add_argument
(
"-w"
,
help
=
"path of the workdir"
)
parser
.
add_argument
(
"-c"
,
help
=
"json configuration file providing the whole set of parameter"
)
parser
.
add_argument
(
"-s"
,
help
=
"json sessions file providing keys about outcomes from aqdl modules"
)
args
=
parser
.
parse_args
()
if
not
os
.
path
.
exists
(
args
.
w
):
raise
ValueError
(
"path "
+
args
.
w
+
" does not exist"
)
with
open
(
os
.
path
.
join
(
args
.
w
,
"config"
,
args
.
c
),
encoding
=
'utf8'
)
as
f
:
...
...
@@ -26,10 +28,11 @@ def main():
# create a new session for results
key
=
get_random_alphanumeric_string
(
20
)
getosm_config
[
'sessiondir'
]
=
os
.
path
.
join
(
args
.
w
,
"session"
,
key
)
os
.
makedirs
(
getosm_config
[
'sessiondir'
],
exist_ok
=
True
)
getosm_function
(
getosm_config
)
print
(
"Getting OSM as RGB picture completed."
)
#save updated sessions file
get_session_config
[
'osmaug_getosm'
]
=
key
get_session_config
[
'osmaug_getosm'
]
=
[
key
]
with
open
(
os
.
path
.
join
(
args
.
w
,
"config"
,
args
.
s
),
'w'
,
encoding
=
'utf8'
)
as
f_sessions
:
json
.
dump
(
get_session_config
,
f_sessions
)
...
...
osmaug/osm/getosm_main.py
View file @
7e553997
...
...
@@ -11,7 +11,7 @@ def getosm_function(params: Dict):
os
.
mkdir
(
resdir
)
points
=
pd
.
DataFrame
.
from_dict
(
params
[
'points'
],
orient
=
'columns'
)
sources
=
pd
.
DataFrame
.
from_dict
(
params
[
'source'
],
orient
=
'columns'
)
for
i
,
src
in
sources
.
iterrows
()
;
for
i
,
src
in
sources
.
iterrows
()
:
print
(
"**---> "
+
src
[
'name'
])
if
src
[
'type'
]
==
"wms"
:
wms_source
=
map_wms_source
(
src
[
'url'
],
src
[
'layers'
],
src
[
'styles'
],
src
[
'fmt'
],
src
[
'transparent'
],
src
[
'cql_filter'
])
...
...
@@ -21,7 +21,7 @@ def getosm_function(params: Dict):
print
(
"-> "
+
row
[
'ID'
])
tmp
=
make_bbox
(
row
[
'coords'
],
row
[
'conv_crs'
],
row
[
'delta_meters'
])
file
=
os
.
path
.
join
(
resdir
,
str
(
row
[
'ID'
])
+
'_'
+
str
(
src
[
'name'
])
+
'_zoom_'
+
str
(
src
[
'zoom'
])
+
'.html'
)
load_map
(
tmp
,
wms_source
,
zoom
,
file
)
load_map
(
tmp
,
wms_source
,
src
[
'
zoom
'
]
,
file
)
tmp_png
=
map2png
(
file
,
5
,
driver_bin
)
tmp_jpg
=
png2jpg
(
tmp_png
)
os
.
remove
(
file
)
...
...
setup.py
View file @
7e553997
...
...
@@ -16,7 +16,7 @@ dev_requirements = []
setup
(
name
=
'osmaug'
,
version
=
'0.0
6
dev'
,
version
=
'0.0
7
dev'
,
author
=
'Jean-Marie Lepioufle, Islen Vallejo'
,
author_email
=
'jml@nilu.no, iv@nilu.no'
,
packages
=
[
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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