Rename ol.projection to ol.proj

This commit is contained in:
Tom Payne
2013-05-30 18:55:58 +02:00
parent 795ea69982
commit 46553c719c
50 changed files with 345 additions and 370 deletions

View File

@@ -4,22 +4,16 @@ goog.require('ol.View2D');
goog.require('ol.animation'); goog.require('ol.animation');
goog.require('ol.easing'); goog.require('ol.easing');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.OSM'); goog.require('ol.source.OSM');
var london = ol.projection.transform( var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857');
[-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857'); var moscow = ol.proj.transform([37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857');
var moscow = ol.projection.transform( var istanbul = ol.proj.transform([28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857');
[37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857'); var rome = ol.proj.transform([12.5, 41.9], 'EPSG:4326', 'EPSG:3857');
var istanbul = ol.projection.transform( var bern = ol.proj.transform([7.4458, 46.95], 'EPSG:4326', 'EPSG:3857');
[28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857'); var madrid = ol.proj.transform([-3.683333, 40.4], 'EPSG:4326', 'EPSG:3857');
var rome = ol.projection.transform(
[12.5, 41.9], 'EPSG:4326', 'EPSG:3857');
var bern = ol.projection.transform(
[7.4458, 46.95], 'EPSG:4326', 'EPSG:3857');
var madrid = ol.projection.transform(
[-3.683333, 40.4], 'EPSG:4326', 'EPSG:3857');
var view = new ol.View2D({ var view = new ol.View2D({
// the view's initial state // the view's initial state

View File

@@ -2,7 +2,7 @@ goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.BingMaps'); goog.require('ol.source.BingMaps');
@@ -23,7 +23,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(), renderers: ol.RendererHints.createFromQueryData(),
target: 'map', target: 'map',
view: new ol.View2D({ view: new ol.View2D({
center: ol.projection.transform([-123.1, 49.25], 'EPSG:4326', 'EPSG:3857'), center: ol.proj.transform([-123.1, 49.25], 'EPSG:4326', 'EPSG:3857'),
zoom: 8 zoom: 8
}) })
}); });

View File

@@ -2,7 +2,7 @@ goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.DebugTileSource'); goog.require('ol.source.DebugTileSource');
goog.require('ol.source.OSM'); goog.require('ol.source.OSM');
goog.require('ol.tilegrid.XYZ'); goog.require('ol.tilegrid.XYZ');
@@ -25,7 +25,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(), renderers: ol.RendererHints.createFromQueryData(),
target: 'map', target: 'map',
view: new ol.View2D({ view: new ol.View2D({
center: ol.projection.transform( center: ol.proj.transform(
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'), [-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
zoom: 10 zoom: 10
}) })

View File

@@ -4,7 +4,7 @@ goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.parser.ogc.GML_v3'); goog.require('ol.parser.ogc.GML_v3');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.style.Polygon'); goog.require('ol.style.Polygon');
@@ -17,7 +17,7 @@ var raster = new ol.layer.TileLayer({
var vector = new ol.layer.Vector({ var vector = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}), }),
style: new ol.style.Style({rules: [ style: new ol.style.Style({rules: [
new ol.style.Rule({ new ol.style.Rule({

View File

@@ -4,7 +4,7 @@ goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.parser.GPX'); goog.require('ol.parser.GPX');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.OSM'); goog.require('ol.source.OSM');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
@@ -14,7 +14,7 @@ var raster = new ol.layer.TileLayer({
var vector = new ol.layer.Vector({ var vector = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });

View File

@@ -2,7 +2,7 @@ goog.require('ol.Map');
goog.require('ol.RendererHint'); goog.require('ol.RendererHint');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.BingMaps'); goog.require('ol.source.BingMaps');
@@ -18,8 +18,7 @@ var map = new ol.Map({
renderer: ol.RendererHint.WEBGL, renderer: ol.RendererHint.WEBGL,
target: 'map', target: 'map',
view: new ol.View2D({ view: new ol.View2D({
center: ol.projection.transform( center: ol.proj.transform([-9.375, 51.483333], 'EPSG:4326', 'EPSG:3857'),
[-9.375, 51.483333], 'EPSG:4326', 'EPSG:3857'),
zoom: 15 zoom: 15
}) })
}); });

View File

@@ -4,7 +4,7 @@ goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.parser.KML'); goog.require('ol.parser.KML');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.TiledWMS'); goog.require('ol.source.TiledWMS');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
@@ -20,7 +20,7 @@ var raster = new ol.layer.TileLayer({
}) })
}); });
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
var vector = new ol.layer.Vector({ var vector = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({

View File

@@ -2,7 +2,7 @@ goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.MapQuestOSM'); goog.require('ol.source.MapQuestOSM');
@@ -15,7 +15,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(), renderers: ol.RendererHints.createFromQueryData(),
target: 'map', target: 'map',
view: new ol.View2D({ view: new ol.View2D({
center: ol.projection.transform( center: ol.proj.transform(
[139.6917, 35.689506], 'EPSG:4326', 'EPSG:3857'), [139.6917, 35.689506], 'EPSG:4326', 'EPSG:3857'),
zoom: 9 zoom: 9
}) })

View File

@@ -4,7 +4,7 @@ goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.MapQuestOpenAerial');
@@ -25,7 +25,7 @@ var map = new ol.Map({
// Vienna label // Vienna label
var vienna = new ol.Overlay({ var vienna = new ol.Overlay({
map: map, map: map,
position: ol.projection.transform( position: ol.proj.transform(
[16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'), [16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'),
element: document.getElementById('vienna') element: document.getElementById('vienna')
}); });
@@ -38,7 +38,7 @@ var popup = new ol.Overlay({
map.on('click', function(evt) { map.on('click', function(evt) {
var element = popup.getElement(); var element = popup.getElement();
var coordinate = evt.getCoordinate(); var coordinate = evt.getCoordinate();
var hdms = ol.coordinate.toStringHDMS(ol.projection.transform( var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
coordinate, 'EPSG:3857', 'EPSG:4326')); coordinate, 'EPSG:3857', 'EPSG:4326'));
$(element).popover('destroy'); $(element).popover('destroy');

View File

@@ -2,7 +2,7 @@ goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.TileJSON'); goog.require('ol.source.TileJSON');
@@ -22,8 +22,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(), renderers: ol.RendererHints.createFromQueryData(),
target: 'map', target: 'map',
view: new ol.View2D({ view: new ol.View2D({
center: ol.projection.transform( center: ol.proj.transform([-77.93255, 37.9555], 'EPSG:4326', 'EPSG:3857'),
[-77.93255, 37.9555], 'EPSG:4326', 'EPSG:3857'),
zoom: 5 zoom: 5
}) })
}); });

View File

@@ -2,7 +2,7 @@ goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.Stamen'); goog.require('ol.source.Stamen');
@@ -22,7 +22,7 @@ var map = new ol.Map({
renderers: ol.RendererHints.createFromQueryData(), renderers: ol.RendererHints.createFromQueryData(),
target: 'map', target: 'map',
view: new ol.View2D({ view: new ol.View2D({
center: ol.projection.transform( center: ol.proj.transform(
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
zoom: 12 zoom: 12
}) })

View File

@@ -6,7 +6,7 @@ goog.require('ol.control.defaults');
goog.require('ol.filter.Filter'); goog.require('ol.filter.Filter');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON'); goog.require('ol.parser.GeoJSON');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.style.Line'); goog.require('ol.style.Line');
goog.require('ol.style.Rule'); goog.require('ol.style.Rule');
@@ -48,7 +48,7 @@ var style = new ol.style.Style({rules: [
var vector = new ol.layer.Vector({ var vector = new ol.layer.Vector({
style: style, style: style,
source: new ol.source.Vector({ source: new ol.source.Vector({
projection: ol.projection.get('EPSG:3857') projection: ol.proj.get('EPSG:3857')
}) })
}); });
@@ -115,7 +115,7 @@ vector.parseFeatures({
'coordinates': [[10000000, -10000000], [-10000000, -10000000]] 'coordinates': [[10000000, -10000000], [-10000000, -10000000]]
} }
}] }]
}, new ol.parser.GeoJSON(), ol.projection.get('EPSG:3857')); }, new ol.parser.GeoJSON(), ol.proj.get('EPSG:3857'));
var map = new ol.Map({ var map = new ol.Map({

View File

@@ -4,7 +4,7 @@ goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON'); goog.require('ol.parser.GeoJSON');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.MapQuestOpenAerial'); goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.style.Polygon'); goog.require('ol.style.Polygon');
@@ -18,7 +18,7 @@ var raster = new ol.layer.TileLayer({
var vector = new ol.layer.Vector({ var vector = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}), }),
style: new ol.style.Style({rules: [ style: new ol.style.Style({rules: [
new ol.style.Rule({ new ol.style.Rule({

View File

@@ -6,11 +6,11 @@ goog.require('ol.control.ScaleLine');
goog.require('ol.control.ScaleLineUnits'); goog.require('ol.control.ScaleLineUnits');
goog.require('ol.control.defaults'); goog.require('ol.control.defaults');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.TiledWMS'); goog.require('ol.source.TiledWMS');
var projection = ol.projection.configureProj4jsProjection({ var projection = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864] extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864]
}); });

View File

@@ -3,11 +3,11 @@ goog.require('ol.Map');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.ImageLayer'); goog.require('ol.layer.ImageLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.SingleImageWMS'); goog.require('ol.source.SingleImageWMS');
var projection = ol.projection.configureProj4jsProjection({ var projection = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864] extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864]
}); });

View File

@@ -1,7 +1,7 @@
goog.require('ol.parser.ogc.WMTSCapabilities'); goog.require('ol.parser.ogc.WMTSCapabilities');
goog.require('ol.projection.addCommonProjections'); goog.require('ol.proj.addCommonProjections');
ol.projection.addCommonProjections(); ol.proj.addCommonProjections();
Proj4js.defs['EPSG:31256'] = '+proj=tmerc +lat_0=0 ' + Proj4js.defs['EPSG:31256'] = '+proj=tmerc +lat_0=0 ' +
'+lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel ' + '+lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel ' +
'+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 ' + '+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 ' +

View File

@@ -3,13 +3,13 @@ goog.require('ol.RendererHint');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.OSM'); goog.require('ol.source.OSM');
goog.require('ol.source.WMTS'); goog.require('ol.source.WMTS');
goog.require('ol.tilegrid.WMTS'); goog.require('ol.tilegrid.WMTS');
var projection = ol.projection.get('EPSG:900913'); var projection = ol.proj.get('EPSG:900913');
var projectionExtent = projection.getExtent(); var projectionExtent = projection.getExtent();
var size = ol.extent.getWidth(projectionExtent) / 256; var size = ol.extent.getWidth(projectionExtent) / 256;
var resolutions = new Array(26); var resolutions = new Array(26);

View File

@@ -14,7 +14,7 @@ goog.require('ol.Pixel');
goog.require('ol.Projection'); goog.require('ol.Projection');
goog.require('ol.TransformFunction'); goog.require('ol.TransformFunction');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('ol.projection'); goog.require('ol.proj');
@@ -44,7 +44,7 @@ ol.control.MousePosition = function(opt_options) {
* @private * @private
* @type {ol.Projection} * @type {ol.Projection}
*/ */
this.projection_ = ol.projection.get(options.projection); this.projection_ = ol.proj.get(options.projection);
/** /**
* @private * @private
@@ -75,7 +75,7 @@ ol.control.MousePosition = function(opt_options) {
* @private * @private
* @type {ol.TransformFunction} * @type {ol.TransformFunction}
*/ */
this.transform_ = ol.projection.identityTransform; this.transform_ = ol.proj.identityTransform;
/** /**
* @private * @private
@@ -157,10 +157,10 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
if (!goog.isNull(pixel)) { if (!goog.isNull(pixel)) {
if (this.renderedProjection_ != this.mapProjection_) { if (this.renderedProjection_ != this.mapProjection_) {
if (!goog.isNull(this.projection_)) { if (!goog.isNull(this.projection_)) {
this.transform_ = ol.projection.getTransformFromProjections( this.transform_ = ol.proj.getTransformFromProjections(
this.mapProjection_, this.projection_); this.mapProjection_, this.projection_);
} else { } else {
this.transform_ = ol.projection.identityTransform; this.transform_ = ol.proj.identityTransform;
} }
this.renderedProjection_ = this.mapProjection_; this.renderedProjection_ = this.mapProjection_;
} }

View File

@@ -12,7 +12,7 @@ goog.require('ol.ProjectionUnits');
goog.require('ol.TransformFunction'); goog.require('ol.TransformFunction');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('ol.css'); goog.require('ol.css');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.sphere.NORMAL'); goog.require('ol.sphere.NORMAL');
@@ -157,8 +157,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
// Convert pointResolution from meters or feet to degrees // Convert pointResolution from meters or feet to degrees
if (goog.isNull(this.toEPSG4326_)) { if (goog.isNull(this.toEPSG4326_)) {
this.toEPSG4326_ = ol.projection.getTransformFromProjections( this.toEPSG4326_ = ol.proj.getTransformFromProjections(
projection, ol.projection.get('EPSG:4326')); projection, ol.proj.get('EPSG:4326'));
} }
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1])); cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
var radius = ol.sphere.NORMAL.radius; var radius = ol.sphere.NORMAL.radius;

View File

@@ -9,7 +9,7 @@ goog.require('goog.math');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.Projection'); goog.require('ol.Projection');
goog.require('ol.projection'); goog.require('ol.proj');
/** /**
@@ -51,7 +51,7 @@ ol.Geolocation = function(opt_options) {
* @private * @private
* @type {ol.TransformFunction} * @type {ol.TransformFunction}
*/ */
this.transform_ = ol.projection.identityTransform; this.transform_ = ol.proj.identityTransform;
/** /**
* @private * @private
@@ -67,7 +67,7 @@ ol.Geolocation = function(opt_options) {
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
if (goog.isDef(options.projection)) { if (goog.isDef(options.projection)) {
this.setProjection(ol.projection.get(options.projection)); this.setProjection(ol.proj.get(options.projection));
} }
if (goog.isDef(options.trackingOptions)) { if (goog.isDef(options.trackingOptions)) {
this.setTrackingOptions(options.trackingOptions); this.setTrackingOptions(options.trackingOptions);
@@ -95,8 +95,8 @@ ol.Geolocation.prototype.disposeInternal = function() {
ol.Geolocation.prototype.handleProjectionChanged_ = function() { ol.Geolocation.prototype.handleProjectionChanged_ = function() {
var projection = this.getProjection(); var projection = this.getProjection();
if (goog.isDefAndNotNull(projection)) { if (goog.isDefAndNotNull(projection)) {
this.transform_ = ol.projection.getTransformFromProjections( this.transform_ = ol.proj.getTransformFromProjections(
ol.projection.get('EPSG:4326'), projection); ol.proj.get('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) { if (!goog.isNull(this.position_)) {
this.set( this.set(
ol.GeolocationProperty.POSITION, this.transform_(this.position_)); ol.GeolocationProperty.POSITION, this.transform_(this.position_));

View File

@@ -6,7 +6,7 @@ goog.require('goog.object');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.geom.SharedVertices'); goog.require('ol.geom.SharedVertices');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.structs.RTree'); goog.require('ol.structs.RTree');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
@@ -330,7 +330,7 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
var addFeatures = function(features) { var addFeatures = function(features) {
var sourceProjection = this.getSource().getProjection(); var sourceProjection = this.getSource().getProjection();
var transform = ol.projection.getTransform(sourceProjection, projection); var transform = ol.proj.getTransform(sourceProjection, projection);
transform( transform(
this.pointVertices_.coordinates, this.pointVertices_.coordinates,

View File

@@ -56,8 +56,8 @@ goog.require('ol.control.defaults');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.interaction.defaults'); goog.require('ol.interaction.defaults');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.projection.addCommonProjections'); goog.require('ol.proj.addCommonProjections');
goog.require('ol.renderer.Map'); goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.Map'); goog.require('ol.renderer.canvas.Map');
goog.require('ol.renderer.canvas.SUPPORTED'); goog.require('ol.renderer.canvas.SUPPORTED');
@@ -1078,7 +1078,7 @@ ol.RendererHints.createFromQueryData = function(opt_queryData) {
}; };
ol.projection.addCommonProjections(); ol.proj.addCommonProjections();
if (goog.DEBUG) { if (goog.DEBUG) {

View File

@@ -3,7 +3,7 @@ goog.require('goog.dom.xml');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.parser.XML'); goog.require('ol.parser.XML');
goog.require('ol.parser.ogc.OWSCommon_v1_1_0'); goog.require('ol.parser.ogc.OWSCommon_v1_1_0');
goog.require('ol.projection'); goog.require('ol.proj');
@@ -79,7 +79,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
var topLeftCorner = this.getChildValue(node); var topLeftCorner = this.getChildValue(node);
var coords = topLeftCorner.split(' '); var coords = topLeftCorner.split(' ');
var axisOrientation = var axisOrientation =
ol.projection.get(obj['supportedCRS']).getAxisOrientation(); ol.proj.get(obj['supportedCRS']).getAxisOrientation();
obj['topLeftCorner'] = ol.coordinate.fromProjectedArray( obj['topLeftCorner'] = ol.coordinate.fromProjectedArray(
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation); [parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
}, },

3
src/ol/proj.jsdoc Normal file
View File

@@ -0,0 +1,3 @@
/**
* @namespace ol.proj
*/

23
src/ol/proj/common.js Normal file
View File

@@ -0,0 +1,23 @@
goog.provide('ol.proj.addCommonProjections');
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.EPSG4326');
/**
* FIXME empty description for jsdoc
*/
ol.proj.addCommonProjections = function() {
// Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning.
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back.
ol.proj.addEquivalentTransforms(
ol.proj.EPSG4326.PROJECTIONS,
ol.proj.EPSG3857.PROJECTIONS,
ol.proj.EPSG3857.fromEPSG4326,
ol.proj.EPSG3857.toEPSG4326);
};

View File

@@ -1,11 +1,11 @@
goog.provide('ol.projection.EPSG3857'); goog.provide('ol.proj.EPSG3857');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol.Projection'); goog.require('ol.Projection');
goog.require('ol.ProjectionUnits'); goog.require('ol.ProjectionUnits');
goog.require('ol.math'); goog.require('ol.math');
goog.require('ol.projection'); goog.require('ol.proj');
@@ -14,38 +14,38 @@ goog.require('ol.projection');
* @extends {ol.Projection} * @extends {ol.Projection}
* @param {string} code Code. * @param {string} code Code.
*/ */
ol.projection.EPSG3857 = function(code) { ol.proj.EPSG3857 = function(code) {
goog.base(this, { goog.base(this, {
code: code, code: code,
units: ol.ProjectionUnits.METERS, units: ol.ProjectionUnits.METERS,
extent: ol.projection.EPSG3857.EXTENT, extent: ol.proj.EPSG3857.EXTENT,
global: true global: true
}); });
}; };
goog.inherits(ol.projection.EPSG3857, ol.Projection); goog.inherits(ol.proj.EPSG3857, ol.Projection);
/** /**
* @const * @const
* @type {number} * @type {number}
*/ */
ol.projection.EPSG3857.RADIUS = 6378137; ol.proj.EPSG3857.RADIUS = 6378137;
/** /**
* @const * @const
* @type {number} * @type {number}
*/ */
ol.projection.EPSG3857.HALF_SIZE = Math.PI * ol.projection.EPSG3857.RADIUS; ol.proj.EPSG3857.HALF_SIZE = Math.PI * ol.proj.EPSG3857.RADIUS;
/** /**
* @const * @const
* @type {ol.Extent} * @type {ol.Extent}
*/ */
ol.projection.EPSG3857.EXTENT = [ ol.proj.EPSG3857.EXTENT = [
-ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE, -ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE,
-ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE -ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE
]; ];
@@ -54,7 +54,7 @@ ol.projection.EPSG3857.EXTENT = [
* *
* @type {Array.<string>} * @type {Array.<string>}
*/ */
ol.projection.EPSG3857.CODES = [ ol.proj.EPSG3857.CODES = [
'EPSG:3857', 'EPSG:3857',
'EPSG:102100', 'EPSG:102100',
'EPSG:102113', 'EPSG:102113',
@@ -69,10 +69,10 @@ ol.projection.EPSG3857.CODES = [
* @const * @const
* @type {Array.<ol.Projection>} * @type {Array.<ol.Projection>}
*/ */
ol.projection.EPSG3857.PROJECTIONS = goog.array.map( ol.proj.EPSG3857.PROJECTIONS = goog.array.map(
ol.projection.EPSG3857.CODES, ol.proj.EPSG3857.CODES,
function(code) { function(code) {
return new ol.projection.EPSG3857(code); return new ol.proj.EPSG3857(code);
}); });
@@ -84,7 +84,7 @@ ol.projection.EPSG3857.PROJECTIONS = goog.array.map(
* @param {number=} opt_dimension Dimension (default is 2). * @param {number=} opt_dimension Dimension (default is 2).
* @return {Array.<number>} Output array of coordinate values. * @return {Array.<number>} Output array of coordinate values.
*/ */
ol.projection.EPSG3857.fromEPSG4326 = function( ol.proj.EPSG3857.fromEPSG4326 = function(
input, opt_output, opt_dimension) { input, opt_output, opt_dimension) {
var length = input.length, var length = input.length,
dimension = opt_dimension > 1 ? opt_dimension : 2, dimension = opt_dimension > 1 ? opt_dimension : 2,
@@ -99,8 +99,8 @@ ol.projection.EPSG3857.fromEPSG4326 = function(
} }
goog.asserts.assert(output.length % dimension === 0); goog.asserts.assert(output.length % dimension === 0);
for (var i = 0; i < length; i += dimension) { for (var i = 0; i < length; i += dimension) {
output[i] = ol.projection.EPSG3857.RADIUS * Math.PI * input[i] / 180; output[i] = ol.proj.EPSG3857.RADIUS * Math.PI * input[i] / 180;
output[i + 1] = ol.projection.EPSG3857.RADIUS * output[i + 1] = ol.proj.EPSG3857.RADIUS *
Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360)); Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360));
} }
return output; return output;
@@ -115,7 +115,7 @@ ol.projection.EPSG3857.fromEPSG4326 = function(
* @param {number=} opt_dimension Dimension (default is 2). * @param {number=} opt_dimension Dimension (default is 2).
* @return {Array.<number>} Output array of coordinate values. * @return {Array.<number>} Output array of coordinate values.
*/ */
ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) { ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
var length = input.length, var length = input.length,
dimension = opt_dimension > 1 ? opt_dimension : 2, dimension = opt_dimension > 1 ? opt_dimension : 2,
output = opt_output; output = opt_output;
@@ -129,9 +129,9 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
} }
goog.asserts.assert(output.length % dimension === 0); goog.asserts.assert(output.length % dimension === 0);
for (var i = 0; i < length; i += dimension) { for (var i = 0; i < length; i += dimension) {
output[i] = 180 * input[i] / (ol.projection.EPSG3857.RADIUS * Math.PI); output[i] = 180 * input[i] / (ol.proj.EPSG3857.RADIUS * Math.PI);
output[i + 1] = 360 * Math.atan( output[i + 1] = 360 * Math.atan(
Math.exp(input[i + 1] / ol.projection.EPSG3857.RADIUS)) / Math.PI - 90; Math.exp(input[i + 1] / ol.proj.EPSG3857.RADIUS)) / Math.PI - 90;
} }
return output; return output;
}; };
@@ -140,7 +140,7 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.projection.EPSG3857.prototype.getPointResolution = ol.proj.EPSG3857.prototype.getPointResolution =
function(resolution, point) { function(resolution, point) {
return resolution / ol.math.cosh(point[1] / ol.projection.EPSG3857.RADIUS); return resolution / ol.math.cosh(point[1] / ol.proj.EPSG3857.RADIUS);
}; };

View File

@@ -0,0 +1,57 @@
goog.provide('ol.proj.EPSG4326');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');
goog.require('ol.proj');
/**
* @constructor
* @extends {ol.Projection}
* @param {string} code Code.
* @param {string=} opt_axisOrientation Axis orientation.
*/
ol.proj.EPSG4326 = function(code, opt_axisOrientation) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.DEGREES,
extent: ol.proj.EPSG4326.EXTENT,
axisOrientation: opt_axisOrientation,
global: true
});
};
goog.inherits(ol.proj.EPSG4326, ol.Projection);
/**
* Extent of the EPSG:4326 projection which is the whole world.
*
* @const
* @type {ol.Extent}
*/
ol.proj.EPSG4326.EXTENT = [-180, 180, -90, 90];
/**
* Projections equal to EPSG:4326.
*
* @const
* @type {Array.<ol.Projection>}
*/
ol.proj.EPSG4326.PROJECTIONS = [
new ol.proj.EPSG4326('CRS:84'),
new ol.proj.EPSG4326('EPSG:4326', 'neu'),
new ol.proj.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.proj.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.proj.EPSG4326('urn:ogc:def:crs:OGC:2:84')
];
/**
* @inheritDoc
*/
ol.proj.EPSG4326.prototype.getPointResolution =
function(resolution, point) {
return resolution;
};

View File

@@ -12,11 +12,11 @@
@exportProperty ol.ProjectionUnits.FEET @exportProperty ol.ProjectionUnits.FEET
@exportProperty ol.ProjectionUnits.METERS @exportProperty ol.ProjectionUnits.METERS
@exportSymbol ol.projection.addProjection @exportSymbol ol.proj.addProjection
@exportSymbol ol.projection.addCommonProjections @exportSymbol ol.proj.addCommonProjections
@exportSymbol ol.projection.get @exportSymbol ol.proj.get
@exportSymbol ol.projection.getTransform @exportSymbol ol.proj.getTransform
@exportSymbol ol.projection.getTransformFromProjections @exportSymbol ol.proj.getTransformFromProjections
@exportSymbol ol.projection.transform @exportSymbol ol.proj.transform
@exportSymbol ol.projection.transformWithProjections @exportSymbol ol.proj.transformWithProjections
@exportSymbol ol.projection.configureProj4jsProjection @exportSymbol ol.proj.configureProj4jsProjection

View File

@@ -1,7 +1,7 @@
goog.provide('ol.Projection'); goog.provide('ol.Projection');
goog.provide('ol.ProjectionLike'); goog.provide('ol.ProjectionLike');
goog.provide('ol.ProjectionUnits'); goog.provide('ol.ProjectionUnits');
goog.provide('ol.projection'); goog.provide('ol.proj');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
@@ -219,8 +219,8 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
// measuring its width and height on the normal sphere, and taking the // measuring its width and height on the normal sphere, and taking the
// average of the width and height. // average of the width and height.
if (goog.isNull(this.toEPSG4326_)) { if (goog.isNull(this.toEPSG4326_)) {
this.toEPSG4326_ = ol.projection.getTransformFromProjections( this.toEPSG4326_ = ol.proj.getTransformFromProjections(
this, ol.projection.getProj4jsProjectionFromCode_({ this, ol.proj.getProj4jsProjectionFromCode_({
code: 'EPSG:4326', code: 'EPSG:4326',
extent: null extent: null
})); }));
@@ -259,21 +259,21 @@ ol.Proj4jsProjection_.prototype.getProj4jsProj = function() {
* @private * @private
* @type {Object.<string, ol.Proj4jsProjection_>} * @type {Object.<string, ol.Proj4jsProjection_>}
*/ */
ol.projection.proj4jsProjections_ = {}; ol.proj.proj4jsProjections_ = {};
/** /**
* @private * @private
* @type {Object.<string, ol.Projection>} * @type {Object.<string, ol.Projection>}
*/ */
ol.projection.projections_ = {}; ol.proj.projections_ = {};
/** /**
* @private * @private
* @type {Object.<string, Object.<string, ol.TransformFunction>>} * @type {Object.<string, Object.<string, ol.TransformFunction>>}
*/ */
ol.projection.transforms_ = {}; ol.proj.transforms_ = {};
/** /**
@@ -282,13 +282,12 @@ ol.projection.transforms_ = {};
* *
* @param {Array.<ol.Projection>} projections Projections. * @param {Array.<ol.Projection>} projections Projections.
*/ */
ol.projection.addEquivalentProjections = function(projections) { ol.proj.addEquivalentProjections = function(projections) {
ol.projection.addProjections(projections); ol.proj.addProjections(projections);
goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(source) {
goog.array.forEach(projections, function(destination) { goog.array.forEach(projections, function(destination) {
if (source !== destination) { if (source !== destination) {
ol.projection.addTransform( ol.proj.addTransform(source, destination, ol.proj.cloneTransform);
source, destination, ol.projection.cloneTransform);
} }
}); });
}); });
@@ -306,12 +305,12 @@ ol.projection.addEquivalentProjections = function(projections) {
* @param {ol.TransformFunction} inverseTransform Transform from any projection * @param {ol.TransformFunction} inverseTransform Transform from any projection
* in projection2 to any projection in projection1.. * in projection2 to any projection in projection1..
*/ */
ol.projection.addEquivalentTransforms = ol.proj.addEquivalentTransforms =
function(projections1, projections2, forwardTransform, inverseTransform) { function(projections1, projections2, forwardTransform, inverseTransform) {
goog.array.forEach(projections1, function(projection1) { goog.array.forEach(projections1, function(projection1) {
goog.array.forEach(projections2, function(projection2) { goog.array.forEach(projections2, function(projection2) {
ol.projection.addTransform(projection1, projection2, forwardTransform); ol.proj.addTransform(projection1, projection2, forwardTransform);
ol.projection.addTransform(projection2, projection1, inverseTransform); ol.proj.addTransform(projection2, projection1, inverseTransform);
}); });
}); });
}; };
@@ -321,8 +320,8 @@ ol.projection.addEquivalentTransforms =
* @param {ol.Proj4jsProjection_} proj4jsProjection Proj4js projection. * @param {ol.Proj4jsProjection_} proj4jsProjection Proj4js projection.
* @private * @private
*/ */
ol.projection.addProj4jsProjection_ = function(proj4jsProjection) { ol.proj.addProj4jsProjection_ = function(proj4jsProjection) {
var proj4jsProjections = ol.projection.proj4jsProjections_; var proj4jsProjections = ol.proj.proj4jsProjections_;
var code = proj4jsProjection.getCode(); var code = proj4jsProjection.getCode();
goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code)); goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code));
proj4jsProjections[code] = proj4jsProjection; proj4jsProjections[code] = proj4jsProjection;
@@ -332,21 +331,20 @@ ol.projection.addProj4jsProjection_ = function(proj4jsProjection) {
/** /**
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
*/ */
ol.projection.addProjection = function(projection) { ol.proj.addProjection = function(projection) {
var projections = ol.projection.projections_; var projections = ol.proj.projections_;
var code = projection.getCode(); var code = projection.getCode();
projections[code] = projection; projections[code] = projection;
ol.projection.addTransform( ol.proj.addTransform(projection, projection, ol.proj.cloneTransform);
projection, projection, ol.projection.cloneTransform);
}; };
/** /**
* @param {Array.<ol.Projection>} projections Projections. * @param {Array.<ol.Projection>} projections Projections.
*/ */
ol.projection.addProjections = function(projections) { ol.proj.addProjections = function(projections) {
goog.array.forEach(projections, function(projection) { goog.array.forEach(projections, function(projection) {
ol.projection.addProjection(projection); ol.proj.addProjection(projection);
}); });
}; };
@@ -354,12 +352,12 @@ ol.projection.addProjections = function(projections) {
/** /**
* FIXME empty description for jsdoc * FIXME empty description for jsdoc
*/ */
ol.projection.clearAllProjections = function() { ol.proj.clearAllProjections = function() {
if (ol.ENABLE_PROJ4JS) { if (ol.ENABLE_PROJ4JS) {
ol.projection.proj4jsProjections_ = {}; ol.proj.proj4jsProjections_ = {};
} }
ol.projection.projections_ = {}; ol.proj.projections_ = {};
ol.projection.transforms_ = {}; ol.proj.transforms_ = {};
}; };
@@ -368,11 +366,11 @@ ol.projection.clearAllProjections = function() {
* @param {string} defaultCode Default code. * @param {string} defaultCode Default code.
* @return {ol.Projection} Projection. * @return {ol.Projection} Projection.
*/ */
ol.projection.createProjection = function(projection, defaultCode) { ol.proj.createProjection = function(projection, defaultCode) {
if (!goog.isDefAndNotNull(projection)) { if (!goog.isDefAndNotNull(projection)) {
return ol.projection.get(defaultCode); return ol.proj.get(defaultCode);
} else if (goog.isString(projection)) { } else if (goog.isString(projection)) {
return ol.projection.get(projection); return ol.proj.get(projection);
} else { } else {
goog.asserts.assertInstanceof(projection, ol.Projection); goog.asserts.assertInstanceof(projection, ol.Projection);
return projection; return projection;
@@ -388,10 +386,10 @@ ol.projection.createProjection = function(projection, defaultCode) {
* @param {ol.Projection} destination Destination. * @param {ol.Projection} destination Destination.
* @param {ol.TransformFunction} transformFn Transform. * @param {ol.TransformFunction} transformFn Transform.
*/ */
ol.projection.addTransform = function(source, destination, transformFn) { ol.proj.addTransform = function(source, destination, transformFn) {
var sourceCode = source.getCode(); var sourceCode = source.getCode();
var destinationCode = destination.getCode(); var destinationCode = destination.getCode();
var transforms = ol.projection.transforms_; var transforms = ol.proj.transforms_;
if (!goog.object.containsKey(transforms, sourceCode)) { if (!goog.object.containsKey(transforms, sourceCode)) {
transforms[sourceCode] = {}; transforms[sourceCode] = {};
} }
@@ -408,10 +406,10 @@ ol.projection.addTransform = function(source, destination, transformFn) {
* @param {ol.Projection} destination Destination projection. * @param {ol.Projection} destination Destination projection.
* @return {ol.TransformFunction} transformFn The unregistered transform. * @return {ol.TransformFunction} transformFn The unregistered transform.
*/ */
ol.projection.removeTransform = function(source, destination) { ol.proj.removeTransform = function(source, destination) {
var sourceCode = source.getCode(); var sourceCode = source.getCode();
var destinationCode = destination.getCode(); var destinationCode = destination.getCode();
var transforms = ol.projection.transforms_; var transforms = ol.proj.transforms_;
goog.asserts.assert(sourceCode in transforms); goog.asserts.assert(sourceCode in transforms);
goog.asserts.assert(destinationCode in transforms[sourceCode]); goog.asserts.assert(destinationCode in transforms[sourceCode]);
var transform = transforms[sourceCode][destinationCode]; var transform = transforms[sourceCode][destinationCode];
@@ -430,15 +428,15 @@ ol.projection.removeTransform = function(source, destination) {
* existing projection object, or undefined. * existing projection object, or undefined.
* @return {ol.Projection} Projection. * @return {ol.Projection} Projection.
*/ */
ol.projection.get = function(projectionLike) { ol.proj.get = function(projectionLike) {
var projection; var projection;
if (projectionLike instanceof ol.Projection) { if (projectionLike instanceof ol.Projection) {
projection = projectionLike; projection = projectionLike;
} else if (goog.isString(projectionLike)) { } else if (goog.isString(projectionLike)) {
var code = projectionLike; var code = projectionLike;
projection = ol.projection.projections_[code]; projection = ol.proj.projections_[code];
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) { if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
projection = ol.projection.getProj4jsProjectionFromCode_({ projection = ol.proj.getProj4jsProjectionFromCode_({
code: code, code: code,
extent: null extent: null
}); });
@@ -459,9 +457,9 @@ ol.projection.get = function(projectionLike) {
* @private * @private
* @return {ol.Proj4jsProjection_} Proj4js projection. * @return {ol.Proj4jsProjection_} Proj4js projection.
*/ */
ol.projection.getProj4jsProjectionFromCode_ = function(options) { ol.proj.getProj4jsProjectionFromCode_ = function(options) {
var code = options.code; var code = options.code;
var proj4jsProjections = ol.projection.proj4jsProjections_; var proj4jsProjections = ol.proj.proj4jsProjections_;
var proj4jsProjection = proj4jsProjections[code]; var proj4jsProjection = proj4jsProjections[code];
if (!goog.isDef(proj4jsProjection)) { if (!goog.isDef(proj4jsProjection)) {
var proj4jsProj = new Proj4js.Proj(code); var proj4jsProj = new Proj4js.Proj(code);
@@ -489,15 +487,15 @@ ol.projection.getProj4jsProjectionFromCode_ = function(options) {
* @param {ol.Projection} projection2 Projection 2. * @param {ol.Projection} projection2 Projection 2.
* @return {boolean} Equivalent. * @return {boolean} Equivalent.
*/ */
ol.projection.equivalent = function(projection1, projection2) { ol.proj.equivalent = function(projection1, projection2) {
if (projection1 === projection2) { if (projection1 === projection2) {
return true; return true;
} else if (projection1.getUnits() != projection2.getUnits()) { } else if (projection1.getUnits() != projection2.getUnits()) {
return false; return false;
} else { } else {
var transformFn = ol.projection.getTransformFromProjections( var transformFn = ol.proj.getTransformFromProjections(
projection1, projection2); projection1, projection2);
return transformFn === ol.projection.cloneTransform; return transformFn === ol.proj.cloneTransform;
} }
}; };
@@ -511,10 +509,10 @@ ol.projection.equivalent = function(projection1, projection2) {
* @param {ol.ProjectionLike} destination Destination. * @param {ol.ProjectionLike} destination Destination.
* @return {ol.TransformFunction} Transform. * @return {ol.TransformFunction} Transform.
*/ */
ol.projection.getTransform = function(source, destination) { ol.proj.getTransform = function(source, destination) {
var sourceProjection = ol.projection.get(source); var sourceProjection = ol.proj.get(source);
var destinationProjection = ol.projection.get(destination); var destinationProjection = ol.proj.get(destination);
return ol.projection.getTransformFromProjections( return ol.proj.getTransformFromProjections(
sourceProjection, destinationProjection); sourceProjection, destinationProjection);
}; };
@@ -527,9 +525,9 @@ ol.projection.getTransform = function(source, destination) {
* @param {ol.Projection} destinationProjection Destination projection. * @param {ol.Projection} destinationProjection Destination projection.
* @return {ol.TransformFunction} Transform. * @return {ol.TransformFunction} Transform.
*/ */
ol.projection.getTransformFromProjections = ol.proj.getTransformFromProjections =
function(sourceProjection, destinationProjection) { function(sourceProjection, destinationProjection) {
var transforms = ol.projection.transforms_; var transforms = ol.proj.transforms_;
var sourceCode = sourceProjection.getCode(); var sourceCode = sourceProjection.getCode();
var destinationCode = destinationProjection.getCode(); var destinationCode = destinationProjection.getCode();
var transform; var transform;
@@ -543,7 +541,7 @@ ol.projection.getTransformFromProjections =
proj4jsSource = sourceProjection; proj4jsSource = sourceProjection;
} else { } else {
proj4jsSource = proj4jsSource =
ol.projection.getProj4jsProjectionFromCode_({ ol.proj.getProj4jsProjectionFromCode_({
code: sourceCode, code: sourceCode,
extent: null extent: null
}); });
@@ -554,7 +552,7 @@ ol.projection.getTransformFromProjections =
proj4jsDestination = destinationProjection; proj4jsDestination = destinationProjection;
} else { } else {
proj4jsDestination = proj4jsDestination =
ol.projection.getProj4jsProjectionFromCode_({ ol.proj.getProj4jsProjectionFromCode_({
code: destinationCode, code: destinationCode,
extent: null extent: null
}); });
@@ -590,12 +588,11 @@ ol.projection.getTransformFromProjections =
} }
return output; return output;
}; };
ol.projection.addTransform( ol.proj.addTransform(sourceProjection, destinationProjection, transform);
sourceProjection, destinationProjection, transform);
} }
if (!goog.isDef(transform)) { if (!goog.isDef(transform)) {
goog.asserts.assert(goog.isDef(transform)); goog.asserts.assert(goog.isDef(transform));
transform = ol.projection.identityTransform; transform = ol.proj.identityTransform;
} }
return transform; return transform;
}; };
@@ -607,7 +604,7 @@ ol.projection.getTransformFromProjections =
* @param {number=} opt_dimension Dimension. * @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Input coordinate array (same array as input). * @return {Array.<number>} Input coordinate array (same array as input).
*/ */
ol.projection.identityTransform = function(input, opt_output, opt_dimension) { ol.proj.identityTransform = function(input, opt_output, opt_dimension) {
if (goog.isDef(opt_output) && input !== opt_output) { if (goog.isDef(opt_output) && input !== opt_output) {
// TODO: consider making this a warning instead // TODO: consider making this a warning instead
goog.asserts.fail('This should not be used internally.'); goog.asserts.fail('This should not be used internally.');
@@ -627,7 +624,7 @@ ol.projection.identityTransform = function(input, opt_output, opt_dimension) {
* @return {Array.<number>} Output coordinate array (new array, same coordinate * @return {Array.<number>} Output coordinate array (new array, same coordinate
* values). * values).
*/ */
ol.projection.cloneTransform = function(input, opt_output, opt_dimension) { ol.proj.cloneTransform = function(input, opt_output, opt_dimension) {
var output; var output;
if (goog.isDef(opt_output)) { if (goog.isDef(opt_output)) {
for (var i = 0, ii = input.length; i < ii; ++i) { for (var i = 0, ii = input.length; i < ii; ++i) {
@@ -647,8 +644,8 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
* @param {ol.ProjectionLike} destination Destination. * @param {ol.ProjectionLike} destination Destination.
* @return {ol.Coordinate} Point. * @return {ol.Coordinate} Point.
*/ */
ol.projection.transform = function(point, source, destination) { ol.proj.transform = function(point, source, destination) {
var transformFn = ol.projection.getTransform(source, destination); var transformFn = ol.proj.getTransform(source, destination);
return transformFn(point); return transformFn(point);
}; };
@@ -661,9 +658,9 @@ ol.projection.transform = function(point, source, destination) {
* @param {ol.Projection} destinationProjection Destination projection. * @param {ol.Projection} destinationProjection Destination projection.
* @return {ol.Coordinate} Point. * @return {ol.Coordinate} Point.
*/ */
ol.projection.transformWithProjections = ol.proj.transformWithProjections =
function(point, sourceProjection, destinationProjection) { function(point, sourceProjection, destinationProjection) {
var transformFn = ol.projection.getTransformFromProjections( var transformFn = ol.proj.getTransformFromProjections(
sourceProjection, destinationProjection); sourceProjection, destinationProjection);
return transformFn(point); return transformFn(point);
}; };
@@ -673,8 +670,8 @@ ol.projection.transformWithProjections =
* @param {ol.Proj4jsProjectionOptions} options Proj4js projection options. * @param {ol.Proj4jsProjectionOptions} options Proj4js projection options.
* @return {ol.Projection} Proj4js projection. * @return {ol.Projection} Proj4js projection.
*/ */
ol.projection.configureProj4jsProjection = function(options) { ol.proj.configureProj4jsProjection = function(options) {
goog.asserts.assert(!goog.object.containsKey( goog.asserts.assert(!goog.object.containsKey(
ol.projection.proj4jsProjections_, options.code)); ol.proj.proj4jsProjections_, options.code));
return ol.projection.getProj4jsProjectionFromCode_(options); return ol.proj.getProj4jsProjectionFromCode_(options);
}; };

View File

@@ -1,3 +0,0 @@
/**
* @namespace ol.projection
*/

View File

@@ -1,23 +0,0 @@
goog.provide('ol.projection.addCommonProjections');
goog.require('ol.projection');
goog.require('ol.projection.EPSG3857');
goog.require('ol.projection.EPSG4326');
/**
* FIXME empty description for jsdoc
*/
ol.projection.addCommonProjections = function() {
// Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning.
ol.projection.addEquivalentProjections(ol.projection.EPSG3857.PROJECTIONS);
ol.projection.addEquivalentProjections(ol.projection.EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back.
ol.projection.addEquivalentTransforms(
ol.projection.EPSG4326.PROJECTIONS,
ol.projection.EPSG3857.PROJECTIONS,
ol.projection.EPSG3857.fromEPSG4326,
ol.projection.EPSG3857.toEPSG4326);
};

View File

@@ -1,57 +0,0 @@
goog.provide('ol.projection.EPSG4326');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');
goog.require('ol.projection');
/**
* @constructor
* @extends {ol.Projection}
* @param {string} code Code.
* @param {string=} opt_axisOrientation Axis orientation.
*/
ol.projection.EPSG4326 = function(code, opt_axisOrientation) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.DEGREES,
extent: ol.projection.EPSG4326.EXTENT,
axisOrientation: opt_axisOrientation,
global: true
});
};
goog.inherits(ol.projection.EPSG4326, ol.Projection);
/**
* Extent of the EPSG:4326 projection which is the whole world.
*
* @const
* @type {ol.Extent}
*/
ol.projection.EPSG4326.EXTENT = [-180, 180, -90, 90];
/**
* Projections equal to EPSG:4326.
*
* @const
* @type {Array.<ol.Projection>}
*/
ol.projection.EPSG4326.PROJECTIONS = [
new ol.projection.EPSG4326('CRS:84'),
new ol.projection.EPSG4326('EPSG:4326', 'neu'),
new ol.projection.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:2:84')
];
/**
* @inheritDoc
*/
ol.projection.EPSG4326.prototype.getPointResolution =
function(resolution, point) {
return resolution;
};

View File

@@ -9,7 +9,7 @@ goog.require('ol.Size');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.ImageTileSource'); goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ'); goog.require('ol.tilegrid.XYZ');
@@ -25,7 +25,7 @@ ol.source.BingMaps = function(options) {
goog.base(this, { goog.base(this, {
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
opaque: true, opaque: true,
projection: ol.projection.get('EPSG:3857') projection: ol.proj.get('EPSG:3857')
}); });
/** /**
@@ -95,7 +95,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord, projection) { function(tileCoord, projection) {
goog.asserts.assert(ol.projection.equivalent( goog.asserts.assert(ol.proj.equivalent(
projection, this.getProjection())); projection, this.getProjection()));
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
@@ -106,8 +106,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
}); });
}))); })));
var transform = ol.projection.getTransformFromProjections( var transform = ol.proj.getTransformFromProjections(
ol.projection.get('EPSG:4326'), this.getProjection()); ol.proj.get('EPSG:4326'), this.getProjection());
var attributions = goog.array.map( var attributions = goog.array.map(
resource.imageryProviders, resource.imageryProviders,
function(imageryProvider) { function(imageryProvider) {

View File

@@ -5,7 +5,7 @@ goog.require('goog.events.EventType');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
goog.require('ol.Extent'); goog.require('ol.Extent');
goog.require('ol.projection'); goog.require('ol.proj');
@@ -22,7 +22,7 @@ ol.source.Source = function(options) {
* @private * @private
* @type {ol.Projection} * @type {ol.Projection}
*/ */
this.projection_ = ol.projection.get(options.projection); this.projection_ = ol.proj.get(options.projection);
/** /**
* @private * @private

View File

@@ -3,7 +3,7 @@ goog.provide('ol.source.StaticImage');
goog.require('ol.Image'); goog.require('ol.Image');
goog.require('ol.ImageUrlFunctionType'); goog.require('ol.ImageUrlFunctionType');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.ImageSource'); goog.require('ol.source.ImageSource');
@@ -21,7 +21,7 @@ ol.source.StaticImage = function(options) {
var imageExtent = options.imageExtent; var imageExtent = options.imageExtent;
var imageSize = options.imageSize; var imageSize = options.imageSize;
var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize.height; var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize.height;
var projection = ol.projection.get(options.projection); var projection = ol.proj.get(options.projection);
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,

View File

@@ -14,7 +14,7 @@ goog.require('ol.Attribution');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.ImageTileSource'); goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ'); goog.require('ol.tilegrid.XYZ');
@@ -45,7 +45,7 @@ ol.source.TileJSON = function(options) {
goog.base(this, { goog.base(this, {
crossOrigin: options.crossOrigin, crossOrigin: options.crossOrigin,
projection: ol.projection.get('EPSG:3857') projection: ol.proj.get('EPSG:3857')
}); });
/** /**
@@ -72,13 +72,13 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
var tileJSON = ol.tilejson.grids_.pop(); var tileJSON = ol.tilejson.grids_.pop();
var epsg4326Projection = ol.projection.get('EPSG:4326'); var epsg4326Projection = ol.proj.get('EPSG:4326');
var extent; var extent;
if (goog.isDef(tileJSON.bounds)) { if (goog.isDef(tileJSON.bounds)) {
var bounds = tileJSON.bounds; var bounds = tileJSON.bounds;
var epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]]; var epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]];
var transform = ol.projection.getTransformFromProjections( var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, this.getProjection()); epsg4326Projection, this.getProjection());
extent = ol.extent.transform(epsg4326Extent, transform); extent = ol.extent.transform(epsg4326Extent, transform);
this.setExtent(extent); this.setExtent(extent);

View File

@@ -10,7 +10,7 @@ goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType'); goog.require('ol.TileUrlFunctionType');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.ImageTileSource'); goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.WMTS'); goog.require('ol.tilegrid.WMTS');
@@ -212,7 +212,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, layer) {
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet( var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
matrixSetObj); matrixSetObj);
var projection = ol.projection.get(matrixSetObj['supportedCRS']); var projection = ol.proj.get(matrixSetObj['supportedCRS']);
var gets = wmtsCap['operationsMetadata']['GetTile']['dcp']['http']['get']; var gets = wmtsCap['operationsMetadata']['GetTile']['dcp']['http']['get'];
var encodings = goog.object.getKeys( var encodings = goog.object.getKeys(

View File

@@ -5,7 +5,7 @@ goog.require('ol.Attribution');
goog.require('ol.Projection'); goog.require('ol.Projection');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType'); goog.require('ol.TileUrlFunctionType');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.ImageTileSource'); goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ'); goog.require('ol.tilegrid.XYZ');
@@ -33,7 +33,7 @@ ol.source.XYZOptions;
*/ */
ol.source.XYZ = function(options) { ol.source.XYZ = function(options) {
var projection = options.projection || ol.projection.get('EPSG:3857'); var projection = options.projection || ol.proj.get('EPSG:3857');
/** /**
* @type {ol.TileUrlFunctionType} * @type {ol.TileUrlFunctionType}

View File

@@ -3,7 +3,7 @@ goog.provide('ol.tilegrid.WMTS');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');
@@ -67,7 +67,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
var matrixIds = []; var matrixIds = [];
var origins = []; var origins = [];
var tileSizes = []; var tileSizes = [];
var projection = ol.projection.get(matrixSet['supportedCRS']); var projection = ol.proj.get(matrixSet['supportedCRS']);
var metersPerUnit = projection.getMetersPerUnit(); var metersPerUnit = projection.getMetersPerUnit();
goog.array.forEach(matrixSet['matrixIds'], function(elt, index, array) { goog.array.forEach(matrixSet['matrixIds'], function(elt, index, array) {
matrixIds.push(elt['identifier']); matrixIds.push(elt['identifier']);

View File

@@ -4,8 +4,8 @@ goog.require('goog.math');
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileRange'); goog.require('ol.TileRange');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.projection.EPSG3857'); goog.require('ol.proj.EPSG3857');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');
@@ -19,15 +19,14 @@ ol.tilegrid.XYZ = function(options) {
var resolutions = new Array(options.maxZoom + 1); var resolutions = new Array(options.maxZoom + 1);
var z; var z;
var size = 2 * ol.projection.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE; var size = 2 * ol.proj.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE;
for (z = 0; z <= options.maxZoom; ++z) { for (z = 0; z <= options.maxZoom; ++z) {
resolutions[z] = size / Math.pow(2, z); resolutions[z] = size / Math.pow(2, z);
} }
goog.base(this, { goog.base(this, {
minZoom: options.minZoom, minZoom: options.minZoom,
origin: [-ol.projection.EPSG3857.HALF_SIZE, origin: [-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE],
ol.projection.EPSG3857.HALF_SIZE],
resolutions: resolutions, resolutions: resolutions,
tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE) tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE)
}); });

View File

@@ -15,7 +15,7 @@ goog.require('ol.Size');
goog.require('ol.View'); goog.require('ol.View');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.projection'); goog.require('ol.proj');
/** /**
@@ -47,7 +47,7 @@ ol.View2D = function(opt_options) {
var values = {}; var values = {};
values[ol.View2DProperty.CENTER] = goog.isDef(options.center) ? values[ol.View2DProperty.CENTER] = goog.isDef(options.center) ?
options.center : null; options.center : null;
values[ol.View2DProperty.PROJECTION] = ol.projection.createProjection( values[ol.View2DProperty.PROJECTION] = ol.proj.createProjection(
options.projection, 'EPSG:3857'); options.projection, 'EPSG:3857');
if (goog.isDef(options.resolution)) { if (goog.isDef(options.resolution)) {
values[ol.View2DProperty.RESOLUTION] = options.resolution; values[ol.View2DProperty.RESOLUTION] = options.resolution;
@@ -405,7 +405,7 @@ ol.View2D.createResolutionConstraint_ = function(options) {
} else { } else {
maxResolution = options.maxResolution; maxResolution = options.maxResolution;
if (!goog.isDef(maxResolution)) { if (!goog.isDef(maxResolution)) {
var projectionExtent = ol.projection.createProjection( var projectionExtent = ol.proj.createProjection(
options.projection, 'EPSG:3857').getExtent(); options.projection, 'EPSG:3857').getExtent();
maxResolution = Math.max( maxResolution = Math.max(
projectionExtent[1] - projectionExtent[0], projectionExtent[1] - projectionExtent[0],

View File

@@ -197,7 +197,7 @@ describe('ol.extent', function() {
describe('transform', function() { describe('transform', function() {
it('does transform', function() { it('does transform', function() {
var transformFn = ol.projection.getTransform('EPSG:4326', 'EPSG:3857'); var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = [-15, 45, -30, 60]; var sourceExtent = [-15, 45, -30, 60];
var destinationExtent = ol.extent.transform(sourceExtent, transformFn); var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
expect(destinationExtent).not.to.be(undefined); expect(destinationExtent).not.to.be(undefined);
@@ -240,4 +240,4 @@ describe('ol.extent', function() {
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.projection'); goog.require('ol.proj');

View File

@@ -9,7 +9,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() { beforeEach(function() {
layer = new ol.layer.Layer({ layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
}); });
@@ -53,7 +53,7 @@ describe('ol.layer.Layer', function() {
it('accepts options', function() { it('accepts options', function() {
var layer = new ol.layer.Layer({ var layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}), }),
brightness: 0.5, brightness: 0.5,
contrast: 10, contrast: 10,
@@ -82,7 +82,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() { beforeEach(function() {
layer = new ol.layer.Layer({ layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
}); });
@@ -120,7 +120,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() { beforeEach(function() {
layer = new ol.layer.Layer({ layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
}); });
@@ -154,7 +154,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() { beforeEach(function() {
layer = new ol.layer.Layer({ layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
}); });
@@ -193,7 +193,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() { beforeEach(function() {
layer = new ol.layer.Layer({ layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
}); });
@@ -227,7 +227,7 @@ describe('ol.layer.Layer', function() {
beforeEach(function() { beforeEach(function() {
layer = new ol.layer.Layer({ layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
}); });
@@ -259,7 +259,7 @@ describe('ol.layer.Layer', function() {
it('sets visible property', function() { it('sets visible property', function() {
var layer = new ol.layer.Layer({ var layer = new ol.layer.Layer({
source: new ol.source.Source({ source: new ol.source.Source({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}) })
}); });
@@ -278,5 +278,5 @@ describe('ol.layer.Layer', function() {
goog.require('goog.dispose'); goog.require('goog.dispose');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.Source'); goog.require('ol.source.Source');

View File

@@ -99,7 +99,7 @@ describe('ol.layer.Vector', function() {
var layer = new ol.layer.Vector({ var layer = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}), }),
style: new ol.style.Style({ style: new ol.style.Style({
rules: [ rules: [
@@ -186,7 +186,7 @@ goog.require('ol.filter.LogicalOperator');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString'); goog.require('ol.geom.LineString');
goog.require('ol.geom.Point'); goog.require('ol.geom.Point');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.style.Line'); goog.require('ol.style.Line');

View File

@@ -1,13 +1,13 @@
goog.provide('ol.test.projection.EPSG3857'); goog.provide('ol.test.projection.EPSG3857');
describe('ol.projection.EPSG3857', function() { describe('ol.proj.EPSG3857', function() {
describe('getPointResolution', function() { describe('getPointResolution', function() {
it('returns the correct point scale at the equator', function() { it('returns the correct point scale at the equator', function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.get('EPSG:3857'); var epsg3857 = ol.proj.get('EPSG:3857');
var resolution = 19.11; var resolution = 19.11;
var point = [0, 0]; var point = [0, 0];
expect(epsg3857.getPointResolution(resolution, point)). expect(epsg3857.getPointResolution(resolution, point)).
@@ -17,22 +17,22 @@ describe('ol.projection.EPSG3857', function() {
it('returns the correct point scale at the latitude of Toronto', it('returns the correct point scale at the latitude of Toronto',
function() { function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.get('EPSG:3857'); var epsg3857 = ol.proj.get('EPSG:3857');
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
var resolution = 19.11; var resolution = 19.11;
var point = ol.projection.transform([0, 43.65], epsg4326, epsg3857); var point = ol.proj.transform([0, 43.65], epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)). expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9); to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9);
}); });
it('returns the correct point scale at various latitudes', function() { it('returns the correct point scale at various latitudes', function() {
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx // @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
var epsg3857 = ol.projection.get('EPSG:3857'); var epsg3857 = ol.proj.get('EPSG:3857');
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
var resolution = 19.11; var resolution = 19.11;
var latitude; var latitude;
for (latitude = 0; latitude < 90; ++latitude) { for (latitude = 0; latitude < 90; ++latitude) {
var point = ol.projection.transform([0, latitude], epsg4326, epsg3857); var point = ol.proj.transform([0, latitude], epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)). expect(epsg3857.getPointResolution(resolution, point)).
to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9); to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9);
} }
@@ -43,5 +43,5 @@ describe('ol.projection.EPSG3857', function() {
}); });
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.projection.EPSG3857'); goog.require('ol.proj.EPSG3857');

View File

@@ -1,17 +1,16 @@
goog.provide('ol.test.Projection'); goog.provide('ol.test.Projection');
describe('ol.projection', function() { describe('ol.proj', function() {
beforeEach(function() { beforeEach(function() {
sinon.spy(ol.projection, 'addTransform'); sinon.spy(ol.proj, 'addTransform');
}); });
afterEach(function() { afterEach(function() {
var argsForCall = ol.projection.addTransform.args; var argsForCall = ol.proj.addTransform.args;
for (var i = 0, ii = argsForCall.length; i < ii; ++i) { for (var i = 0, ii = argsForCall.length; i < ii; ++i) {
try { try {
ol.projection.removeTransform.apply( ol.proj.removeTransform.apply(ol.proj, argsForCall[i].splice(0, 2));
ol.projection, argsForCall[i].splice(0, 2));
} catch (error) { } catch (error) {
if (error instanceof goog.asserts.AssertionError) { if (error instanceof goog.asserts.AssertionError) {
// The removeTransform function may have been called explicitly by the // The removeTransform function may have been called explicitly by the
@@ -21,16 +20,16 @@ describe('ol.projection', function() {
} }
} }
} }
ol.projection.addTransform.restore(); ol.proj.addTransform.restore();
}); });
describe('projection equivalence', function() { describe('projection equivalence', function() {
function _testAllEquivalent(codes) { function _testAllEquivalent(codes) {
var projections = goog.array.map(codes, ol.projection.get); var projections = goog.array.map(codes, ol.proj.get);
goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(source) {
goog.array.forEach(projections, function(destination) { goog.array.forEach(projections, function(destination) {
expect(ol.projection.equivalent(source, destination)).to.be.ok(); expect(ol.proj.equivalent(source, destination)).to.be.ok();
}); });
}); });
} }
@@ -57,10 +56,10 @@ describe('ol.projection', function() {
describe('identify transform', function() { describe('identify transform', function() {
it('returns a new object, with same coord values', function() { it('returns a new object, with same coord values', function() {
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
var uniqueObject = {}; var uniqueObject = {};
var sourcePoint = [uniqueObject, uniqueObject]; var sourcePoint = [uniqueObject, uniqueObject];
var destinationPoint = ol.projection.transform( var destinationPoint = ol.proj.transform(
sourcePoint, epsg4326, epsg4326); sourcePoint, epsg4326, epsg4326);
expect(sourcePoint === destinationPoint).to.not.be(); expect(sourcePoint === destinationPoint).to.not.be();
expect(destinationPoint[0] === sourcePoint[0]).to.be.ok(); expect(destinationPoint[0] === sourcePoint[0]).to.be.ok();
@@ -71,8 +70,7 @@ describe('ol.projection', function() {
describe('transform 0,0 from 4326 to 3857', function() { describe('transform 0,0 from 4326 to 3857', function() {
it('returns expected value', function() { it('returns expected value', function() {
var point = ol.projection.transform( var point = ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:3857');
[0, 0], 'EPSG:4326', 'EPSG:3857');
expect(point).not.to.be(undefined); expect(point).not.to.be(undefined);
expect(point).not.to.be(null); expect(point).not.to.be(null);
expect(point[1]).to.roughlyEqual(0, 1e-9); expect(point[1]).to.roughlyEqual(0, 1e-9);
@@ -82,8 +80,7 @@ describe('ol.projection', function() {
describe('transform 0,0 from 3857 to 4326', function() { describe('transform 0,0 from 3857 to 4326', function() {
it('returns expected value', function() { it('returns expected value', function() {
var point = ol.projection.transform( var point = ol.proj.transform([0, 0], 'EPSG:3857', 'EPSG:4326');
[0, 0], 'EPSG:3857', 'EPSG:4326');
expect(point).not.to.be(undefined); expect(point).not.to.be(undefined);
expect(point).not.to.be(null); expect(point).not.to.be(null);
expect(point[0]).to.eql(0); expect(point[0]).to.eql(0);
@@ -95,10 +92,8 @@ describe('ol.projection', function() {
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
it('returns expected value', function() { it('returns expected value', function() {
var point = ol.projection.transform( var point = ol.proj.transform(
[-5.625, 52.4827802220782], [-5.625, 52.4827802220782], 'EPSG:4326', 'EPSG:900913');
'EPSG:4326',
'EPSG:900913');
expect(point).not.to.be(undefined); expect(point).not.to.be(undefined);
expect(point).not.to.be(null); expect(point).not.to.be(null);
expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9); expect(point[0]).to.roughlyEqual(-626172.13571216376, 1e-9);
@@ -110,10 +105,8 @@ describe('ol.projection', function() {
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
it('returns expected value', function() { it('returns expected value', function() {
var point = ol.projection.transform( var point = ol.proj.transform([-626172.13571216376, 6887893.4928337997],
[-626172.13571216376, 6887893.4928337997], 'EPSG:900913', 'EPSG:4326');
'EPSG:900913',
'EPSG:4326');
expect(point).not.to.be(undefined); expect(point).not.to.be(undefined);
expect(point).not.to.be(null); expect(point).not.to.be(null);
expect(point[0]).to.roughlyEqual(-5.625, 1e-9); expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
@@ -124,10 +117,8 @@ describe('ol.projection', function() {
describe('Proj4js integration', function() { describe('Proj4js integration', function() {
it('allows Proj4js projections to be used transparently', function() { it('allows Proj4js projections to be used transparently', function() {
var point = ol.projection.transform( var point = ol.proj.transform(
[-626172.13571216376, 6887893.4928337997], [-626172.13571216376, 6887893.4928337997], 'GOOGLE', 'WGS84');
'GOOGLE',
'WGS84');
expect(point[0]).to.roughlyEqual(-5.625, 1e-9); expect(point[0]).to.roughlyEqual(-5.625, 1e-9);
expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9); expect(point[1]).to.roughlyEqual(52.4827802220782, 1e-9);
}); });
@@ -137,10 +128,8 @@ describe('ol.projection', function() {
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' + '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
var point = ol.projection.transform( var point = ol.proj.transform([7.439583333333333, 46.95240555555556],
[7.439583333333333, 46.95240555555556], 'EPSG:4326', 'EPSG:21781');
'EPSG:4326',
'EPSG:21781');
expect(point[0]).to.roughlyEqual(600072.300, 1); expect(point[0]).to.roughlyEqual(600072.300, 1);
expect(point[1]).to.roughlyEqual(200146.976, 1); expect(point[1]).to.roughlyEqual(200146.976, 1);
}); });
@@ -152,24 +141,22 @@ describe('ol.projection', function() {
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs'; '+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
var code = 'urn:ogc:def:crs:EPSG:21781'; var code = 'urn:ogc:def:crs:EPSG:21781';
var srsCode = 'EPSG:21781'; var srsCode = 'EPSG:21781';
var proj = ol.projection.get(code); var proj = ol.proj.get(code);
expect(ol.projection.proj4jsProjections_.hasOwnProperty(code)) expect(ol.proj.proj4jsProjections_.hasOwnProperty(code)).to.be.ok();
.to.be.ok(); expect(ol.proj.proj4jsProjections_.hasOwnProperty(srsCode)).to.be.ok();
expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode)) var proj2 = ol.proj.get(srsCode);
.to.be.ok();
var proj2 = ol.projection.get(srsCode);
expect(proj2).to.be(proj); expect(proj2).to.be(proj);
}); });
it('numerically estimates point scale at the equator', function() { it('numerically estimates point scale at the equator', function() {
var googleProjection = ol.projection.get('GOOGLE'); var googleProjection = ol.proj.get('GOOGLE');
expect(googleProjection.getPointResolution(1, [0, 0])). expect(googleProjection.getPointResolution(1, [0, 0])).
to.roughlyEqual(1, 1e-1); to.roughlyEqual(1, 1e-1);
}); });
it('numerically estimates point scale at various latitudes', function() { it('numerically estimates point scale at various latitudes', function() {
var epsg3857Projection = ol.projection.get('EPSG:3857'); var epsg3857Projection = ol.proj.get('EPSG:3857');
var googleProjection = ol.projection.get('GOOGLE'); var googleProjection = ol.proj.get('GOOGLE');
var point, y; var point, y;
for (y = -20; y <= 20; ++y) { for (y = -20; y <= 20; ++y) {
point = [0, 1000000 * y]; point = [0, 1000000 * y];
@@ -179,8 +166,8 @@ describe('ol.projection', function() {
}); });
it('numerically estimates point scale at various points', function() { it('numerically estimates point scale at various points', function() {
var epsg3857Projection = ol.projection.get('EPSG:3857'); var epsg3857Projection = ol.proj.get('EPSG:3857');
var googleProjection = ol.projection.get('GOOGLE'); var googleProjection = ol.proj.get('GOOGLE');
var point, x, y; var point, x, y;
for (x = -20; x <= 20; ++x) { for (x = -20; x <= 20; ++x) {
for (y = -20; y <= 20; ++y) { for (y = -20; y <= 20; ++y) {
@@ -193,13 +180,13 @@ describe('ol.projection', function() {
}); });
describe('ol.projection.getTransformFromProjections()', function() { describe('ol.proj.getTransformFromProjections()', function() {
var sm = ol.projection.get('GOOGLE'); var sm = ol.proj.get('GOOGLE');
var gg = ol.projection.get('EPSG:4326'); var gg = ol.proj.get('EPSG:4326');
it('returns a transform function', function() { it('returns a transform function', function() {
var transform = ol.projection.getTransformFromProjections(sm, gg); var transform = ol.proj.getTransformFromProjections(sm, gg);
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
var output = transform([-12000000, 5000000]); var output = transform([-12000000, 5000000]);
@@ -209,7 +196,7 @@ describe('ol.projection', function() {
}); });
it('works for longer arrays', function() { it('works for longer arrays', function() {
var transform = ol.projection.getTransformFromProjections(sm, gg); var transform = ol.proj.getTransformFromProjections(sm, gg);
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
var output = transform([-12000000, 5000000, -12000000, 5000000]); var output = transform([-12000000, 5000000, -12000000, 5000000]);
@@ -222,15 +209,15 @@ describe('ol.projection', function() {
}); });
describe('ol.projection.getTransform()', function() { describe('ol.proj.getTransform()', function() {
it('returns a function', function() { it('returns a function', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
}); });
it('returns a transform function', function() { it('returns a transform function', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
var output = transform([-626172.13571216376, 6887893.4928337997]); var output = transform([-626172.13571216376, 6887893.4928337997]);
@@ -241,7 +228,7 @@ describe('ol.projection', function() {
}); });
it('works for longer arrays of coordinate values', function() { it('works for longer arrays of coordinate values', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
var output = transform([ var output = transform([
@@ -259,7 +246,7 @@ describe('ol.projection', function() {
}); });
it('accepts an optional destination array', function() { it('accepts an optional destination array', function() {
var transform = ol.projection.getTransform('EPSG:3857', 'EPSG:4326'); var transform = ol.proj.getTransform('EPSG:3857', 'EPSG:4326');
var input = [-12000000, 5000000]; var input = [-12000000, 5000000];
var output = []; var output = [];
@@ -273,7 +260,7 @@ describe('ol.projection', function() {
}); });
it('accepts a dimension', function() { it('accepts a dimension', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.proj.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).to.be('function'); expect(typeof transform).to.be('function');
var dimension = 3; var dimension = 3;
@@ -295,7 +282,7 @@ describe('ol.projection', function() {
}); });
}); });
describe('ol.projection.removeTransform()', function() { describe('ol.proj.removeTransform()', function() {
var extent = [180, 180, -90, 90]; var extent = [180, 180, -90, 90];
var units = ol.ProjectionUnits.DEGREES; var units = ol.ProjectionUnits.DEGREES;
@@ -312,14 +299,14 @@ describe('ol.projection', function() {
extent: extent extent: extent
}); });
var transform = function(input, output, dimension) {return input}; var transform = function(input, output, dimension) {return input};
ol.projection.addTransform(foo, bar, transform); ol.proj.addTransform(foo, bar, transform);
expect(ol.projection.transforms_).not.to.be(undefined); expect(ol.proj.transforms_).not.to.be(undefined);
expect(ol.projection.transforms_.foo).not.to.be(undefined); expect(ol.proj.transforms_.foo).not.to.be(undefined);
expect(ol.projection.transforms_.foo.bar).to.be(transform); expect(ol.proj.transforms_.foo.bar).to.be(transform);
var removed = ol.projection.removeTransform(foo, bar); var removed = ol.proj.removeTransform(foo, bar);
expect(removed).to.be(transform); expect(removed).to.be(transform);
expect(ol.projection.transforms_.foo).to.be(undefined); expect(ol.proj.transforms_.foo).to.be(undefined);
}); });
}); });
@@ -327,21 +314,21 @@ describe('ol.projection', function() {
describe('ol.Projection.prototype.getMetersPerUnit()', function() { describe('ol.Projection.prototype.getMetersPerUnit()', function() {
it('returns value in meters', function() { it('returns value in meters', function() {
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
expect(epsg4326.getMetersPerUnit()).to.eql(111194.87428468118); expect(epsg4326.getMetersPerUnit()).to.eql(111194.87428468118);
}); });
}); });
describe('ol.projection.configureProj4jsProjection()', function() { describe('ol.proj.configureProj4jsProjection()', function() {
beforeEach(function() { beforeEach(function() {
ol.projection.proj4jsProjections_ = {}; ol.proj.proj4jsProjections_ = {};
}); });
it('returns a configured projection', function() { it('returns a configured projection', function() {
var extent = [485869.5728, 837076.5648, 76443.1884, 299941.7864]; var extent = [485869.5728, 837076.5648, 76443.1884, 299941.7864];
var epsg21781 = ol.projection.configureProj4jsProjection({ var epsg21781 = ol.proj.configureProj4jsProjection({
code: 'EPSG:21781', code: 'EPSG:21781',
extent: extent extent: extent
}); });
@@ -359,4 +346,4 @@ goog.require('goog.array');
goog.require('goog.asserts.AssertionError'); goog.require('goog.asserts.AssertionError');
goog.require('ol.Projection'); goog.require('ol.Projection');
goog.require('ol.ProjectionUnits'); goog.require('ol.ProjectionUnits');
goog.require('ol.projection'); goog.require('ol.proj');

View File

@@ -5,7 +5,7 @@ describe('ol.source.TileSource', function() {
describe('constructor', function() { describe('constructor', function() {
it('returns a tile source', function() { it('returns a tile source', function() {
var source = new ol.source.TileSource({ var source = new ol.source.TileSource({
projection: ol.projection.get('EPSG:4326') projection: ol.proj.get('EPSG:4326')
}); });
expect(source).to.be.a(ol.source.Source); expect(source).to.be.a(ol.source.Source);
expect(source).to.be.a(ol.source.TileSource); expect(source).to.be.a(ol.source.TileSource);
@@ -202,7 +202,7 @@ ol.test.source.MockTileSource = function(loaded) {
goog.base(this, { goog.base(this, {
extent: extent, extent: extent,
projection: ol.projection.get('EPSG:4326'), projection: ol.proj.get('EPSG:4326'),
tileGrid: tileGrid tileGrid: tileGrid
}); });
@@ -269,7 +269,7 @@ goog.require('ol.Size');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileState'); goog.require('ol.TileState');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.Source'); goog.require('ol.source.Source');
goog.require('ol.source.TileSource'); goog.require('ol.source.TileSource');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');

View File

@@ -4,7 +4,7 @@ describe('ol.source.wms', function() {
describe('ol.source.wms.getUrl', function() { describe('ol.source.wms.getUrl', function() {
it('creates expected URL', function() { it('creates expected URL', function() {
var epsg3857 = ol.projection.get('EPSG:3857'); var epsg3857 = ol.proj.get('EPSG:3857');
var extent = [-20037508.342789244, 0, -20037508.342789244, 0]; var extent = [-20037508.342789244, 0, -20037508.342789244, 0];
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' + var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
@@ -15,7 +15,7 @@ describe('ol.source.wms', function() {
expect(url).to.eql(expected); expect(url).to.eql(expected);
}); });
it('creates expected URL respecting axis orientation', function() { it('creates expected URL respecting axis orientation', function() {
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.proj.get('EPSG:4326');
var extent = [-180, 0, -90, 90]; var extent = [-180, 0, -90, 90];
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' + var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
@@ -30,5 +30,5 @@ describe('ol.source.wms', function() {
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.source.wms'); goog.require('ol.source.wms');

View File

@@ -164,7 +164,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('createForProjection', function() { describe('createForProjection', function() {
it('allows easier creation of a tile grid', function() { it('allows easier creation of a tile grid', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.proj.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection); var grid = ol.tilegrid.createForProjection(projection);
expect(grid).to.be.a(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
@@ -173,7 +173,7 @@ describe('ol.tilegrid.TileGrid', function() {
}); });
it('accepts a number of zoom levels', function() { it('accepts a number of zoom levels', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.proj.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection, 18); var grid = ol.tilegrid.createForProjection(projection, 18);
expect(grid).to.be.a(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
@@ -182,7 +182,7 @@ describe('ol.tilegrid.TileGrid', function() {
}); });
it('accepts a big number of zoom levels', function() { it('accepts a big number of zoom levels', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.proj.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection, 23); var grid = ol.tilegrid.createForProjection(projection, 23);
expect(grid).to.be.a(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
@@ -195,7 +195,7 @@ describe('ol.tilegrid.TileGrid', function() {
describe('getForProjection', function() { describe('getForProjection', function() {
it('gets the default tile grid for a projection', function() { it('gets the default tile grid for a projection', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.proj.get('EPSG:3857');
var grid = ol.tilegrid.getForProjection(projection); var grid = ol.tilegrid.getForProjection(projection);
expect(grid).to.be.a(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
@@ -205,7 +205,7 @@ describe('ol.tilegrid.TileGrid', function() {
}); });
it('stores the default tile grid on a projection', function() { it('stores the default tile grid on a projection', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.proj.get('EPSG:3857');
var grid = ol.tilegrid.getForProjection(projection); var grid = ol.tilegrid.getForProjection(projection);
var gridAgain = ol.tilegrid.getForProjection(projection); var gridAgain = ol.tilegrid.getForProjection(projection);
@@ -635,5 +635,5 @@ describe('ol.tilegrid.TileGrid', function() {
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.projection'); goog.require('ol.proj');
goog.require('ol.tilegrid.TileGrid'); goog.require('ol.tilegrid.TileGrid');

View File

@@ -80,7 +80,7 @@ describe('ol.TileUrlFunction', function() {
describe('createFromParamsFunction', function() { describe('createFromParamsFunction', function() {
var paramsFunction = function(url, params) { return arguments; }; var paramsFunction = function(url, params) { return arguments; };
var projection = ol.projection.get('EPSG:3857'); var projection = ol.proj.get('EPSG:3857');
var fakeTileSource = {getTileGrid: function() {return null;}}; var fakeTileSource = {getTileGrid: function() {return null;}};
var params = {foo: 'bar'}; var params = {foo: 'bar'};
var tileUrlFunction = ol.TileUrlFunction.createFromParamsFunction( var tileUrlFunction = ol.TileUrlFunction.createFromParamsFunction(
@@ -101,4 +101,4 @@ describe('ol.TileUrlFunction', function() {
goog.require('ol.Size'); goog.require('ol.Size');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.projection'); goog.require('ol.proj');