Rename ol.ProjectionUnits to ol.proj.Units

This commit is contained in:
Tim Schaub
2013-08-30 14:30:43 -06:00
parent 9a29c0e22d
commit b524de417b
12 changed files with 42 additions and 42 deletions

View File

@@ -1,11 +1,11 @@
goog.require('ol.Attribution');
goog.require('ol.Map');
goog.require('ol.ProjectionUnits');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.layer.Image');
goog.require('ol.layer.Tile');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
goog.require('ol.source.ImageWMS');
goog.require('ol.source.TileWMS');
@@ -47,7 +47,7 @@ var layers = [
// projection object.
var projection = new ol.proj.Projection({
code: 'EPSG:21781',
units: ol.ProjectionUnits.METERS
units: ol.proj.Units.METERS
});
var map = new ol.Map({

View File

@@ -85,7 +85,7 @@
* Object literal with config options for the projection.
* @typedef {Object} ol.ProjectionOptions
* @property {string} code The SRS identifier code, e.g. 'EPSG:4326'.
* @property {ol.ProjectionUnits} units Units.
* @property {ol.proj.Units} units Units.
* @property {ol.Extent|undefined} extent The validity extent for the SRS.
* @property {string|undefined} axisOrientation The axis orientation as
* specified in Proj4. The default is 'enu'.

View File

@@ -10,12 +10,12 @@ goog.require('goog.events');
goog.require('goog.math');
goog.require('goog.style');
goog.require('ol.Object');
goog.require('ol.ProjectionUnits');
goog.require('ol.TransformFunction');
goog.require('ol.View2DState');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.proj');
goog.require('ol.proj.Units');
goog.require('ol.sphere.NORMAL');
@@ -197,7 +197,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
var cosLatitude;
var units = this.getUnits();
if (projectionUnits == ol.ProjectionUnits.DEGREES &&
if (projectionUnits == ol.proj.Units.DEGREES &&
(units == ol.control.ScaleLineUnits.METRIC ||
units == ol.control.ScaleLineUnits.IMPERIAL)) {
@@ -205,10 +205,10 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
this.toEPSG4326_ = null;
cosLatitude = Math.cos(goog.math.toRadians(center[1]));
pointResolution *= Math.PI * cosLatitude * ol.sphere.NORMAL.radius / 180;
projectionUnits = ol.ProjectionUnits.METERS;
projectionUnits = ol.proj.Units.METERS;
} else if ((projectionUnits == ol.ProjectionUnits.FEET ||
projectionUnits == ol.ProjectionUnits.METERS) &&
} else if ((projectionUnits == ol.proj.Units.FEET ||
projectionUnits == ol.proj.Units.METERS) &&
units == ol.control.ScaleLineUnits.DEGREES) {
// Convert pointResolution from meters or feet to degrees
@@ -218,11 +218,11 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
}
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
var radius = ol.sphere.NORMAL.radius;
if (projectionUnits == ol.ProjectionUnits.FEET) {
if (projectionUnits == ol.proj.Units.FEET) {
radius /= 0.3048;
}
pointResolution *= 180 / (Math.PI * cosLatitude * radius);
projectionUnits = ol.ProjectionUnits.DEGREES;
projectionUnits = ol.proj.Units.DEGREES;
} else {
this.toEPSG4326_ = null;
@@ -231,9 +231,9 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
goog.asserts.assert(
((units == ol.control.ScaleLineUnits.METRIC ||
units == ol.control.ScaleLineUnits.IMPERIAL) &&
projectionUnits == ol.ProjectionUnits.METERS) ||
projectionUnits == ol.proj.Units.METERS) ||
(units == ol.control.ScaleLineUnits.DEGREES &&
projectionUnits == ol.ProjectionUnits.DEGREES));
projectionUnits == ol.proj.Units.DEGREES));
var nominalCount = this.minWidth_ * pointResolution;
var suffix = '';

View File

@@ -7,10 +7,10 @@
@exportProperty ol.proj.Projection.prototype.getMetersPerUnit
@exportProperty ol.proj.Projection.prototype.isGlobal
@exportSymbol ol.ProjectionUnits
@exportProperty ol.ProjectionUnits.DEGREES
@exportProperty ol.ProjectionUnits.FEET
@exportProperty ol.ProjectionUnits.METERS
@exportSymbol ol.proj.Units
@exportProperty ol.proj.Units.DEGREES
@exportProperty ol.proj.Units.FEET
@exportProperty ol.proj.Units.METERS
@exportSymbol ol.proj.addProjection
@exportSymbol ol.proj.get

View File

@@ -4,11 +4,11 @@ goog.provide('ol.proj.EPSG21781');
goog.require('goog.asserts');
goog.require('goog.math');
goog.require('ol.ProjectionUnits');
goog.require('ol.ellipsoid.BESSEL1841');
goog.require('ol.proj');
goog.require('ol.proj.EPSG4326');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
@@ -23,7 +23,7 @@ ol.proj.CH = function(options) {
code: options.code,
extent: options.extent,
global: false,
units: ol.ProjectionUnits.METERS
units: ol.proj.Units.METERS
});
};
goog.inherits(ol.proj.CH, ol.proj.Projection);

