Skip to content

Commit

Permalink
Reproject when writing features in ngeo.FeatureHelper, when exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
adube committed Apr 20, 2016
1 parent 84850da commit 04e55f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/directives/exportfeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ngeo.ExportfeaturesController = function($element, $injector, $scope,
*/
this.items_ = [];

// build the drop-down menu and items of there's more than one format
// build the drop-down menu and items if there's more than one format
if (formats.length > 1) {
$element.attr('id', id);
var $menu = $('<ul />', {
Expand Down
20 changes: 9 additions & 11 deletions src/services/featurehelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,24 +516,22 @@ ngeo.FeatureHelper.prototype.export_ = function(features, format, fileName,
opt_mimeType) {
var mimeType = opt_mimeType !== undefined ? opt_mimeType : 'text/plain';

// clone the features to:
// - transform the exported features to EPSG:4326
// - apply the original style to the clone (the original may have select
// style active)
// clone the features to apply the original style to the clone
// (the original may have select style active)
var clones = [];
var clone;
features.forEach(function(feature) {
clone = new ol.Feature();
clone.setProperties(feature.getProperties());
clone.setGeometry(clone.getGeometry().clone());
if (this.projection_) {
clone.getGeometry().transform(this.projection_, ol.proj.get('EPSG:4326'));
}
clone = new ol.Feature(feature.getProperties());
this.setStyle(clone, false);
clones.push(clone);
}, this);

var data = format.writeFeatures(clones);
var writeOptions = this.projection_ ? {
dataProjection: 'EPSG:4326',
featureProjection: this.projection_
} : {};

var data = format.writeFeatures(clones, writeOptions);

$('<a />', {
'download': fileName,
Expand Down

0 comments on commit 04e55f0

Please sign in to comment.