Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
eef3c6f3
Commit
eef3c6f3
authored
Feb 19, 2019
by
Emmanuel René Huchim Puc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wkt script with shapely
parent
65f57ac2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
updateCompleteToWKT.py
catalog/management/commands/updateCompleteToWKT.py
+28
-0
views.py
catalog/views.py
+1
-6
No files found.
catalog/management/commands/updateCompleteToWKT.py
0 → 100644
View file @
eef3c6f3
from
django.core.management.base
import
BaseCommand
,
CommandError
from
catalog.models
import
Polygon
import
json
from
shapely.geometry
import
shape
class
Command
(
BaseCommand
):
def
handle
(
self
,
*
args
,
**
options
):
polygons
=
self
.
_ignore
(
Polygon
.
objects
.
all
(),
'santa lucia aeropuerto'
)
for
index
,
polygon
in
enumerate
(
polygons
):
geometry
=
self
.
_get_geometry
(
polygon
)
shapely_geometry
=
shape
(
geometry
)
polygon
.
wkt_polygon
=
shapely_geometry
.
wkt
polygon
.
save
()
print
(
'polygon
%
s updated c;'
%
index
)
def
_get_geometry
(
self
,
polygon
):
info
=
json
.
loads
(
polygon
.
json_info
)
return
info
[
'geometry'
]
def
_ignore
(
self
,
polygons
,
names
):
to_ignore
=
names
.
split
(
','
)
return
[
p
for
p
in
polygons
if
p
.
name
not
in
to_ignore
]
catalog/views.py
View file @
eef3c6f3
...
...
@@ -19,11 +19,6 @@ configfile = os.path.join(dirname, '../config/config.json')
with
open
(
configfile
,
'r'
)
as
f
:
config
=
json
.
load
(
f
)
print
(
config
[
'PATHS'
][
'PATH_GEOSENTINEL'
])
print
(
config
[
'PATHS'
][
'PATH_NAS'
])
print
(
config
[
'API_SENTINEL'
][
'SENTINEL_USER'
])
print
(
config
[
'API_SENTINEL'
][
'SENTINEL_PASS'
])
NAS_PATH
=
config
[
'PATHS'
][
'PATH_NAS'
]
USERS_PATH
=
config
[
'PATHS'
][
'PATH_USERS'
]
SENTINEL_PATH
=
config
[
'PATHS'
][
'PATH_GEOSENTINEL'
]
...
...
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