Merge pull request #1640 from tschaub/reproject
Use projection option instead of reprojectTo for vector file sources. The projection of the vector source represents the projection of the cached features.
This commit is contained in:
@@ -24,7 +24,6 @@ ol.source.GeoJSON = function(opt_options) {
|
||||
logo: options.logo,
|
||||
object: options.object,
|
||||
projection: options.projection,
|
||||
reprojectTo: options.reprojectTo,
|
||||
text: options.text,
|
||||
url: options.url,
|
||||
urls: options.urls
|
||||
|
||||
@@ -23,7 +23,6 @@ ol.source.GPX = function(opt_options) {
|
||||
logo: options.logo,
|
||||
node: options.node,
|
||||
projection: options.projection,
|
||||
reprojectTo: options.reprojectTo,
|
||||
text: options.text,
|
||||
url: options.url,
|
||||
urls: options.urls
|
||||
|
||||
@@ -25,7 +25,6 @@ ol.source.KML = function(opt_options) {
|
||||
logo: options.logo,
|
||||
node: options.node,
|
||||
projection: options.projection,
|
||||
reprojectTo: options.reprojectTo,
|
||||
text: options.text,
|
||||
url: options.url,
|
||||
urls: options.urls
|
||||
|
||||
@@ -24,7 +24,6 @@ ol.source.TopoJSON = function(opt_options) {
|
||||
logo: options.logo,
|
||||
object: options.object,
|
||||
projection: options.projection,
|
||||
reprojectTo: options.reprojectTo,
|
||||
text: options.text,
|
||||
url: options.url
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// FIXME remove reprojectTo
|
||||
// FIXME consider delaying feature reading so projection can be provided by
|
||||
// consumer (e.g. the view)
|
||||
|
||||
goog.provide('ol.source.VectorFile');
|
||||
|
||||
@@ -35,13 +36,6 @@ ol.source.VectorFile = function(opt_options) {
|
||||
*/
|
||||
this.format = options.format;
|
||||
|
||||
/**
|
||||
* @type {ol.proj.Projection}
|
||||
* @private
|
||||
*/
|
||||
this.reprojectTo_ = goog.isDef(options.reprojectTo) ?
|
||||
ol.proj.get(options.reprojectTo) : ol.proj.get('EPSG:3857');
|
||||
|
||||
if (goog.isDef(options.doc)) {
|
||||
this.readFeatures_(options.doc);
|
||||
}
|
||||
@@ -121,14 +115,17 @@ ol.source.VectorFile.prototype.readFeatures_ = function(source) {
|
||||
var format = this.format;
|
||||
var features = format.readFeatures(source);
|
||||
var featureProjection = format.readProjection(source);
|
||||
if (!ol.proj.equivalent(featureProjection, this.reprojectTo_)) {
|
||||
var transform = ol.proj.getTransform(featureProjection, this.reprojectTo_);
|
||||
var i, ii;
|
||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||
var feature = features[i];
|
||||
var geometry = feature.getGeometry();
|
||||
if (!goog.isNull(geometry)) {
|
||||
geometry.transform(transform);
|
||||
var projection = this.getProjection();
|
||||
if (!goog.isNull(projection)) {
|
||||
if (!ol.proj.equivalent(featureProjection, projection)) {
|
||||
var transform = ol.proj.getTransform(featureProjection, projection);
|
||||
var i, ii;
|
||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||
var feature = features[i];
|
||||
var geometry = feature.getGeometry();
|
||||
if (!goog.isNull(geometry)) {
|
||||
geometry.transform(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user