Named exports from ol/proj

This commit is contained in:
Tim Schaub
2017-12-13 22:14:27 -07:00
committed by Andreas Hocevar
parent fab77e8d37
commit 6f72ffe498
127 changed files with 853 additions and 882 deletions

View File

@@ -2,14 +2,14 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import {easeIn, easeOut} from '../src/ol/easing.js'; import {easeIn, easeOut} from '../src/ol/easing.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
var london = _ol_proj_.fromLonLat([-0.12755, 51.507222]); var london = fromLonLat([-0.12755, 51.507222]);
var moscow = _ol_proj_.fromLonLat([37.6178, 55.7517]); var moscow = fromLonLat([37.6178, 55.7517]);
var istanbul = _ol_proj_.fromLonLat([28.9744, 41.0128]); var istanbul = fromLonLat([28.9744, 41.0128]);
var rome = _ol_proj_.fromLonLat([12.5, 41.9]); var rome = fromLonLat([12.5, 41.9]);
var bern = _ol_proj_.fromLonLat([7.4458, 46.95]); var bern = fromLonLat([7.4458, 46.95]);
var view = new _ol_View_({ var view = new _ol_View_({
center: istanbul, center: istanbul,

View File

@@ -4,7 +4,7 @@ import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js';
import _ol_has_ from '../src/ol/has.js'; import _ol_has_ from '../src/ol/has.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
@@ -96,7 +96,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([7, 52]), center: fromLonLat([7, 52]),
zoom: 3 zoom: 3
}) })
}); });

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileDebug_ from '../src/ol/source/TileDebug.js'; import _ol_source_TileDebug_ from '../src/ol/source/TileDebug.js';
@@ -27,8 +27,7 @@ var map = new _ol_Map_({
} }
}), }),
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.transform( center: fromLonLat([-0.1275, 51.507222]),
[-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'),
zoom: 10 zoom: 10
}) })
}); });

17
examples/d3.js vendored
View File

@@ -1,10 +1,10 @@
// NOCOMPILE // NOCOMPILE
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import {getWidth, getCenter} from '../src/ol/extent.js';
import _ol_layer_Image_ from '../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../src/ol/layer/Image.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat, toLonLat} from '../src/ol/proj.js';
import _ol_source_ImageCanvas_ from '../src/ol/source/ImageCanvas.js'; import _ol_source_ImageCanvas_ from '../src/ol/source/ImageCanvas.js';
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
@@ -19,7 +19,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-97, 38]), center: fromLonLat([-97, 38]),
zoom: 4 zoom: 4
}) })
}); });
@@ -57,13 +57,11 @@ d3.json('data/topojson/us.json', function(error, us) {
var pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1]; var pixelBoundsHeight = pixelBounds[1][1] - pixelBounds[0][1];
var geoBounds = d3.geoBounds(features); var geoBounds = d3.geoBounds(features);
var geoBoundsLeftBottom = _ol_proj_.transform( var geoBoundsLeftBottom = fromLonLat(geoBounds[0], projection);
geoBounds[0], 'EPSG:4326', projection); var geoBoundsRightTop = fromLonLat(geoBounds[1], projection);
var geoBoundsRightTop = _ol_proj_.transform(
geoBounds[1], 'EPSG:4326', projection);
var geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0]; var geoBoundsWidth = geoBoundsRightTop[0] - geoBoundsLeftBottom[0];
if (geoBoundsWidth < 0) { if (geoBoundsWidth < 0) {
geoBoundsWidth += _ol_extent_.getWidth(projection.getExtent()); geoBoundsWidth += getWidth(projection.getExtent());
} }
var geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1]; var geoBoundsHeight = geoBoundsRightTop[1] - geoBoundsLeftBottom[1];
@@ -72,8 +70,7 @@ d3.json('data/topojson/us.json', function(error, us) {
var r = Math.max(widthResolution, heightResolution); var r = Math.max(widthResolution, heightResolution);
var scale = r / (resolution / pixelRatio); var scale = r / (resolution / pixelRatio);
var center = _ol_proj_.transform(_ol_extent_.getCenter(extent), var center = toLonLat(getCenter(extent), projection);
projection, 'EPSG:4326');
d3Projection.scale(scale).center(center) d3Projection.scale(scale).center(center)
.translate([canvasWidth / 2, canvasHeight / 2]); .translate([canvasWidth / 2, canvasHeight / 2]);
d3Path = d3Path.projection(d3Projection).context(context); d3Path = d3Path.projection(d3Projection).context(context);

View File

@@ -4,14 +4,10 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_math_ from '../src/ol/math.js'; import _ol_math_ from '../src/ol/math.js';
import _ol_proj_ from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
var projection = _ol_proj_.get('EPSG:3857');
var view = new _ol_View_({ var view = new _ol_View_({
center: [0, 0], center: [0, 0],
projection: projection,
extent: projection.getExtent(),
zoom: 2 zoom: 2
}); });
var map = new _ol_Map_({ var map = new _ol_Map_({

View File

@@ -7,7 +7,7 @@ import {easeOut} from '../src/ol/easing.js';
import _ol_geom_Point_ from '../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../src/ol/geom/Point.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_style_Circle_ from '../src/ol/style/Circle.js'; import _ol_style_Circle_ from '../src/ol/style/Circle.js';
@@ -46,8 +46,7 @@ map.addLayer(vector);
function addRandomFeature() { function addRandomFeature() {
var x = Math.random() * 360 - 180; var x = Math.random() * 360 - 180;
var y = Math.random() * 180 - 90; var y = Math.random() * 180 - 90;
var geom = new _ol_geom_Point_(_ol_proj_.transform([x, y], var geom = new _ol_geom_Point_(fromLonLat([x, y]));
'EPSG:4326', 'EPSG:3857'));
var feature = new _ol_Feature_(geom); var feature = new _ol_Feature_(geom);
source.addFeature(feature); source.addFeature(feature);
} }

View File

@@ -5,7 +5,6 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; import _ol_geom_LineString_ from '../src/ol/geom/LineString.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js';
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
@@ -94,7 +93,7 @@ flightsSource = new _ol_source_Vector_({
var arcLine = arcGenerator.Arc(100, {offset: 10}); var arcLine = arcGenerator.Arc(100, {offset: 10});
if (arcLine.geometries.length === 1) { if (arcLine.geometries.length === 1) {
var line = new _ol_geom_LineString_(arcLine.geometries[0].coords); var line = new _ol_geom_LineString_(arcLine.geometries[0].coords);
line.transform(_ol_proj_.get('EPSG:4326'), _ol_proj_.get('EPSG:3857')); line.transform('EPSG:4326', 'EPSG:3857');
var feature = new _ol_Feature_({ var feature = new _ol_Feature_({
geometry: line, geometry: line,

View File

@@ -5,12 +5,12 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import _ol_geom_LineString_ from '../src/ol/geom/LineString.js'; import _ol_geom_LineString_ from '../src/ol/geom/LineString.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
// creating the view // creating the view
var view = new _ol_View_({ var view = new _ol_View_({
center: _ol_proj_.fromLonLat([5.8713, 45.6452]), center: fromLonLat([5.8713, 45.6452]),
zoom: 19 zoom: 19
}); });
@@ -214,9 +214,7 @@ function simulatePositionChange(position) {
var coords = position.coords; var coords = position.coords;
geolocation.set('accuracy', coords.accuracy); geolocation.set('accuracy', coords.accuracy);
geolocation.set('heading', degToRad(coords.heading)); geolocation.set('heading', degToRad(coords.heading));
var position_ = [coords.longitude, coords.latitude]; var projectedPosition = fromLonLat([coords.longitude, coords.latitude]);
var projectedPosition = _ol_proj_.transform(position_, 'EPSG:4326',
'EPSG:3857');
geolocation.set('position', projectedPosition); geolocation.set('position', projectedPosition);
geolocation.set('speed', coords.speed); geolocation.set('speed', coords.speed);
geolocation.changed(); geolocation.changed();

View File

@@ -2,7 +2,7 @@ import _ol_Graticule_ from '../src/ol/Graticule.js';
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
@@ -17,8 +17,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([4.8, 47.75]), center: fromLonLat([4.8, 47.75]),
extent: _ol_proj_.get('EPSG:3857').getExtent(),
zoom: 5 zoom: 5
}) })
}); });

View File

@@ -4,7 +4,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_geom_Point_ from '../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../src/ol/geom/Point.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_style_Icon_ from '../src/ol/style/Icon.js'; import _ol_style_Icon_ from '../src/ol/style/Icon.js';
@@ -12,15 +12,15 @@ import _ol_style_Style_ from '../src/ol/style/Style.js';
var rome = new _ol_Feature_({ var rome = new _ol_Feature_({
geometry: new _ol_geom_Point_(_ol_proj_.fromLonLat([12.5, 41.9])) geometry: new _ol_geom_Point_(fromLonLat([12.5, 41.9]))
}); });
var london = new _ol_Feature_({ var london = new _ol_Feature_({
geometry: new _ol_geom_Point_(_ol_proj_.fromLonLat([-0.12755, 51.507222])) geometry: new _ol_geom_Point_(fromLonLat([-0.12755, 51.507222]))
}); });
var madrid = new _ol_Feature_({ var madrid = new _ol_Feature_({
geometry: new _ol_geom_Point_(_ol_proj_.fromLonLat([-3.683333, 40.4])) geometry: new _ol_geom_Point_(fromLonLat([-3.683333, 40.4]))
}); });
rome.setStyle(new _ol_style_Style_({ rome.setStyle(new _ol_style_Style_({
@@ -67,7 +67,7 @@ var map = new _ol_Map_({
layers: [rasterLayer, vectorLayer], layers: [rasterLayer, vectorLayer],
target: document.getElementById('map'), target: document.getElementById('map'),
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([2.896372, 44.60240]), center: fromLonLat([2.896372, 44.60240]),
zoom: 3 zoom: 3
}) })
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
@@ -14,7 +14,7 @@ var map = new _ol_Map_({
layers: [imagery], layers: [imagery],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-120, 50]), center: fromLonLat([-120, 50]),
zoom: 6 zoom: 6
}) })
}); });

View File

@@ -5,7 +5,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
@@ -45,7 +45,7 @@ var map = new _ol_Map_({
layers: [rasterLayer, vectorLayer], layers: [rasterLayer, vectorLayer],
target: document.getElementById('map'), target: document.getElementById('map'),
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([126.979293, 37.528787]), center: fromLonLat([126.979293, 37.528787]),
zoom: 15 zoom: 15
}) })
}); });

View File

@@ -3,12 +3,9 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_format_KML_ from '../src/ol/format/KML.js'; import _ol_format_KML_ from '../src/ol/format/KML.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js';
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
var projection = _ol_proj_.get('EPSG:3857');
var raster = new _ol_layer_Tile_({ var raster = new _ol_layer_Tile_({
source: new _ol_source_BingMaps_({ source: new _ol_source_BingMaps_({
imagerySet: 'Aerial', imagerySet: 'Aerial',
@@ -28,7 +25,7 @@ var map = new _ol_Map_({
target: document.getElementById('map'), target: document.getElementById('map'),
view: new _ol_View_({ view: new _ol_View_({
center: [876970.8463461736, 5859807.853963373], center: [876970.8463461736, 5859807.853963373],
projection: projection, projection: 'EPSG:3857',
zoom: 10 zoom: 10
}) })
}); });

View File

@@ -1,11 +1,11 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {transformExtent} from '../src/ol/proj.js';
import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js';
function transform(extent) { function transform(extent) {
return _ol_proj_.transformExtent(extent, 'EPSG:4326', 'EPSG:3857'); return transformExtent(extent, 'EPSG:4326', 'EPSG:3857');
} }
var extents = { var extents = {

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Group_ from '../src/ol/layer/Group.js'; import _ol_layer_Group_ from '../src/ol/layer/Group.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js';
@@ -29,7 +29,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([37.40570, 8.81566]), center: fromLonLat([37.40570, 8.81566]),
zoom: 4 zoom: 4
}) })
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
@@ -20,7 +20,7 @@ var map = new _ol_Map_({
layers: [roads, imagery], layers: [roads, imagery],
target: container, target: container,
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-109, 46.5]), center: fromLonLat([-109, 46.5]),
zoom: 6 zoom: 6
}) })
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'; var key = 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5';
@@ -16,7 +16,7 @@ var map = new _ol_Map_({
layers: [imagery], layers: [imagery],
target: container, target: container,
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-109, 46.5]), center: fromLonLat([-109, 46.5]),
zoom: 6 zoom: 6
}) })
}); });

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_format_MVT_ from '../src/ol/format/MVT.js'; import _ol_format_MVT_ from '../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {get as getProjection} from '../src/ol/proj.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Icon_ from '../src/ol/style/Icon.js'; import _ol_style_Icon_ from '../src/ol/style/Icon.js';
@@ -39,7 +39,7 @@ var map = new _ol_Map_({
'OpenStreetMap contributors</a>', 'OpenStreetMap contributors</a>',
format: new _ol_format_MVT_(), format: new _ol_format_MVT_(),
tileGrid: new _ol_tilegrid_TileGrid_({ tileGrid: new _ol_tilegrid_TileGrid_({
extent: _ol_proj_.get('EPSG:3857').getExtent(), extent: getProjection('EPSG:3857').getExtent(),
resolutions: resolutions, resolutions: resolutions,
tileSize: 512 tileSize: 512
}), }),

View File

@@ -3,7 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {toLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -37,10 +37,8 @@ function wrapLon(value) {
function onMoveEnd(evt) { function onMoveEnd(evt) {
var map = evt.map; var map = evt.map;
var extent = map.getView().calculateExtent(map.getSize()); var extent = map.getView().calculateExtent(map.getSize());
var bottomLeft = _ol_proj_.transform(_ol_extent_.getBottomLeft(extent), var bottomLeft = toLonLat(_ol_extent_.getBottomLeft(extent));
'EPSG:3857', 'EPSG:4326'); var topRight = toLonLat(_ol_extent_.getTopRight(extent));
var topRight = _ol_proj_.transform(_ol_extent_.getTopRight(extent),
'EPSG:3857', 'EPSG:4326');
display('left', wrapLon(bottomLeft[0])); display('left', wrapLon(bottomLeft[0]));
display('bottom', bottomLeft[1]); display('bottom', bottomLeft[1]);
display('right', wrapLon(topRight[0])); display('right', wrapLon(topRight[0]));

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
@@ -83,7 +83,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-74.0064, 40.7142]), center: fromLonLat([-74.0064, 40.7142]),
maxZoom: 19, maxZoom: 19,
zoom: 15 zoom: 15
}) })

View File

