Move readProjectionFrom* functions to the base classes

This commit is contained in:
Frederic Junod
2015-01-20 16:59:58 +01:00
parent 2970da3461
commit 077a827197
14 changed files with 65 additions and 75 deletions

View File

@@ -501,22 +501,6 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
ol.format.GPX.prototype.readProjection; ol.format.GPX.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.GPX.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/**
* @inheritDoc
*/
ol.format.GPX.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {string} value Value for the link's `href` attribute. * @param {string} value Value for the link's `href` attribute.

View File

@@ -218,11 +218,3 @@ ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) {
* @api * @api
*/ */
ol.format.IGC.prototype.readProjection; ol.format.IGC.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.IGC.prototype.readProjectionFromText = function(text) {
return this.defaultDataProjection;
};

View File

@@ -1721,22 +1721,6 @@ ol.format.KML.prototype.readNameFromNode = function(node) {
ol.format.KML.prototype.readProjection; ol.format.KML.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.KML.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/**
* @inheritDoc
*/
ol.format.KML.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};
/** /**
* @param {Node} node Node to append a TextNode with the color to. * @param {Node} node Node to append a TextNode with the color to.
* @param {ol.Color|string} color Color. * @param {ol.Color|string} color Color.

View File

@@ -234,19 +234,3 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
* @api stable * @api stable
*/ */
ol.format.OSMXML.prototype.readProjection; ol.format.OSMXML.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.OSMXML.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/**
* @inheritDoc
*/
ol.format.OSMXML.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};

View File

@@ -340,14 +340,6 @@ ol.format.Polyline.prototype.readGeometryFromText =
ol.format.Polyline.prototype.readProjection; ol.format.Polyline.prototype.readProjection;
/**
* @inheritDoc
*/
ol.format.Polyline.prototype.readProjectionFromText = function(text) {
return this.defaultDataProjection;
};
/** /**
* @inheritDoc * @inheritDoc
*/ */

View File

@@ -111,7 +111,9 @@ ol.format.TextFeature.prototype.readProjection = function(source) {
* @protected * @protected
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
ol.format.TextFeature.prototype.readProjectionFromText = goog.abstractMethod; ol.format.TextFeature.prototype.readProjectionFromText = function(text) {
return this.defaultDataProjection;
};
/** /**

View File

@@ -291,14 +291,6 @@ ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) {
}; };
/**
* @inheritDoc
*/
ol.format.WKT.prototype.readProjectionFromText = function(text) {
return null;
};
/** /**
* Encode a feature as a WKT string. * Encode a feature as a WKT string.
* *

View File

@@ -185,7 +185,9 @@ ol.format.XMLFeature.prototype.readProjection = function(source) {
* @protected * @protected
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
ol.format.XMLFeature.prototype.readProjectionFromDocument = goog.abstractMethod; ol.format.XMLFeature.prototype.readProjectionFromDocument = function(doc) {
return this.defaultDataProjection;
};
/** /**
@@ -193,7 +195,9 @@ ol.format.XMLFeature.prototype.readProjectionFromDocument = goog.abstractMethod;
* @protected * @protected
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
ol.format.XMLFeature.prototype.readProjectionFromNode = goog.abstractMethod; ol.format.XMLFeature.prototype.readProjectionFromNode = function(node) {
return this.defaultDataProjection;
};
/** /**

View File

@@ -7,6 +7,18 @@ describe('ol.format.GPX', function() {
format = new ol.format.GPX(); format = new ol.format.GPX();
}); });
describe('#readProjection', function() {
it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument();
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode();
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
});
describe('readFeatures', function() { describe('readFeatures', function() {
describe('rte', function() { describe('rte', function() {

View File

@@ -29,6 +29,13 @@ describe('ol.format.IGC', function() {
format = new ol.format.IGC(); format = new ol.format.IGC();
}); });
describe('#readProjectionFromText', function() {
it('returns the default projection', function() {
var projection = format.readProjectionFromText(igc);
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
});
describe('#readFeature', function() { describe('#readFeature', function() {
it('does not read invalid features', function() { it('does not read invalid features', function() {
expect(format.readFeature('invalid')).to.be(null); expect(format.readFeature('invalid')).to.be(null);

View File

@@ -8,6 +8,18 @@ describe('ol.format.KML', function() {
format = new ol.format.KML(); format = new ol.format.KML();
}); });
describe('#readProjection', function() {
it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument();
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode();
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
});
describe('#readFeatures', function() { describe('#readFeatures', function() {
describe('id', function() { describe('id', function() {

View File

@@ -8,6 +8,18 @@ describe('ol.format.OSMXML', function() {
format = new ol.format.OSMXML(); format = new ol.format.OSMXML();
}); });
describe('#readProjection', function() {
it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument();
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode();
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
});
describe('#readFeatures', function() { describe('#readFeatures', function() {
it('can read an empty document', function() { it('can read an empty document', function() {

View File

@@ -40,6 +40,12 @@ describe('ol.format.Polyline', function() {
// Reset testing data // Reset testing data
beforeEach(resetTestingData); beforeEach(resetTestingData);
describe('#readProjectionFromText', function() {
it('returns the default projection', function() {
var projection = format.readProjectionFromText(encodedFlatPoints);
expect(projection).to.eql(ol.proj.get('EPSG:4326'));
});
});
describe('encodeDeltas', function() { describe('encodeDeltas', function() {
it('returns expected value', function() { it('returns expected value', function() {

View File

@@ -4,6 +4,13 @@ describe('ol.format.WKT', function() {
var format = new ol.format.WKT(); var format = new ol.format.WKT();
describe('#readProjectionFromText', function() {
it('returns the default projection', function() {
var projection = format.readProjectionFromText('POINT(1 2)');
expect(projection).to.be(null);
});
});
describe('#readGeometry()', function() { describe('#readGeometry()', function() {
it('transforms with dataProjection and featureProjection', function() { it('transforms with dataProjection and featureProjection', function() {