View File

@@ -2,10 +2,10 @@ goog.provide('ol.proj.EPSG3857');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.ProjectionUnits');
goog.require('ol.math');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
@@ -17,7 +17,7 @@ goog.require('ol.proj.Projection');
ol.proj.EPSG3857 = function(code) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.METERS,
units: ol.proj.Units.METERS,
extent: ol.proj.EPSG3857.EXTENT,
global: true
});

View File

@@ -1,8 +1,8 @@
goog.provide('ol.proj.EPSG4326');
goog.require('ol.ProjectionUnits');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
@@ -15,7 +15,7 @@ goog.require('ol.proj.Projection');
ol.proj.EPSG4326 = function(code, opt_axisOrientation) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.DEGREES,
units: ol.proj.Units.DEGREES,
extent: ol.proj.EPSG4326.EXTENT,
axisOrientation: opt_axisOrientation,
global: true

View File

@@ -1,7 +1,7 @@
goog.provide('ol.ProjectionUnits');
goog.provide('ol.proj');
goog.provide('ol.proj.Projection');
goog.provide('ol.proj.ProjectionLike');
goog.provide('ol.proj.Units');
goog.require('goog.array');
goog.require('goog.asserts');
@@ -35,7 +35,7 @@ ol.proj.ProjectionLike;
/**
* @enum {string}
*/
ol.ProjectionUnits = {
ol.proj.Units = {
DEGREES: 'degrees',
FEET: 'ft',
METERS: 'm'
@@ -43,13 +43,13 @@ ol.ProjectionUnits = {
/**
* @const {Object.<ol.ProjectionUnits, number>} Meters per unit lookup table.
* @const {Object.<ol.proj.Units, number>} Meters per unit lookup table.
*/
ol.METERS_PER_UNIT = {};
ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] =
ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] =
2 * Math.PI * ol.sphere.NORMAL.radius / 360;
ol.METERS_PER_UNIT[ol.ProjectionUnits.FEET] = 0.3048;
ol.METERS_PER_UNIT[ol.ProjectionUnits.METERS] = 1;
ol.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048;
ol.METERS_PER_UNIT[ol.proj.Units.METERS] = 1;
@@ -67,7 +67,7 @@ ol.proj.Projection = function(options) {
/**
* @private
* @type {ol.ProjectionUnits}
* @type {ol.proj.Units}
*/
this.units_ = options.units;
@@ -132,7 +132,7 @@ ol.proj.Projection.prototype.getPointResolution = goog.abstractMethod;
/**
* Get the units of this projection.
* @return {ol.ProjectionUnits} Units.
* @return {ol.proj.Units} Units.
*/
ol.proj.Projection.prototype.getUnits = function() {
return this.units_;
@@ -199,7 +199,7 @@ ol.proj.Projection.prototype.setDefaultTileGrid = function(tileGrid) {
*/
ol.Proj4jsProjection_ = function(proj4jsProj, options) {
var units = /** @type {ol.ProjectionUnits} */ (proj4jsProj.units);
var units = /** @type {ol.proj.Units} */ (proj4jsProj.units);
var config = /** @type {ol.ProjectionOptions} */ ({
units: units,
@@ -242,7 +242,7 @@ ol.Proj4jsProjection_.prototype.getMetersPerUnit = function() {
*/
ol.Proj4jsProjection_.prototype.getPointResolution =
function(resolution, point) {
if (this.getUnits() == ol.ProjectionUnits.DEGREES) {
if (this.getUnits() == ol.proj.Units.DEGREES) {
return resolution;
} else {
// Estimate point resolution by transforming the center pixel to EPSG:4326,
@@ -267,7 +267,7 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
var height = ol.sphere.NORMAL.haversineDistance(
vertices.slice(4, 6), vertices.slice(6, 8));
var pointResolution = (width + height) / 2;
if (this.getUnits() == ol.ProjectionUnits.FEET) {
if (this.getUnits() == ol.proj.Units.FEET) {
// The radius of the normal sphere is defined in meters, so we must
// convert back to feet.
pointResolution /= 0.3048;

View File

@@ -3,13 +3,13 @@ goog.provide('ol.tilegrid.TileGrid');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.Coordinate');
goog.require('ol.ProjectionUnits');
goog.require('ol.Size');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
goog.require('ol.array');
goog.require('ol.extent');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
/**
@@ -412,7 +412,7 @@ ol.tilegrid.createForProjection =
function(projection, opt_maxZoom, opt_tileSize) {
var projectionExtent = projection.getExtent();
var size = goog.isNull(projectionExtent) ?
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
360 * ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] /
projection.getMetersPerUnit() :
Math.max(projectionExtent[2] - projectionExtent[0],
projectionExtent[3] - projectionExtent[1]);

View File

@@ -7,7 +7,6 @@ goog.require('goog.asserts');
goog.require('ol.Constraints');
goog.require('ol.IView2D');
goog.require('ol.IView3D');
goog.require('ol.ProjectionUnits');
goog.require('ol.ResolutionConstraint');
goog.require('ol.RotationConstraint');
goog.require('ol.RotationConstraintType');
@@ -17,6 +16,7 @@ goog.require('ol.coordinate');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
/**
@@ -496,7 +496,7 @@ ol.View2D.createResolutionConstraint_ = function(options) {
.getExtent();
var size = goog.isNull(projectionExtent) ?
// use an extent that can fit the whole world if need be
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
360 * ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] /
ol.METERS_PER_UNIT[projection.getUnits()] :
Math.max(projectionExtent[2] - projectionExtent[0],
projectionExtent[3] - projectionExtent[1]);

View File

@@ -272,7 +272,7 @@ describe('ol.proj', function() {
describe('ol.proj.removeTransform()', function() {
var extent = [180, -90, 180, 90];
var units = ol.ProjectionUnits.DEGREES;
var units = ol.proj.Units.DEGREES;
it('removes functions cached by addTransform', function() {
var foo = new ol.proj.Projection({
@@ -341,7 +341,7 @@ describe('ol.proj', function() {
});
expect(epsg21781.getCode()).to.eql('EPSG:21781');
expect(epsg21781.getExtent()).to.be(extent);
expect(epsg21781.getUnits()).to.be(ol.ProjectionUnits.METERS);
expect(epsg21781.getUnits()).to.be(ol.proj.Units.METERS);
expect(epsg21781.isGlobal()).to.not.be();
});
@@ -351,7 +351,7 @@ describe('ol.proj', function() {
goog.require('goog.array');
goog.require('ol.ProjectionUnits');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
goog.require('ol.proj.common');

View File

@@ -196,7 +196,7 @@ describe('ol.tilegrid.TileGrid', function() {
var grid = ol.tilegrid.createForProjection(projection);
var resolutions = grid.getResolutions();
expect(resolutions[5]).to.be(
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
360 * ol.METERS_PER_UNIT[ol.proj.Units.DEGREES] /
ol.DEFAULT_TILE_SIZE / Math.pow(2, 5));
});
@@ -643,8 +643,8 @@ describe('ol.tilegrid.TileGrid', function() {
});
goog.require('ol.Coordinate');
goog.require('ol.ProjectionUnits');
goog.require('ol.TileCoord');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
goog.require('ol.tilegrid.TileGrid');