@@ -3,7 +3,7 @@ import _ol_Overlay_ from '../src/ol/Overlay.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_coordinate_ from '../src/ol/coordinate.js'; import _ol_coordinate_ from '../src/ol/coordinate.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat, toLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -20,7 +20,7 @@ var map = new _ol_Map_({
}) })
}); });
var pos = _ol_proj_.fromLonLat([16.3725, 48.208889]); var pos = fromLonLat([16.3725, 48.208889]);
// Vienna marker // Vienna marker
var marker = new _ol_Overlay_({ var marker = new _ol_Overlay_({
@@ -47,8 +47,7 @@ map.addOverlay(popup);
map.on('click', function(evt) { map.on('click', function(evt) {
var element = popup.getElement(); var element = popup.getElement();
var coordinate = evt.coordinate; var coordinate = evt.coordinate;
var hdms = _ol_coordinate_.toStringHDMS(_ol_proj_.transform( var hdms = _ol_coordinate_.toStringHDMS(toLonLat(coordinate));
coordinate, 'EPSG:3857', 'EPSG:4326'));
$(element).popover('destroy'); $(element).popover('destroy');
popup.setPosition(coordinate); popup.setPosition(coordinate);

View File

@@ -3,7 +3,7 @@ import _ol_Overlay_ from '../src/ol/Overlay.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_coordinate_ from '../src/ol/coordinate.js'; import _ol_coordinate_ from '../src/ol/coordinate.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {toLonLat} from '../src/ol/proj.js';
import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js';
@@ -64,8 +64,7 @@ var map = new _ol_Map_({
*/ */
map.on('singleclick', function(evt) { map.on('singleclick', function(evt) {
var coordinate = evt.coordinate; var coordinate = evt.coordinate;
var hdms = _ol_coordinate_.toStringHDMS(_ol_proj_.transform( var hdms = _ol_coordinate_.toStringHDMS(toLonLat(coordinate));
coordinate, 'EPSG:3857', 'EPSG:4326'));
content.innerHTML = '<p>You clicked here:</p><code>' + hdms + content.innerHTML = '<p>You clicked here:</p><code>' + hdms +
'</code>'; '</code>';

View File

@@ -3,7 +3,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Image_ from '../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../src/ol/layer/Image.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
import _ol_source_Raster_ from '../src/ol/source/Raster.js'; import _ol_source_Raster_ from '../src/ol/source/Raster.js';
@@ -98,7 +98,7 @@ var map = new _ol_Map_({
layers: [imagery, rasterImage], layers: [imagery, rasterImage],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-119.07, 47.65]), center: fromLonLat([-119.07, 47.65]),
zoom: 11 zoom: 11
}) })
}); });

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {get as getProjection, getTransform} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; import _ol_source_TileImage_ from '../src/ol/source/TileImage.js';
@@ -42,8 +42,8 @@ function setProjection(code, name, proj4def, bbox) {
var newProjCode = 'EPSG:' + code; var newProjCode = 'EPSG:' + code;
proj4.defs(newProjCode, proj4def); proj4.defs(newProjCode, proj4def);
var newProj = _ol_proj_.get(newProjCode); var newProj = getProjection(newProjCode);
var fromLonLat = _ol_proj_.getTransform('EPSG:4326', newProj); var fromLonLat = getTransform('EPSG:4326', newProj);
// very approximate calculation of projection extent // very approximate calculation of projection extent
var extent = _ol_extent_.applyTransform( var extent = _ol_extent_.applyTransform(

View File

@@ -1,9 +1,9 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import {getCenter} from '../src/ol/extent.js';
import _ol_layer_Image_ from '../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../src/ol/layer/Image.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {transform} from '../src/ol/proj.js';
import _ol_source_ImageStatic_ from '../src/ol/source/ImageStatic.js'; import _ol_source_ImageStatic_ from '../src/ol/source/ImageStatic.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
@@ -31,8 +31,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.transform( center: transform(getCenter(imageExtent), 'EPSG:27700', 'EPSG:3857'),
_ol_extent_.getCenter(imageExtent), 'EPSG:27700', 'EPSG:3857'),
zoom: 4 zoom: 4
}) })
}); });

View File

@@ -3,7 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js'; import _ol_format_WMTSCapabilities_ from '../src/ol/format/WMTSCapabilities.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {get as getProjection} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileImage_ from '../src/ol/source/TileImage.js'; import _ol_source_TileImage_ from '../src/ol/source/TileImage.js';
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
@@ -16,39 +16,39 @@ proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
'+x_0=400000 +y_0=-100000 +ellps=airy ' + '+x_0=400000 +y_0=-100000 +ellps=airy ' +
'+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' + '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
'+units=m +no_defs'); '+units=m +no_defs');
var proj27700 = _ol_proj_.get('EPSG:27700'); var proj27700 = getProjection('EPSG:27700');
proj27700.setExtent([0, 0, 700000, 1300000]); proj27700.setExtent([0, 0, 700000, 1300000]);
proj4.defs('EPSG:23032', '+proj=utm +zone=32 +ellps=intl ' + proj4.defs('EPSG:23032', '+proj=utm +zone=32 +ellps=intl ' +
'+towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs'); '+towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs');
var proj23032 = _ol_proj_.get('EPSG:23032'); var proj23032 = getProjection('EPSG:23032');
proj23032.setExtent([-1206118.71, 4021309.92, 1295389.00, 8051813.28]); proj23032.setExtent([-1206118.71, 4021309.92, 1295389.00, 8051813.28]);
proj4.defs('EPSG:5479', '+proj=lcc +lat_1=-76.66666666666667 +lat_2=' + proj4.defs('EPSG:5479', '+proj=lcc +lat_1=-76.66666666666667 +lat_2=' +
'-79.33333333333333 +lat_0=-78 +lon_0=163 +x_0=7000000 +y_0=5000000 ' + '-79.33333333333333 +lat_0=-78 +lon_0=163 +x_0=7000000 +y_0=5000000 ' +
'+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); '+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
var proj5479 = _ol_proj_.get('EPSG:5479'); var proj5479 = getProjection('EPSG:5479');
proj5479.setExtent([6825737.53, 4189159.80, 9633741.96, 5782472.71]); proj5479.setExtent([6825737.53, 4189159.80, 9633741.96, 5782472.71]);
proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' + proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' +
'+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
'+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs'); '+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs');
var proj21781 = _ol_proj_.get('EPSG:21781'); var proj21781 = getProjection('EPSG:21781');
proj21781.setExtent([485071.54, 75346.36, 828515.78, 299941.84]); proj21781.setExtent([485071.54, 75346.36, 828515.78, 299941.84]);
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 ' + proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 ' +
'+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); '+x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
var proj3413 = _ol_proj_.get('EPSG:3413'); var proj3413 = getProjection('EPSG:3413');
proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]); proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]);
proj4.defs('EPSG:2163', '+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 ' + proj4.defs('EPSG:2163', '+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 ' +
'+a=6370997 +b=6370997 +units=m +no_defs'); '+a=6370997 +b=6370997 +units=m +no_defs');
var proj2163 = _ol_proj_.get('EPSG:2163'); var proj2163 = getProjection('EPSG:2163');
proj2163.setExtent([-8040784.5135, -2577524.9210, 3668901.4484, 4785105.1096]); proj2163.setExtent([-8040784.5135, -2577524.9210, 3668901.4484, 4785105.1096]);
proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 ' + proj4.defs('ESRI:54009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 ' +
'+units=m +no_defs'); '+units=m +no_defs');
var proj54009 = _ol_proj_.get('ESRI:54009'); var proj54009 = getProjection('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]); proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);
@@ -124,7 +124,7 @@ layers['grandcanyon'] = new _ol_layer_Tile_({
}); });
var startResolution = var startResolution =
_ol_extent_.getWidth(_ol_proj_.get('EPSG:3857').getExtent()) / 256; _ol_extent_.getWidth(getProjection('EPSG:3857').getExtent()) / 256;
var resolutions = new Array(22); var resolutions = new Array(22);
for (var i = 0, ii = resolutions.length; i < ii; ++i) { for (var i = 0, ii = resolutions.length; i < ii; ++i) {
resolutions[i] = startResolution / Math.pow(2, i); resolutions[i] = startResolution / Math.pow(2, i);
@@ -167,7 +167,7 @@ var renderEdgesCheckbox = document.getElementById('render-edges');
var renderEdges = false; var renderEdges = false;
function updateViewProjection() { function updateViewProjection() {
var newProj = _ol_proj_.get(viewProjSelect.value); var newProj = getProjection(viewProjSelect.value);
var newProjExtent = newProj.getExtent(); var newProjExtent = newProj.getExtent();
var newView = new _ol_View_({ var newView = new _ol_View_({
projection: newProj, projection: newProj,
@@ -178,7 +178,7 @@ function updateViewProjection() {
map.setView(newView); map.setView(newView);
// Example how to prevent double occurrence of map by limiting layer extent // Example how to prevent double occurrence of map by limiting layer extent
if (newProj == _ol_proj_.get('EPSG:3857')) { if (newProj == getProjection('EPSG:3857')) {
layers['bng'].setExtent([-1057216, 6405988, 404315, 8759696]); layers['bng'].setExtent([-1057216, 6405988, 404315, 8759696]);
} else { } else {
layers['bng'].setExtent(undefined); layers['bng'].setExtent(undefined);

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat, transformExtent} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' + proj4.defs('Indiana-East', 'PROJCS["IN83-EF",GEOGCS["LL83",DATUM["NAD83",' +
@@ -24,9 +24,9 @@ var map = new _ol_Map_({
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
projection: 'Indiana-East', projection: 'Indiana-East',
center: _ol_proj_.fromLonLat([-85.685, 39.891], 'Indiana-East'), center: fromLonLat([-85.685, 39.891], 'Indiana-East'),
zoom: 7, zoom: 7,
extent: _ol_proj_.transformExtent([-172.54, 23.81, -47.74, 86.46], extent: transformExtent([-172.54, 23.81, -47.74, 86.46],
'EPSG:4326', 'Indiana-East'), 'EPSG:4326', 'Indiana-East'),
minZoom: 6 minZoom: 6
}) })

View File

@@ -3,7 +3,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Image_ from '../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../src/ol/layer/Image.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_Raster_ from '../src/ol/source/Raster.js'; import _ol_source_Raster_ from '../src/ol/source/Raster.js';
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
@@ -49,7 +49,7 @@ var map = new _ol_Map_({
}) })
], ],
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-122.3267, 37.8377]), center: fromLonLat([-122.3267, 37.8377]),
zoom: 11 zoom: 11
}) })
}); });
@@ -74,6 +74,6 @@ for (var i = 0, ii = locations.length; i < ii; ++i) {
function relocate(event) { function relocate(event) {
var data = event.target.dataset; var data = event.target.dataset;
var view = map.getView(); var view = map.getView();
view.setCenter(_ol_proj_.fromLonLat(data.center.split(',').map(Number))); view.setCenter(fromLonLat(data.center.split(',').map(Number)));
view.setZoom(Number(data.zoom)); view.setZoom(Number(data.zoom));
} }

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js';
@@ -20,7 +20,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-77.93255, 37.9555]), center: fromLonLat([-77.93255, 37.9555]),
zoom: 7 zoom: 7
}) })
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
@@ -20,8 +20,7 @@ var map = new _ol_Map_({
], ],
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.transform( center: fromLonLat([-122.416667, 37.783333]),
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
zoom: 12 zoom: 12
}) })
}); });

View File

@@ -5,7 +5,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
@@ -50,7 +50,7 @@ var map = new _ol_Map_({
layers: [rasterLayer, vectorLayer], layers: [rasterLayer, vectorLayer],
target: document.getElementById('map'), target: document.getElementById('map'),
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([126.980366, 37.526540]), center: fromLonLat([126.980366, 37.526540]),
zoom: 15 zoom: 15
}) })
}); });

View File

@@ -8,7 +8,7 @@ import _ol_interaction_Select_ from '../src/ol/interaction/Select.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
import _ol_tilegrid_ from '../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../src/ol/tilegrid.js';
@@ -81,7 +81,7 @@ var map = new _ol_Map_({
layers: [raster, vector], layers: [raster, vector],
target: document.getElementById('map'), target: document.getElementById('map'),
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.transform([-122.619, 45.512], 'EPSG:4326', 'EPSG:3857'), center: fromLonLat([-122.619, 45.512]),
zoom: 12 zoom: 12
}) })
}); });

View File

@@ -4,7 +4,7 @@ import _ol_format_EsriJSON_ from '../src/ol/format/EsriJSON.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
@@ -108,7 +108,7 @@ var map = new _ol_Map_({
layers: [raster, vector], layers: [raster, vector],
target: document.getElementById('map'), target: document.getElementById('map'),
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.transform([-97.6114, 38.8403], 'EPSG:4326', 'EPSG:3857'), center: fromLonLat([-97.6114, 38.8403]),
zoom: 7 zoom: 7
}) })
}); });

View File

