Named exports from ol/proj
This commit is contained in:
committed by
Andreas Hocevar
parent
fab77e8d37
commit
6f72ffe498
@@ -12,7 +12,7 @@ import _ol_events_EventType_ from './events/EventType.js';
|
||||
import _ol_geom_Polygon_ from './geom/Polygon.js';
|
||||
import _ol_has_ from './has.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';
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ var _ol_Geolocation_ = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.TransformFunction}
|
||||
*/
|
||||
this.transform_ = _ol_proj_.identityTransform;
|
||||
this.transform_ = identityTransform;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -108,8 +108,8 @@ _ol_Geolocation_.prototype.disposeInternal = function() {
|
||||
_ol_Geolocation_.prototype.handleProjectionChanged_ = function() {
|
||||
var projection = this.getProjection();
|
||||
if (projection) {
|
||||
this.transform_ = _ol_proj_.getTransformFromProjections(
|
||||
_ol_proj_.get('EPSG:4326'), projection);
|
||||
this.transform_ = getTransformFromProjections(
|
||||
getProjection('EPSG:4326'), projection);
|
||||
if (this.position_) {
|
||||
this.set(
|
||||
_ol_GeolocationProperty_.POSITION, this.transform_(this.position_));
|
||||
@@ -332,7 +332,7 @@ _ol_Geolocation_.prototype.getTrackingOptions = function() {
|
||||
* @api
|
||||
*/
|
||||
_ol_Geolocation_.prototype.setProjection = function(projection) {
|
||||
this.set(_ol_GeolocationProperty_.PROJECTION, _ol_proj_.get(projection));
|
||||
this.set(_ol_GeolocationProperty_.PROJECTION, getProjection(projection));
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_geom_LineString_ from './geom/LineString.js';
|
||||
import _ol_geom_Point_ from './geom/Point.js';
|
||||
import _ol_geom_flat_geodesic_ from './geom/flat/geodesic.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_style_Fill_ from './style/Fill.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_)
|
||||
];
|
||||
|
||||
validExtent = _ol_proj_.transformExtent(validExtent, this.projection_,
|
||||
validExtent = transformExtent(validExtent, this.projection_,
|
||||
'EPSG:4326');
|
||||
var maxLat = validExtent[3];
|
||||
var maxLon = validExtent[2];
|
||||
@@ -554,7 +554,7 @@ _ol_Graticule_.prototype.handlePostCompose_ = function(e) {
|
||||
resolution * resolution / (4 * pixelRatio * pixelRatio);
|
||||
|
||||
var updateProjectionInfo = !this.projection_ ||
|
||||
!_ol_proj_.equivalent(this.projection_, projection);
|
||||
!equivalentProjection(this.projection_, projection);
|
||||
|
||||
if (updateProjectionInfo) {
|
||||
this.updateProjectionInfo_(projection);
|
||||
@@ -598,11 +598,11 @@ _ol_Graticule_.prototype.handlePostCompose_ = function(e) {
|
||||
* @private
|
||||
*/
|
||||
_ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) {
|
||||
var epsg4326Projection = _ol_proj_.get('EPSG:4326');
|
||||
var epsg4326Projection = getProjection('EPSG:4326');
|
||||
|
||||
var extent = projection.getExtent();
|
||||
var worldExtent = projection.getWorldExtent();
|
||||
var worldExtentP = _ol_proj_.transformExtent(worldExtent,
|
||||
var worldExtentP = transformExtent(worldExtent,
|
||||
epsg4326Projection, projection);
|
||||
|
||||
var maxLat = worldExtent[3];
|
||||
@@ -626,11 +626,9 @@ _ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) {
|
||||
this.minLonP_ = minLonP;
|
||||
|
||||
|
||||
this.fromLonLatTransform_ = _ol_proj_.getTransform(
|
||||
epsg4326Projection, projection);
|
||||
this.fromLonLatTransform_ = getTransform(epsg4326Projection, projection);
|
||||
|
||||
this.toLonLatTransform_ = _ol_proj_.getTransform(
|
||||
projection, epsg4326Projection);
|
||||
this.toLonLatTransform_ = getTransform(projection, epsg4326Projection);
|
||||
|
||||
this.projectionCenterLonLat_ = this.toLonLatTransform_(getCenter(extent));
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import _ol_geom_Polygon_ from './geom/Polygon.js';
|
||||
import _ol_geom_SimpleGeometry_ from './geom/SimpleGeometry.js';
|
||||
import _ol_math_ from './math.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';
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ var _ol_View_ = function(opt_options) {
|
||||
* @const
|
||||
* @type {ol.proj.Projection}
|
||||
*/
|
||||
this.projection_ = _ol_proj_.createProjection(options.projection, 'EPSG:3857');
|
||||
this.projection_ = createProjection(options.projection, 'EPSG:3857');
|
||||
|
||||
this.applyOptions_(options);
|
||||
};
|
||||
@@ -1129,11 +1129,11 @@ _ol_View_.createResolutionConstraint_ = function(options) {
|
||||
resolutions);
|
||||
} else {
|
||||
// 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 size = !extent ?
|
||||
// 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() :
|
||||
Math.max(getWidth(extent), getHeight(extent));
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import _ol_events_ from '../events.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
import _ol_Object_ from '../Object.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
|
||||
@@ -200,7 +200,7 @@ _ol_control_MousePosition_.prototype.setCoordinateFormat = function(format) {
|
||||
* @api
|
||||
*/
|
||||
_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_) {
|
||||
var projection = this.getProjection();
|
||||
if (projection) {
|
||||
this.transform_ = _ol_proj_.getTransformFromProjections(
|
||||
this.transform_ = getTransformFromProjections(
|
||||
this.mapProjection_, projection);
|
||||
} else {
|
||||
this.transform_ = _ol_proj_.identityTransform;
|
||||
this.transform_ = identityTransform;
|
||||
}
|
||||
}
|
||||
var map = this.getMap();
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_control_Control_ from '../control/Control.js';
|
||||
import _ol_control_ScaleLineUnits_ from '../control/ScaleLineUnits.js';
|
||||
import _ol_css_ from '../css.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';
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ _ol_control_ScaleLine_.prototype.updateElement_ = function() {
|
||||
_ol_proj_Units_.DEGREES :
|
||||
_ol_proj_Units_.METERS;
|
||||
var pointResolution =
|
||||
_ol_proj_.getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
|
||||
getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
|
||||
if (units != _ol_control_ScaleLineUnits_.DEGREES) {
|
||||
pointResolution *= projection.getMetersPerUnit();
|
||||
}
|
||||
@@ -183,7 +183,7 @@ _ol_control_ScaleLine_.prototype.updateElement_ = function() {
|
||||
var nominalCount = this.minWidth_ * pointResolution;
|
||||
var suffix = '';
|
||||
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) {
|
||||
nominalCount *= metersPerDegree;
|
||||
} else {
|
||||
|
||||
@@ -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_orient_ from '../geom/flat/orient.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -547,7 +547,7 @@ _ol_format_EsriJSON_.prototype.readProjectionFromObject = function(object) {
|
||||
var esriJSONObject = /** @type {EsriJSONObject} */ (object);
|
||||
if (esriJSONObject.spatialReference && esriJSONObject.spatialReference.wkid) {
|
||||
var crs = esriJSONObject.spatialReference.wkid;
|
||||
return _ol_proj_.get('EPSG:' + crs);
|
||||
return getProjection('EPSG:' + crs);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -627,8 +627,7 @@ _ol_format_EsriJSON_.prototype.writeFeatureObject = function(
|
||||
_ol_format_EsriJSON_.writeGeometry_(geometry, opt_options);
|
||||
if (opt_options && opt_options.featureProjection) {
|
||||
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
|
||||
wkid: _ol_proj_.get(
|
||||
opt_options.featureProjection).getCode().split(':').pop()
|
||||
wkid: getProjection(opt_options.featureProjection).getCode().split(':').pop()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import _ol_geom_Geometry_ from '../geom/Geometry.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
|
||||
@@ -175,15 +175,15 @@ _ol_format_Feature_.prototype.writeGeometry = function(geometry, opt_options) {}
|
||||
_ol_format_Feature_.transformWithOptions = function(
|
||||
geometry, write, opt_options) {
|
||||
var featureProjection = opt_options ?
|
||||
_ol_proj_.get(opt_options.featureProjection) : null;
|
||||
getProjection(opt_options.featureProjection) : null;
|
||||
var dataProjection = opt_options ?
|
||||
_ol_proj_.get(opt_options.dataProjection) : null;
|
||||
getProjection(opt_options.dataProjection) : null;
|
||||
/**
|
||||
* @type {ol.geom.Geometry|ol.Extent}
|
||||
*/
|
||||
var transformed;
|
||||
if (featureProjection && dataProjection &&
|
||||
!_ol_proj_.equivalent(featureProjection, dataProjection)) {
|
||||
!equivalentProjection(featureProjection, dataProjection)) {
|
||||
if (geometry instanceof _ol_geom_Geometry_) {
|
||||
transformed = (write ? geometry.clone() : geometry).transform(
|
||||
write ? featureProjection : dataProjection,
|
||||
@@ -191,7 +191,7 @@ _ol_format_Feature_.transformWithOptions = function(
|
||||
} else {
|
||||
// FIXME this is necessary because ol.format.GML treats extents
|
||||
// as geometries
|
||||
transformed = _ol_proj_.transformExtent(
|
||||
transformed = transformExtent(
|
||||
geometry,
|
||||
dataProjection,
|
||||
featureProjection);
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_format_GMLBase_ from '../format/GMLBase.js';
|
||||
import _ol_format_XSD_ from '../format/XSD.js';
|
||||
import _ol_geom_Geometry_ from '../geom/Geometry.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';
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ _ol_format_GML2_.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
||||
var containerSrs = context['srsName'];
|
||||
var axisOrientation = 'enu';
|
||||
if (containerSrs) {
|
||||
var proj = _ol_proj_.get(containerSrs);
|
||||
var proj = getProjection(containerSrs);
|
||||
if (proj) {
|
||||
axisOrientation = proj.getAxisOrientation();
|
||||
}
|
||||
@@ -289,7 +289,7 @@ _ol_format_GML2_.prototype.writeGeometryElement = function(node, geometry, objec
|
||||
var value;
|
||||
if (Array.isArray(geometry)) {
|
||||
if (context.dataProjection) {
|
||||
value = _ol_proj_.transformExtent(
|
||||
value = transformExtent(
|
||||
geometry, context.featureProjection, context.dataProjection);
|
||||
} else {
|
||||
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) {
|
||||
var axisOrientation = 'enu';
|
||||
if (opt_srsName) {
|
||||
axisOrientation = _ol_proj_.get(opt_srsName).getAxisOrientation();
|
||||
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
|
||||
}
|
||||
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
||||
point[0] + ',' + point[1] :
|
||||
|
||||
@@ -14,7 +14,7 @@ import _ol_geom_MultiLineString_ from '../geom/MultiLineString.js';
|
||||
import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.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';
|
||||
|
||||
/**
|
||||
@@ -320,7 +320,7 @@ _ol_format_GML3_.prototype.readFlatPos_ = function(node, objectStack) {
|
||||
var containerSrs = context['srsName'];
|
||||
var axisOrientation = 'enu';
|
||||
if (containerSrs) {
|
||||
var proj = _ol_proj_.get(containerSrs);
|
||||
var proj = getProjection(containerSrs);
|
||||
axisOrientation = proj.getAxisOrientation();
|
||||
}
|
||||
if (axisOrientation === 'neu') {
|
||||
@@ -356,7 +356,7 @@ _ol_format_GML3_.prototype.readFlatPosList_ = function(node, objectStack) {
|
||||
var contextDimension = context['srsDimension'];
|
||||
var axisOrientation = 'enu';
|
||||
if (containerSrs) {
|
||||
var proj = _ol_proj_.get(containerSrs);
|
||||
var proj = getProjection(containerSrs);
|
||||
axisOrientation = proj.getAxisOrientation();
|
||||
}
|
||||
var coords = s.split(/\s+/);
|
||||
@@ -582,7 +582,7 @@ _ol_format_GML3_.prototype.writePos_ = function(node, value, objectStack) {
|
||||
var srsName = context['srsName'];
|
||||
var axisOrientation = 'enu';
|
||||
if (srsName) {
|
||||
axisOrientation = _ol_proj_.get(srsName).getAxisOrientation();
|
||||
axisOrientation = getProjection(srsName).getAxisOrientation();
|
||||
}
|
||||
var point = value.getCoordinates();
|
||||
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) {
|
||||
var axisOrientation = 'enu';
|
||||
if (opt_srsName) {
|
||||
axisOrientation = _ol_proj_.get(opt_srsName).getAxisOrientation();
|
||||
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
|
||||
}
|
||||
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
|
||||
point[0] + ' ' + point[1] :
|
||||
@@ -956,7 +956,7 @@ _ol_format_GML3_.prototype.writeGeometryElement = function(node, geometry, objec
|
||||
var value;
|
||||
if (Array.isArray(geometry)) {
|
||||
if (context.dataProjection) {
|
||||
value = _ol_proj_.transformExtent(
|
||||
value = transformExtent(
|
||||
geometry, context.featureProjection, context.dataProjection);
|
||||
} else {
|
||||
value = geometry;
|
||||
|
||||
@@ -18,7 +18,7 @@ import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.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';
|
||||
|
||||
/**
|
||||
@@ -592,7 +592,7 @@ _ol_format_GMLBase_.prototype.readFeaturesFromNode = function(node, opt_options)
|
||||
* @inheritDoc
|
||||
*/
|
||||
_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'));
|
||||
};
|
||||
export default _ol_format_GMLBase_;
|
||||
|
||||
@@ -11,7 +11,7 @@ import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js';
|
||||
import _ol_geom_LineString_ from '../geom/LineString.js';
|
||||
import _ol_geom_MultiLineString_ from '../geom/MultiLineString.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';
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ var _ol_format_GPX_ = function(opt_options) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get('EPSG:4326');
|
||||
this.defaultDataProjection = getProjection('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @type {function(ol.Feature, Node)|undefined}
|
||||
|
||||
@@ -17,7 +17,7 @@ import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -37,13 +37,13 @@ var _ol_format_GeoJSON_ = function(opt_options) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get(
|
||||
this.defaultDataProjection = getProjection(
|
||||
options.defaultDataProjection ?
|
||||
options.defaultDataProjection : 'EPSG:4326');
|
||||
|
||||
|
||||
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;
|
||||
if (crs) {
|
||||
if (crs.type == 'name') {
|
||||
projection = _ol_proj_.get(crs.properties.name);
|
||||
projection = getProjection(crs.properties.name);
|
||||
} else {
|
||||
_ol_asserts_.assert(false, 36); // Unknown SRS type
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_format_IGCZ_ from '../format/IGCZ.js';
|
||||
import _ol_format_TextFeature_ from '../format/TextFeature.js';
|
||||
import _ol_geom_GeometryLayout_ from '../geom/GeometryLayout.js';
|
||||
import _ol_geom_LineString_ from '../geom/LineString.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -28,7 +28,7 @@ var _ol_format_IGC_ = function(opt_options) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get('EPSG:4326');
|
||||
this.defaultDataProjection = getProjection('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -24,7 +24,7 @@ import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.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_Icon_ from '../style/Icon.js';
|
||||
import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js';
|
||||
@@ -59,7 +59,7 @@ var _ol_format_KML_ = function(opt_options) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get('EPSG:4326');
|
||||
this.defaultDataProjection = getProjection('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -12,7 +12,7 @@ import _ol_geom_LineString_ from '../geom/LineString.js';
|
||||
import _ol_geom_Point_ from '../geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.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';
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ var _ol_format_OSMXML_ = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get('EPSG:4326');
|
||||
this.defaultDataProjection = getProjection('EPSG:4326');
|
||||
};
|
||||
|
||||
inherits(_ol_format_OSMXML_, _ol_format_XMLFeature_);
|
||||
|
||||
@@ -11,7 +11,7 @@ import _ol_geom_LineString_ from '../geom/LineString.js';
|
||||
import _ol_geom_SimpleGeometry_ from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_flip_ from '../geom/flat/flip.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
|
||||
@@ -33,7 +33,7 @@ var _ol_format_Polyline_ = function(opt_options) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get('EPSG:4326');
|
||||
this.defaultDataProjection = getProjection('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -11,7 +11,7 @@ import _ol_geom_MultiPoint_ from '../geom/MultiPoint.js';
|
||||
import _ol_geom_MultiPolygon_ from '../geom/MultiPolygon.js';
|
||||
import _ol_geom_Point_ from '../geom/Point.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -43,7 +43,7 @@ var _ol_format_TopoJSON_ = function(opt_options) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = _ol_proj_.get(
|
||||
this.defaultDataProjection = getProjection(
|
||||
options.defaultDataProjection ?
|
||||
options.defaultDataProjection : 'EPSG:4326');
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import _ol_format_XMLFeature_ from '../format/XMLFeature.js';
|
||||
import _ol_format_XSD_ from '../format/XSD.js';
|
||||
import _ol_geom_Geometry_ from '../geom/Geometry.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';
|
||||
|
||||
/**
|
||||
@@ -1098,7 +1098,7 @@ _ol_format_WFS_.prototype.readProjectionFromNode = function(node) {
|
||||
n.firstChild.nodeType === 3))) {
|
||||
var objectStack = [{}];
|
||||
this.gmlFormat_.readGeometryElement(n, objectStack);
|
||||
return _ol_proj_.get(objectStack.pop().srsName);
|
||||
return getProjection(objectStack.pop().srsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import _ol_Object_ from '../Object.js';
|
||||
import {createEmpty, getHeight, returnOrUpdate} from '../extent.js';
|
||||
import _ol_functions_ from '../functions.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_transform_ from '../transform.js';
|
||||
|
||||
@@ -255,7 +255,7 @@ _ol_geom_Geometry_.prototype.translate = function(deltaX, deltaY) {};
|
||||
*/
|
||||
_ol_geom_Geometry_.prototype.transform = function(source, destination) {
|
||||
var tmpTransform = this.tmpTransform_;
|
||||
source = _ol_proj_.get(source);
|
||||
source = getProjection(source);
|
||||
var transformFn = source.getUnits() == _ol_proj_Units_.TILE_PIXELS ?
|
||||
function(inCoordinates, outCoordinates, stride) {
|
||||
var pixelExtent = source.getExtent();
|
||||
@@ -267,9 +267,9 @@ _ol_geom_Geometry_.prototype.transform = function(source, destination) {
|
||||
0, 0);
|
||||
_ol_geom_flat_transform_.transform2D(inCoordinates, 0, inCoordinates.length, stride,
|
||||
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);
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/flat/geodesic
|
||||
*/
|
||||
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_ = {};
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
|
||||
_ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
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 sinLat1 = Math.sin(_ol_math_.toRadians(lat1));
|
||||
@@ -123,7 +123,7 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
||||
Math.atan2(Math.sin(theta) * sinD * cosLat1,
|
||||
cosD - sinLat1 * Math.sin(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.
|
||||
*/
|
||||
_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_(
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
@@ -146,7 +146,7 @@ _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squared
|
||||
function(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.
|
||||
*/
|
||||
_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_(
|
||||
/**
|
||||
* @param {number} frac Fraction.
|
||||
@@ -169,6 +169,6 @@ _ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squared
|
||||
function(frac) {
|
||||
return [lon1 + ((lon2 - lon1) * frac), lat];
|
||||
},
|
||||
_ol_proj_.getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||
};
|
||||
export default _ol_geom_flat_geodesic_;
|
||||
|
||||
@@ -9,7 +9,7 @@ import _ol_events_ from '../events.js';
|
||||
import _ol_events_Event_ from '../events/Event.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -41,7 +41,7 @@ var _ol_interaction_DragAndDrop_ = function(opt_options) {
|
||||
* @type {ol.proj.Projection}
|
||||
*/
|
||||
this.projection_ = options.projection ?
|
||||
_ol_proj_.get(options.projection) : null;
|
||||
getProjection(options.projection) : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
471
src/ol/proj.js
471
src/ol/proj.js
@@ -1,17 +1,16 @@
|
||||
/**
|
||||
* @module ol/proj
|
||||
*/
|
||||
import _ol_Sphere_ from './Sphere.js';
|
||||
import Sphere from './Sphere.js';
|
||||
import {applyTransform} from './extent.js';
|
||||
import _ol_math_ from './math.js';
|
||||
import _ol_proj_EPSG3857_ from './proj/EPSG3857.js';
|
||||
import _ol_proj_EPSG4326_ from './proj/EPSG4326.js';
|
||||
import _ol_proj_Projection_ from './proj/Projection.js';
|
||||
import _ol_proj_Units_ from './proj/Units.js';
|
||||
import math from './math.js';
|
||||
import EPSG3857 from './proj/EPSG3857.js';
|
||||
import EPSG4326 from './proj/EPSG4326.js';
|
||||
import Projection from './proj/Projection.js';
|
||||
import Units from './proj/Units.js';
|
||||
import _ol_proj_proj4_ from './proj/proj4.js';
|
||||
import _ol_proj_projections_ from './proj/projections.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>}
|
||||
* @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.
|
||||
* @private
|
||||
* @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.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.setProj4 = function(proj4) {
|
||||
export function setProj4(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.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.getPointResolution = function(projection, resolution, point, opt_units) {
|
||||
projection = _ol_proj_.get(projection);
|
||||
export function getPointResolution(projection, resolution, point, opt_units) {
|
||||
projection = get(projection);
|
||||
var pointResolution;
|
||||
var getter = projection.getPointResolutionFunc();
|
||||
if (getter) {
|
||||
pointResolution = getter(resolution, point);
|
||||
} else {
|
||||
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;
|
||||
} else {
|
||||
// Estimate point resolution by transforming the center pixel to EPSG:4326,
|
||||
// measuring its width and height on the normal sphere, and taking the
|
||||
// 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 = [
|
||||
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
|
||||
];
|
||||
vertices = toEPSG4326(vertices, vertices, 2);
|
||||
var width = _ol_proj_.SPHERE_.haversineDistance(
|
||||
var width = SPHERE.haversineDistance(
|
||||
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));
|
||||
pointResolution = (width + height) / 2;
|
||||
var metersPerUnit = opt_units ?
|
||||
_ol_proj_Units_.METERS_PER_UNIT[opt_units] :
|
||||
Units.METERS_PER_UNIT[opt_units] :
|
||||
projection.getMetersPerUnit();
|
||||
if (metersPerUnit !== undefined) {
|
||||
pointResolution /= metersPerUnit;
|
||||
@@ -104,7 +189,7 @@ _ol_proj_.getPointResolution = function(projection, resolution, point, opt_units
|
||||
}
|
||||
}
|
||||
return pointResolution;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -114,16 +199,16 @@ _ol_proj_.getPointResolution = function(projection, resolution, point, opt_units
|
||||
* @param {Array.<ol.proj.Projection>} projections Projections.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.addEquivalentProjections = function(projections) {
|
||||
_ol_proj_.addProjections(projections);
|
||||
export function addEquivalentProjections(projections) {
|
||||
addProjections(projections);
|
||||
projections.forEach(function(source) {
|
||||
projections.forEach(function(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
|
||||
* 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) {
|
||||
projections2.forEach(function(projection2) {
|
||||
_ol_proj_transforms_.add(projection1, projection2, forwardTransform);
|
||||
_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.
|
||||
*/
|
||||
_ol_proj_.clearAllProjections = function() {
|
||||
export function clearAllProjections() {
|
||||
_ol_proj_projections_.clear();
|
||||
_ol_proj_transforms_.clear();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -184,15 +248,48 @@ _ol_proj_.clearAllProjections = function() {
|
||||
* @param {string} defaultCode Default code.
|
||||
* @return {ol.proj.Projection} Projection.
|
||||
*/
|
||||
_ol_proj_.createProjection = function(projection, defaultCode) {
|
||||
export function createProjection(projection, defaultCode) {
|
||||
if (!projection) {
|
||||
return _ol_proj_.get(defaultCode);
|
||||
return get(defaultCode);
|
||||
} else if (typeof projection === 'string') {
|
||||
return _ol_proj_.get(projection);
|
||||
return get(projection);
|
||||
} else {
|
||||
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}.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.addCoordinateTransforms = function(source, destination, forward, inverse) {
|
||||
var sourceProj = _ol_proj_.get(source);
|
||||
var destProj = _ol_proj_.get(destination);
|
||||
export function addCoordinateTransforms(source, destination, forward, inverse) {
|
||||
var sourceProj = get(source);
|
||||
var destProj = get(destination);
|
||||
_ol_proj_transforms_.add(sourceProj, destProj,
|
||||
_ol_proj_.createTransformFromCoordinateTransform(forward));
|
||||
createTransformFromCoordinateTransform(forward));
|
||||
_ol_proj_transforms_.add(destProj, sourceProj,
|
||||
_ol_proj_.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;
|
||||
});
|
||||
};
|
||||
createTransformFromCoordinateTransform(inverse));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -266,10 +330,10 @@ _ol_proj_.createTransformFromCoordinateTransform = function(transform) {
|
||||
* @return {ol.Coordinate} Coordinate projected to the target projection.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.fromLonLat = function(coordinate, opt_projection) {
|
||||
return _ol_proj_.transform(coordinate, 'EPSG:4326',
|
||||
export function fromLonLat(coordinate, opt_projection) {
|
||||
return transform(coordinate, 'EPSG:4326',
|
||||
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.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.toLonLat = function(coordinate, opt_projection) {
|
||||
var lonLat = _ol_proj_.transform(coordinate,
|
||||
export function toLonLat(coordinate, opt_projection) {
|
||||
var lonLat = transform(coordinate,
|
||||
opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326');
|
||||
var lon = lonLat[0];
|
||||
if (lon < -180 || lon > 180) {
|
||||
lonLat[0] = _ol_math_.modulo(lon + 180, 360) - 180;
|
||||
lonLat[0] = math.modulo(lon + 180, 360) - 180;
|
||||
}
|
||||
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.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.equivalent = function(projection1, projection2) {
|
||||
export function equivalent(projection1, projection2) {
|
||||
if (projection1 === projection2) {
|
||||
return true;
|
||||
}
|
||||
@@ -339,11 +374,48 @@ _ol_proj_.equivalent = function(projection1, projection2) {
|
||||
if (projection1.getCode() === projection2.getCode()) {
|
||||
return equalUnits;
|
||||
} else {
|
||||
var transformFn = _ol_proj_.getTransformFromProjections(
|
||||
projection1, projection2);
|
||||
return transformFn === _ol_proj_.cloneTransform && equalUnits;
|
||||
var transformFunc = getTransformFromProjections(projection1, projection2);
|
||||
return transformFunc === 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.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.getTransform = function(source, destination) {
|
||||
var sourceProjection = _ol_proj_.get(source);
|
||||
var destinationProjection = _ol_proj_.get(destination);
|
||||
return _ol_proj_.getTransformFromProjections(
|
||||
export function getTransform(source, destination) {
|
||||
var sourceProjection = get(source);
|
||||
var destinationProjection = get(destination);
|
||||
return getTransformFromProjections(
|
||||
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.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.transform = function(coordinate, source, destination) {
|
||||
var transformFn = _ol_proj_.getTransform(source, destination);
|
||||
return transformFn(coordinate, undefined, coordinate.length);
|
||||
};
|
||||
export function transform(coordinate, source, destination) {
|
||||
var transformFunc = getTransform(source, destination);
|
||||
return transformFunc(coordinate, undefined, coordinate.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -470,10 +466,10 @@ _ol_proj_.transform = function(coordinate, source, destination) {
|
||||
* @return {ol.Extent} The transformed extent.
|
||||
* @api
|
||||
*/
|
||||
_ol_proj_.transformExtent = function(extent, source, destination) {
|
||||
var transformFn = _ol_proj_.getTransform(source, destination);
|
||||
return applyTransform(extent, transformFn);
|
||||
};
|
||||
export function transformExtent(extent, source, destination) {
|
||||
var transformFunc = getTransform(source, destination);
|
||||
return applyTransform(extent, transformFunc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -484,30 +480,29 @@ _ol_proj_.transformExtent = function(extent, source, destination) {
|
||||
* @param {ol.proj.Projection} destinationProjection Destination projection.
|
||||
* @return {ol.Coordinate} Point.
|
||||
*/
|
||||
_ol_proj_.transformWithProjections = function(point, sourceProjection, destinationProjection) {
|
||||
var transformFn = _ol_proj_.getTransformFromProjections(
|
||||
export function transformWithProjections(point, sourceProjection, destinationProjection) {
|
||||
var transformFunc = getTransformFromProjections(
|
||||
sourceProjection, destinationProjection);
|
||||
return transformFn(point);
|
||||
};
|
||||
return transformFunc(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* `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
|
||||
// projections with equal meaning.
|
||||
_ol_proj_.addEquivalentProjections(_ol_proj_EPSG3857_.PROJECTIONS);
|
||||
_ol_proj_.addEquivalentProjections(_ol_proj_EPSG4326_.PROJECTIONS);
|
||||
addEquivalentProjections(EPSG3857.PROJECTIONS);
|
||||
addEquivalentProjections(EPSG4326.PROJECTIONS);
|
||||
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
|
||||
// coordinates and back.
|
||||
_ol_proj_.addEquivalentTransforms(
|
||||
_ol_proj_EPSG4326_.PROJECTIONS,
|
||||
_ol_proj_EPSG3857_.PROJECTIONS,
|
||||
_ol_proj_EPSG3857_.fromEPSG4326,
|
||||
_ol_proj_EPSG3857_.toEPSG4326);
|
||||
};
|
||||
addEquivalentTransforms(
|
||||
EPSG4326.PROJECTIONS,
|
||||
EPSG3857.PROJECTIONS,
|
||||
EPSG3857.fromEPSG4326,
|
||||
EPSG3857.toEPSG4326);
|
||||
}
|
||||
|
||||
_ol_proj_.addCommon();
|
||||
export default _ol_proj_;
|
||||
addCommon();
|
||||
|
||||
@@ -10,7 +10,7 @@ import _ol_events_EventType_ from '../../events/EventType.js';
|
||||
import _ol_ext_rbush_ from 'rbush';
|
||||
import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, intersects} from '../../extent.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_render_ReplayType_ from '../../render/ReplayType.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);
|
||||
var tileProjection = sourceTile.getProjection();
|
||||
var reproject = false;
|
||||
if (!_ol_proj_.equivalent(projection, tileProjection)) {
|
||||
if (!equivalentProjection(projection, tileProjection)) {
|
||||
reproject = true;
|
||||
sourceTile.setProjection(projection);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import _ol_dom_ from './dom.js';
|
||||
import {containsCoordinate, createEmpty, extend, getHeight, getTopLeft, getWidth} from './extent.js';
|
||||
import _ol_math_ from './math.js';
|
||||
import _ol_proj_ from './proj.js';
|
||||
import {getPointResolution, transform} from './proj.js';
|
||||
var _ol_reproj_ = {};
|
||||
|
||||
|
||||
@@ -23,11 +23,10 @@ var _ol_reproj_ = {};
|
||||
_ol_reproj_.calculateSourceResolution = function(sourceProj, targetProj,
|
||||
targetCenter, targetResolution) {
|
||||
|
||||
var sourceCenter = _ol_proj_.transform(targetCenter, targetProj, sourceProj);
|
||||
var sourceCenter = transform(targetCenter, targetProj, sourceProj);
|
||||
|
||||
// calculate the ideal resolution of the source data
|
||||
var sourceResolution =
|
||||
_ol_proj_.getPointResolution(targetProj, targetResolution, targetCenter);
|
||||
var sourceResolution = getPointResolution(targetProj, targetResolution, targetCenter);
|
||||
|
||||
var targetMetersPerUnit = targetProj.getMetersPerUnit();
|
||||
if (targetMetersPerUnit !== undefined) {
|
||||
@@ -44,8 +43,7 @@ _ol_reproj_.calculateSourceResolution = function(sourceProj, targetProj,
|
||||
|
||||
var sourceExtent = sourceProj.getExtent();
|
||||
if (!sourceExtent || containsCoordinate(sourceExtent, sourceCenter)) {
|
||||
var compensationFactor =
|
||||
_ol_proj_.getPointResolution(sourceProj, sourceResolution, sourceCenter) /
|
||||
var compensationFactor = getPointResolution(sourceProj, sourceResolution, sourceCenter) /
|
||||
sourceResolution;
|
||||
if (isFinite(compensationFactor) && compensationFactor > 0) {
|
||||
sourceResolution /= compensationFactor;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {boundingExtent, createEmpty, extendCoordinate, getBottomLeft, getBottomRight,
|
||||
getTopLeft, getTopRight, getWidth, intersects} from '../extent.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>} */
|
||||
var transformInvCache = {};
|
||||
var transformInv = _ol_proj_.getTransform(this.targetProj_, this.sourceProj_);
|
||||
var transformInv = getTransform(this.targetProj_, this.sourceProj_);
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate} c A coordinate.
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
|
||||
import {applyTransform, intersects} from '../extent.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_TileImage_ from '../source/TileImage.js';
|
||||
import _ol_tilecoord_ from '../tilecoord.js';
|
||||
@@ -32,7 +32,7 @@ var _ol_source_BingMaps_ = function(options) {
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: 'anonymous',
|
||||
opaque: true,
|
||||
projection: _ol_proj_.get('EPSG:3857'),
|
||||
projection: getProjection('EPSG:3857'),
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
state: _ol_source_State_.LOADING,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
@@ -178,8 +178,8 @@ _ol_source_BingMaps_.prototype.handleImageryMetadataResponse = function(response
|
||||
}));
|
||||
|
||||
if (resource.imageryProviders) {
|
||||
var transform = _ol_proj_.getTransformFromProjections(
|
||||
_ol_proj_.get('EPSG:4326'), this.getProjection());
|
||||
var transform = getTransformFromProjections(
|
||||
getProjection('EPSG:4326'), this.getProjection());
|
||||
|
||||
this.setAttributions(function(frameState) {
|
||||
var attributions = [];
|
||||
|
||||
@@ -7,7 +7,7 @@ import _ol_ImageState_ from '../ImageState.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import _ol_events_Event_ from '../events/Event.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_source_Source_ from '../source/Source.js';
|
||||
|
||||
@@ -92,7 +92,7 @@ _ol_source_Image_.prototype.getImage = function(extent, resolution, pixelRatio,
|
||||
if (!ENABLE_RASTER_REPROJECTION ||
|
||||
!sourceProjection ||
|
||||
!projection ||
|
||||
_ol_proj_.equivalent(sourceProjection, projection)) {
|
||||
equivalent(sourceProjection, projection)) {
|
||||
if (sourceProjection) {
|
||||
projection = sourceProjection;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ _ol_source_Image_.prototype.getImage = function(extent, resolution, pixelRatio,
|
||||
} else {
|
||||
if (this.reprojectedImage_) {
|
||||
if (this.reprojectedRevision_ == this.getRevision() &&
|
||||
_ol_proj_.equivalent(
|
||||
equivalent(
|
||||
this.reprojectedImage_.getProjection(), projection) &&
|
||||
this.reprojectedImage_.getResolution() == resolution &&
|
||||
equals(this.reprojectedImage_.getExtent(), extent)) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_dom_ from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.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';
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ var _ol_source_ImageStatic_ = function(options) {
|
||||
_ol_source_Image_.call(this, {
|
||||
attributions: options.attributions,
|
||||
logo: options.logo,
|
||||
projection: _ol_proj_.get(options.projection)
|
||||
projection: getProjection(options.projection)
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import _ol_events_ from '../events.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
import {containsExtent, getCenter, getForViewAndSize, getHeight, getWidth} from '../extent.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_source_Image_ from '../source/Image.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) {
|
||||
return undefined;
|
||||
}
|
||||
var projectionObj = _ol_proj_.get(projection);
|
||||
var projectionObj = getProjection(projection);
|
||||
var sourceProjectionObj = this.getProjection();
|
||||
|
||||
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
|
||||
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,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits, nullFunction} from '../index.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';
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ var _ol_source_Source_ = function(options) {
|
||||
* @private
|
||||
* @type {ol.proj.Projection}
|
||||
*/
|
||||
this.projection_ = _ol_proj_.get(options.projection);
|
||||
this.projection_ = getProjection(options.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits, nullFunction} from '../index.js';
|
||||
import _ol_TileCache_ from '../TileCache.js';
|
||||
import _ol_TileState_ from '../TileState.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_source_Source_ from '../source/Source.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) {
|
||||
var thisProj = this.getProjection();
|
||||
if (thisProj && !_ol_proj_.equivalent(thisProj, projection)) {
|
||||
if (thisProj && !equivalent(thisProj, projection)) {
|
||||
return null;
|
||||
} else {
|
||||
return this.tileCache;
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_TileCache_ from '../TileCache.js';
|
||||
import _ol_TileState_ from '../TileState.js';
|
||||
import _ol_events_ from '../events.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_source_UrlTile_ from '../source/UrlTile.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) {
|
||||
if (ENABLE_RASTER_REPROJECTION &&
|
||||
this.getProjection() && projection &&
|
||||
!_ol_proj_.equivalent(this.getProjection(), projection)) {
|
||||
this.getProjection() && projection && !equivalent(this.getProjection(), projection)) {
|
||||
return 0;
|
||||
} else {
|
||||
return this.getGutterInternal();
|
||||
@@ -154,8 +153,7 @@ _ol_source_TileImage_.prototype.getGutterInternal = function() {
|
||||
*/
|
||||
_ol_source_TileImage_.prototype.getOpaque = function(projection) {
|
||||
if (ENABLE_RASTER_REPROJECTION &&
|
||||
this.getProjection() && projection &&
|
||||
!_ol_proj_.equivalent(this.getProjection(), projection)) {
|
||||
this.getProjection() && projection && !equivalent(this.getProjection(), projection)) {
|
||||
return false;
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
var thisProj = this.getProjection();
|
||||
if (this.tileGrid &&
|
||||
(!thisProj || _ol_proj_.equivalent(thisProj, projection))) {
|
||||
if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
|
||||
return this.tileGrid;
|
||||
} else {
|
||||
var projKey = getUid(projection).toString();
|
||||
@@ -192,8 +189,7 @@ _ol_source_TileImage_.prototype.getTileCacheForProjection = function(projection)
|
||||
if (!ENABLE_RASTER_REPROJECTION) {
|
||||
return _ol_source_UrlTile_.prototype.getTileCacheForProjection.call(this, projection);
|
||||
}
|
||||
var thisProj = this.getProjection();
|
||||
if (!thisProj || _ol_proj_.equivalent(thisProj, projection)) {
|
||||
var thisProj = this.getProjection(); if (!thisProj || equivalent(thisProj, projection)) {
|
||||
return this.tileCache;
|
||||
} else {
|
||||
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) {
|
||||
var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection());
|
||||
if (!ENABLE_RASTER_REPROJECTION ||
|
||||
!sourceProjection || !projection ||
|
||||
_ol_proj_.equivalent(sourceProjection, projection)) {
|
||||
!sourceProjection || !projection || equivalent(sourceProjection, projection)) {
|
||||
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection);
|
||||
} else {
|
||||
var cache = this.getTileCacheForProjection(projection);
|
||||
@@ -356,7 +351,7 @@ _ol_source_TileImage_.prototype.setRenderReprojectionEdges = function(render) {
|
||||
*/
|
||||
_ol_source_TileImage_.prototype.setTileGridForProjection = function(projection, tilegrid) {
|
||||
if (ENABLE_RASTER_REPROJECTION) {
|
||||
var proj = _ol_proj_.get(projection);
|
||||
var proj = getProjection(projection);
|
||||
if (proj) {
|
||||
var projKey = getUid(proj).toString();
|
||||
if (!(projKey in this.tileGridForProjection)) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
|
||||
import _ol_asserts_ from '../asserts.js';
|
||||
import {applyTransform, intersects} from '../extent.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_TileImage_ from '../source/TileImage.js';
|
||||
import _ol_tilegrid_ from '../tilegrid.js';
|
||||
@@ -38,7 +38,7 @@ var _ol_source_TileJSON_ = function(options) {
|
||||
attributions: options.attributions,
|
||||
cacheSize: options.cacheSize,
|
||||
crossOrigin: options.crossOrigin,
|
||||
projection: _ol_proj_.get('EPSG:3857'),
|
||||
projection: getProjection('EPSG:3857'),
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
state: _ol_source_State_.LOADING,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
@@ -114,12 +114,12 @@ _ol_source_TileJSON_.prototype.getTileJSON = function() {
|
||||
*/
|
||||
_ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
|
||||
var epsg4326Projection = _ol_proj_.get('EPSG:4326');
|
||||
var epsg4326Projection = getProjection('EPSG:4326');
|
||||
|
||||
var sourceProjection = this.getProjection();
|
||||
var extent;
|
||||
if (tileJSON.bounds !== undefined) {
|
||||
var transform = _ol_proj_.getTransformFromProjections(
|
||||
var transform = getTransformFromProjections(
|
||||
epsg4326Projection, sourceProjection);
|
||||
extent = applyTransform(tileJSON.bounds, transform);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import _ol_events_ from '../events.js';
|
||||
import _ol_events_EventType_ from '../events/EventType.js';
|
||||
import {applyTransform, intersects} from '../extent.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_Tile_ from '../source/Tile.js';
|
||||
import _ol_tilecoord_ from '../tilecoord.js';
|
||||
@@ -27,7 +27,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
|
||||
*/
|
||||
var _ol_source_TileUTFGrid_ = function(options) {
|
||||
_ol_source_Tile_.call(this, {
|
||||
projection: _ol_proj_.get('EPSG:3857'),
|
||||
projection: getProjection('EPSG:3857'),
|
||||
state: _ol_source_State_.LOADING
|
||||
});
|
||||
|
||||
@@ -166,12 +166,12 @@ _ol_source_TileUTFGrid_.prototype.handleTileJSONError = function() {
|
||||
*/
|
||||
_ol_source_TileUTFGrid_.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
|
||||
var epsg4326Projection = _ol_proj_.get('EPSG:4326');
|
||||
var epsg4326Projection = getProjection('EPSG:4326');
|
||||
|
||||
var sourceProjection = this.getProjection();
|
||||
var extent;
|
||||
if (tileJSON.bounds !== undefined) {
|
||||
var transform = _ol_proj_.getTransformFromProjections(
|
||||
var transform = getTransformFromProjections(
|
||||
epsg4326Projection, sourceProjection);
|
||||
extent = applyTransform(tileJSON.bounds, transform);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import _ol_asserts_ from '../asserts.js';
|
||||
import {buffer, createEmpty} from '../extent.js';
|
||||
import _ol_obj_ from '../obj.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_size_ from '../size.js';
|
||||
import _ol_source_TileImage_ from '../source/TileImage.js';
|
||||
@@ -110,7 +110,7 @@ inherits(_ol_source_TileWMS_, _ol_source_TileImage_);
|
||||
* @api
|
||||
*/
|
||||
_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 tileGrid = this.getTileGrid();
|
||||
@@ -137,8 +137,8 @@ _ol_source_TileWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolu
|
||||
|
||||
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
|
||||
tileResolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution);
|
||||
tileExtent = _ol_proj_.transformExtent(tileExtent, projectionObj, sourceProjectionObj);
|
||||
coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj);
|
||||
tileExtent = transformExtent(tileExtent, projectionObj, sourceProjectionObj);
|
||||
coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
|
||||
}
|
||||
|
||||
var baseParams = {
|
||||
|
||||
@@ -6,7 +6,7 @@ import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import {containsExtent} from '../extent.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_WMTSRequestEncoding_ from '../source/WMTSRequestEncoding.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'];
|
||||
});
|
||||
var supportedCRS = tileMatrixSet['SupportedCRS'];
|
||||
var proj1 = _ol_proj_.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
_ol_proj_.get(supportedCRS);
|
||||
var proj2 = _ol_proj_.get(config['projection']);
|
||||
var proj1 = getProjection(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
getProjection(supportedCRS);
|
||||
var proj2 = getProjection(config['projection']);
|
||||
if (proj1 && proj2) {
|
||||
return _ol_proj_.equivalent(proj1, proj2);
|
||||
return equivalent(proj1, proj2);
|
||||
} else {
|
||||
return supportedCRS == config['projection'];
|
||||
}
|
||||
@@ -392,13 +392,13 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var projection;
|
||||
var code = matrixSetObj['SupportedCRS'];
|
||||
if (code) {
|
||||
projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
_ol_proj_.get(code);
|
||||
projection = getProjection(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
getProjection(code);
|
||||
}
|
||||
if ('projection' in config) {
|
||||
var projConfig = _ol_proj_.get(config['projection']);
|
||||
var projConfig = getProjection(config['projection']);
|
||||
if (projConfig) {
|
||||
if (!projection || _ol_proj_.equivalent(projConfig, projection)) {
|
||||
if (!projection || equivalent(projConfig, projection)) {
|
||||
projection = projConfig;
|
||||
}
|
||||
}
|
||||
@@ -407,10 +407,10 @@ _ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
|
||||
var wgs84BoundingBox = l['WGS84BoundingBox'];
|
||||
var extent, wrapX;
|
||||
if (wgs84BoundingBox !== undefined) {
|
||||
var wgs84ProjectionExtent = _ol_proj_.get('EPSG:4326').getExtent();
|
||||
var wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent();
|
||||
wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] &&
|
||||
wgs84BoundingBox[2] == wgs84ProjectionExtent[2]);
|
||||
extent = _ol_proj_.transformExtent(
|
||||
extent = transformExtent(
|
||||
wgs84BoundingBox, 'EPSG:4326', projection);
|
||||
var projectionExtent = projection.getExtent();
|
||||
if (projectionExtent) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import _ol_size_ from './size.js';
|
||||
import {containsCoordinate, createOrUpdate, getCorner, getHeight, getWidth} from './extent.js';
|
||||
import Corner from './extent/Corner.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_tilegrid_TileGrid_ from './tilegrid/TileGrid.js';
|
||||
var _ol_tilegrid_ = {};
|
||||
@@ -83,7 +83,7 @@ _ol_tilegrid_.createXYZ = function(opt_options) {
|
||||
_ol_obj_.assign(options, opt_options !== undefined ?
|
||||
opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({}));
|
||||
if (options.extent === undefined) {
|
||||
options.extent = _ol_proj_.get('EPSG:3857').getExtent();
|
||||
options.extent = getProjection('EPSG:3857').getExtent();
|
||||
}
|
||||
options.resolutions = _ol_tilegrid_.resolutionsFromExtent(
|
||||
options.extent, options.maxZoom, options.tileSize);
|
||||
@@ -147,10 +147,10 @@ _ol_tilegrid_.createForProjection = function(projection, opt_maxZoom, opt_tileSi
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
_ol_tilegrid_.extentFromProjection = function(projection) {
|
||||
projection = _ol_proj_.get(projection);
|
||||
projection = getProjection(projection);
|
||||
var extent = projection.getExtent();
|
||||
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();
|
||||
extent = createOrUpdate(-half, -half, half, half);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.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';
|
||||
|
||||
/**
|
||||
@@ -94,8 +94,8 @@ _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet = function(matrixSet, opt_ext
|
||||
var tileHeightPropName = 'TileHeight';
|
||||
|
||||
var code = matrixSet[supportedCRSPropName];
|
||||
var projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
_ol_proj_.get(code);
|
||||
var projection = getProjection(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
|
||||
getProjection(code);
|
||||
var metersPerUnit = projection.getMetersPerUnit();
|
||||
// swap origin x and y coordinates if axis orientation is lat/long
|
||||
var switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
|
||||
|
||||
Reference in New Issue
Block a user