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
bd3b39c2
Commit
bd3b39c2
authored
May 28, 2018
by
Emmanuel René Huchim Puc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use wkt format to draw
parent
e29d5187
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+6
-3
openLayers4.js
catalog/static/js/openLayers4.js
+19
-0
views.py
catalog/views.py
+2
-1
No files found.
catalog/static/js/dataRetrieval.js
View file @
bd3b39c2
...
@@ -103,14 +103,17 @@ function drawPolygon(element) {
...
@@ -103,14 +103,17 @@ function drawPolygon(element) {
// remove prev polygon
// remove prev polygon
osmap
.
removePolygon
();
osmap
.
removePolygon
();
// draw wkt polygon
osmap
.
addWKTPolygon
(
polygon
.
wkt_polygon
)
// format coords to draw
// format coords to draw
var
coords
=
osmap
.
formatCoords
(
polygon
.
geojson
.
geometry
.
coordinates
);
//
var coords = osmap.formatCoords(polygon.geojson.geometry.coordinates);
// get the biggest area
// get the biggest area
var
biggest
=
osmap
.
getBiggestPolygon
(
coords
);
//
var biggest = osmap.getBiggestPolygon(coords);
// draw coordsR
// draw coordsR
osmap
.
addPolygon
(
biggest
);
//
osmap.addPolygon(biggest);
}
}
})
})
}
}
...
...
catalog/static/js/openLayers4.js
View file @
bd3b39c2
...
@@ -102,6 +102,25 @@ OpenStreetMapsClass.prototype.addPolygon = function(coords)
...
@@ -102,6 +102,25 @@ OpenStreetMapsClass.prototype.addPolygon = function(coords)
this
.
showCoords
(
feature
.
getGeometry
());
this
.
showCoords
(
feature
.
getGeometry
());
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/**
* Draw a polygon in the map
* @param wkt coords int wkt format to draw
*/
OpenStreetMapsClass
.
prototype
.
addWKTPolygon
=
function
(
wkt
)
{
var
format
=
new
ol
.
format
.
WKT
();
var
feature
=
format
.
readFeature
(
wkt
,
{
dataProjection
:
'EPSG:4326'
,
featureProjection
:
'EPSG:3857'
});
this
.
map
.
getView
().
fit
(
feature
.
getGeometry
(),
{
duration
:
1000
,
padding
:
[
0
,
0
,
70
,
0
]});
this
.
vectorLayer
.
getSource
().
addFeature
(
feature
);
document
.
getElementById
(
"id_polygon"
).
value
=
wkt
;
}
//------------------------------------------------------------------------------
/**
/**
* calculate the area of each polygon and return the coords of the biggest polygon
* calculate the area of each polygon and return the coords of the biggest polygon
* @param coords polygons coords
* @param coords polygons coords
...
...
catalog/views.py
View file @
bd3b39c2
...
@@ -120,7 +120,8 @@ class SearchSubmitView(View):
...
@@ -120,7 +120,8 @@ class SearchSubmitView(View):
'id'
:
str
(
polygon
.
id
),
'id'
:
str
(
polygon
.
id
),
'city'
:
polygonInfo
[
'properties'
][
'NOMGEO'
],
'city'
:
polygonInfo
[
'properties'
][
'NOMGEO'
],
'state'
:
self
.
state_parser
[
polygonInfo
[
'properties'
][
'CVE_ENT'
]],
'state'
:
self
.
state_parser
[
polygonInfo
[
'properties'
][
'CVE_ENT'
]],
'geojson'
:
polygonInfo
'geojson'
:
polygonInfo
,
'wkt_polygon'
:
polygon
.
wkt_polygon
})
})
# context = {
# context = {
...
...
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