@@ -5,7 +5,7 @@ import _ol_format_OSMXML_ from '../src/ol/format/OSMXML.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js'; import _ol_loadingstrategy_ from '../src/ol/loadingstrategy.js';
import _ol_proj_ from '../src/ol/proj.js'; import {transformExtent} from '../src/ol/proj.js';
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js'; import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_style_Circle_ from '../src/ol/style/Circle.js'; import _ol_style_Circle_ from '../src/ol/style/Circle.js';
@@ -80,8 +80,7 @@ var styles = {
var vectorSource = new _ol_source_Vector_({ var vectorSource = new _ol_source_Vector_({
format: new _ol_format_OSMXML_(), format: new _ol_format_OSMXML_(),
loader: function(extent, resolution, projection) { loader: function(extent, resolution, projection) {
var epsg4326Extent = var epsg4326Extent = transformExtent(extent, projection, 'EPSG:4326');
_ol_proj_.transformExtent(extent, projection, 'EPSG:4326');
var client = new XMLHttpRequest(); var client = new XMLHttpRequest();
client.open('POST', 'https://overpass-api.de/api/interpreter'); client.open('POST', 'https://overpass-api.de/api/interpreter');
client.addEventListener('load', function() { client.addEventListener('load', function() {

View File

@@ -3,7 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {addProjection, addCoordinateTransforms, transform} from '../src/ol/proj.js';
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
@@ -20,13 +20,13 @@ var projection = new _ol_proj_Projection_({
extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864], extent: [485869.5728, 76443.1884, 837076.5648, 299941.7864],
units: 'm' units: 'm'
}); });
_ol_proj_.addProjection(projection); addProjection(projection);
// We also declare EPSG:21781/EPSG:4326 transform functions. These functions // We also declare EPSG:21781/EPSG:4326 transform functions. These functions
// are necessary for the ScaleLine control and when calling ol.proj.transform // are necessary for the ScaleLine control and when calling ol.proj.transform
// for setting the view's initial center (see below). // for setting the view's initial center (see below).
_ol_proj_.addCoordinateTransforms('EPSG:4326', projection, addCoordinateTransforms('EPSG:4326', projection,
function(coordinate) { function(coordinate) {
return [ return [
WGStoCHy(coordinate[1], coordinate[0]), WGStoCHy(coordinate[1], coordinate[0]),
@@ -79,7 +79,7 @@ var map = new _ol_Map_({
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
projection: projection, projection: projection,
center: _ol_proj_.transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'), center: transform([8.23, 46.86], 'EPSG:4326', 'EPSG:21781'),
extent: extent, extent: extent,
zoom: 2 zoom: 2
}) })

View File

@@ -2,13 +2,13 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {get as getProjection} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
import _ol_tilegrid_TileGrid_ from '../src/ol/tilegrid/TileGrid.js'; import _ol_tilegrid_TileGrid_ from '../src/ol/tilegrid/TileGrid.js';
var projExtent = _ol_proj_.get('EPSG:3857').getExtent(); var projExtent = getProjection('EPSG:3857').getExtent();
var startResolution = _ol_extent_.getWidth(projExtent) / 256; var startResolution = _ol_extent_.getWidth(projExtent) / 256;
var resolutions = new Array(22); var resolutions = new Array(22);
for (var i = 0, ii = resolutions.length; i < ii; ++i) { for (var i = 0, ii = resolutions.length; i < ii; ++i) {

View File

@@ -3,7 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js'; import _ol_control_ScaleLine_ from '../src/ol/control/ScaleLine.js';
import _ol_layer_Image_ from '../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../src/ol/layer/Image.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js'; import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
@@ -65,7 +65,7 @@ var map = new _ol_Map_({
target: 'map', target: 'map',
view: new _ol_View_({ view: new _ol_View_({
projection: projection, projection: projection,
center: _ol_proj_.fromLonLat([8.23, 46.86], projection), center: fromLonLat([8.23, 46.86], projection),
extent: extent, extent: extent,
zoom: 2 zoom: 2
}) })

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {transformExtent} from '../src/ol/proj.js';
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js'; import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
@@ -10,7 +10,7 @@ function threeHoursAgo() {
return new Date(Math.round(Date.now() / 3600000) * 3600000 - 3600000 * 3); return new Date(Math.round(Date.now() / 3600000) * 3600000 - 3600000 * 3);
} }
var extent = _ol_proj_.transformExtent([-126, 24, -66, 50], 'EPSG:4326', 'EPSG:3857'); var extent = transformExtent([-126, 24, -66, 50], 'EPSG:4326', 'EPSG:3857');
var startDate = threeHoursAgo(); var startDate = threeHoursAgo();
var frameRate = 0.5; // frames per second var frameRate = 0.5; // frames per second
var animationId = null; var animationId = null;

View File

@@ -2,14 +2,14 @@ import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {get as getProjection} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; import _ol_source_WMTS_ from '../src/ol/source/WMTS.js';
import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js'; import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js';
// create the WMTS tile grid in the google projection // create the WMTS tile grid in the google projection
var projection = _ol_proj_.get('EPSG:3857'); var projection = getProjection('EPSG:3857');
var tileSizePixels = 256; var tileSizePixels = 256;
var tileSizeMtrs = _ol_extent_.getWidth(projection.getExtent()) / tileSizePixels; var tileSizeMtrs = _ol_extent_.getWidth(projection.getExtent()) / tileSizePixels;
var matrixIds = []; var matrixIds = [];

View File

@@ -3,7 +3,7 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat, get as getProjection} from '../src/ol/proj.js';
import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; import _ol_source_WMTS_ from '../src/ol/source/WMTS.js';
import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js'; import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js';
@@ -17,13 +17,13 @@ var map = new _ol_Map_({
}), }),
view: new _ol_View_({ view: new _ol_View_({
zoom: 5, zoom: 5,
center: _ol_proj_.transform([5, 45], 'EPSG:4326', 'EPSG:3857') center: fromLonLat([5, 45])
}) })
}); });
var resolutions = []; var resolutions = [];
var matrixIds = []; var matrixIds = [];
var proj3857 = _ol_proj_.get('EPSG:3857'); var proj3857 = getProjection('EPSG:3857');
var maxResolution = _ol_extent_.getWidth(proj3857.getExtent()) / 256; var maxResolution = _ol_extent_.getWidth(proj3857.getExtent()) / 256;
for (var i = 0; i < 18; i++) { for (var i = 0; i < 18; i++) {

View File

@@ -3,13 +3,13 @@ import _ol_View_ from '../src/ol/View.js';
import _ol_control_ from '../src/ol/control.js'; import _ol_control_ from '../src/ol/control.js';
import * as _ol_extent_ from '../src/ol/extent.js'; import * as _ol_extent_ from '../src/ol/extent.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {get as getProjection} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_WMTS_ from '../src/ol/source/WMTS.js'; import _ol_source_WMTS_ from '../src/ol/source/WMTS.js';
import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js'; import _ol_tilegrid_WMTS_ from '../src/ol/tilegrid/WMTS.js';
var projection = _ol_proj_.get('EPSG:3857'); var projection = getProjection('EPSG:3857');
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(14); var resolutions = new Array(14);

View File

@@ -1,11 +1,8 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js';
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
var projection = _ol_proj_.get('EPSG:4326');
// The tile size supported by the ArcGIS tile service. // The tile size supported by the ArcGIS tile service.
var tileSize = 512; var tileSize = 512;
@@ -19,7 +16,7 @@ var map = new _ol_Map_({
source: new _ol_source_XYZ_({ source: new _ol_source_XYZ_({
attributions: 'Copyright:© 2013 ESRI, i-cubed, GeoEye', attributions: 'Copyright:© 2013 ESRI, i-cubed, GeoEye',
maxZoom: 16, maxZoom: 16,
projection: projection, projection: 'EPSG:4326',
tileSize: tileSize, tileSize: tileSize,
tileUrlFunction: function(tileCoord) { tileUrlFunction: function(tileCoord) {
return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString()) return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString())
@@ -32,7 +29,7 @@ var map = new _ol_Map_({
], ],
view: new _ol_View_({ view: new _ol_View_({
center: [0, 0], center: [0, 0],
projection: projection, projection: 'EPSG:4326',
zoom: 2, zoom: 2,
minZoom: 2 minZoom: 2
}) })

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
@@ -18,7 +18,7 @@ var map = new _ol_Map_({
}) })
], ],
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.fromLonLat([-121.1, 47.5]), center: fromLonLat([-121.1, 47.5]),
zoom: 7 zoom: 7
}) })
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../src/ol/Map.js'; import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js'; import _ol_View_ from '../src/ol/View.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_proj_ from '../src/ol/proj.js'; import {transform, transformExtent} from '../src/ol/proj.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
import _ol_source_XYZ_ from '../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../src/ol/source/XYZ.js';
@@ -16,7 +16,7 @@ var map = new _ol_Map_({
source: new _ol_source_OSM_() source: new _ol_source_OSM_()
}), }),
new _ol_layer_Tile_({ new _ol_layer_Tile_({
extent: _ol_proj_.transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'), extent: transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'),
source: new _ol_source_XYZ_({ source: new _ol_source_XYZ_({
attributions: 'Tiles © USGS, rendered with ' + attributions: 'Tiles © USGS, rendered with ' +
'<a href="http://www.maptiler.com/">MapTiler</a>', '<a href="http://www.maptiler.com/">MapTiler</a>',
@@ -29,7 +29,7 @@ var map = new _ol_Map_({
], ],
view: new _ol_View_({ view: new _ol_View_({
projection: 'EPSG:3857', projection: 'EPSG:3857',
center: _ol_proj_.transform([-112.18688965, 36.057944835], center: transform([-112.18688965, 36.057944835],
'EPSG:4326', 'EPSG:3857'), 'EPSG:4326', 'EPSG:3857'),
zoom: 12 zoom: 12
}) })

View File

@@ -12,7 +12,7 @@ import _ol_events_EventType_ from './events/EventType.js';
import _ol_geom_Polygon_ from './geom/Polygon.js'; import _ol_geom_Polygon_ from './geom/Polygon.js';
import _ol_has_ from './has.js'; import _ol_has_ from './has.js';
import _ol_math_ from './math.js'; import _ol_math_ from './math.js';
import _ol_proj_ from './proj.js'; import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
import _ol_proj_EPSG4326_ from './proj/EPSG4326.js'; import _ol_proj_EPSG4326_ from './proj/EPSG4326.js';
/** /**
@@ -58,7 +58,7 @@ var _ol_Geolocation_ = function(opt_options) {
* @private * @private
* @type {ol.TransformFunction} * @type {ol.TransformFunction}
*/ */
this.transform_ = _ol_proj_.identityTransform; this.transform_ = identityTransform;
/** /**
* @private * @private
@@ -108,8 +108,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 (projection) { if (projection) {
this.transform_ = _ol_proj_.getTransformFromProjections( this.transform_ = getTransformFromProjections(
_ol_proj_.get('EPSG:4326'), projection); getProjection('EPSG:4326'), projection);
if (this.position_) { if (this.position_) {
this.set( this.set(
_ol_GeolocationProperty_.POSITION, this.transform_(this.position_)); _ol_GeolocationProperty_.POSITION, this.transform_(this.position_));
@@ -332,7 +332,7 @@ _ol_Geolocation_.prototype.getTrackingOptions = function() {
* @api * @api
*/ */
_ol_Geolocation_.prototype.setProjection = function(projection) { _ol_Geolocation_.prototype.setProjection = function(projection) {
this.set(_ol_GeolocationProperty_.PROJECTION, _ol_proj_.get(projection)); this.set(_ol_GeolocationProperty_.PROJECTION, getProjection(projection));
}; };

View File

@@ -8,7 +8,7 @@ import _ol_geom_LineString_ from './geom/LineString.js';
import _ol_geom_Point_ from './geom/Point.js'; import _ol_geom_Point_ from './geom/Point.js';
import _ol_geom_flat_geodesic_ from './geom/flat/geodesic.js'; import _ol_geom_flat_geodesic_ from './geom/flat/geodesic.js';
import _ol_math_ from './math.js'; import _ol_math_ from './math.js';
import _ol_proj_ from './proj.js'; import {get as getProjection, equivalent as equivalentProjection, getTransform, transformExtent} from './proj.js';
import _ol_render_EventType_ from './render/EventType.js'; import _ol_render_EventType_ from './render/EventType.js';
import _ol_style_Fill_ from './style/Fill.js'; import _ol_style_Fill_ from './style/Fill.js';
import _ol_style_Stroke_ from './style/Stroke.js'; import _ol_style_Stroke_ from './style/Stroke.js';
@@ -372,7 +372,7 @@ _ol_Graticule_.prototype.createGraticule_ = function(extent, center, resolution,
Math.min(extent[3], this.maxLatP_) Math.min(extent[3], this.maxLatP_)
]; ];
validExtent = _ol_proj_.transformExtent(validExtent, this.projection_, validExtent = transformExtent(validExtent, this.projection_,
'EPSG:4326'); 'EPSG:4326');
var maxLat = validExtent[3]; var maxLat = validExtent[3];
var maxLon = validExtent[2]; var maxLon = validExtent[2];
@@ -554,7 +554,7 @@ _ol_Graticule_.prototype.handlePostCompose_ = function(e) {
resolution * resolution / (4 * pixelRatio * pixelRatio); resolution * resolution / (4 * pixelRatio * pixelRatio);
var updateProjectionInfo = !this.projection_ || var updateProjectionInfo = !this.projection_ ||
!_ol_proj_.equivalent(this.projection_, projection); !equivalentProjection(this.projection_, projection);
if (updateProjectionInfo) { if (updateProjectionInfo) {
this.updateProjectionInfo_(projection); this.updateProjectionInfo_(projection);
@@ -598,11 +598,11 @@ _ol_Graticule_.prototype.handlePostCompose_ = function(e) {
* @private * @private
*/ */
_ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) { _ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) {
var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var epsg4326Projection = getProjection('EPSG:4326');
var extent = projection.getExtent(); var extent = projection.getExtent();
var worldExtent = projection.getWorldExtent(); var worldExtent = projection.getWorldExtent();
var worldExtentP = _ol_proj_.transformExtent(worldExtent, var worldExtentP = transformExtent(worldExtent,
epsg4326Projection, projection); epsg4326Projection, projection);
var maxLat = worldExtent[3]; var maxLat = worldExtent[3];
@@ -626,11 +626,9 @@ _ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) {
this.minLonP_ = minLonP; this.minLonP_ = minLonP;
this.fromLonLatTransform_ = _ol_proj_.getTransform( this.fromLonLatTransform_ = getTransform(epsg4326Projection, projection);
epsg4326Projection, projection);
this.toLonLatTransform_ = _ol_proj_.getTransform( this.toLonLatTransform_ = getTransform(projection, epsg4326Projection);
projection, epsg4326Projection);
this.projectionCenterLonLat_ = this.toLonLatTransform_(getCenter(extent)); this.projectionCenterLonLat_ = this.toLonLatTransform_(getCenter(extent));

View File

@@ -19,7 +19,7 @@ import _ol_geom_Polygon_ from './geom/Polygon.js';
import _ol_geom_SimpleGeometry_ from './geom/SimpleGeometry.js'; import _ol_geom_SimpleGeometry_ from './geom/SimpleGeometry.js';
import _ol_math_ from './math.js'; import _ol_math_ from './math.js';
import _ol_obj_ from './obj.js'; import _ol_obj_ from './obj.js';
import _ol_proj_ from './proj.js'; import {createProjection, METERS_PER_UNIT} from './proj.js';
import _ol_proj_Units_ from './proj/Units.js'; import _ol_proj_Units_ from './proj/Units.js';
@@ -116,7 +116,7 @@ var _ol_View_ = function(opt_options) {
* @const * @const
* @type {ol.proj.Projection} * @type {ol.proj.Projection}
*/ */
this.projection_ = _ol_proj_.createProjection(options.projection, 'EPSG:3857'); this.projection_ = createProjection(options.projection, 'EPSG:3857');
this.applyOptions_(options); this.applyOptions_(options);
}; };
@@ -1129,11 +1129,11 @@ _ol_View_.createResolutionConstraint_ = function(options) {
resolutions); resolutions);
} else { } else {
// calculate the default min and max resolution // calculate the default min and max resolution
var projection = _ol_proj_.createProjection(options.projection, 'EPSG:3857'); var projection = createProjection(options.projection, 'EPSG:3857');
var extent = projection.getExtent(); var extent = projection.getExtent();
var size = !extent ? var size = !extent ?
// use an extent that can fit the whole world if need be // use an extent that can fit the whole world if need be
360 * _ol_proj_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES] / 360 * METERS_PER_UNIT[_ol_proj_Units_.DEGREES] /
projection.getMetersPerUnit() : projection.getMetersPerUnit() :
Math.max(getWidth(extent), getHeight(extent)); Math.max(getWidth(extent), getHeight(extent));

View File

@@ -7,7 +7,7 @@ import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js'; import _ol_events_EventType_ from '../events/EventType.js';
import _ol_Object_ from '../Object.js'; import _ol_Object_ from '../Object.js';
import _ol_control_Control_ from '../control/Control.js'; import _ol_control_Control_ from '../control/Control.js';
import _ol_proj_ from '../proj.js'; import {getTransformFromProjections, identityTransform, get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -200,7 +200,7 @@ _ol_control_MousePosition_.prototype.setCoordinateFormat = function(format) {
* @api * @api
*/ */
_ol_control_MousePosition_.prototype.setProjection = function(projection) { _ol_control_MousePosition_.prototype.setProjection = function(projection) {
this.set(_ol_control_MousePosition_.Property_.PROJECTION, _ol_proj_.get(projection)); this.set(_ol_control_MousePosition_.Property_.PROJECTION, getProjection(projection));
}; };
@@ -214,10 +214,10 @@ _ol_control_MousePosition_.prototype.updateHTML_ = function(pixel) {
if (!this.transform_) { if (!this.transform_) {
var projection = this.getProjection(); var projection = this.getProjection();
if (projection) { if (projection) {
this.transform_ = _ol_proj_.getTransformFromProjections( this.transform_ = getTransformFromProjections(
this.mapProjection_, projection); this.mapProjection_, projection);
} else { } else {
this.transform_ = _ol_proj_.identityTransform; this.transform_ = identityTransform;
} }
} }
var map = this.getMap(); var map = this.getMap();

View File

@@ -8,7 +8,7 @@ import _ol_control_Control_ from '../control/Control.js';
import _ol_control_ScaleLineUnits_ from '../control/ScaleLineUnits.js'; import _ol_control_ScaleLineUnits_ from '../control/ScaleLineUnits.js';
import _ol_css_ from '../css.js'; import _ol_css_ from '../css.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import _ol_proj_ from '../proj.js'; import {getPointResolution, METERS_PER_UNIT} from '../proj.js';
import _ol_proj_Units_ from '../proj/Units.js'; import _ol_proj_Units_ from '../proj/Units.js';
/** /**
@@ -175,7 +175,7 @@ _ol_control_ScaleLine_.prototype.updateElement_ = function() {
_ol_proj_Units_.DEGREES : _ol_proj_Units_.DEGREES :
_ol_proj_Units_.METERS; _ol_proj_Units_.METERS;
var pointResolution = var pointResolution =
_ol_proj_.getPointResolution(projection, viewState.resolution, center, pointResolutionUnits); getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
if (units != _ol_control_ScaleLineUnits_.DEGREES) { if (units != _ol_control_ScaleLineUnits_.DEGREES) {
pointResolution *= projection.getMetersPerUnit(); pointResolution *= projection.getMetersPerUnit();
} }
@@ -183,7 +183,7 @@ _ol_control_ScaleLine_.prototype.updateElement_ = function() {
var nominalCount = this.minWidth_ * pointResolution; var nominalCount = this.minWidth_ * pointResolution;
var suffix = ''; var suffix = '';
if (units == _ol_control_ScaleLineUnits_.DEGREES) { if (units == _ol_control_ScaleLineUnits_.DEGREES) {
var metersPerDegree = _ol_proj_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES]; var metersPerDegree = METERS_PER_UNIT[_ol_proj_Units_.DEGREES];
if (projection.getUnits() == _ol_proj_Units_.DEGREES) { if (projection.getUnits() == _ol_proj_Units_.DEGREES) {
nominalCount *= metersPerDegree; nominalCount *= metersPerDegree;
} else { } else {

View File

@@ -19,7 +19,7 @@ import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -547,7 +547,7 @@ _ol_format_EsriJSON_.prototype.readProjectionFromObject = function(object) {
var esriJSONObject = /** @type {EsriJSONObject} */ (object); var esriJSONObject = /** @type {EsriJSONObject} */ (object);
if (esriJSONObject.spatialReference && esriJSONObject.spatialReference.wkid) { if (esriJSONObject.spatialReference && esriJSONObject.spatialReference.wkid) {
var crs = esriJSONObject.spatialReference.wkid; var crs = esriJSONObject.spatialReference.wkid;
return _ol_proj_.get('EPSG:' + crs); return getProjection('EPSG:' + crs);
} else { } else {
return null; return null;
} }
@@ -627,8 +627,7 @@ _ol_format_EsriJSON_.prototype.writeFeatureObject = function(
_ol_format_EsriJSON_.writeGeometry_(geometry, opt_options); _ol_format_EsriJSON_.writeGeometry_(geometry, opt_options);
if (opt_options && opt_options.featureProjection) { if (opt_options && opt_options.featureProjection) {
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({ object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: _ol_proj_.get( wkid: getProjection(opt_options.featureProjection).getCode().split(':').pop()
opt_options.featureProjection).getCode().split(':').pop()
}); });
} }
} }

View File

@@ -3,7 +3,7 @@
*/ */
import _ol_geom_Geometry_ from '../geom/Geometry.js'; import _ol_geom_Geometry_ from '../geom/Geometry.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -175,15 +175,15 @@ _ol_format_Feature_.prototype.writeGeometry = function(geometry, opt_options) {}
_ol_format_Feature_.transformWithOptions = function( _ol_format_Feature_.transformWithOptions = function(
geometry, write, opt_options) { geometry, write, opt_options) {
var featureProjection = opt_options ? var featureProjection = opt_options ?
_ol_proj_.get(opt_options.featureProjection) : null; getProjection(opt_options.featureProjection) : null;
var dataProjection = opt_options ? var dataProjection = opt_options ?
_ol_proj_.get(opt_options.dataProjection) : null; getProjection(opt_options.dataProjection) : null;
/** /**
* @type {ol.geom.Geometry|ol.Extent} * @type {ol.geom.Geometry|ol.Extent}
*/ */
var transformed; var transformed;
if (featureProjection && dataProjection && if (featureProjection && dataProjection &&
!_ol_proj_.equivalent(featureProjection, dataProjection)) { !equivalentProjection(featureProjection, dataProjection)) {
if (geometry instanceof _ol_geom_Geometry_) { if (geometry instanceof _ol_geom_Geometry_) {
transformed = (write ? geometry.clone() : geometry).transform( transformed = (write ? geometry.clone() : geometry).transform(
write ? featureProjection : dataProjection, write ? featureProjection : dataProjection,
@@ -191,7 +191,7 @@ _ol_format_Feature_.transformWithOptions = function(
} else { } else {
// FIXME this is necessary because ol.format.GML treats extents // FIXME this is necessary because ol.format.GML treats extents
// as geometries // as geometries
transformed = _ol_proj_.transformExtent( transformed = transformExtent(
geometry, geometry,
dataProjection, dataProjection,
featureProjection); featureProjection);

View File

@@ -8,7 +8,7 @@ import _ol_format_GMLBase_ from '../format/GMLBase.js';
import _ol_format_XSD_ from '../format/XSD.js'; import _ol_format_XSD_ from '../format/XSD.js';
import _ol_geom_Geometry_ from '../geom/Geometry.js'; import _ol_geom_Geometry_ from '../geom/Geometry.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, transformExtent} from '../proj.js';
import _ol_xml_ from '../xml.js'; import _ol_xml_ from '../xml.js';
/** /**
@@ -63,7 +63,7 @@ _ol_format_GML2_.prototype.readFlatCoordinates_ = function(node, objectStack) {
var containerSrs = context['srsName']; var containerSrs = context['srsName'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (containerSrs) { if (containerSrs) {
var proj = _ol_proj_.get(containerSrs); var proj = getProjection(containerSrs);
if (proj) { if (proj) {
axisOrientation = proj.getAxisOrientation(); axisOrientation = proj.getAxisOrientation();
} }
@@ -289,7 +289,7 @@ _ol_format_GML2_.prototype.writeGeometryElement = function(node, geometry, objec
var value; var value;
if (Array.isArray(geometry)) { if (Array.isArray(geometry)) {
if (context.dataProjection) { if (context.dataProjection) {
value = _ol_proj_.transformExtent( value = transformExtent(
geometry, context.featureProjection, context.dataProjection); geometry, context.featureProjection, context.dataProjection);
} else { } else {
value = geometry; value = geometry;
@@ -467,7 +467,7 @@ _ol_format_GML2_.prototype.writeRing_ = function(node, ring, objectStack) {
_ol_format_GML2_.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { _ol_format_GML2_.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (opt_srsName) { if (opt_srsName) {
axisOrientation = _ol_proj_.get(opt_srsName).getAxisOrientation(); axisOrientation = getProjection(opt_srsName).getAxisOrientation();
} }
var coords = ((axisOrientation.substr(0, 2) === 'en') ? var coords = ((axisOrientation.substr(0, 2) === 'en') ?
point[0] + ',' + point[1] : point[0] + ',' + point[1] :

View File

@@ -14,7 +14,7 @@ import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js';
import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js'; import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, transformExtent} from '../proj.js';
import _ol_xml_ from '../xml.js'; import _ol_xml_ from '../xml.js';
/** /**
@@ -320,7 +320,7 @@ _ol_format_GML3_.prototype.readFlatPos_ = function(node, objectStack) {
var containerSrs = context['srsName']; var containerSrs = context['srsName'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (containerSrs) { if (containerSrs) {
var proj = _ol_proj_.get(containerSrs); var proj = getProjection(containerSrs);
axisOrientation = proj.getAxisOrientation(); axisOrientation = proj.getAxisOrientation();
} }
if (axisOrientation === 'neu') { if (axisOrientation === 'neu') {
@@ -356,7 +356,7 @@ _ol_format_GML3_.prototype.readFlatPosList_ = function(node, objectStack) {
var contextDimension = context['srsDimension']; var contextDimension = context['srsDimension'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (containerSrs) { if (containerSrs) {
var proj = _ol_proj_.get(containerSrs); var proj = getProjection(containerSrs);
axisOrientation = proj.getAxisOrientation(); axisOrientation = proj.getAxisOrientation();
} }
var coords = s.split(/\s+/); var coords = s.split(/\s+/);
@@ -582,7 +582,7 @@ _ol_format_GML3_.prototype.writePos_ = function(node, value, objectStack) {
var srsName = context['srsName']; var srsName = context['srsName'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (srsName) { if (srsName) {
axisOrientation = _ol_proj_.get(srsName).getAxisOrientation(); axisOrientation = getProjection(srsName).getAxisOrientation();
} }
var point = value.getCoordinates(); var point = value.getCoordinates();
var coords; var coords;
@@ -611,7 +611,7 @@ _ol_format_GML3_.prototype.writePos_ = function(node, value, objectStack) {
_ol_format_GML3_.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) { _ol_format_GML3_.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (opt_srsName) { if (opt_srsName) {
axisOrientation = _ol_proj_.get(opt_srsName).getAxisOrientation(); axisOrientation = getProjection(opt_srsName).getAxisOrientation();
} }
var coords = ((axisOrientation.substr(0, 2) === 'en') ? var coords = ((axisOrientation.substr(0, 2) === 'en') ?
point[0] + ' ' + point[1] : point[0] + ' ' + point[1] :
@@ -956,7 +956,7 @@ _ol_format_GML3_.prototype.writeGeometryElement = function(node, geometry, objec
var value; var value;
if (Array.isArray(geometry)) { if (Array.isArray(geometry)) {
if (context.dataProjection) { if (context.dataProjection) {
value = _ol_proj_.transformExtent( value = transformExtent(
geometry, context.featureProjection, context.dataProjection); geometry, context.featureProjection, context.dataProjection);
} else { } else {
value = geometry; value = geometry;

View File

@@ -18,7 +18,7 @@ import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
import _ol_geom_Point_ from '../geom/Point.js'; import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js'; import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_xml_ from '../xml.js'; import _ol_xml_ from '../xml.js';
/** /**
@@ -592,7 +592,7 @@ _ol_format_GMLBase_.prototype.readFeaturesFromNode = function(node, opt_options)
* @inheritDoc * @inheritDoc
*/ */
_ol_format_GMLBase_.prototype.readProjectionFromNode = function(node) { _ol_format_GMLBase_.prototype.readProjectionFromNode = function(node) {
return _ol_proj_.get(this.srsName ? this.srsName : return getProjection(this.srsName ? this.srsName :
node.firstElementChild.getAttribute('srsName')); node.firstElementChild.getAttribute('srsName'));
}; };
export default _ol_format_GMLBase_; export default _ol_format_GMLBase_;

View File

@@ -11,7 +11,7 @@ import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js';
import _ol_geom_LineString_ from '../geom/LineString.js'; import _ol_geom_LineString_ from '../geom/LineString.js';
import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js'; import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js';
import _ol_geom_Point_ from '../geom/Point.js'; import _ol_geom_Point_ from '../geom/Point.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_xml_ from '../xml.js'; import _ol_xml_ from '../xml.js';
/** /**
@@ -32,7 +32,7 @@ var _ol_format_GPX_ = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); this.defaultDataProjection = getProjection('EPSG:4326');
/** /**
* @type {function(ol.Feature, Node)|undefined} * @type {function(ol.Feature, Node)|undefined}

View File

@@ -17,7 +17,7 @@ import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
import _ol_geom_Point_ from '../geom/Point.js'; import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js'; import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -37,13 +37,13 @@ var _ol_format_GeoJSON_ = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get( this.defaultDataProjection = getProjection(
options.defaultDataProjection ? options.defaultDataProjection ?
options.defaultDataProjection : 'EPSG:4326'); options.defaultDataProjection : 'EPSG:4326');
if (options.featureProjection) { if (options.featureProjection) {
this.defaultFeatureProjection = _ol_proj_.get(options.featureProjection); this.defaultFeatureProjection = getProjection(options.featureProjection);
} }
/** /**
@@ -467,7 +467,7 @@ _ol_format_GeoJSON_.prototype.readProjectionFromObject = function(object) {
var projection; var projection;
if (crs) { if (crs) {
if (crs.type == 'name') { if (crs.type == 'name') {
projection = _ol_proj_.get(crs.properties.name); projection = getProjection(crs.properties.name);
} else { } else {
_ol_asserts_.assert(false, 36); // Unknown SRS type _ol_asserts_.assert(false, 36); // Unknown SRS type
} }

View File

@@ -8,7 +8,7 @@ import _ol_format_IGCZ_ from '../format/IGCZ.js';
import _ol_format_TextFeature_ from '../format/TextFeature.js'; import _ol_format_TextFeature_ from '../format/TextFeature.js';
import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js'; import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js';
import _ol_geom_LineString_ from '../geom/LineString.js'; import _ol_geom_LineString_ from '../geom/LineString.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -28,7 +28,7 @@ var _ol_format_IGC_ = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); this.defaultDataProjection = getProjection('EPSG:4326');
/** /**
* @private * @private

View File

@@ -24,7 +24,7 @@ import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
import _ol_geom_Point_ from '../geom/Point.js'; import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js'; import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_math_ from '../math.js'; import _ol_math_ from '../math.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_style_Fill_ from '../style/Fill.js'; import _ol_style_Fill_ from '../style/Fill.js';
import _ol_style_Icon_ from '../style/Icon.js'; import _ol_style_Icon_ from '../style/Icon.js';
import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js';
@@ -59,7 +59,7 @@ var _ol_format_KML_ = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); this.defaultDataProjection = getProjection('EPSG:4326');
/** /**
* @private * @private

View File

@@ -12,7 +12,7 @@ import _ol_geom_LineString_ from '../geom/LineString.js';
import _ol_geom_Point_ from '../geom/Point.js'; import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js'; import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_xml_ from '../xml.js'; import _ol_xml_ from '../xml.js';
/** /**
@@ -30,7 +30,7 @@ var _ol_format_OSMXML_ = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); this.defaultDataProjection = getProjection('EPSG:4326');
}; };
inherits(_ol_format_OSMXML_, _ol_format_XMLFeature_); inherits(_ol_format_OSMXML_, _ol_format_XMLFeature_);

View File

@@ -11,7 +11,7 @@ import _ol_geom_LineString_ from '../geom/LineString.js';
import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js'; import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js';
import _ol_geom_flat_flip_ from '../geom/flat/flip.js'; import _ol_geom_flat_flip_ from '../geom/flat/flip.js';
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js'; import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -33,7 +33,7 @@ var _ol_format_Polyline_ = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get('EPSG:4326'); this.defaultDataProjection = getProjection('EPSG:4326');
/** /**
* @private * @private

View File

@@ -11,7 +11,7 @@ import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js';
import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
import _ol_geom_Point_ from '../geom/Point.js'; import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js'; import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -43,7 +43,7 @@ var _ol_format_TopoJSON_ = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.defaultDataProjection = _ol_proj_.get( this.defaultDataProjection = getProjection(
options.defaultDataProjection ? options.defaultDataProjection ?
options.defaultDataProjection : 'EPSG:4326'); options.defaultDataProjection : 'EPSG:4326');

View File

@@ -11,7 +11,7 @@ import _ol_format_XMLFeature_ from '../format/XMLFeature.js';
import _ol_format_XSD_ from '../format/XSD.js'; import _ol_format_XSD_ from '../format/XSD.js';
import _ol_geom_Geometry_ from '../geom/Geometry.js'; import _ol_geom_Geometry_ from '../geom/Geometry.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_xml_ from '../xml.js'; import _ol_xml_ from '../xml.js';
/** /**
@@ -1098,7 +1098,7 @@ _ol_format_WFS_.prototype.readProjectionFromNode = function(node) {
n.firstChild.nodeType === 3))) { n.firstChild.nodeType === 3))) {
var objectStack = [{}]; var objectStack = [{}];
this.gmlFormat_.readGeometryElement(n, objectStack); this.gmlFormat_.readGeometryElement(n, objectStack);
return _ol_proj_.get(objectStack.pop().srsName); return getProjection(objectStack.pop().srsName);
} }
} }
} }

View File

@@ -6,7 +6,7 @@ import _ol_Object_ from '../Object.js';
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js'; import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
import _ol_functions_ from '../functions.js'; import _ol_functions_ from '../functions.js';
import _ol_geom_flat_transform_ from '../geom/flat/transform.js'; import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, getTransform} from '../proj.js';
import _ol_proj_Units_ from '../proj/Units.js'; import _ol_proj_Units_ from '../proj/Units.js';
import _ol_transform_ from '../transform.js'; import _ol_transform_ from '../transform.js';
@@ -255,7 +255,7 @@ _ol_geom_Geometry_.prototype.translate = function(deltaX, deltaY) {};
*/ */
_ol_geom_Geometry_.prototype.transform = function(source, destination) { _ol_geom_Geometry_.prototype.transform = function(source, destination) {
var tmpTransform = this.tmpTransform_; var tmpTransform = this.tmpTransform_;
source = _ol_proj_.get(source); source = getProjection(source);
var transformFn = source.getUnits() == _ol_proj_Units_.TILE_PIXELS ? var transformFn = source.getUnits() == _ol_proj_Units_.TILE_PIXELS ?
function(inCoordinates, outCoordinates, stride) { function(inCoordinates, outCoordinates, stride) {
var pixelExtent = source.getExtent(); var pixelExtent = source.getExtent();
@@ -267,9 +267,9 @@ _ol_geom_Geometry_.prototype.transform = function(source, destination) {
0, 0); 0, 0);
_ol_geom_flat_transform_.transform2D(inCoordinates, 0, inCoordinates.length, stride, _ol_geom_flat_transform_.transform2D(inCoordinates, 0, inCoordinates.length, stride,
tmpTransform, outCoordinates); tmpTransform, outCoordinates);
return _ol_proj_.getTransform(source, destination)(inCoordinates, outCoordinates, stride); return getTransform(source, destination)(inCoordinates, outCoordinates, stride);
} : } :
_ol_proj_.getTransform(source, destination); getTransform(source, destination);
this.applyTransform(transformFn); this.applyTransform(transformFn);
return this; return this;
}; };

View File

@@ -2,7 +2,7 @@
* @module ol/geom/flat/geodesic * @module ol/geom/flat/geodesic
*/ */
import _ol_math_ from '../../math.js'; import _ol_math_ from '../../math.js';
import _ol_proj_ from '../../proj.js'; import {get as getProjection, getTransform} from '../../proj.js';
var _ol_geom_flat_geodesic_ = {}; var _ol_geom_flat_geodesic_ = {};
@@ -93,7 +93,7 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
_ol_geom_flat_geodesic_.greatCircleArc = function( _ol_geom_flat_geodesic_.greatCircleArc = function(
lon1, lat1, lon2, lat2, projection, squaredTolerance) { lon1, lat1, lon2, lat2, projection, squaredTolerance) {
var geoProjection = _ol_proj_.get('EPSG:4326'); var geoProjection = getProjection('EPSG:4326');
var cosLat1 = Math.cos(_ol_math_.toRadians(lat1)); var cosLat1 = Math.cos(_ol_math_.toRadians(lat1));
var sinLat1 = Math.sin(_ol_math_.toRadians(lat1)); var sinLat1 = Math.sin(_ol_math_.toRadians(lat1));
@@ -123,7 +123,7 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
Math.atan2(Math.sin(theta) * sinD * cosLat1, Math.atan2(Math.sin(theta) * sinD * cosLat1,
cosD - sinLat1 * Math.sin(lat)); cosD - sinLat1 * Math.sin(lat));
return [_ol_math_.toDegrees(lon), _ol_math_.toDegrees(lat)]; return [_ol_math_.toDegrees(lon), _ol_math_.toDegrees(lat)];
}, _ol_proj_.getTransform(geoProjection, projection), squaredTolerance); }, getTransform(geoProjection, projection), squaredTolerance);
}; };
@@ -137,7 +137,7 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
* @return {Array.<number>} Flat coordinates. * @return {Array.<number>} Flat coordinates.
*/ */
_ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squaredTolerance) { _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squaredTolerance) {
var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var epsg4326Projection = getProjection('EPSG:4326');
return _ol_geom_flat_geodesic_.line_( return _ol_geom_flat_geodesic_.line_(
/** /**
* @param {number} frac Fraction. * @param {number} frac Fraction.
@@ -146,7 +146,7 @@ _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squared
function(frac) { function(frac) {
return [lon, lat1 + ((lat2 - lat1) * frac)]; return [lon, lat1 + ((lat2 - lat1) * frac)];
}, },
_ol_proj_.getTransform(epsg4326Projection, projection), squaredTolerance); getTransform(epsg4326Projection, projection), squaredTolerance);
}; };
@@ -160,7 +160,7 @@ _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squared
* @return {Array.<number>} Flat coordinates. * @return {Array.<number>} Flat coordinates.
*/ */
_ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squaredTolerance) { _ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squaredTolerance) {
var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var epsg4326Projection = getProjection('EPSG:4326');
return _ol_geom_flat_geodesic_.line_( return _ol_geom_flat_geodesic_.line_(
/** /**
* @param {number} frac Fraction. * @param {number} frac Fraction.
@@ -169,6 +169,6 @@ _ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squared
function(frac) { function(frac) {
return [lon1 + ((lon2 - lon1) * frac), lat]; return [lon1 + ((lon2 - lon1) * frac), lat];
}, },
_ol_proj_.getTransform(epsg4326Projection, projection), squaredTolerance); getTransform(epsg4326Projection, projection), squaredTolerance);
}; };
export default _ol_geom_flat_geodesic_; export default _ol_geom_flat_geodesic_;

View File

@@ -9,7 +9,7 @@ import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js'; import _ol_events_Event_ from '../events/Event.js';
import _ol_events_EventType_ from '../events/EventType.js'; import _ol_events_EventType_ from '../events/EventType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
/** /**
* @classdesc * @classdesc
@@ -41,7 +41,7 @@ var _ol_interaction_DragAndDrop_ = function(opt_options) {
* @type {ol.proj.Projection} * @type {ol.proj.Projection}
*/ */
this.projection_ = options.projection ? this.projection_ = options.projection ?
_ol_proj_.get(options.projection) : null; getProjection(options.projection) : null;
/** /**
* @private * @private

View File

@@ -1,17 +1,16 @@
/** /**
* @module ol/proj * @module ol/proj
*/ */
import _ol_Sphere_ from './Sphere.js'; import Sphere from './Sphere.js';
import {applyTransform} from './extent.js'; import {applyTransform} from './extent.js';
import _ol_math_ from './math.js'; import math from './math.js';
import _ol_proj_EPSG3857_ from './proj/EPSG3857.js'; import EPSG3857 from './proj/EPSG3857.js';
import _ol_proj_EPSG4326_ from './proj/EPSG4326.js'; import EPSG4326 from './proj/EPSG4326.js';
import _ol_proj_Projection_ from './proj/Projection.js'; import Projection from './proj/Projection.js';
import _ol_proj_Units_ from './proj/Units.js'; import Units from './proj/Units.js';
import _ol_proj_proj4_ from './proj/proj4.js'; import _ol_proj_proj4_ from './proj/proj4.js';
import _ol_proj_projections_ from './proj/projections.js'; import _ol_proj_projections_ from './proj/projections.js';
import _ol_proj_transforms_ from './proj/transforms.js'; import _ol_proj_transforms_ from './proj/transforms.js';
var _ol_proj_ = {};
/** /**
@@ -20,15 +19,14 @@ var _ol_proj_ = {};
* @type {Object.<ol.proj.Units, number>} * @type {Object.<ol.proj.Units, number>}
* @api * @api
*/ */
_ol_proj_.METERS_PER_UNIT = _ol_proj_Units_.METERS_PER_UNIT; export var METERS_PER_UNIT = Units.METERS_PER_UNIT;
/** /**
* A place to store the mean radius of the Earth. * A place to store the mean radius of the Earth.
* @private
* @type {ol.Sphere} * @type {ol.Sphere}
*/ */
_ol_proj_.SPHERE_ = new _ol_Sphere_(_ol_Sphere_.DEFAULT_RADIUS); var SPHERE = new Sphere(Sphere.DEFAULT_RADIUS);
/** /**
@@ -43,9 +41,96 @@ _ol_proj_.SPHERE_ = new _ol_Sphere_(_ol_Sphere_.DEFAULT_RADIUS);
* @param {Proj4} proj4 Proj4. * @param {Proj4} proj4 Proj4.
* @api * @api
*/ */
_ol_proj_.setProj4 = function(proj4) { export function setProj4(proj4) {
_ol_proj_proj4_.set(proj4); _ol_proj_proj4_.set(proj4);
}; }
/**
* @param {Array.<number>} input Input coordinate array.
* @param {Array.<number>=} opt_output Output array of coordinate values.
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Output coordinate array (new array, same coordinate
* values).
*/
export function cloneTransform(input, opt_output, opt_dimension) {
var output;
if (opt_output !== undefined) {
for (var i = 0, ii = input.length; i < ii; ++i) {
opt_output[i] = input[i];
}
output = opt_output;
} else {
output = input.slice();
}
return output;
}
/**
* @param {Array.<number>} input Input coordinate array.
* @param {Array.<number>=} opt_output Output array of coordinate values.
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Input coordinate array (same array as input).
*/
export function identityTransform(input, opt_output, opt_dimension) {
if (opt_output !== undefined && input !== opt_output) {
for (var i = 0, ii = input.length; i < ii; ++i) {
opt_output[i] = input[i];
}
input = opt_output;
}
return input;
}
/**
* Add a Projection object to the list of supported projections that can be
* looked up by their code.
*
* @param {ol.proj.Projection} projection Projection instance.
* @api
*/
export function addProjection(projection) {
_ol_proj_projections_.add(projection.getCode(), projection);
_ol_proj_transforms_.add(projection, projection, cloneTransform);
}
/**
* @param {Array.<ol.proj.Projection>} projections Projections.
*/
export function addProjections(projections) {
projections.forEach(addProjection);
}
/**
* Fetches a Projection object for the code specified.
*
* @param {ol.ProjectionLike} projectionLike Either a code string which is
* a combination of authority and identifier such as "EPSG:4326", or an
* existing projection object, or undefined.
* @return {ol.proj.Projection} Projection object, or null if not in list.
* @api
*/
export function get(projectionLike) {
var projection = null;
if (projectionLike instanceof Projection) {
projection = projectionLike;
} else if (typeof projectionLike === 'string') {
var code = projectionLike;
projection = _ol_proj_projections_.get(code);
if (!projection) {
var proj4js = _ol_proj_proj4_.get();
if (typeof proj4js == 'function' && proj4js.defs(code) !== undefined) {
projection = new Projection({code: code});
addProjection(projection);
}
}
}
return projection;
}
/** /**
@@ -68,21 +153,21 @@ _ol_proj_.setProj4 = function(proj4) {
* @return {number} Point resolution. * @return {number} Point resolution.
* @api * @api
*/ */
_ol_proj_.getPointResolution = function(projection, resolution, point, opt_units) { export function getPointResolution(projection, resolution, point, opt_units) {
projection = _ol_proj_.get(projection); projection = get(projection);
var pointResolution; var pointResolution;
var getter = projection.getPointResolutionFunc(); var getter = projection.getPointResolutionFunc();
if (getter) { if (getter) {
pointResolution = getter(resolution, point); pointResolution = getter(resolution, point);
} else { } else {
var units = projection.getUnits(); var units = projection.getUnits();
if (units == _ol_proj_Units_.DEGREES && !opt_units || opt_units == _ol_proj_Units_.DEGREES) { if (units == Units.DEGREES && !opt_units || opt_units == Units.DEGREES) {
pointResolution = resolution; pointResolution = resolution;
} else { } else {
// Estimate point resolution by transforming the center pixel to EPSG:4326, // Estimate point resolution by transforming the center pixel to EPSG:4326,
// 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.
var toEPSG4326 = _ol_proj_.getTransformFromProjections(projection, _ol_proj_.get('EPSG:4326')); var toEPSG4326 = getTransformFromProjections(projection, get('EPSG:4326'));
var vertices = [ var vertices = [
point[0] - resolution / 2, point[1], point[0] - resolution / 2, point[1],
point[0] + resolution / 2, point[1], point[0] + resolution / 2, point[1],
@@ -90,13 +175,13 @@ _ol_proj_.getPointResolution = function(projection, resolution, point, opt_units
point[0], point[1] + resolution / 2 point[0], point[1] + resolution / 2
]; ];
vertices = toEPSG4326(vertices, vertices, 2); vertices = toEPSG4326(vertices, vertices, 2);
var width = _ol_proj_.SPHERE_.haversineDistance( var width = SPHERE.haversineDistance(
vertices.slice(0, 2), vertices.slice(2, 4)); vertices.slice(0, 2), vertices.slice(2, 4));
var height = _ol_proj_.SPHERE_.haversineDistance( var height = SPHERE.haversineDistance(
vertices.slice(4, 6), vertices.slice(6, 8)); vertices.slice(4, 6), vertices.slice(6, 8));
pointResolution = (width + height) / 2; pointResolution = (width + height) / 2;
var metersPerUnit = opt_units ? var metersPerUnit = opt_units ?
_ol_proj_Units_.METERS_PER_UNIT[opt_units] : Units.METERS_PER_UNIT[opt_units] :
projection.getMetersPerUnit(); projection.getMetersPerUnit();
if (metersPerUnit !== undefined) { if (metersPerUnit !== undefined) {
pointResolution /= metersPerUnit; pointResolution /= metersPerUnit;
@@ -104,7 +189,7 @@ _ol_proj_.getPointResolution = function(projection, resolution, point, opt_units
} }
} }
return pointResolution; return pointResolution;
}; }
/** /**
@@ -114,16 +199,16 @@ _ol_proj_.getPointResolution = function(projection, resolution, point, opt_units
* @param {Array.<ol.proj.Projection>} projections Projections. * @param {Array.<ol.proj.Projection>} projections Projections.
* @api * @api
*/ */
_ol_proj_.addEquivalentProjections = function(projections) { export function addEquivalentProjections(projections) {
_ol_proj_.addProjections(projections); addProjections(projections);
projections.forEach(function(source) { projections.forEach(function(source) {
projections.forEach(function(destination) { projections.forEach(function(destination) {
if (source !== destination) { if (source !== destination) {
_ol_proj_transforms_.add(source, destination, _ol_proj_.cloneTransform); _ol_proj_transforms_.add(source, destination, cloneTransform);
} }
}); });
}); });
}; }
/** /**
@@ -139,44 +224,23 @@ _ol_proj_.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_proj_.addEquivalentTransforms = function(projections1, projections2, forwardTransform, inverseTransform) { export function addEquivalentTransforms(projections1, projections2, forwardTransform, inverseTransform) {
projections1.forEach(function(projection1) { projections1.forEach(function(projection1) {
projections2.forEach(function(projection2) { projections2.forEach(function(projection2) {
_ol_proj_transforms_.add(projection1, projection2, forwardTransform); _ol_proj_transforms_.add(projection1, projection2, forwardTransform);
_ol_proj_transforms_.add(projection2, projection1, inverseTransform); _ol_proj_transforms_.add(projection2, projection1, inverseTransform);
}); });
}); });
}; }
/**
* Add a Projection object to the list of supported projections that can be
* looked up by their code.
*
* @param {ol.proj.Projection} projection Projection instance.
* @api
*/
_ol_proj_.addProjection = function(projection) {
_ol_proj_projections_.add(projection.getCode(), projection);
_ol_proj_transforms_.add(projection, projection, _ol_proj_.cloneTransform);
};
/**
* @param {Array.<ol.proj.Projection>} projections Projections.
*/
_ol_proj_.addProjections = function(projections) {
projections.forEach(_ol_proj_.addProjection);
};
/** /**
* Clear all cached projections and transforms. * Clear all cached projections and transforms.
*/ */
_ol_proj_.clearAllProjections = function() { export function clearAllProjections() {
_ol_proj_projections_.clear(); _ol_proj_projections_.clear();
_ol_proj_transforms_.clear(); _ol_proj_transforms_.clear();
}; }
/** /**
@@ -184,15 +248,48 @@ _ol_proj_.clearAllProjections = function() {
* @param {string} defaultCode Default code. * @param {string} defaultCode Default code.
* @return {ol.proj.Projection} Projection. * @return {ol.proj.Projection} Projection.
*/ */
_ol_proj_.createProjection = function(projection, defaultCode) { export function createProjection(projection, defaultCode) {
if (!projection) { if (!projection) {
return _ol_proj_.get(defaultCode); return get(defaultCode);
} else if (typeof projection === 'string') { } else if (typeof projection === 'string') {
return _ol_proj_.get(projection); return get(projection);
} else { } else {
return /** @type {ol.proj.Projection} */ (projection); return /** @type {ol.proj.Projection} */ (projection);
} }
}; }
/**
* Creates a {@link ol.TransformFunction} from a simple 2D coordinate transform
* function.
* @param {function(ol.Coordinate): ol.Coordinate} coordTransform Coordinate
* transform.
* @return {ol.TransformFunction} Transform function.
*/
export function createTransformFromCoordinateTransform(coordTransform) {
return (
/**
* @param {Array.<number>} input Input.
* @param {Array.<number>=} opt_output Output.
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Output.
*/
function(input, opt_output, opt_dimension) {
var length = input.length;
var dimension = opt_dimension !== undefined ? opt_dimension : 2;
var output = opt_output !== undefined ? opt_output : new Array(length);
var point, i, j;
for (i = 0; i < length; i += dimension) {
point = coordTransform([input[i], input[i + 1]]);
output[i] = point[0];
output[i + 1] = point[1];
for (j = dimension - 1; j >= 2; --j) {
output[i + j] = input[i + j];
}
}
return output;
});
}
/** /**
@@ -214,47 +311,14 @@ _ol_proj_.createProjection = function(projection, defaultCode) {
* the transformed {@link ol.Coordinate}. * the transformed {@link ol.Coordinate}.
* @api * @api
*/ */
_ol_proj_.addCoordinateTransforms = function(source, destination, forward, inverse) { export function addCoordinateTransforms(source, destination, forward, inverse) {
var sourceProj = _ol_proj_.get(source); var sourceProj = get(source);
var destProj = _ol_proj_.get(destination); var destProj = get(destination);
_ol_proj_transforms_.add(sourceProj, destProj, _ol_proj_transforms_.add(sourceProj, destProj,
_ol_proj_.createTransformFromCoordinateTransform(forward)); createTransformFromCoordinateTransform(forward));
_ol_proj_transforms_.add(destProj, sourceProj, _ol_proj_transforms_.add(destProj, sourceProj,
_ol_proj_.createTransformFromCoordinateTransform(inverse)); createTransformFromCoordinateTransform(inverse));
}; }
/**
* Creates a {@link ol.TransformFunction} from a simple 2D coordinate transform
* function.
* @param {function(ol.Coordinate): ol.Coordinate} transform Coordinate
* transform.
* @return {ol.TransformFunction} Transform function.
*/
_ol_proj_.createTransformFromCoordinateTransform = function(transform) {
return (
/**
* @param {Array.<number>} input Input.
* @param {Array.<number>=} opt_output Output.
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Output.
*/
function(input, opt_output, opt_dimension) {
var length = input.length;
var dimension = opt_dimension !== undefined ? opt_dimension : 2;
var output = opt_output !== undefined ? opt_output : new Array(length);
var point, i, j;
for (i = 0; i < length; i += dimension) {
point = transform([input[i], input[i + 1]]);
output[i] = point[0];
output[i + 1] = point[1];
for (j = dimension - 1; j >= 2; --j) {
output[i + j] = input[i + j];
}
}
return output;
});
};
/** /**
@@ -266,10 +330,10 @@ _ol_proj_.createTransformFromCoordinateTransform = function(transform) {
* @return {ol.Coordinate} Coordinate projected to the target projection. * @return {ol.Coordinate} Coordinate projected to the target projection.
* @api * @api
*/ */
_ol_proj_.fromLonLat = function(coordinate, opt_projection) { export function fromLonLat(coordinate, opt_projection) {
return _ol_proj_.transform(coordinate, 'EPSG:4326', return transform(coordinate, 'EPSG:4326',
opt_projection !== undefined ? opt_projection : 'EPSG:3857'); opt_projection !== undefined ? opt_projection : 'EPSG:3857');
}; }
/** /**
@@ -281,44 +345,15 @@ _ol_proj_.fromLonLat = function(coordinate, opt_projection) {
* with longitude as 1st and latitude as 2nd element. * with longitude as 1st and latitude as 2nd element.
* @api * @api
*/ */
_ol_proj_.toLonLat = function(coordinate, opt_projection) { export function toLonLat(coordinate, opt_projection) {
var lonLat = _ol_proj_.transform(coordinate, var lonLat = transform(coordinate,
opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326'); opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326');
var lon = lonLat[0]; var lon = lonLat[0];
if (lon < -180 || lon > 180) { if (lon < -180 || lon > 180) {
lonLat[0] = _ol_math_.modulo(lon + 180, 360) - 180; lonLat[0] = math.modulo(lon + 180, 360) - 180;
} }
return lonLat; return lonLat;
}; }
/**
* Fetches a Projection object for the code specified.
*
* @param {ol.ProjectionLike} projectionLike Either a code string which is
* a combination of authority and identifier such as "EPSG:4326", or an
* existing projection object, or undefined.
* @return {ol.proj.Projection} Projection object, or null if not in list.
* @api
*/
_ol_proj_.get = function(projectionLike) {
var projection = null;
if (projectionLike instanceof _ol_proj_Projection_) {
projection = projectionLike;
} else if (typeof projectionLike === 'string') {
var code = projectionLike;
projection = _ol_proj_projections_.get(code);
if (!projection) {
var proj4js = _ol_proj_proj4_.get();
if (typeof proj4js == 'function' &&
proj4js.defs(code) !== undefined) {
projection = new _ol_proj_Projection_({code: code});
_ol_proj_.addProjection(projection);
}
}
}
return projection;
};
/** /**
@@ -331,7 +366,7 @@ _ol_proj_.get = function(projectionLike) {
* @return {boolean} Equivalent. * @return {boolean} Equivalent.
* @api * @api
*/ */
_ol_proj_.equivalent = function(projection1, projection2) { export function equivalent(projection1, projection2) {
if (projection1 === projection2) { if (projection1 === projection2) {
return true; return true;
} }
@@ -339,11 +374,48 @@ _ol_proj_.equivalent = function(projection1, projection2) {
if (projection1.getCode() === projection2.getCode()) { if (projection1.getCode() === projection2.getCode()) {
return equalUnits; return equalUnits;
} else { } else {
var transformFn = _ol_proj_.getTransformFromProjections( var transformFunc = getTransformFromProjections(projection1, projection2);
projection1, projection2); return transformFunc === cloneTransform && equalUnits;
return transformFn === _ol_proj_.cloneTransform && equalUnits;
} }
}; }
/**
* Searches in the list of transform functions for the function for converting
* coordinates from the source projection to the destination projection.
*
* @param {ol.proj.Projection} sourceProjection Source Projection object.
* @param {ol.proj.Projection} destinationProjection Destination Projection
* object.
* @return {ol.TransformFunction} Transform function.
*/
export function getTransformFromProjections(sourceProjection, destinationProjection) {
var sourceCode = sourceProjection.getCode();
var destinationCode = destinationProjection.getCode();
var transformFunc = _ol_proj_transforms_.get(sourceCode, destinationCode);
if (!transformFunc) {
var proj4js = _ol_proj_proj4_.get();
if (typeof proj4js == 'function') {
var sourceDef = proj4js.defs(sourceCode);
var destinationDef = proj4js.defs(destinationCode);
if (sourceDef !== undefined && destinationDef !== undefined) {
if (sourceDef === destinationDef) {
addEquivalentProjections([destinationProjection, sourceProjection]);
} else {
var proj4Transform = proj4js(destinationCode, sourceCode);
addCoordinateTransforms(destinationProjection, sourceProjection,
proj4Transform.forward, proj4Transform.inverse);
}
transformFunc = _ol_proj_transforms_.get(sourceCode, destinationCode);
}
}
}
if (!transformFunc) {
transformFunc = identityTransform;
}
return transformFunc;
}
/** /**
@@ -356,88 +428,12 @@ _ol_proj_.equivalent = function(projection1, projection2) {
* @return {ol.TransformFunction} Transform function. * @return {ol.TransformFunction} Transform function.
* @api * @api
*/ */
_ol_proj_.getTransform = function(source, destination) { export function getTransform(source, destination) {
var sourceProjection = _ol_proj_.get(source); var sourceProjection = get(source);
var destinationProjection = _ol_proj_.get(destination); var destinationProjection = get(destination);
return _ol_proj_.getTransformFromProjections( return getTransformFromProjections(
sourceProjection, destinationProjection); sourceProjection, destinationProjection);
}; }
/**
* Searches in the list of transform functions for the function for converting
* coordinates from the source projection to the destination projection.
*
* @param {ol.proj.Projection} sourceProjection Source Projection object.
* @param {ol.proj.Projection} destinationProjection Destination Projection
* object.
* @return {ol.TransformFunction} Transform function.
*/
_ol_proj_.getTransformFromProjections = function(sourceProjection, destinationProjection) {
var sourceCode = sourceProjection.getCode();
var destinationCode = destinationProjection.getCode();
var transform = _ol_proj_transforms_.get(sourceCode, destinationCode);
if (!transform) {
var proj4js = _ol_proj_proj4_.get();
if (typeof proj4js == 'function') {
var sourceDef = proj4js.defs(sourceCode);
var destinationDef = proj4js.defs(destinationCode);
if (sourceDef !== undefined && destinationDef !== undefined) {
if (sourceDef === destinationDef) {
_ol_proj_.addEquivalentProjections([destinationProjection, sourceProjection]);
} else {
var proj4Transform = proj4js(destinationCode, sourceCode);
_ol_proj_.addCoordinateTransforms(destinationProjection, sourceProjection,
proj4Transform.forward, proj4Transform.inverse);
}
transform = _ol_proj_transforms_.get(sourceCode, destinationCode);
}
}
}
if (!transform) {
transform = _ol_proj_.identityTransform;
}
return transform;
};
/**
* @param {Array.<number>} input Input coordinate array.
* @param {Array.<number>=} opt_output Output array of coordinate values.
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Input coordinate array (same array as input).
*/
_ol_proj_.identityTransform = function(input, opt_output, opt_dimension) {
if (opt_output !== undefined && input !== opt_output) {
for (var i = 0, ii = input.length; i < ii; ++i) {
opt_output[i] = input[i];
}
input = opt_output;
}
return input;
};
/**
* @param {Array.<number>} input Input coordinate array.
* @param {Array.<number>=} opt_output Output array of coordinate values.
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Output coordinate array (new array, same coordinate
* values).
*/
_ol_proj_.cloneTransform = function(input, opt_output, opt_dimension) {
var output;
if (opt_output !== undefined) {
for (var i = 0, ii = input.length; i < ii; ++i) {
opt_output[i] = input[i];
}
output = opt_output;
} else {
output = input.slice();
}
return output;
};
/** /**
@@ -454,10 +450,10 @@ _ol_proj_.cloneTransform = function(input, opt_output, opt_dimension) {
* @return {ol.Coordinate} Coordinate. * @return {ol.Coordinate} Coordinate.
* @api * @api
*/ */
_ol_proj_.transform = function(coordinate, source, destination) { export function transform(coordinate, source, destination) {
var transformFn = _ol_proj_.getTransform(source, destination); var transformFunc = getTransform(source, destination);
return transformFn(coordinate, undefined, coordinate.length); return transformFunc(coordinate, undefined, coordinate.length);
}; }
/** /**
@@ -470,10 +466,10 @@ _ol_proj_.transform = function(coordinate, source, destination) {
* @return {ol.Extent} The transformed extent. * @return {ol.Extent} The transformed extent.
* @api * @api
*/ */
_ol_proj_.transformExtent = function(extent, source, destination) { export function transformExtent(extent, source, destination) {
var transformFn = _ol_proj_.getTransform(source, destination); var transformFunc = getTransform(source, destination);
return applyTransform(extent, transformFn); return applyTransform(extent, transformFunc);
}; }
/** /**
@@ -484,30 +480,29 @@ _ol_proj_.transformExtent = function(extent, source, destination) {
* @param {ol.proj.Projection} destinationProjection Destination projection. * @param {ol.proj.Projection} destinationProjection Destination projection.
* @return {ol.Coordinate} Point. * @return {ol.Coordinate} Point.
*/ */
_ol_proj_.transformWithProjections = function(point, sourceProjection, destinationProjection) { export function transformWithProjections(point, sourceProjection, destinationProjection) {
var transformFn = _ol_proj_.getTransformFromProjections( var transformFunc = getTransformFromProjections(
sourceProjection, destinationProjection); sourceProjection, destinationProjection);
return transformFn(point); return transformFunc(point);
}; }
/** /**
* Add transforms to and from EPSG:4326 and EPSG:3857. This function is called * Add transforms to and from EPSG:4326 and EPSG:3857. This function is called
* by when this module is executed and should only need to be called again after * by when this module is executed and should only need to be called again after
* `ol.proj.clearAllProjections()` is called (e.g. in tests). * `clearAllProjections()` is called (e.g. in tests).
*/ */
_ol_proj_.addCommon = function() { export function addCommon() {
// Add transformations that don't alter coordinates to convert within set of // Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning. // projections with equal meaning.
_ol_proj_.addEquivalentProjections(_ol_proj_EPSG3857_.PROJECTIONS); addEquivalentProjections(EPSG3857.PROJECTIONS);
_ol_proj_.addEquivalentProjections(_ol_proj_EPSG4326_.PROJECTIONS); addEquivalentProjections(EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back. // coordinates and back.
_ol_proj_.addEquivalentTransforms( addEquivalentTransforms(
_ol_proj_EPSG4326_.PROJECTIONS, EPSG4326.PROJECTIONS,
_ol_proj_EPSG3857_.PROJECTIONS, EPSG3857.PROJECTIONS,
_ol_proj_EPSG3857_.fromEPSG4326, EPSG3857.fromEPSG4326,
_ol_proj_EPSG3857_.toEPSG4326); EPSG3857.toEPSG4326);
}; }
_ol_proj_.addCommon(); addCommon();
export default _ol_proj_;

View File

@@ -10,7 +10,7 @@ import _ol_events_EventType_ from '../../events/EventType.js';
import _ol_ext_rbush_ from 'rbush'; import _ol_ext_rbush_ from 'rbush';
import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, intersects} from '../../extent.js'; import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, intersects} from '../../extent.js';
import _ol_layer_VectorTileRenderType_ from '../../layer/VectorTileRenderType.js'; import _ol_layer_VectorTileRenderType_ from '../../layer/VectorTileRenderType.js';
import _ol_proj_ from '../../proj.js'; import {equivalent as equivalentProjection} from '../../proj.js';
import _ol_proj_Units_ from '../../proj/Units.js'; import _ol_proj_Units_ from '../../proj/Units.js';
import _ol_render_ReplayType_ from '../../render/ReplayType.js'; import _ol_render_ReplayType_ from '../../render/ReplayType.js';
import _ol_render_canvas_ from '../../render/canvas.js'; import _ol_render_canvas_ from '../../render/canvas.js';
@@ -185,7 +185,7 @@ _ol_renderer_canvas_VectorTileLayer_.prototype.createReplayGroup_ = function(
buffer(sharedExtent, layer.getRenderBuffer() * resolution); buffer(sharedExtent, layer.getRenderBuffer() * resolution);
var tileProjection = sourceTile.getProjection(); var tileProjection = sourceTile.getProjection();
var reproject = false; var reproject = false;
if (!_ol_proj_.equivalent(projection, tileProjection)) { if (!equivalentProjection(projection, tileProjection)) {
reproject = true; reproject = true;
sourceTile.setProjection(projection); sourceTile.setProjection(projection);
} }

View File

@@ -4,7 +4,7 @@
import _ol_dom_ from './dom.js'; import _ol_dom_ from './dom.js';
import {containsCoordinate, createEmpty, extend, getHeight, getTopLeft, getWidth} from './extent.js'; import {containsCoordinate, createEmpty, extend, getHeight, getTopLeft, getWidth} from './extent.js';
import _ol_math_ from './math.js'; import _ol_math_ from './math.js';
import _ol_proj_ from './proj.js'; import {getPointResolution, transform} from './proj.js';
var _ol_reproj_ = {}; var _ol_reproj_ = {};
@@ -23,11 +23,10 @@ var _ol_reproj_ = {};
_ol_reproj_.calculateSourceResolution = function(sourceProj, targetProj, _ol_reproj_.calculateSourceResolution = function(sourceProj, targetProj,
targetCenter, targetResolution) { targetCenter, targetResolution) {
var sourceCenter = _ol_proj_.transform(targetCenter, targetProj, sourceProj); var sourceCenter = transform(targetCenter, targetProj, sourceProj);
// calculate the ideal resolution of the source data // calculate the ideal resolution of the source data
var sourceResolution = var sourceResolution = getPointResolution(targetProj, targetResolution, targetCenter);
_ol_proj_.getPointResolution(targetProj, targetResolution, targetCenter);
var targetMetersPerUnit = targetProj.getMetersPerUnit(); var targetMetersPerUnit = targetProj.getMetersPerUnit();
if (targetMetersPerUnit !== undefined) { if (targetMetersPerUnit !== undefined) {
@@ -44,8 +43,7 @@ _ol_reproj_.calculateSourceResolution = function(sourceProj, targetProj,
var sourceExtent = sourceProj.getExtent(); var sourceExtent = sourceProj.getExtent();
if (!sourceExtent || containsCoordinate(sourceExtent, sourceCenter)) { if (!sourceExtent || containsCoordinate(sourceExtent, sourceCenter)) {
var compensationFactor = var compensationFactor = getPointResolution(sourceProj, sourceResolution, sourceCenter) /
_ol_proj_.getPointResolution(sourceProj, sourceResolution, sourceCenter) /
sourceResolution; sourceResolution;
if (isFinite(compensationFactor) && compensationFactor > 0) { if (isFinite(compensationFactor) && compensationFactor > 0) {
sourceResolution /= compensationFactor; sourceResolution /= compensationFactor;

View File

@@ -4,7 +4,7 @@
import {boundingExtent, createEmpty, extendCoordinate, getBottomLeft, getBottomRight, import {boundingExtent, createEmpty, extendCoordinate, getBottomLeft, getBottomRight,
getTopLeft, getTopRight, getWidth, intersects} from '../extent.js'; getTopLeft, getTopRight, getWidth, intersects} from '../extent.js';
import _ol_math_ from '../math.js'; import _ol_math_ from '../math.js';
import _ol_proj_ from '../proj.js'; import {getTransform} from '../proj.js';
/** /**
@@ -58,7 +58,7 @@ var _ol_reproj_Triangulation_ = function(sourceProj, targetProj, targetExtent,
/** @type {!Object.<string, ol.Coordinate>} */ /** @type {!Object.<string, ol.Coordinate>} */
var transformInvCache = {}; var transformInvCache = {};
var transformInv = _ol_proj_.getTransform(this.targetProj_, this.sourceProj_); var transformInv = getTransform(this.targetProj_, this.sourceProj_);
/** /**
* @param {ol.Coordinate} c A coordinate. * @param {ol.Coordinate} c A coordinate.

View File

@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import {applyTransform, intersects} from '../extent.js'; import {applyTransform, intersects} from '../extent.js';
import _ol_net_ from '../net.js'; import _ol_net_ from '../net.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, getTransformFromProjections} from '../proj.js';
import _ol_source_State_ from '../source/State.js'; import _ol_source_State_ from '../source/State.js';
import _ol_source_TileImage_ from '../source/TileImage.js'; import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilecoord_ from '../tilecoord.js'; import _ol_tilecoord_ from '../tilecoord.js';
@@ -32,7 +32,7 @@ var _ol_source_BingMaps_ = function(options) {
cacheSize: options.cacheSize, cacheSize: options.cacheSize,
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
opaque: true, opaque: true,
projection: _ol_proj_.get('EPSG:3857'), projection: getProjection('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold, reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: _ol_source_State_.LOADING, state: _ol_source_State_.LOADING,
tileLoadFunction: options.tileLoadFunction, tileLoadFunction: options.tileLoadFunction,
@@ -178,8 +178,8 @@ _ol_source_BingMaps_.prototype.handleImageryMetadataResponse = function(response
})); }));
if (resource.imageryProviders) { if (resource.imageryProviders) {
var transform = _ol_proj_.getTransformFromProjections( var transform = getTransformFromProjections(
_ol_proj_.get('EPSG:4326'), this.getProjection()); getProjection('EPSG:4326'), this.getProjection());
this.setAttributions(function(frameState) { this.setAttributions(function(frameState) {
var attributions = []; var attributions = [];

View File

@@ -7,7 +7,7 @@ import _ol_ImageState_ from '../ImageState.js';
import _ol_array_ from '../array.js'; import _ol_array_ from '../array.js';
import _ol_events_Event_ from '../events/Event.js'; import _ol_events_Event_ from '../events/Event.js';
import {equals} from '../extent.js'; import {equals} from '../extent.js';
import _ol_proj_ from '../proj.js'; import {equivalent} from '../proj.js';
import _ol_reproj_Image_ from '../reproj/Image.js'; import _ol_reproj_Image_ from '../reproj/Image.js';
import _ol_source_Source_ from '../source/Source.js'; import _ol_source_Source_ from '../source/Source.js';
@@ -92,7 +92,7 @@ _ol_source_Image_.prototype.getImage = function(extent, resolution, pixelRatio,
if (!ENABLE_RASTER_REPROJECTION || if (!ENABLE_RASTER_REPROJECTION ||
!sourceProjection || !sourceProjection ||
!projection || !projection ||
_ol_proj_.equivalent(sourceProjection, projection)) { equivalent(sourceProjection, projection)) {
if (sourceProjection) { if (sourceProjection) {
projection = sourceProjection; projection = sourceProjection;
} }
@@ -100,7 +100,7 @@ _ol_source_Image_.prototype.getImage = function(extent, resolution, pixelRatio,
} else { } else {
if (this.reprojectedImage_) { if (this.reprojectedImage_) {
if (this.reprojectedRevision_ == this.getRevision() && if (this.reprojectedRevision_ == this.getRevision() &&
_ol_proj_.equivalent( equivalent(
this.reprojectedImage_.getProjection(), projection) && this.reprojectedImage_.getProjection(), projection) &&
this.reprojectedImage_.getResolution() == resolution && this.reprojectedImage_.getResolution() == resolution &&
equals(this.reprojectedImage_.getExtent(), extent)) { equals(this.reprojectedImage_.getExtent(), extent)) {

View File

@@ -8,7 +8,7 @@ import _ol_dom_ from '../dom.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js'; import _ol_events_EventType_ from '../events/EventType.js';
import {intersects, getHeight, getWidth} from '../extent.js'; import {intersects, getHeight, getWidth} from '../extent.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_source_Image_ from '../source/Image.js'; import _ol_source_Image_ from '../source/Image.js';
/** /**
@@ -33,7 +33,7 @@ var _ol_source_ImageStatic_ = function(options) {
_ol_source_Image_.call(this, { _ol_source_Image_.call(this, {
attributions: options.attributions, attributions: options.attributions,
logo: options.logo, logo: options.logo,
projection: _ol_proj_.get(options.projection) projection: getProjection(options.projection)
}); });
/** /**

View File

@@ -10,7 +10,7 @@ import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js'; import _ol_events_EventType_ from '../events/EventType.js';
import {containsExtent, getCenter, getForViewAndSize, getHeight, getWidth} from '../extent.js'; import {containsExtent, getCenter, getForViewAndSize, getHeight, getWidth} from '../extent.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, transform} from '../proj.js';
import _ol_reproj_ from '../reproj.js'; import _ol_reproj_ from '../reproj.js';
import _ol_source_Image_ from '../source/Image.js'; import _ol_source_Image_ from '../source/Image.js';
import _ol_source_WMSServerType_ from '../source/WMSServerType.js'; import _ol_source_WMSServerType_ from '../source/WMSServerType.js';
@@ -138,12 +138,12 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol
if (this.url_ === undefined) { if (this.url_ === undefined) {
return undefined; return undefined;
} }
var projectionObj = _ol_proj_.get(projection); var projectionObj = getProjection(projection);
var sourceProjectionObj = this.getProjection(); var sourceProjectionObj = this.getProjection();
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) { if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
resolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution); resolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution);
coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj); coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
} }
var extent = getForViewAndSize(coordinate, resolution, 0, var extent = getForViewAndSize(coordinate, resolution, 0,

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits, nullFunction} from '../index.js'; import {inherits, nullFunction} from '../index.js';
import _ol_Object_ from '../Object.js'; import _ol_Object_ from '../Object.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_source_State_ from '../source/State.js'; import _ol_source_State_ from '../source/State.js';
/** /**
@@ -28,7 +28,7 @@ var _ol_source_Source_ = function(options) {
* @private * @private
* @type {ol.proj.Projection} * @type {ol.proj.Projection}
*/ */
this.projection_ = _ol_proj_.get(options.projection); this.projection_ = getProjection(options.projection);
/** /**
* @private * @private

View File

@@ -5,7 +5,7 @@ import {inherits, nullFunction} from '../index.js';
import _ol_TileCache_ from '../TileCache.js'; import _ol_TileCache_ from '../TileCache.js';
import _ol_TileState_ from '../TileState.js'; import _ol_TileState_ from '../TileState.js';
import _ol_events_Event_ from '../events/Event.js'; import _ol_events_Event_ from '../events/Event.js';
import _ol_proj_ from '../proj.js'; import {equivalent} from '../proj.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
import _ol_source_Source_ from '../source/Source.js'; import _ol_source_Source_ from '../source/Source.js';
import _ol_tilecoord_ from '../tilecoord.js'; import _ol_tilecoord_ from '../tilecoord.js';
@@ -230,7 +230,7 @@ _ol_source_Tile_.prototype.getTileGridForProjection = function(projection) {
*/ */
_ol_source_Tile_.prototype.getTileCacheForProjection = function(projection) { _ol_source_Tile_.prototype.getTileCacheForProjection = function(projection) {
var thisProj = this.getProjection(); var thisProj = this.getProjection();
if (thisProj && !_ol_proj_.equivalent(thisProj, projection)) { if (thisProj && !equivalent(thisProj, projection)) {
return null; return null;
} else { } else {
return this.tileCache; return this.tileCache;

View File

@@ -8,7 +8,7 @@ import _ol_TileCache_ from '../TileCache.js';
import _ol_TileState_ from '../TileState.js'; import _ol_TileState_ from '../TileState.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js'; import _ol_events_EventType_ from '../events/EventType.js';
import _ol_proj_ from '../proj.js'; import {equivalent, get as getProjection} from '../proj.js';
import _ol_reproj_Tile_ from '../reproj/Tile.js'; import _ol_reproj_Tile_ from '../reproj/Tile.js';
import _ol_source_UrlTile_ from '../source/UrlTile.js'; import _ol_source_UrlTile_ from '../source/UrlTile.js';
import _ol_tilecoord_ from '../tilecoord.js'; import _ol_tilecoord_ from '../tilecoord.js';
@@ -131,8 +131,7 @@ _ol_source_TileImage_.prototype.expireCache = function(projection, usedTiles) {
*/ */
_ol_source_TileImage_.prototype.getGutter = function(projection) { _ol_source_TileImage_.prototype.getGutter = function(projection) {
if (ENABLE_RASTER_REPROJECTION && if (ENABLE_RASTER_REPROJECTION &&
this.getProjection() && projection && this.getProjection() && projection && !equivalent(this.getProjection(), projection)) {
!_ol_proj_.equivalent(this.getProjection(), projection)) {
return 0; return 0;
} else { } else {
return this.getGutterInternal(); return this.getGutterInternal();
@@ -154,8 +153,7 @@ _ol_source_TileImage_.prototype.getGutterInternal = function() {
*/ */
_ol_source_TileImage_.prototype.getOpaque = function(projection) { _ol_source_TileImage_.prototype.getOpaque = function(projection) {
if (ENABLE_RASTER_REPROJECTION && if (ENABLE_RASTER_REPROJECTION &&
this.getProjection() && projection && this.getProjection() && projection && !equivalent(this.getProjection(), projection)) {
!_ol_proj_.equivalent(this.getProjection(), projection)) {
return false; return false;
} else { } else {
return _ol_source_UrlTile_.prototype.getOpaque.call(this, projection); return _ol_source_UrlTile_.prototype.getOpaque.call(this, projection);
@@ -171,8 +169,7 @@ _ol_source_TileImage_.prototype.getTileGridForProjection = function(projection)
return _ol_source_UrlTile_.prototype.getTileGridForProjection.call(this, projection); return _ol_source_UrlTile_.prototype.getTileGridForProjection.call(this, projection);
} }
var thisProj = this.getProjection(); var thisProj = this.getProjection();
if (this.tileGrid && if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
(!thisProj || _ol_proj_.equivalent(thisProj, projection))) {
return this.tileGrid; return this.tileGrid;
} else { } else {
var projKey = getUid(projection).toString(); var projKey = getUid(projection).toString();
@@ -192,8 +189,7 @@ _ol_source_TileImage_.prototype.getTileCacheForProjection = function(projection)
if (!ENABLE_RASTER_REPROJECTION) { if (!ENABLE_RASTER_REPROJECTION) {
return _ol_source_UrlTile_.prototype.getTileCacheForProjection.call(this, projection); return _ol_source_UrlTile_.prototype.getTileCacheForProjection.call(this, projection);
} }
var thisProj = this.getProjection(); var thisProj = this.getProjection(); if (!thisProj || equivalent(thisProj, projection)) {
if (!thisProj || _ol_proj_.equivalent(thisProj, projection)) {
return this.tileCache; return this.tileCache;
} else { } else {
var projKey = getUid(projection).toString(); var projKey = getUid(projection).toString();
@@ -241,8 +237,7 @@ _ol_source_TileImage_.prototype.createTile_ = function(z, x, y, pixelRatio, proj
_ol_source_TileImage_.prototype.getTile = function(z, x, y, pixelRatio, projection) { _ol_source_TileImage_.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection()); var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection());
if (!ENABLE_RASTER_REPROJECTION || if (!ENABLE_RASTER_REPROJECTION ||
!sourceProjection || !projection || !sourceProjection || !projection || equivalent(sourceProjection, projection)) {
_ol_proj_.equivalent(sourceProjection, projection)) {
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection); return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection);
} else { } else {
var cache = this.getTileCacheForProjection(projection); var cache = this.getTileCacheForProjection(projection);
@@ -356,7 +351,7 @@ _ol_source_TileImage_.prototype.setRenderReprojectionEdges = function(render) {
*/ */
_ol_source_TileImage_.prototype.setTileGridForProjection = function(projection, tilegrid) { _ol_source_TileImage_.prototype.setTileGridForProjection = function(projection, tilegrid) {
if (ENABLE_RASTER_REPROJECTION) { if (ENABLE_RASTER_REPROJECTION) {
var proj = _ol_proj_.get(projection); var proj = getProjection(projection);
if (proj) { if (proj) {
var projKey = getUid(proj).toString(); var projKey = getUid(proj).toString();
if (!(projKey in this.tileGridForProjection)) { if (!(projKey in this.tileGridForProjection)) {

View File

@@ -12,7 +12,7 @@ import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_asserts_ from '../asserts.js'; import _ol_asserts_ from '../asserts.js';
import {applyTransform, intersects} from '../extent.js'; import {applyTransform, intersects} from '../extent.js';
import _ol_net_ from '../net.js'; import _ol_net_ from '../net.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, getTransformFromProjections} from '../proj.js';
import _ol_source_State_ from '../source/State.js'; import _ol_source_State_ from '../source/State.js';
import _ol_source_TileImage_ from '../source/TileImage.js'; import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilegrid_ from '../tilegrid.js'; import _ol_tilegrid_ from '../tilegrid.js';
@@ -38,7 +38,7 @@ var _ol_source_TileJSON_ = function(options) {
attributions: options.attributions, attributions: options.attributions,
cacheSize: options.cacheSize, cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin, crossOrigin: options.crossOrigin,
projection: _ol_proj_.get('EPSG:3857'), projection: getProjection('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold, reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: _ol_source_State_.LOADING, state: _ol_source_State_.LOADING,
tileLoadFunction: options.tileLoadFunction, tileLoadFunction: options.tileLoadFunction,
@@ -114,12 +114,12 @@ _ol_source_TileJSON_.prototype.getTileJSON = function() {
*/ */
_ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) { _ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var epsg4326Projection = getProjection('EPSG:4326');
var sourceProjection = this.getProjection(); var sourceProjection = this.getProjection();
var extent; var extent;
if (tileJSON.bounds !== undefined) { if (tileJSON.bounds !== undefined) {
var transform = _ol_proj_.getTransformFromProjections( var transform = getTransformFromProjections(
epsg4326Projection, sourceProjection); epsg4326Projection, sourceProjection);
extent = applyTransform(tileJSON.bounds, transform); extent = applyTransform(tileJSON.bounds, transform);
} }

View File

@@ -10,7 +10,7 @@ import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js'; import _ol_events_EventType_ from '../events/EventType.js';
import {applyTransform, intersects} from '../extent.js'; import {applyTransform, intersects} from '../extent.js';
import _ol_net_ from '../net.js'; import _ol_net_ from '../net.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, getTransformFromProjections} from '../proj.js';
import _ol_source_State_ from '../source/State.js'; import _ol_source_State_ from '../source/State.js';
import _ol_source_Tile_ from '../source/Tile.js'; import _ol_source_Tile_ from '../source/Tile.js';
import _ol_tilecoord_ from '../tilecoord.js'; import _ol_tilecoord_ from '../tilecoord.js';
@@ -27,7 +27,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
*/ */
var _ol_source_TileUTFGrid_ = function(options) { var _ol_source_TileUTFGrid_ = function(options) {
_ol_source_Tile_.call(this, { _ol_source_Tile_.call(this, {
projection: _ol_proj_.get('EPSG:3857'), projection: getProjection('EPSG:3857'),
state: _ol_source_State_.LOADING state: _ol_source_State_.LOADING
}); });
@@ -166,12 +166,12 @@ _ol_source_TileUTFGrid_.prototype.handleTileJSONError = function() {
*/ */
_ol_source_TileUTFGrid_.prototype.handleTileJSONResponse = function(tileJSON) { _ol_source_TileUTFGrid_.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = _ol_proj_.get('EPSG:4326'); var epsg4326Projection = getProjection('EPSG:4326');
var sourceProjection = this.getProjection(); var sourceProjection = this.getProjection();
var extent; var extent;
if (tileJSON.bounds !== undefined) { if (tileJSON.bounds !== undefined) {
var transform = _ol_proj_.getTransformFromProjections( var transform = getTransformFromProjections(
epsg4326Projection, sourceProjection); epsg4326Projection, sourceProjection);
extent = applyTransform(tileJSON.bounds, transform); extent = applyTransform(tileJSON.bounds, transform);
} }

View File

@@ -8,7 +8,7 @@ import _ol_asserts_ from '../asserts.js';
import {buffer, createEmpty} from '../extent.js'; import {buffer, createEmpty} from '../extent.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_math_ from '../math.js'; import _ol_math_ from '../math.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, transform, transformExtent} from '../proj.js';
import _ol_reproj_ from '../reproj.js'; import _ol_reproj_ from '../reproj.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
import _ol_source_TileImage_ from '../source/TileImage.js'; import _ol_source_TileImage_ from '../source/TileImage.js';
@@ -110,7 +110,7 @@ inherits(_ol_source_TileWMS_, _ol_source_TileImage_);
* @api * @api
*/ */
_ol_source_TileWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) { _ol_source_TileWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
var projectionObj = _ol_proj_.get(projection); var projectionObj = getProjection(projection);
var sourceProjectionObj = this.getProjection(); var sourceProjectionObj = this.getProjection();
var tileGrid = this.getTileGrid(); var tileGrid = this.getTileGrid();
@@ -137,8 +137,8 @@ _ol_source_TileWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolu
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) { if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
tileResolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution); tileResolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution);
tileExtent = _ol_proj_.transformExtent(tileExtent, projectionObj, sourceProjectionObj); tileExtent = transformExtent(tileExtent, projectionObj, sourceProjectionObj);
coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj); coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
} }
var baseParams = { var baseParams = {

View File

@@ -6,7 +6,7 @@ import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_array_ from '../array.js'; import _ol_array_ from '../array.js';
import {containsExtent} from '../extent.js'; import {containsExtent} from '../extent.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection, equivalent, transformExtent} from '../proj.js';
import _ol_source_TileImage_ from '../source/TileImage.js'; import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_source_WMTSRequestEncoding_ from '../source/WMTSRequestEncoding.js'; import _ol_source_WMTSRequestEncoding_ from '../source/WMTSRequestEncoding.js';
import _ol_tilegrid_WMTS_ from '../tilegrid/WMTS.js'; import _ol_tilegrid_WMTS_ from '../tilegrid/WMTS.js';
@@ -330,11 +330,11 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
return el['Identifier'] == elt['TileMatrixSet']; return el['Identifier'] == elt['TileMatrixSet'];
}); });
var supportedCRS = tileMatrixSet['SupportedCRS']; var supportedCRS = tileMatrixSet['SupportedCRS'];
var proj1 = _ol_proj_.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || var proj1 = getProjection(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
_ol_proj_.get(supportedCRS); getProjection(supportedCRS);
var proj2 = _ol_proj_.get(config['projection']); var proj2 = getProjection(config['projection']);
if (proj1 && proj2) { if (proj1 && proj2) {
return _ol_proj_.equivalent(proj1, proj2); return equivalent(proj1, proj2);
} else { } else {
return supportedCRS == config['projection']; return supportedCRS == config['projection'];
} }
@@ -392,13 +392,13 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
var projection; var projection;
var code = matrixSetObj['SupportedCRS']; var code = matrixSetObj['SupportedCRS'];
if (code) { if (code) {
projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || projection = getProjection(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
_ol_proj_.get(code); getProjection(code);
} }
if ('projection' in config) { if ('projection' in config) {
var projConfig = _ol_proj_.get(config['projection']); var projConfig = getProjection(config['projection']);
if (projConfig) { if (projConfig) {
if (!projection || _ol_proj_.equivalent(projConfig, projection)) { if (!projection || equivalent(projConfig, projection)) {
projection = projConfig; projection = projConfig;
} }
} }
@@ -407,10 +407,10 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
var wgs84BoundingBox = l['WGS84BoundingBox']; var wgs84BoundingBox = l['WGS84BoundingBox'];
var extent, wrapX; var extent, wrapX;
if (wgs84BoundingBox !== undefined) { if (wgs84BoundingBox !== undefined) {
var wgs84ProjectionExtent = _ol_proj_.get('EPSG:4326').getExtent(); var wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent();
wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] && wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] &&
wgs84BoundingBox[2] == wgs84ProjectionExtent[2]); wgs84BoundingBox[2] == wgs84ProjectionExtent[2]);
extent = _ol_proj_.transformExtent( extent = transformExtent(
wgs84BoundingBox, 'EPSG:4326', projection); wgs84BoundingBox, 'EPSG:4326', projection);
var projectionExtent = projection.getExtent(); var projectionExtent = projection.getExtent();
if (projectionExtent) { if (projectionExtent) {

View File

@@ -6,7 +6,7 @@ import _ol_size_ from './size.js';
import {containsCoordinate, createOrUpdate, getCorner, getHeight, getWidth} from './extent.js'; import {containsCoordinate, createOrUpdate, getCorner, getHeight, getWidth} from './extent.js';
import Corner from './extent/Corner.js'; import Corner from './extent/Corner.js';
import _ol_obj_ from './obj.js'; import _ol_obj_ from './obj.js';
import _ol_proj_ from './proj.js'; import {get as getProjection, METERS_PER_UNIT} from './proj.js';
import _ol_proj_Units_ from './proj/Units.js'; import _ol_proj_Units_ from './proj/Units.js';
import _ol_tilegrid_TileGrid_ from './tilegrid/TileGrid.js'; import _ol_tilegrid_TileGrid_ from './tilegrid/TileGrid.js';
var _ol_tilegrid_ = {}; var _ol_tilegrid_ = {};
@@ -83,7 +83,7 @@ _ol_tilegrid_.createXYZ = function(opt_options) {
_ol_obj_.assign(options, opt_options !== undefined ? _ol_obj_.assign(options, opt_options !== undefined ?
opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({}));
if (options.extent === undefined) { if (options.extent === undefined) {
options.extent = _ol_proj_.get('EPSG:3857').getExtent(); options.extent = getProjection('EPSG:3857').getExtent();
} }
options.resolutions = _ol_tilegrid_.resolutionsFromExtent( options.resolutions = _ol_tilegrid_.resolutionsFromExtent(
options.extent, options.maxZoom, options.tileSize); options.extent, options.maxZoom, options.tileSize);
@@ -147,10 +147,10 @@ _ol_tilegrid_.createForProjection = function(projection, opt_maxZoom, opt_tileSi
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
_ol_tilegrid_.extentFromProjection = function(projection) { _ol_tilegrid_.extentFromProjection = function(projection) {
projection = _ol_proj_.get(projection); projection = getProjection(projection);
var extent = projection.getExtent(); var extent = projection.getExtent();
if (!extent) { if (!extent) {
var half = 180 * _ol_proj_.METERS_PER_UNIT[_ol_proj_Units_.DEGREES] / var half = 180 * METERS_PER_UNIT[_ol_proj_Units_.DEGREES] /
projection.getMetersPerUnit(); projection.getMetersPerUnit();
extent = createOrUpdate(-half, -half, half, half); extent = createOrUpdate(-half, -half, half, half);
} }

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_array_ from '../array.js'; import _ol_array_ from '../array.js';
import _ol_proj_ from '../proj.js'; import {get as getProjection} from '../proj.js';
import _ol_tilegrid_TileGrid_ from '../tilegrid/TileGrid.js'; import _ol_tilegrid_TileGrid_ from '../tilegrid/TileGrid.js';
/** /**
@@ -94,8 +94,8 @@ _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet = function(matrixSet, opt_ext
var tileHeightPropName = 'TileHeight'; var tileHeightPropName = 'TileHeight';
var code = matrixSet[supportedCRSPropName]; var code = matrixSet[supportedCRSPropName];
var projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) || var projection = getProjection(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
_ol_proj_.get(code); getProjection(code);
var metersPerUnit = projection.getMetersPerUnit(); var metersPerUnit = projection.getMetersPerUnit();
// swap origin x and y coordinates if axis orientation is lat/long // swap origin x and y coordinates if axis orientation is lat/long
var switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne'; var switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js'; import _ol_View_ from '../../../../src/ol/View.js';
import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js'; import _ol_layer_Image_ from '../../../../src/ol/layer/Image.js';
import _ol_obj_ from '../../../../src/ol/obj.js'; import _ol_obj_ from '../../../../src/ol/obj.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection, transform, transformExtent} from '../../../../src/ol/proj.js';
import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js'; import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
@@ -17,7 +17,7 @@ describe('ol.rendering.layer.Image', function() {
target: createMapDiv(50, 50), target: createMapDiv(50, 50),
renderer: renderer, renderer: renderer,
view: new _ol_View_({ view: new _ol_View_({
center: _ol_proj_.transform( center: transform(
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
zoom: 5 zoom: 5
}) })
@@ -69,7 +69,7 @@ describe('ol.rendering.layer.Image', function() {
url: 'rendering/ol/data/tiles/osm/5/5/12.png', url: 'rendering/ol/data/tiles/osm/5/5/12.png',
imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent( imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent(
[5, 5, -12 - 1]), [5, 5, -12 - 1]),
projection: _ol_proj_.get('EPSG:3857') projection: getProjection('EPSG:3857')
}); });
}); });
@@ -97,7 +97,7 @@ describe('ol.rendering.layer.Image', function() {
beforeEach(function() { beforeEach(function() {
source = new _ol_source_ImageStatic_({ source = new _ol_source_ImageStatic_({
url: 'rendering/ol/data/tiles/osm/5/5/12.png', url: 'rendering/ol/data/tiles/osm/5/5/12.png',
imageExtent: _ol_proj_.transformExtent( imageExtent: transformExtent(
[-123, 37, -122, 38], 'EPSG:4326', 'EPSG:3857') [-123, 37, -122, 38], 'EPSG:4326', 'EPSG:3857')
}); });
}); });

View File

@@ -4,7 +4,7 @@ import * as _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js'; import _ol_layer_Tile_ from '../../../../src/ol/layer/Tile.js';
import _ol_obj_ from '../../../../src/ol/obj.js'; import _ol_obj_ from '../../../../src/ol/obj.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {transform} from '../../../../src/ol/proj.js';
import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js'; import _ol_source_TileImage_ from '../../../../src/ol/source/TileImage.js';
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
@@ -25,7 +25,7 @@ describe('ol.rendering.layer.Tile', function() {
target: createMapDiv(size[0], size[1]), target: createMapDiv(size[0], size[1]),
renderer: renderer, renderer: renderer,
view: new _ol_View_({ view: new _ol_View_({
center: opt_center !== undefined ? opt_center : _ol_proj_.transform( center: opt_center !== undefined ? opt_center : transform(
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'), [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
resolutions: opt_resolutions, resolutions: opt_resolutions,
zoom: 5 zoom: 5
@@ -285,7 +285,7 @@ describe('ol.rendering.layer.Tile', function() {
stroke: new _ol_style_Stroke_({color: 'red', width: 1}) stroke: new _ol_style_Stroke_({color: 'red', width: 1})
})); }));
e.vectorContext.drawPoint(new _ol_geom_Point_( e.vectorContext.drawPoint(new _ol_geom_Point_(
_ol_proj_.transform([-123, 38], 'EPSG:4326', 'EPSG:3857'))); transform([-123, 38], 'EPSG:4326', 'EPSG:3857')));
}); });
}; };
}); });

View File

@@ -1,5 +1,5 @@
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js'; import _ol_proj_EPSG3857_ from '../../../../src/ol/proj/EPSG3857.js';
import _ol_reproj_Image_ from '../../../../src/ol/reproj/Image.js'; import _ol_reproj_Image_ from '../../../../src/ol/reproj/Image.js';
import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js'; import _ol_source_ImageStatic_ from '../../../../src/ol/source/ImageStatic.js';
@@ -14,7 +14,7 @@ describe('ol.rendering.reproj.Image', function() {
var imagesRequested = 0; var imagesRequested = 0;
var image = new _ol_reproj_Image_(sourceProj, _ol_proj_.get(targetProj), var image = new _ol_reproj_Image_(sourceProj, getProjection(targetProj),
targetExtent, targetResolution, pixelRatio, targetExtent, targetResolution, pixelRatio,
function(extent, resolution, pixelRatio) { function(extent, resolution, pixelRatio) {
imagesRequested++; imagesRequested++;
@@ -38,7 +38,7 @@ describe('ol.rendering.reproj.Image', function() {
source = new _ol_source_ImageStatic_({ source = new _ol_source_ImageStatic_({
url: 'rendering/ol/data/tiles/osm/5/5/12.png', url: 'rendering/ol/data/tiles/osm/5/5/12.png',
imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent([5, 5, -13]), imageExtent: _ol_tilegrid_.createXYZ().getTileCoordExtent([5, 5, -13]),
projection: _ol_proj_.get('EPSG:3857') projection: getProjection('EPSG:3857')
}); });
}); });

View File

@@ -1,6 +1,6 @@
import _ol_TileState_ from '../../../../src/ol/TileState.js'; import _ol_TileState_ from '../../../../src/ol/TileState.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js'; import _ol_reproj_Tile_ from '../../../../src/ol/reproj/Tile.js';
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
@@ -16,7 +16,7 @@ describe('ol.rendering.reproj.Tile', function() {
var tilesRequested = 0; var tilesRequested = 0;
var tile = new _ol_reproj_Tile_(sourceProjection, source.getTileGrid(), var tile = new _ol_reproj_Tile_(sourceProjection, source.getTileGrid(),
_ol_proj_.get(targetProjection), targetTileGrid, getProjection(targetProjection), targetTileGrid,
[z, x, y], null, pixelRatio, sourceGutter, [z, x, y], null, pixelRatio, sourceGutter,
function(z, x, y, pixelRatio) { function(z, x, y, pixelRatio) {
tilesRequested++; tilesRequested++;
@@ -58,7 +58,7 @@ describe('ol.rendering.reproj.Tile', function() {
proj4.defs('EPSG:5070', proj4.defs('EPSG:5070',
'+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' + '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 ' +
'+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'); '+y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
var proj5070 = _ol_proj_.get('EPSG:5070'); var proj5070 = getProjection('EPSG:5070');
proj5070.setExtent([-6e6, 0, 4e6, 6e6]); proj5070.setExtent([-6e6, 0, 4e6, 6e6]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:5070', 5, [64, 64]); var tileGrid = _ol_tilegrid_.createForProjection('EPSG:5070', 5, [64, 64]);
@@ -69,7 +69,7 @@ describe('ol.rendering.reproj.Tile', function() {
it('to ESRI:54009', function(done) { it('to ESRI:54009', function(done) {
proj4.defs('ESRI:54009', proj4.defs('ESRI:54009',
'+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
var proj54009 = _ol_proj_.get('ESRI:54009'); var proj54009 = getProjection('ESRI:54009');
proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]); proj54009.setExtent([-18e6, -9e6, 18e6, 9e6]);
var tileGrid = _ol_tilegrid_.createForProjection('ESRI:54009', 7, [64, 64]); var tileGrid = _ol_tilegrid_.createForProjection('ESRI:54009', 7, [64, 64]);
@@ -96,7 +96,7 @@ describe('ol.rendering.reproj.Tile', function() {
proj4.defs('EPSG:3740', proj4.defs('EPSG:3740',
'+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' + '+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 ' +
'+units=m +no_defs'); '+units=m +no_defs');
var proj3740 = _ol_proj_.get('EPSG:3740'); var proj3740 = getProjection('EPSG:3740');
proj3740.setExtent([318499.05, 2700792.39, 4359164.89, 7149336.98]); proj3740.setExtent([318499.05, 2700792.39, 4359164.89, 7149336.98]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3740', 4, [64, 64]); var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3740', 4, [64, 64]);
@@ -158,7 +158,7 @@ describe('ol.rendering.reproj.Tile', function() {
it('wraps X when prime meridian is shifted', function(done) { it('wraps X when prime meridian is shifted', function(done) {
proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs'); proj4.defs('merc_180', '+proj=merc +lon_0=180 +units=m +no_defs');
var proj_ = _ol_proj_.get('merc_180'); var proj_ = getProjection('merc_180');
proj_.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]); proj_.setExtent([-20026376.39, -20048966.10, 20026376.39, 20048966.10]);
var tileGrid = _ol_tilegrid_.createForProjection('merc_180', 0, [64, 64]); var tileGrid = _ol_tilegrid_.createForProjection('merc_180', 0, [64, 64]);
@@ -169,7 +169,7 @@ describe('ol.rendering.reproj.Tile', function() {
it('displays north pole correctly (EPSG:3413)', function(done) { it('displays north pole correctly (EPSG:3413)', function(done) {
proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' + proj4.defs('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 ' +
'+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); '+k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
var proj3413 = _ol_proj_.get('EPSG:3413'); var proj3413 = getProjection('EPSG:3413');
proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]); proj3413.setExtent([-4194304, -4194304, 4194304, 4194304]);
var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3413', 0, [64, 64]); var tileGrid = _ol_tilegrid_.createForProjection('EPSG:3413', 0, [64, 64]);

View File

@@ -1,7 +1,7 @@
import _ol_Map_ from '../../../../src/ol/Map.js'; import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js'; import _ol_View_ from '../../../../src/ol/View.js';
import _ol_control_ScaleLine_ from '../../../../src/ol/control/ScaleLine.js'; import _ol_control_ScaleLine_ from '../../../../src/ol/control/ScaleLine.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {fromLonLat} from '../../../../src/ol/proj.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
describe('ol.control.ScaleLine', function() { describe('ol.control.ScaleLine', function() {
@@ -249,7 +249,7 @@ describe('ol.control.ScaleLine', function() {
var ctrl = new _ol_control_ScaleLine_(); var ctrl = new _ol_control_ScaleLine_();
ctrl.setMap(map); ctrl.setMap(map);
map.setView(new _ol_View_({ map.setView(new _ol_View_({
center: _ol_proj_.fromLonLat([7, 52]), center: fromLonLat([7, 52]),
zoom: 2, zoom: 2,
projection: 'EPSG:3857' projection: 'EPSG:3857'
})); }));
@@ -306,7 +306,7 @@ describe('ol.control.ScaleLine', function() {
var ctrl = new _ol_control_ScaleLine_(); var ctrl = new _ol_control_ScaleLine_();
ctrl.setMap(map); ctrl.setMap(map);
map.setView(new _ol_View_({ map.setView(new _ol_View_({
center: _ol_proj_.fromLonLat([7, 0]), center: fromLonLat([7, 0]),
zoom: 2, zoom: 2,
projection: 'EPSG:4326' projection: 'EPSG:4326'
})); }));
@@ -324,7 +324,7 @@ describe('ol.control.ScaleLine', function() {
}); });
ctrl.setMap(map); ctrl.setMap(map);
map.setView(new _ol_View_({ map.setView(new _ol_View_({
center: _ol_proj_.fromLonLat([7, 0]), center: fromLonLat([7, 0]),
zoom: 2, zoom: 2,
projection: 'EPSG:4326' projection: 'EPSG:4326'
})); }));

View File

@@ -1,5 +1,5 @@
import * as _ol_extent_ from '../../../src/ol/extent.js'; import * as _ol_extent_ from '../../../src/ol/extent.js';
import _ol_proj_ from '../../../src/ol/proj.js'; import {getTransform} from '../../../src/ol/proj.js';
describe('ol.extent', function() { describe('ol.extent', function() {
@@ -737,7 +737,7 @@ describe('ol.extent', function() {
describe('#applyTransform()', function() { describe('#applyTransform()', function() {
it('does transform', function() { it('does transform', function() {
var transformFn = _ol_proj_.getTransform('EPSG:4326', 'EPSG:3857'); var transformFn = getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = [-15, -30, 45, 60]; var sourceExtent = [-15, -30, 45, 60];
var destinationExtent = _ol_extent_.applyTransform( var destinationExtent = _ol_extent_.applyTransform(
sourceExtent, transformFn); sourceExtent, transformFn);

View File

@@ -8,7 +8,7 @@ import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.EsriJSON', function() { describe('ol.format.EsriJSON', function() {
@@ -239,7 +239,7 @@ describe('ol.format.EsriJSON', function() {
}); });
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
expect(feature[0].getGeometry().getCoordinates()).to.eql( expect(feature[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
}); });
it('can read and transform a feature collection', function() { it('can read and transform a feature collection', function() {
@@ -249,18 +249,18 @@ describe('ol.format.EsriJSON', function() {
}); });
expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_);
expect(features[0].getGeometry().getCoordinates()).to.eql( expect(features[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
expect(features[1].getGeometry().getCoordinates()).to.eql([ expect(features[1].getGeometry().getCoordinates()).to.eql([
_ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
]); ]);
expect(features[2].getGeometry().getCoordinates()).to.eql([[ expect(features[2].getGeometry().getCoordinates()).to.eql([[
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857') transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857')
]]); ]]);
}); });
@@ -753,7 +753,7 @@ describe('ol.format.EsriJSON', function() {
expect(second.get('bam')).to.be('baz'); expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(_ol_geom_LineString_); expect(second.getGeometry()).to.be.a(_ol_geom_LineString_);
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:3857')); expect(format.readProjection(json)).to.be(getProjection('EPSG:3857'));
}); });

View File

@@ -8,7 +8,7 @@ import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {fromLonLat, get as getProjection, toLonLat, transform} from '../../../../src/ol/proj.js';
describe('ol.format.GeoJSON', function() { describe('ol.format.GeoJSON', function() {
@@ -211,7 +211,7 @@ describe('ol.format.GeoJSON', function() {
}); });
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
expect(feature[0].getGeometry().getCoordinates()).to.eql( expect(feature[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
}); });
it('uses featureProjection passed to the constructor', function() { it('uses featureProjection passed to the constructor', function() {
@@ -219,7 +219,7 @@ describe('ol.format.GeoJSON', function() {
var feature = format.readFeatures(pointGeoJSON); var feature = format.readFeatures(pointGeoJSON);
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
expect(feature[0].getGeometry().getCoordinates()).to.eql( expect(feature[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
}); });
it('gives precedence to options passed to the read method', function() { it('gives precedence to options passed to the read method', function() {
@@ -229,7 +229,7 @@ describe('ol.format.GeoJSON', function() {
}); });
expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(feature[0].getGeometry()).to.be.an(_ol_geom_Point_);
expect(feature[0].getGeometry().getCoordinates()).to.eql( expect(feature[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
}); });
it('can read and transform a feature collection', function() { it('can read and transform a feature collection', function() {
@@ -238,18 +238,18 @@ describe('ol.format.GeoJSON', function() {
}); });
expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_); expect(features[0].getGeometry()).to.be.an(_ol_geom_Point_);
expect(features[0].getGeometry().getCoordinates()).to.eql( expect(features[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
expect(features[1].getGeometry().getCoordinates()).to.eql([ expect(features[1].getGeometry().getCoordinates()).to.eql([
_ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
]); ]);
expect(features[2].getGeometry().getCoordinates()).to.eql([[ expect(features[2].getGeometry().getCoordinates()).to.eql([[
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857') transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857')
]]); ]]);
}); });
@@ -342,7 +342,7 @@ describe('ol.format.GeoJSON', function() {
expect(first.get('bam')).to.be('baz'); expect(first.get('bam')).to.be('baz');
expect(first.getGeometry()).to.be.a(_ol_geom_LineString_); expect(first.getGeometry()).to.be.a(_ol_geom_LineString_);
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:4326')); expect(format.readProjection(json)).to.be(getProjection('EPSG:4326'));
}); });
}); });
@@ -471,7 +471,7 @@ describe('ol.format.GeoJSON', function() {
expect(second.get('bam')).to.be('baz'); expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(_ol_geom_LineString_); expect(second.getGeometry()).to.be.a(_ol_geom_LineString_);
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:3857')); expect(format.readProjection(json)).to.be(getProjection('EPSG:3857'));
}); });
@@ -514,7 +514,7 @@ describe('ol.format.GeoJSON', function() {
expect(second.get('bam')).to.be('baz'); expect(second.get('bam')).to.be('baz');
expect(second.getGeometry()).to.be.a(_ol_geom_LineString_); expect(second.getGeometry()).to.be.a(_ol_geom_LineString_);
expect(format.readProjection(json)).to.be(_ol_proj_.get('EPSG:4326')); expect(format.readProjection(json)).to.be(getProjection('EPSG:4326'));
}); });
@@ -597,18 +597,18 @@ describe('ol.format.GeoJSON', function() {
}); });
it('accepts featureProjection', function() { it('accepts featureProjection', function() {
var point = new _ol_geom_Point_(_ol_proj_.fromLonLat([10, 20])); var point = new _ol_geom_Point_(fromLonLat([10, 20]));
var geojson = format.writeGeometry(point, {featureProjection: 'EPSG:3857'}); var geojson = format.writeGeometry(point, {featureProjection: 'EPSG:3857'});
var obj = JSON.parse(geojson); var obj = JSON.parse(geojson);
expect(obj.coordinates).to.eql(_ol_proj_.toLonLat(point.getCoordinates())); expect(obj.coordinates).to.eql(toLonLat(point.getCoordinates()));
}); });
it('respects featureProjection passed to constructor', function() { it('respects featureProjection passed to constructor', function() {
var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'}); var format = new _ol_format_GeoJSON_({featureProjection: 'EPSG:3857'});
var point = new _ol_geom_Point_(_ol_proj_.fromLonLat([10, 20])); var point = new _ol_geom_Point_(fromLonLat([10, 20]));
var geojson = format.writeGeometry(point); var geojson = format.writeGeometry(point);
var obj = JSON.parse(geojson); var obj = JSON.parse(geojson);
expect(obj.coordinates).to.eql(_ol_proj_.toLonLat(point.getCoordinates())); expect(obj.coordinates).to.eql(toLonLat(point.getCoordinates()));
}); });
it('encodes linestring', function() { it('encodes linestring', function() {

View File

@@ -8,7 +8,7 @@ import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {transform} from '../../../../src/ol/proj.js';
import _ol_xml_ from '../../../../src/ol/xml.js'; import _ol_xml_ from '../../../../src/ol/xml.js';
var readGeometry = function(format, text, opt_options) { var readGeometry = function(format, text, opt_options) {
@@ -393,7 +393,7 @@ describe('ol.format.GML3', function() {
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
var coordinates = g.getCoordinates(); var coordinates = g.getCoordinates();
expect(coordinates.splice(0, 2)).to.eql( expect(coordinates.splice(0, 2)).to.eql(
_ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857')); transform([1, 2], 'CRS:84', 'EPSG:3857'));
config.dataProjection = 'CRS:84'; config.dataProjection = 'CRS:84';
var serialized = format.writeGeometryNode(g, config); var serialized = format.writeGeometryNode(g, config);
var pos = serialized.firstElementChild.firstElementChild.textContent; var pos = serialized.firstElementChild.firstElementChild.textContent;
@@ -415,7 +415,7 @@ describe('ol.format.GML3', function() {
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
var coordinates = g.getCoordinates(); var coordinates = g.getCoordinates();
expect(coordinates.splice(0, 2)).to.eql( expect(coordinates.splice(0, 2)).to.eql(
_ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857')); transform([1, 2], 'CRS:84', 'EPSG:3857'));
}); });
it('can read and write a point geometry in EPSG:4326', function() { it('can read and write a point geometry in EPSG:4326', function() {
@@ -462,9 +462,9 @@ describe('ol.format.GML3', function() {
expect(g).to.be.an(_ol_geom_LineString_); expect(g).to.be.an(_ol_geom_LineString_);
var coordinates = g.getCoordinates(); var coordinates = g.getCoordinates();
expect(coordinates[0].slice(0, 2)).to.eql( expect(coordinates[0].slice(0, 2)).to.eql(
_ol_proj_.transform([1, 2], 'CRS:84', 'EPSG:3857')); transform([1, 2], 'CRS:84', 'EPSG:3857'));
expect(coordinates[1].slice(0, 2)).to.eql( expect(coordinates[1].slice(0, 2)).to.eql(
_ol_proj_.transform([3, 4], 'CRS:84', 'EPSG:3857')); transform([3, 4], 'CRS:84', 'EPSG:3857'));
var serialized = format.writeGeometryNode(g, config); var serialized = format.writeGeometryNode(g, config);
var poss = serialized.firstElementChild.firstElementChild.textContent; var poss = serialized.firstElementChild.firstElementChild.textContent;
var coordinate = poss.split(' '); var coordinate = poss.split(' ');

View File

@@ -4,7 +4,7 @@ import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js'; import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection, transform} from '../../../../src/ol/proj.js';
import _ol_xml_ from '../../../../src/ol/xml.js'; import _ol_xml_ from '../../../../src/ol/xml.js';
describe('ol.format.GPX', function() { describe('ol.format.GPX', function() {
@@ -17,12 +17,12 @@ describe('ol.format.GPX', function() {
describe('#readProjection', function() { describe('#readProjection', function() {
it('returns the default projection from document', function() { it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument(); var projection = format.readProjectionFromDocument();
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
it('returns the default projection from node', function() { it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode(); var projection = format.readProjectionFromNode();
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
}); });
@@ -121,8 +121,8 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(_ol_Feature_); expect(f).to.be.an(_ol_Feature_);
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_LineString_); expect(g).to.be.an(_ol_geom_LineString_);
var p1 = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); var p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
var p2 = _ol_proj_.transform([6, 5], 'EPSG:4326', 'EPSG:3857'); var p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
expect(g.getCoordinates()).to.eql([p1, p2]); expect(g.getCoordinates()).to.eql([p1, p2]);
expect(g.getLayout()).to.be('XY'); expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs, { var serialized = format.writeFeaturesNode(fs, {
@@ -285,9 +285,9 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(_ol_Feature_); expect(f).to.be.an(_ol_Feature_);
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_MultiLineString_); expect(g).to.be.an(_ol_geom_MultiLineString_);
var p1 = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); var p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
p1.push(3, 1263115752); p1.push(3, 1263115752);
var p2 = _ol_proj_.transform([6, 5], 'EPSG:4326', 'EPSG:3857'); var p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
p2.push(7, 1263115812); p2.push(7, 1263115812);
expect(g.getCoordinates()).to.eql([[p1, p2]]); expect(g.getCoordinates()).to.eql([[p1, p2]]);
expect(g.getLayout()).to.be('XYZM'); expect(g.getLayout()).to.be('XYZM');
@@ -416,7 +416,7 @@ describe('ol.format.GPX', function() {
expect(f).to.be.an(_ol_Feature_); expect(f).to.be.an(_ol_Feature_);
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
var expectedPoint = _ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857'); var expectedPoint = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
expect(g.getCoordinates()).to.eql(expectedPoint); expect(g.getCoordinates()).to.eql(expectedPoint);
expect(g.getLayout()).to.be('XY'); expect(g.getLayout()).to.be('XY');
var serialized = format.writeFeaturesNode(fs, { var serialized = format.writeFeaturesNode(fs, {

View File

@@ -1,6 +1,6 @@
import _ol_format_IGC_ from '../../../../src/ol/format/IGC.js'; import _ol_format_IGC_ from '../../../../src/ol/format/IGC.js';
import _ol_Feature_ from '../../../../src/ol/Feature.js'; import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.IGC', function() { describe('ol.format.IGC', function() {
@@ -35,7 +35,7 @@ describe('ol.format.IGC', function() {
describe('#readProjectionFromText', function() { describe('#readProjectionFromText', function() {
it('returns the default projection', function() { it('returns the default projection', function() {
var projection = format.readProjectionFromText(igc); var projection = format.readProjectionFromText(igc);
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
}); });
@@ -64,16 +64,16 @@ describe('ol.format.IGC', function() {
var geom = feature.getGeometry(); var geom = feature.getGeometry();
expect(geom.getType()).to.eql('LineString'); expect(geom.getType()).to.eql('LineString');
var expectedPoint1 = _ol_proj_.transform( var expectedPoint1 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint1.push(1303202928); expectedPoint1.push(1303202928);
var expectedPoint2 = _ol_proj_.transform( var expectedPoint2 = transform(
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857'); [6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
expectedPoint2.push(1303203353); expectedPoint2.push(1303203353);
var expectedPoint3 = _ol_proj_.transform( var expectedPoint3 = transform(
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857'); [6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
expectedPoint3.push(1303203815); expectedPoint3.push(1303203815);
var expectedPoint4 = _ol_proj_.transform( var expectedPoint4 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint4.push(1303289328); expectedPoint4.push(1303289328);
@@ -113,16 +113,16 @@ describe('ol.format.IGC', function() {
var geom = feature.getGeometry(); var geom = feature.getGeometry();
expect(geom.getType()).to.eql('LineString'); expect(geom.getType()).to.eql('LineString');
var expectedPoint1 = _ol_proj_.transform( var expectedPoint1 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint1.push(1303202928); expectedPoint1.push(1303202928);
var expectedPoint2 = _ol_proj_.transform( var expectedPoint2 = transform(
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857'); [6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
expectedPoint2.push(1303203353); expectedPoint2.push(1303203353);
var expectedPoint3 = _ol_proj_.transform( var expectedPoint3 = transform(
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857'); [6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
expectedPoint3.push(1303203815); expectedPoint3.push(1303203815);
var expectedPoint4 = _ol_proj_.transform( var expectedPoint4 = transform(
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857'); [6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
expectedPoint4.push(1303289328); expectedPoint4.push(1303289328);

View File

@@ -10,7 +10,7 @@ import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {addProjection, addCoordinateTransforms, transform, get as getProjection} from '../../../../src/ol/proj.js';
import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js';
import _ol_proj_transforms_ from '../../../../src/ol/proj/transforms.js'; import _ol_proj_transforms_ from '../../../../src/ol/proj/transforms.js';
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
@@ -80,12 +80,12 @@ describe('ol.format.KML', function() {
describe('#readProjection', function() { describe('#readProjection', function() {
it('returns the default projection from document', function() { it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument(); var projection = format.readProjectionFromDocument();
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
it('returns the default projection from node', function() { it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode(); var projection = format.readProjectionFromNode();
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
}); });
@@ -266,7 +266,7 @@ describe('ol.format.KML', function() {
expect(f).to.be.an(_ol_Feature_); expect(f).to.be.an(_ol_Feature_);
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
var expectedPoint = _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); var expectedPoint = transform([1, 2], 'EPSG:4326', 'EPSG:3857');
expectedPoint.push(3); expectedPoint.push(3);
expect(g.getCoordinates()).to.eql(expectedPoint); expect(g.getCoordinates()).to.eql(expectedPoint);
}); });
@@ -310,7 +310,7 @@ describe('ol.format.KML', function() {
expect(f).to.be.an(_ol_Feature_); expect(f).to.be.an(_ol_Feature_);
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
var expectedPoint = _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); var expectedPoint = transform([1, 2], 'EPSG:4326', 'EPSG:3857');
expectedPoint.push(3); expectedPoint.push(3);
expect(g.getCoordinates()).to.eql(expectedPoint); expect(g.getCoordinates()).to.eql(expectedPoint);
}); });
@@ -356,8 +356,8 @@ describe('ol.format.KML', function() {
}); });
it('can transform and write XYZ Point geometries', function() { it('can transform and write XYZ Point geometries', function() {
_ol_proj_.addProjection(new _ol_proj_Projection_({code: 'double'})); addProjection(new _ol_proj_Projection_({code: 'double'}));
_ol_proj_.addCoordinateTransforms('EPSG:4326', 'double', addCoordinateTransforms('EPSG:4326', 'double',
function(coordinate) { function(coordinate) {
return [2 * coordinate[0], 2 * coordinate[1]]; return [2 * coordinate[0], 2 * coordinate[1]];
}, },
@@ -387,9 +387,9 @@ describe('ol.format.KML', function() {
expect(node).to.xmleql(_ol_xml_.parse(text)); expect(node).to.xmleql(_ol_xml_.parse(text));
_ol_proj_transforms_.remove( _ol_proj_transforms_.remove(
_ol_proj_.get('EPSG:4326'), _ol_proj_.get('double')); getProjection('EPSG:4326'), getProjection('double'));
_ol_proj_transforms_.remove( _ol_proj_transforms_.remove(
_ol_proj_.get('double'), _ol_proj_.get('EPSG:4326')); getProjection('double'), getProjection('EPSG:4326'));
}); });
it('can write XYM Point geometries', function() { it('can write XYM Point geometries', function() {
@@ -2849,7 +2849,7 @@ describe('ol.format.KML', function() {
expect(f).to.be.an(_ol_Feature_); expect(f).to.be.an(_ol_Feature_);
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
var expectedPoint = _ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857'); var expectedPoint = transform([1, 2], 'EPSG:4326', 'EPSG:3857');
expectedPoint.push(3); expectedPoint.push(3);
expect(g.getCoordinates()).to.eql(expectedPoint); expect(g.getCoordinates()).to.eql(expectedPoint);
}); });

View File

@@ -2,7 +2,7 @@ import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_format_OSMXML_ from '../../../../src/ol/format/OSMXML.js'; import _ol_format_OSMXML_ from '../../../../src/ol/format/OSMXML.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.OSMXML', function() { describe('ol.format.OSMXML', function() {
@@ -15,12 +15,12 @@ describe('ol.format.OSMXML', function() {
describe('#readProjection', function() { describe('#readProjection', function() {
it('returns the default projection from document', function() { it('returns the default projection from document', function() {
var projection = format.readProjectionFromDocument(); var projection = format.readProjectionFromDocument();
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
it('returns the default projection from node', function() { it('returns the default projection from node', function() {
var projection = format.readProjectionFromNode(); var projection = format.readProjectionFromNode();
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
}); });
@@ -132,7 +132,7 @@ describe('ol.format.OSMXML', function() {
var g = f.getGeometry(); var g = f.getGeometry();
expect(g).to.be.an(_ol_geom_Point_); expect(g).to.be.an(_ol_geom_Point_);
expect(g.getCoordinates()).to.eql( expect(g.getCoordinates()).to.eql(
_ol_proj_.transform([2, 1], 'EPSG:4326', 'EPSG:3857')); transform([2, 1], 'EPSG:4326', 'EPSG:3857'));
}); });
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Feature_ from '../../../../src/ol/Feature.js'; import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_format_Polyline_ from '../../../../src/ol/format/Polyline.js'; import _ol_format_Polyline_ from '../../../../src/ol/format/Polyline.js';
import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js'; import _ol_geom_LineString_ from '../../../../src/ol/geom/LineString.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {get as getProjection, transform} from '../../../../src/ol/proj.js';
describe('ol.format.Polyline', function() { describe('ol.format.Polyline', function() {
@@ -32,9 +32,9 @@ describe('ol.format.Polyline', function() {
]; ];
encodedFlatPoints = '_p~iF~ps|U_ulLnnqC_mqNvxq`@'; encodedFlatPoints = '_p~iF~ps|U_ulLnnqC_mqNvxq`@';
points3857 = [ points3857 = [
_ol_proj_.transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'), transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'), transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857') transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857')
]; ];
floats = [0.00, 0.15, -0.01, -0.16, 0.16, 0.01]; floats = [0.00, 0.15, -0.01, -0.16, 0.16, 0.01];
@@ -54,7 +54,7 @@ describe('ol.format.Polyline', function() {
describe('#readProjectionFromText', function() { describe('#readProjectionFromText', function() {
it('returns the default projection', function() { it('returns the default projection', function() {
var projection = format.readProjectionFromText(encodedFlatPoints); var projection = format.readProjectionFromText(encodedFlatPoints);
expect(projection).to.eql(_ol_proj_.get('EPSG:4326')); expect(projection).to.eql(getProjection('EPSG:4326'));
}); });
}); });
@@ -352,7 +352,7 @@ describe('ol.format.Polyline', function() {
it('returns the expected projection', function() { it('returns the expected projection', function() {
var projection = format.readProjection(encodedFlatPoints); var projection = format.readProjection(encodedFlatPoints);
expect(projection).to.be(_ol_proj_.get('EPSG:4326')); expect(projection).to.be(getProjection('EPSG:4326'));
}); });
}); });

View File

@@ -2,7 +2,7 @@ import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_format_Feature_ from '../../../../src/ol/format/Feature.js'; import _ol_format_Feature_ from '../../../../src/ol/format/Feature.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {transform} from '../../../../src/ol/proj.js';
import _ol_format_TopoJSON_ from '../../../../src/ol/format/TopoJSON.js'; import _ol_format_TopoJSON_ from '../../../../src/ol/format/TopoJSON.js';
var aruba = { var aruba = {
@@ -123,25 +123,25 @@ describe('ol.format.TopoJSON', function() {
var point = features[0].getGeometry(); var point = features[0].getGeometry();
expect(point.getType()).to.be('Point'); expect(point.getType()).to.be('Point');
expect(features[0].getGeometry().getCoordinates()).to.eql( expect(features[0].getGeometry().getCoordinates()).to.eql(
_ol_proj_.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')); transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
var line = features[1].getGeometry(); var line = features[1].getGeometry();
expect(line.getType()).to.be('LineString'); expect(line.getType()).to.be('LineString');
expect(line.getCoordinates()).to.eql([ expect(line.getCoordinates()).to.eql([
_ol_proj_.transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857') transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
]); ]);
var polygon = features[2].getGeometry(); var polygon = features[2].getGeometry();
expect(polygon.getType()).to.be('Polygon'); expect(polygon.getType()).to.be('Polygon');
expect(polygon.getCoordinates()).to.eql([[ expect(polygon.getCoordinates()).to.eql([[
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'), transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'), transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
_ol_proj_.transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857') transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857')
]]); ]]);
done(); done();

View File

@@ -7,7 +7,7 @@ import _ol_geom_MultiLineString_ from '../../../../src/ol/geom/MultiLineString.j
import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js'; import _ol_geom_MultiPoint_ from '../../../../src/ol/geom/MultiPoint.js';
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js'; import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js'; import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {transform} from '../../../../src/ol/proj.js';
import _ol_xml_ from '../../../../src/ol/xml.js'; import _ol_xml_ from '../../../../src/ol/xml.js';
describe('ol.format.WFS', function() { describe('ol.format.WFS', function() {
@@ -67,7 +67,7 @@ describe('ol.format.WFS', function() {
expect(feature.get('STATE_NAME')).to.equal('Illinois'); expect(feature.get('STATE_NAME')).to.equal('Illinois');
var geom = feature.getGeometry(); var geom = feature.getGeometry();
expect(geom).to.be.an(_ol_geom_MultiPolygon_); expect(geom).to.be.an(_ol_geom_MultiPolygon_);
var p = _ol_proj_.transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857'); var p = transform([-88.071, 37.511], 'EPSG:4326', 'EPSG:3857');
p.push(0); p.push(0);
expect(geom.getFirstCoordinate()).to.eql(p); expect(geom.getFirstCoordinate()).to.eql(p);
}); });

View File

@@ -1,7 +1,7 @@
import _ol_Feature_ from '../../../../src/ol/Feature.js'; import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js'; import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_format_WKT_ from '../../../../src/ol/format/WKT.js'; import _ol_format_WKT_ from '../../../../src/ol/format/WKT.js';
import _ol_proj_ from '../../../../src/ol/proj.js'; import {transform} from '../../../../src/ol/proj.js';
describe('ol.format.WKT', function() { describe('ol.format.WKT', function() {
@@ -24,7 +24,7 @@ describe('ol.format.WKT', function() {
featureProjection: 'EPSG:3857' featureProjection: 'EPSG:3857'
}); });
expect(geom.getCoordinates()).to.eql( expect(geom.getCoordinates()).to.eql(
_ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
}); });
}); });
@@ -54,7 +54,7 @@ describe('ol.format.WKT', function() {
}); });
var geom = feature.getGeometry(); var geom = feature.getGeometry();
expect(geom.getCoordinates()).to.eql( expect(geom.getCoordinates()).to.eql(
_ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
}); });
}); });
@@ -91,9 +91,9 @@ describe('ol.format.WKT', function() {
expect(point1.getType()).to.eql('Point'); expect(point1.getType()).to.eql('Point');
expect(point2.getType()).to.eql('Point'); expect(point2.getType()).to.eql('Point');
expect(point1.getCoordinates()).to.eql( expect(point1.getCoordinates()).to.eql(
_ol_proj_.transform([1, 2], 'EPSG:4326', 'EPSG:3857')); transform([1, 2], 'EPSG:4326', 'EPSG:3857'));
expect(point2.getCoordinates()).to.eql( expect(point2.getCoordinates()).to.eql(
_ol_proj_.transform([4, 5], 'EPSG:4326', 'EPSG:3857')); transform([4, 5], 'EPSG:4326', 'EPSG:3857'));
}); });
}); });

View File

@@ -1,6 +1,6 @@
import _ol_Graticule_ from '../../../src/ol/Graticule.js'; import _ol_Graticule_ from '../../../src/ol/Graticule.js';
import _ol_Map_ from '../../../src/ol/Map.js'; import _ol_Map_ from '../../../src/ol/Map.js';
import _ol_proj_ from '../../../src/ol/proj.js'; import {get as getProjection} from '../../../src/ol/proj.js';
import _ol_style_Stroke_ from '../../../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../../../src/ol/style/Stroke.js';
import _ol_style_Text_ from '../../../src/ol/style/Text.js'; import _ol_style_Text_ from '../../../src/ol/style/Text.js';
@@ -18,7 +18,7 @@ describe('ol.Graticule', function() {
createGraticule(); createGraticule();
var extent = [-25614353.926475704, -7827151.696402049, var extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049]; 25614353.926475704, 7827151.696402049];
var projection = _ol_proj_.get('EPSG:3857'); var projection = getProjection('EPSG:3857');
var resolution = 39135.75848201024; var resolution = 39135.75848201024;
var squaredTolerance = resolution * resolution / 4.0; var squaredTolerance = resolution * resolution / 4.0;
graticule.updateProjectionInfo_(projection); graticule.updateProjectionInfo_(projection);
@@ -36,7 +36,7 @@ describe('ol.Graticule', function() {
}); });
var extent = [-25614353.926475704, -7827151.696402049, var extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049]; 25614353.926475704, 7827151.696402049];
var projection = _ol_proj_.get('EPSG:3857'); var projection = getProjection('EPSG:3857');
var resolution = 39135.75848201024; var resolution = 39135.75848201024;
var squaredTolerance = resolution * resolution / 4.0; var squaredTolerance = resolution * resolution / 4.0;
graticule.updateProjectionInfo_(projection); graticule.updateProjectionInfo_(projection);
@@ -91,7 +91,7 @@ describe('ol.Graticule', function() {
}); });
var extent = [-25614353.926475704, -7827151.696402049, var extent = [-25614353.926475704, -7827151.696402049,
25614353.926475704, 7827151.696402049]; 25614353.926475704, 7827151.696402049];
var projection = _ol_proj_.get('EPSG:3857'); var projection = getProjection('EPSG:3857');
var resolution = 39135.75848201024; var resolution = 39135.75848201024;
var squaredTolerance = resolution * resolution / 4.0; var squaredTolerance = resolution * resolution / 4.0;
graticule.updateProjectionInfo_(projection); graticule.updateProjectionInfo_(projection);

Some files were not shown because too many files have changed in this diff Show More