use wkt format to draw

parent e29d5187
......@@ -103,14 +103,17 @@ function drawPolygon(element) {
// remove prev polygon
osmap.removePolygon();
// draw wkt polygon
osmap.addWKTPolygon(polygon.wkt_polygon)
// format coords to draw
var coords = osmap.formatCoords(polygon.geojson.geometry.coordinates);
// var coords = osmap.formatCoords(polygon.geojson.geometry.coordinates);
// get the biggest area
var biggest = osmap.getBiggestPolygon(coords);
// var biggest = osmap.getBiggestPolygon(coords);
// draw coordsR
osmap.addPolygon(biggest);
// osmap.addPolygon(biggest);
}
})
}
......
......@@ -102,6 +102,25 @@ OpenStreetMapsClass.prototype.addPolygon = function(coords)
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
* @param coords polygons coords
......
......@@ -120,7 +120,8 @@ class SearchSubmitView(View):
'id': str(polygon.id),
'city': polygonInfo['properties']['NOMGEO'],
'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
'geojson': polygonInfo
'geojson': polygonInfo,
'wkt_polygon': polygon.wkt_polygon
})
# context = {
......
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