openlayers/ol3 — pull request #2242 by elemoine (2014-06-24 16:22:52+00:00)
Title: Add ol.Feature#clone

This PR suggests adding a clone method to ol.Feature. Please review.

My use-case: I need to serialize features in a different projection. Without a clone method it looks like this:

```js
var features = [];
vectorSource.forEachFeature(function(feature) {
var clone = new ol.Feature();
clone.setId(feature.getId());
clone.setValues(feature.getProperties());
clone.setGeometryName(feature.getGeometryName());
var geometryClone = feature.getGeometry().clone();
clone.setGeometry(geometryClone);
var style = feature.getStyle();
if (style) {
clone.setStyle(style);
}
features.push(clone);
});
var serialized = format.writeFeatures(features);
```

With a clone method it looks like this:

```js
var feature = [];
vectorSource.forEachFeature(function(feature) {
var clone = feature.clone();
clone.setId(feature.getId()); // clone does not set the id
features.push(clone);
});
var serialized = format.writeFeatures(features);
```