rename _ol_math_ imports

This commit is contained in:
Ron Young
2017-12-20 19:31:00 -06:00
parent 8ef8f59cd9
commit a11208d126
36 changed files with 180 additions and 183 deletions

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 {defaults as defaultControls} from '../src/ol/control.js'; import {defaults as defaultControls} from '../src/ol/control.js';
import TileLayer from '../src/ol/layer/Tile.js'; import TileLayer from '../src/ol/layer/Tile.js';
import _ol_math_ from '../src/ol/math.js'; import {toRadians} from '../src/ol/math.js';
import _ol_source_OSM_ from '../src/ol/source/OSM.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js';
var view = new _ol_View_({ var view = new _ol_View_({
@@ -36,9 +36,9 @@ gn.init().then(function() {
gn.start(function(event) { gn.start(function(event) {
var center = view.getCenter(); var center = view.getCenter();
var resolution = view.getResolution(); var resolution = view.getResolution();
var alpha = _ol_math_.toRadians(event.do.beta); var alpha = toRadians(event.do.beta);
var beta = _ol_math_.toRadians(event.do.beta); var beta = toRadians(event.do.beta);
var gamma = _ol_math_.toRadians(event.do.gamma); var gamma = toRadians(event.do.gamma);
el('alpha').innerText = alpha + ' [rad]'; el('alpha').innerText = alpha + ' [rad]';
el('beta').innerText = beta + ' [rad]'; el('beta').innerText = beta + ' [rad]';

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/CenterConstraint * @module ol/CenterConstraint
*/ */
import _ol_math_ from './math.js'; import {clamp} from './math.js';
var _ol_CenterConstraint_ = {}; var _ol_CenterConstraint_ = {};
@@ -18,8 +18,8 @@ _ol_CenterConstraint_.createExtent = function(extent) {
function(center) { function(center) {
if (center) { if (center) {
return [ return [
_ol_math_.clamp(center[0], extent[0], extent[2]), clamp(center[0], extent[0], extent[2]),
_ol_math_.clamp(center[1], extent[1], extent[3]) clamp(center[1], extent[1], extent[3])
]; ];
} else { } else {
return undefined; return undefined;

View File

@@ -9,7 +9,7 @@ import _ol_events_ from './events.js';
import EventType from './events/EventType.js'; import EventType from './events/EventType.js';
import Polygon from './geom/Polygon.js'; import Polygon from './geom/Polygon.js';
import _ol_has_ from './has.js'; import _ol_has_ from './has.js';
import _ol_math_ from './math.js'; import {toRadians} from './math.js';
import {get as getProjection, getTransformFromProjections, identityTransform} 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';
@@ -164,7 +164,7 @@ Geolocation.prototype.positionChange_ = function(position) {
coords.altitudeAccuracy === null ? coords.altitudeAccuracy === null ?
undefined : coords.altitudeAccuracy); undefined : coords.altitudeAccuracy);
this.set(_ol_GeolocationProperty_.HEADING, coords.heading === null ? this.set(_ol_GeolocationProperty_.HEADING, coords.heading === null ?
undefined : _ol_math_.toRadians(coords.heading)); undefined : toRadians(coords.heading));
if (!this.position_) { if (!this.position_) {
this.position_ = [coords.longitude, coords.latitude]; this.position_ = [coords.longitude, coords.latitude];
} else { } else {

View File

@@ -7,7 +7,7 @@ import GeometryLayout from './geom/GeometryLayout.js';
import LineString from './geom/LineString.js'; import LineString from './geom/LineString.js';
import Point from './geom/Point.js'; import 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 {clamp} from './math.js';
import {get as getProjection, equivalent as equivalentProjection, getTransform, transformExtent} from './proj.js'; import {get as getProjection, equivalent as equivalentProjection, getTransform, transformExtent} from './proj.js';
import RenderEventType from './render/EventType.js'; import RenderEventType from './render/EventType.js';
import _ol_style_Fill_ from './style/Fill.js'; import _ol_style_Fill_ from './style/Fill.js';
@@ -357,7 +357,7 @@ Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) {
var flatCoordinates = lineString.getFlatCoordinates(); var flatCoordinates = lineString.getFlatCoordinates();
var clampedBottom = Math.max(extent[1], flatCoordinates[1]); var clampedBottom = Math.max(extent[1], flatCoordinates[1]);
var clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]); var clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]);
var lat = _ol_math_.clamp( var lat = clamp(
extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_, extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_,
clampedBottom, clampedTop); clampedBottom, clampedTop);
var coordinate = [flatCoordinates[0], lat]; var coordinate = [flatCoordinates[0], lat];
@@ -406,7 +406,7 @@ Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) {
var flatCoordinates = lineString.getFlatCoordinates(); var flatCoordinates = lineString.getFlatCoordinates();
var clampedLeft = Math.max(extent[0], flatCoordinates[0]); var clampedLeft = Math.max(extent[0], flatCoordinates[0]);
var clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]); var clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]);
var lon = _ol_math_.clamp( var lon = clamp(
extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_, extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_,
clampedLeft, clampedRight); clampedLeft, clampedRight);
var coordinate = [lon, flatCoordinates[1]]; var coordinate = [lon, flatCoordinates[1]];
@@ -461,7 +461,7 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
// Create meridians // Create meridians
centerLon = Math.floor(centerLon / interval) * interval; centerLon = Math.floor(centerLon / interval) * interval;
lon = _ol_math_.clamp(centerLon, this.minLon_, this.maxLon_); lon = clamp(centerLon, this.minLon_, this.maxLon_);
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0); idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0);
@@ -471,7 +471,7 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx); idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
} }
lon = _ol_math_.clamp(centerLon, this.minLon_, this.maxLon_); lon = clamp(centerLon, this.minLon_, this.maxLon_);
cnt = 0; cnt = 0;
while (lon != this.maxLon_ && cnt++ < maxLines) { while (lon != this.maxLon_ && cnt++ < maxLines) {
@@ -487,7 +487,7 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
// Create parallels // Create parallels
centerLat = Math.floor(centerLat / interval) * interval; centerLat = Math.floor(centerLat / interval) * interval;
lat = _ol_math_.clamp(centerLat, this.minLat_, this.maxLat_); lat = clamp(centerLat, this.minLat_, this.maxLat_);
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0); idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0);
@@ -497,7 +497,7 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx); idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
} }
lat = _ol_math_.clamp(centerLat, this.minLat_, this.maxLat_); lat = clamp(centerLat, this.minLat_, this.maxLat_);
cnt = 0; cnt = 0;
while (lat != this.maxLat_ && cnt++ < maxLines) { while (lat != this.maxLat_ && cnt++ < maxLines) {

View File

@@ -2,7 +2,7 @@
* @module ol/ResolutionConstraint * @module ol/ResolutionConstraint
*/ */
import {linearFindNearest} from './array.js'; import {linearFindNearest} from './array.js';
import _ol_math_ from './math.js'; import {clamp} from './math.js';
var _ol_ResolutionConstraint_ = {}; var _ol_ResolutionConstraint_ = {};
@@ -21,7 +21,7 @@ _ol_ResolutionConstraint_.createSnapToResolutions = function(resolutions) {
function(resolution, delta, direction) { function(resolution, delta, direction) {
if (resolution !== undefined) { if (resolution !== undefined) {
var z = linearFindNearest(resolutions, resolution, direction); var z = linearFindNearest(resolutions, resolution, direction);
z = _ol_math_.clamp(z + delta, 0, resolutions.length - 1); z = clamp(z + delta, 0, resolutions.length - 1);
var index = Math.floor(z); var index = Math.floor(z);
if (z != index && index < resolutions.length - 1) { if (z != index && index < resolutions.length - 1) {
var power = resolutions[index] / resolutions[index + 1]; var power = resolutions[index] / resolutions[index + 1];

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/RotationConstraint * @module ol/RotationConstraint
*/ */
import _ol_math_ from './math.js'; import {toRadians} from './math.js';
var _ol_RotationConstraint_ = {}; var _ol_RotationConstraint_ = {};
@@ -61,7 +61,7 @@ _ol_RotationConstraint_.createSnapToN = function(n) {
* @return {ol.RotationConstraintType} Rotation constraint. * @return {ol.RotationConstraintType} Rotation constraint.
*/ */
_ol_RotationConstraint_.createSnapToZero = function(opt_tolerance) { _ol_RotationConstraint_.createSnapToZero = function(opt_tolerance) {
var tolerance = opt_tolerance || _ol_math_.toRadians(5); var tolerance = opt_tolerance || toRadians(5);
return ( return (
/** /**
* @param {number|undefined} rotation Rotation. * @param {number|undefined} rotation Rotation.

View File

@@ -8,7 +8,7 @@
* http://www.movable-type.co.uk/scripts/latlong.html * http://www.movable-type.co.uk/scripts/latlong.html
* Licensed under CC-BY-3.0. * Licensed under CC-BY-3.0.
*/ */
import _ol_math_ from './math.js'; import {toRadians, toDegrees} from './math.js';
import GeometryType from './geom/GeometryType.js'; import GeometryType from './geom/GeometryType.js';
@@ -89,8 +89,8 @@ _ol_Sphere_.prototype.haversineDistance = function(c1, c2) {
* @return {ol.Coordinate} The target point. * @return {ol.Coordinate} The target point.
*/ */
_ol_Sphere_.prototype.offset = function(c1, distance, bearing) { _ol_Sphere_.prototype.offset = function(c1, distance, bearing) {
var lat1 = _ol_math_.toRadians(c1[1]); var lat1 = toRadians(c1[1]);
var lon1 = _ol_math_.toRadians(c1[0]); var lon1 = toRadians(c1[0]);
var dByR = distance / this.radius; var dByR = distance / this.radius;
var lat = Math.asin( var lat = Math.asin(
Math.sin(lat1) * Math.cos(dByR) + Math.sin(lat1) * Math.cos(dByR) +
@@ -98,7 +98,7 @@ _ol_Sphere_.prototype.offset = function(c1, distance, bearing) {
var lon = lon1 + Math.atan2( var lon = lon1 + Math.atan2(
Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1), Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),
Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)); Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat));
return [_ol_math_.toDegrees(lon), _ol_math_.toDegrees(lat)]; return [toDegrees(lon), toDegrees(lat)];
}; };
@@ -202,10 +202,10 @@ _ol_Sphere_.getLength_ = function(coordinates, radius) {
* @return {number} The great circle distance between the points (in meters). * @return {number} The great circle distance between the points (in meters).
*/ */
_ol_Sphere_.getDistance_ = function(c1, c2, radius) { _ol_Sphere_.getDistance_ = function(c1, c2, radius) {
var lat1 = _ol_math_.toRadians(c1[1]); var lat1 = toRadians(c1[1]);
var lat2 = _ol_math_.toRadians(c2[1]); var lat2 = toRadians(c2[1]);
var deltaLatBy2 = (lat2 - lat1) / 2; var deltaLatBy2 = (lat2 - lat1) / 2;
var deltaLonBy2 = _ol_math_.toRadians(c2[0] - c1[0]) / 2; var deltaLonBy2 = toRadians(c2[0] - c1[0]) / 2;
var a = Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) + var a = Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +
Math.sin(deltaLonBy2) * Math.sin(deltaLonBy2) * Math.sin(deltaLonBy2) * Math.sin(deltaLonBy2) *
Math.cos(lat1) * Math.cos(lat2); Math.cos(lat1) * Math.cos(lat2);
@@ -293,9 +293,9 @@ _ol_Sphere_.getArea_ = function(coordinates, radius) {
var y1 = coordinates[len - 1][1]; var y1 = coordinates[len - 1][1];
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
var x2 = coordinates[i][0], y2 = coordinates[i][1]; var x2 = coordinates[i][0], y2 = coordinates[i][1];
area += _ol_math_.toRadians(x2 - x1) * area += toRadians(x2 - x1) *
(2 + Math.sin(_ol_math_.toRadians(y1)) + (2 + Math.sin(toRadians(y1)) +
Math.sin(_ol_math_.toRadians(y2))); Math.sin(toRadians(y2)));
x1 = x2; x1 = x2;
y1 = y2; y1 = y2;
} }

View File

@@ -17,7 +17,7 @@ import {getForViewAndSize, getCenter, getHeight, getWidth, isEmpty} from './exte
import GeometryType from './geom/GeometryType.js'; import GeometryType from './geom/GeometryType.js';
import Polygon from './geom/Polygon.js'; import Polygon from './geom/Polygon.js';
import SimpleGeometry from './geom/SimpleGeometry.js'; import SimpleGeometry from './geom/SimpleGeometry.js';
import _ol_math_ from './math.js'; import {clamp, modulo} from './math.js';
import _ol_obj_ from './obj.js'; import _ol_obj_ from './obj.js';
import {createProjection, METERS_PER_UNIT} 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';
@@ -191,7 +191,7 @@ _ol_View_.prototype.applyOptions_ = function(options) {
this.maxResolution_, options.zoom - this.minZoom_); this.maxResolution_, options.zoom - this.minZoom_);
if (this.resolutions_) { // in case map zoom is out of min/max zoom range if (this.resolutions_) { // in case map zoom is out of min/max zoom range
properties[_ol_ViewProperty_.RESOLUTION] = _ol_math_.clamp( properties[_ol_ViewProperty_.RESOLUTION] = clamp(
Number(this.getResolution() || properties[_ol_ViewProperty_.RESOLUTION]), Number(this.getResolution() || properties[_ol_ViewProperty_.RESOLUTION]),
this.minResolution_, this.maxResolution_); this.minResolution_, this.maxResolution_);
} }
@@ -328,7 +328,7 @@ _ol_View_.prototype.animate = function(var_args) {
if (options.rotation !== undefined) { if (options.rotation !== undefined) {
animation.sourceRotation = rotation; animation.sourceRotation = rotation;
var delta = _ol_math_.modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI; var delta = modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI;
animation.targetRotation = rotation + delta; animation.targetRotation = rotation + delta;
rotation = animation.targetRotation; rotation = animation.targetRotation;
} }
@@ -436,7 +436,7 @@ _ol_View_.prototype.updateAnimations_ = function() {
} }
if (animation.sourceRotation !== undefined && animation.targetRotation !== undefined) { if (animation.sourceRotation !== undefined && animation.targetRotation !== undefined) {
var rotation = progress === 1 ? var rotation = progress === 1 ?
_ol_math_.modulo(animation.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : modulo(animation.targetRotation + Math.PI, 2 * Math.PI) - Math.PI :
animation.sourceRotation + progress * (animation.targetRotation - animation.sourceRotation); animation.sourceRotation + progress * (animation.targetRotation - animation.sourceRotation);
if (animation.anchor) { if (animation.anchor) {
this.set(_ol_ViewProperty_.CENTER, this.set(_ol_ViewProperty_.CENTER,

View File

@@ -2,7 +2,7 @@
* @module ol/color * @module ol/color
*/ */
import {assert} from './asserts.js'; import {assert} from './asserts.js';
import _ol_math_ from './math.js'; import {clamp} from './math.js';
/** /**
@@ -184,10 +184,10 @@ function fromStringInternal_(s) {
*/ */
export function normalize(color, opt_color) { export function normalize(color, opt_color) {
var result = opt_color || []; var result = opt_color || [];
result[0] = _ol_math_.clamp((color[0] + 0.5) | 0, 0, 255); result[0] = clamp((color[0] + 0.5) | 0, 0, 255);
result[1] = _ol_math_.clamp((color[1] + 0.5) | 0, 0, 255); result[1] = clamp((color[1] + 0.5) | 0, 0, 255);
result[2] = _ol_math_.clamp((color[2] + 0.5) | 0, 0, 255); result[2] = clamp((color[2] + 0.5) | 0, 0, 255);
result[3] = _ol_math_.clamp(color[3], 0, 1); result[3] = clamp(color[3], 0, 1);
return result; return result;
} }

View File

@@ -11,7 +11,7 @@ import {easeOut} from '../easing.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
import PointerEventType from '../pointer/EventType.js'; import PointerEventType from '../pointer/EventType.js';
import _ol_pointer_PointerEventHandler_ from '../pointer/PointerEventHandler.js'; import _ol_pointer_PointerEventHandler_ from '../pointer/PointerEventHandler.js';
@@ -338,7 +338,7 @@ ZoomSlider.prototype.getRelativePosition_ = function(x, y) {
} else { } else {
amount = y / this.heightLimit_; amount = y / this.heightLimit_;
} }
return _ol_math_.clamp(amount, 0, 1); return clamp(amount, 0, 1);
}; };

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/coordinate * @module ol/coordinate
*/ */
import _ol_math_ from './math.js'; import {modulo} from './math.js';
import _ol_string_ from './string.js'; import _ol_string_ from './string.js';
var _ol_coordinate_ = {}; var _ol_coordinate_ = {};
@@ -142,7 +142,7 @@ _ol_coordinate_.createStringXY = function(opt_fractionDigits) {
* @return {string} String. * @return {string} String.
*/ */
_ol_coordinate_.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) { _ol_coordinate_.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) {
var normalizedDegrees = _ol_math_.modulo(degrees + 180, 360) - 180; var normalizedDegrees = modulo(degrees + 180, 360) - 180;
var x = Math.abs(3600 * normalizedDegrees); var x = Math.abs(3600 * normalizedDegrees);
var dflPrecision = opt_fractionDigits || 0; var dflPrecision = opt_fractionDigits || 0;
var precision = Math.pow(10, dflPrecision); var precision = Math.pow(10, dflPrecision);

View File

@@ -18,7 +18,7 @@ import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js'; import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js'; import Polygon from '../geom/Polygon.js';
import _ol_math_ from '../math.js'; import {toRadians} from '../math.js';
import {get as getProjection} 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';
@@ -617,7 +617,7 @@ KML.IconStyleParser_ = function(node, objectStack) {
var heading = /** @type {number} */ var heading = /** @type {number} */
(object['heading']); (object['heading']);
if (heading !== undefined) { if (heading !== undefined) {
rotation = _ol_math_.toRadians(heading); rotation = toRadians(heading);
} }
var scale = /** @type {number|undefined} */ var scale = /** @type {number|undefined} */

View File

@@ -10,7 +10,7 @@ import Point from '../geom/Point.js';
import SimpleGeometry from '../geom/SimpleGeometry.js'; import SimpleGeometry from '../geom/SimpleGeometry.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_inflate_ from '../geom/flat/inflate.js'; import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
import _ol_math_ from '../math.js'; import {squaredDistance as squaredDx} from '../math.js';
/** /**
* @classdesc * @classdesc
@@ -69,7 +69,7 @@ MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
var stride = this.stride; var stride = this.stride;
var i, ii, j; var i, ii, j;
for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) { for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
var squaredDistance = _ol_math_.squaredDistance( var squaredDistance = squaredDx(
x, y, flatCoordinates[i], flatCoordinates[i + 1]); x, y, flatCoordinates[i], flatCoordinates[i + 1]);
if (squaredDistance < minSquaredDistance) { if (squaredDistance < minSquaredDistance) {
minSquaredDistance = squaredDistance; minSquaredDistance = squaredDistance;

View File

@@ -7,7 +7,7 @@ import GeometryLayout from '../geom/GeometryLayout.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import SimpleGeometry from '../geom/SimpleGeometry.js'; import SimpleGeometry from '../geom/SimpleGeometry.js';
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
import _ol_math_ from '../math.js'; import {squaredDistance as squaredDx} from '../math.js';
/** /**
* @classdesc * @classdesc
@@ -45,7 +45,7 @@ Point.prototype.clone = function() {
*/ */
Point.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) { Point.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {
var flatCoordinates = this.flatCoordinates; var flatCoordinates = this.flatCoordinates;
var squaredDistance = _ol_math_.squaredDistance( var squaredDistance = squaredDx(
x, y, flatCoordinates[0], flatCoordinates[1]); x, y, flatCoordinates[0], flatCoordinates[1]);
if (squaredDistance < minSquaredDistance) { if (squaredDistance < minSquaredDistance) {
var stride = this.stride; var stride = this.stride;

View File

@@ -18,7 +18,7 @@ import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js'; import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js'; import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
import _ol_math_ from '../math.js'; import {modulo} from '../math.js';
/** /**
* @classdesc * @classdesc
@@ -459,7 +459,7 @@ Polygon.makeRegular = function(polygon, center, radius, opt_angle) {
var angle, offset; var angle, offset;
for (var i = 0; i <= sides; ++i) { for (var i = 0; i <= sides; ++i) {
offset = i * stride; offset = i * stride;
angle = startAngle + (_ol_math_.modulo(i, sides) * 2 * Math.PI / sides); angle = startAngle + (modulo(i, sides) * 2 * Math.PI / sides);
flatCoordinates[offset] = center[0] + (radius * Math.cos(angle)); flatCoordinates[offset] = center[0] + (radius * Math.cos(angle));
flatCoordinates[offset + 1] = center[1] + (radius * Math.sin(angle)); flatCoordinates[offset + 1] = center[1] + (radius * Math.sin(angle));
} }

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/geom/flat/closest * @module ol/geom/flat/closest
*/ */
import _ol_math_ from '../../math.js'; import {lerp, squaredDistance as squaredDx} from '../../math.js';
var _ol_geom_flat_closest_ = {}; var _ol_geom_flat_closest_ = {};
@@ -31,7 +31,7 @@ _ol_geom_flat_closest_.point = function(flatCoordinates, offset1, offset2, strid
offset = offset2; offset = offset2;
} else if (t > 0) { } else if (t > 0) {
for (i = 0; i < stride; ++i) { for (i = 0; i < stride; ++i) {
closestPoint[i] = _ol_math_.lerp(flatCoordinates[offset1 + i], closestPoint[i] = lerp(flatCoordinates[offset1 + i],
flatCoordinates[offset2 + i], t); flatCoordinates[offset2 + i], t);
} }
closestPoint.length = stride; closestPoint.length = stride;
@@ -63,7 +63,7 @@ _ol_geom_flat_closest_.getMaxSquaredDelta = function(flatCoordinates, offset, en
for (offset += stride; offset < end; offset += stride) { for (offset += stride; offset < end; offset += stride) {
var x2 = flatCoordinates[offset]; var x2 = flatCoordinates[offset];
var y2 = flatCoordinates[offset + 1]; var y2 = flatCoordinates[offset + 1];
var squaredDelta = _ol_math_.squaredDistance(x1, y1, x2, y2); var squaredDelta = squaredDx(x1, y1, x2, y2);
if (squaredDelta > maxSquaredDelta) { if (squaredDelta > maxSquaredDelta) {
maxSquaredDelta = squaredDelta; maxSquaredDelta = squaredDelta;
} }
@@ -137,7 +137,7 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
var i, squaredDistance; var i, squaredDistance;
if (maxDelta === 0) { if (maxDelta === 0) {
// All points are identical, so just test the first point. // All points are identical, so just test the first point.
squaredDistance = _ol_math_.squaredDistance( squaredDistance = squaredDx(
x, y, flatCoordinates[offset], flatCoordinates[offset + 1]); x, y, flatCoordinates[offset], flatCoordinates[offset + 1]);
if (squaredDistance < minSquaredDistance) { if (squaredDistance < minSquaredDistance) {
for (i = 0; i < stride; ++i) { for (i = 0; i < stride; ++i) {
@@ -154,7 +154,7 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
while (index < end) { while (index < end) {
_ol_geom_flat_closest_.point( _ol_geom_flat_closest_.point(
flatCoordinates, index - stride, index, stride, x, y, tmpPoint); flatCoordinates, index - stride, index, stride, x, y, tmpPoint);
squaredDistance = _ol_math_.squaredDistance(x, y, tmpPoint[0], tmpPoint[1]); squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
if (squaredDistance < minSquaredDistance) { if (squaredDistance < minSquaredDistance) {
minSquaredDistance = squaredDistance; minSquaredDistance = squaredDistance;
for (i = 0; i < stride; ++i) { for (i = 0; i < stride; ++i) {
@@ -182,7 +182,7 @@ _ol_geom_flat_closest_.getClosestPoint = function(flatCoordinates, offset, end,
// Check the closing segment. // Check the closing segment.
_ol_geom_flat_closest_.point( _ol_geom_flat_closest_.point(
flatCoordinates, end - stride, offset, stride, x, y, tmpPoint); flatCoordinates, end - stride, offset, stride, x, y, tmpPoint);
squaredDistance = _ol_math_.squaredDistance(x, y, tmpPoint[0], tmpPoint[1]); squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);
if (squaredDistance < minSquaredDistance) { if (squaredDistance < minSquaredDistance) {
minSquaredDistance = squaredDistance; minSquaredDistance = squaredDistance;
for (i = 0; i < stride; ++i) { for (i = 0; i < stride; ++i) {

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/geom/flat/geodesic * @module ol/geom/flat/geodesic
*/ */
import _ol_math_ from '../../math.js'; import {squaredSegmentDistance, toRadians, toDegrees} from '../../math.js';
import {get as getProjection, getTransform} from '../../proj.js'; import {get as getProjection, getTransform} from '../../proj.js';
var _ol_geom_flat_geodesic_ = {}; var _ol_geom_flat_geodesic_ = {};
@@ -59,7 +59,7 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
fracM = (fracA + fracB) / 2; fracM = (fracA + fracB) / 2;
geoM = interpolate(fracM); geoM = interpolate(fracM);
m = transform(geoM); m = transform(geoM);
if (_ol_math_.squaredSegmentDistance(m[0], m[1], a[0], a[1], if (squaredSegmentDistance(m[0], m[1], a[0], a[1],
b[0], b[1]) < squaredTolerance) { b[0], b[1]) < squaredTolerance) {
// If the m point is sufficiently close to the straight line, then we // If the m point is sufficiently close to the straight line, then we
// discard it. Just use the b coordinate and move on to the next line // discard it. Just use the b coordinate and move on to the next line
@@ -95,12 +95,12 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
var geoProjection = getProjection('EPSG:4326'); var geoProjection = getProjection('EPSG:4326');
var cosLat1 = Math.cos(_ol_math_.toRadians(lat1)); var cosLat1 = Math.cos(toRadians(lat1));
var sinLat1 = Math.sin(_ol_math_.toRadians(lat1)); var sinLat1 = Math.sin(toRadians(lat1));
var cosLat2 = Math.cos(_ol_math_.toRadians(lat2)); var cosLat2 = Math.cos(toRadians(lat2));
var sinLat2 = Math.sin(_ol_math_.toRadians(lat2)); var sinLat2 = Math.sin(toRadians(lat2));
var cosDeltaLon = Math.cos(_ol_math_.toRadians(lon2 - lon1)); var cosDeltaLon = Math.cos(toRadians(lon2 - lon1));
var sinDeltaLon = Math.sin(_ol_math_.toRadians(lon2 - lon1)); var sinDeltaLon = Math.sin(toRadians(lon2 - lon1));
var d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon; var d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
return _ol_geom_flat_geodesic_.line_( return _ol_geom_flat_geodesic_.line_(
@@ -119,10 +119,10 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
var x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon; var x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon;
var theta = Math.atan2(y, x); var theta = Math.atan2(y, x);
var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta)); var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
var lon = _ol_math_.toRadians(lon1) + var lon = toRadians(lon1) +
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 [toDegrees(lon), toDegrees(lat)];
}, getTransform(geoProjection, projection), squaredTolerance); }, getTransform(geoProjection, projection), squaredTolerance);
}; };

View File

@@ -2,7 +2,7 @@
* @module ol/geom/flat/interpolate * @module ol/geom/flat/interpolate
*/ */
import {binarySearch} from '../../array.js'; import {binarySearch} from '../../array.js';
import _ol_math_ from '../../math.js'; import {lerp} from '../../math.js';
var _ol_geom_flat_interpolate_ = {}; var _ol_geom_flat_interpolate_ = {};
@@ -47,9 +47,9 @@ _ol_geom_flat_interpolate_.lineString = function(flatCoordinates, offset, end, s
var t = (target - cumulativeLengths[-index - 2]) / var t = (target - cumulativeLengths[-index - 2]) /
(cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]); (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);
var o = offset + (-index - 2) * stride; var o = offset + (-index - 2) * stride;
pointX = _ol_math_.lerp( pointX = lerp(
flatCoordinates[o], flatCoordinates[o + stride], t); flatCoordinates[o], flatCoordinates[o + stride], t);
pointY = _ol_math_.lerp( pointY = lerp(
flatCoordinates[o + 1], flatCoordinates[o + stride + 1], t); flatCoordinates[o + 1], flatCoordinates[o + stride + 1], t);
} else { } else {
pointX = flatCoordinates[offset + index * stride]; pointX = flatCoordinates[offset + index * stride];
@@ -120,7 +120,7 @@ _ol_geom_flat_interpolate_.lineStringCoordinateAtM = function(flatCoordinates, o
coordinate = []; coordinate = [];
var i; var i;
for (i = 0; i < stride - 1; ++i) { for (i = 0; i < stride - 1; ++i) {
coordinate.push(_ol_math_.lerp(flatCoordinates[(lo - 1) * stride + i], coordinate.push(lerp(flatCoordinates[(lo - 1) * stride + i],
flatCoordinates[lo * stride + i], t)); flatCoordinates[lo * stride + i], t));
} }
coordinate.push(m); coordinate.push(m);

View File

@@ -27,7 +27,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import _ol_math_ from '../../math.js'; import {squaredSegmentDistance, squaredDistance} from '../../math.js';
var _ol_geom_flat_simplify_ = {}; var _ol_geom_flat_simplify_ = {};
@@ -103,7 +103,7 @@ _ol_geom_flat_simplify_.douglasPeucker = function(flatCoordinates, offset, end,
for (i = first + stride; i < last; i += stride) { for (i = first + stride; i < last; i += stride) {
var x = flatCoordinates[i]; var x = flatCoordinates[i];
var y = flatCoordinates[i + 1]; var y = flatCoordinates[i + 1];
var squaredDistance = _ol_math_.squaredSegmentDistance( var squaredDistance = squaredSegmentDistance(
x, y, x1, y1, x2, y2); x, y, x1, y1, x2, y2);
if (squaredDistance > maxSquaredDistance) { if (squaredDistance > maxSquaredDistance) {
index = i; index = i;
@@ -221,7 +221,7 @@ _ol_geom_flat_simplify_.radialDistance = function(flatCoordinates, offset, end,
for (offset += stride; offset < end; offset += stride) { for (offset += stride; offset < end; offset += stride) {
x2 = flatCoordinates[offset]; x2 = flatCoordinates[offset];
y2 = flatCoordinates[offset + 1]; y2 = flatCoordinates[offset + 1];
if (_ol_math_.squaredDistance(x1, y1, x2, y2) > squaredTolerance) { if (squaredDistance(x1, y1, x2, y2) > squaredTolerance) {
// copy point at offset // copy point at offset
simplifiedFlatCoordinates[simplifiedOffset++] = x2; simplifiedFlatCoordinates[simplifiedOffset++] = x2;
simplifiedFlatCoordinates[simplifiedOffset++] = y2; simplifiedFlatCoordinates[simplifiedOffset++] = y2;

View File

@@ -1,7 +1,7 @@
/** /**
* @module ol/geom/flat/textpath * @module ol/geom/flat/textpath
*/ */
import _ol_math_ from '../../math.js'; import {lerp} from '../../math.js';
var _ol_geom_flat_textpath_ = {}; var _ol_geom_flat_textpath_ = {};
@@ -67,8 +67,8 @@ _ol_geom_flat_textpath_.lineString = function(
} }
} }
var interpolate = segmentPos / segmentLength; var interpolate = segmentPos / segmentLength;
var x = _ol_math_.lerp(x1, x2, interpolate); var x = lerp(x1, x2, interpolate);
var y = _ol_math_.lerp(y1, y2, interpolate); var y = lerp(y1, y2, interpolate);
if (previousAngle == angle) { if (previousAngle == angle) {
if (reverse) { if (reverse) {
data[0] = x; data[0] = x;

View File

@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import _ol_Object_ from '../Object.js'; import _ol_Object_ from '../Object.js';
import {easeOut, linear} from '../easing.js'; import {easeOut, linear} from '../easing.js';
import _ol_interaction_Property_ from '../interaction/Property.js'; import _ol_interaction_Property_ from '../interaction/Property.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
/** /**
@@ -198,7 +198,7 @@ Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
if (resolution !== undefined) { if (resolution !== undefined) {
var resolutions = view.getResolutions(); var resolutions = view.getResolutions();
resolution = _ol_math_.clamp( resolution = clamp(
resolution, resolution,
view.getMinResolution() || resolutions[resolutions.length - 1], view.getMinResolution() || resolutions[resolutions.length - 1],
view.getMaxResolution() || resolutions[0]); view.getMaxResolution() || resolutions[0]);

View File

@@ -7,7 +7,7 @@ import {easeOut} from '../easing.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import _ol_has_ from '../has.js'; import _ol_has_ from '../has.js';
import Interaction from '../interaction/Interaction.js'; import Interaction from '../interaction/Interaction.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
/** /**
@@ -260,7 +260,7 @@ _ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) {
view.cancelAnimations(); view.cancelAnimations();
} }
var maxDelta = MAX_DELTA; var maxDelta = MAX_DELTA;
var delta = _ol_math_.clamp(this.delta_, -maxDelta, maxDelta); var delta = clamp(this.delta_, -maxDelta, maxDelta);
Interaction.zoomByDelta(view, -delta, this.lastAnchor_, Interaction.zoomByDelta(view, -delta, this.lastAnchor_,
this.duration_); this.duration_);
this.mode_ = undefined; this.mode_ = undefined;

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Object_ from '../Object.js'; import _ol_Object_ from '../Object.js';
import _ol_layer_Property_ from '../layer/Property.js'; import _ol_layer_Property_ from '../layer/Property.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
/** /**
@@ -76,7 +76,7 @@ _ol_layer_Base_.prototype.getType = function() {
* @return {ol.LayerState} Layer state. * @return {ol.LayerState} Layer state.
*/ */
_ol_layer_Base_.prototype.getLayerState = function() { _ol_layer_Base_.prototype.getLayerState = function() {
this.state_.opacity = _ol_math_.clamp(this.getOpacity(), 0, 1); this.state_.opacity = clamp(this.getOpacity(), 0, 1);
this.state_.sourceState = this.getSourceState(); this.state_.sourceState = this.getSourceState();
this.state_.visible = this.getVisible(); this.state_.visible = this.getVisible();
this.state_.extent = this.getExtent(); this.state_.extent = this.getExtent();

View File

@@ -6,7 +6,7 @@ import {inherits} from '../index.js';
import _ol_Object_ from '../Object.js'; import _ol_Object_ from '../Object.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import _ol_layer_Vector_ from '../layer/Vector.js'; import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.js';
import RenderEventType from '../render/EventType.js'; import RenderEventType from '../render/EventType.js';
import _ol_style_Icon_ from '../style/Icon.js'; import _ol_style_Icon_ from '../style/Icon.js';
@@ -111,7 +111,7 @@ var Heatmap = function(opt_options) {
this.setStyle(function(feature, resolution) { this.setStyle(function(feature, resolution) {
var weight = weightFunction(feature); var weight = weightFunction(feature);
var opacity = weight !== undefined ? _ol_math_.clamp(weight, 0, 1) : 1; var opacity = weight !== undefined ? clamp(weight, 0, 1) : 1;
// cast to 8 bits // cast to 8 bits
var index = (255 * opacity) | 0; var index = (255 * opacity) | 0;
var style = this.styleCache_[index]; var style = this.styleCache_[index];

View File

@@ -2,8 +2,6 @@
* @module ol/math * @module ol/math
*/ */
import {assert} from './asserts.js'; import {assert} from './asserts.js';
var _ol_math_ = {};
/** /**
* Takes a number and clamps it to within the provided bounds. * Takes a number and clamps it to within the provided bounds.
@@ -13,9 +11,9 @@ var _ol_math_ = {};
* @return {number} The input number if it is within bounds, or the nearest * @return {number} The input number if it is within bounds, or the nearest
* number within the bounds. * number within the bounds.
*/ */
_ol_math_.clamp = function(value, min, max) { export function clamp(value, min, max) {
return Math.min(Math.max(value, min), max); return Math.min(Math.max(value, min), max);
}; }
/** /**
@@ -27,7 +25,7 @@ _ol_math_.clamp = function(value, min, max) {
* @param {number} x X. * @param {number} x X.
* @return {number} Hyperbolic cosine of x. * @return {number} Hyperbolic cosine of x.
*/ */
_ol_math_.cosh = (function() { export var cosh = (function() {
// Wrapped in a iife, to save the overhead of checking for the native // Wrapped in a iife, to save the overhead of checking for the native
// implementation on every invocation. // implementation on every invocation.
var cosh; var cosh;
@@ -49,10 +47,10 @@ _ol_math_.cosh = (function() {
* @param {number} x X. * @param {number} x X.
* @return {number} The smallest power of two greater than or equal to x. * @return {number} The smallest power of two greater than or equal to x.
*/ */
_ol_math_.roundUpToPowerOfTwo = function(x) { export function roundUpToPowerOfTwo(x) {
assert(0 < x, 29); // `x` must be greater than `0` assert(0 < x, 29); // `x` must be greater than `0`
return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2)); return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2));
}; }
/** /**
@@ -66,7 +64,7 @@ _ol_math_.roundUpToPowerOfTwo = function(x) {
* @param {number} y2 Y2. * @param {number} y2 Y2.
* @return {number} Squared distance. * @return {number} Squared distance.
*/ */
_ol_math_.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) { export function squaredSegmentDistance(x, y, x1, y1, x2, y2) {
var dx = x2 - x1; var dx = x2 - x1;
var dy = y2 - y1; var dy = y2 - y1;
if (dx !== 0 || dy !== 0) { if (dx !== 0 || dy !== 0) {
@@ -79,8 +77,8 @@ _ol_math_.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) {
y1 += dy * t; y1 += dy * t;
} }
} }
return _ol_math_.squaredDistance(x, y, x1, y1); return squaredDistance(x, y, x1, y1);
}; }
/** /**
@@ -91,11 +89,11 @@ _ol_math_.squaredSegmentDistance = function(x, y, x1, y1, x2, y2) {
* @param {number} y2 Y2. * @param {number} y2 Y2.
* @return {number} Squared distance. * @return {number} Squared distance.
*/ */
_ol_math_.squaredDistance = function(x1, y1, x2, y2) { export function squaredDistance(x1, y1, x2, y2) {
var dx = x2 - x1; var dx = x2 - x1;
var dy = y2 - y1; var dy = y2 - y1;
return dx * dx + dy * dy; return dx * dx + dy * dy;
}; }
/** /**
@@ -105,7 +103,7 @@ _ol_math_.squaredDistance = function(x1, y1, x2, y2) {
* in row-major order. * in row-major order.
* @return {Array.<number>} The resulting vector. * @return {Array.<number>} The resulting vector.
*/ */
_ol_math_.solveLinearSystem = function(mat) { export function solveLinearSystem(mat) {
var n = mat.length; var n = mat.length;
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
@@ -151,7 +149,7 @@ _ol_math_.solveLinearSystem = function(mat) {
} }
} }
return x; return x;
}; }
/** /**
@@ -160,9 +158,9 @@ _ol_math_.solveLinearSystem = function(mat) {
* @param {number} angleInRadians Angle in radians. * @param {number} angleInRadians Angle in radians.
* @return {number} Angle in degrees. * @return {number} Angle in degrees.
*/ */
_ol_math_.toDegrees = function(angleInRadians) { export function toDegrees(angleInRadians) {
return angleInRadians * 180 / Math.PI; return angleInRadians * 180 / Math.PI;
}; }
/** /**
@@ -171,9 +169,9 @@ _ol_math_.toDegrees = function(angleInRadians) {
* @param {number} angleInDegrees Angle in degrees. * @param {number} angleInDegrees Angle in degrees.
* @return {number} Angle in radians. * @return {number} Angle in radians.
*/ */
_ol_math_.toRadians = function(angleInDegrees) { export function toRadians(angleInDegrees) {
return angleInDegrees * Math.PI / 180; return angleInDegrees * Math.PI / 180;
}; }
/** /**
* Returns the modulo of a / b, depending on the sign of b. * Returns the modulo of a / b, depending on the sign of b.
@@ -182,10 +180,10 @@ _ol_math_.toRadians = function(angleInDegrees) {
* @param {number} b Divisor. * @param {number} b Divisor.
* @return {number} Modulo. * @return {number} Modulo.
*/ */
_ol_math_.modulo = function(a, b) { export function modulo(a, b) {
var r = a % b; var r = a % b;
return r * b < 0 ? r + b : r; return r * b < 0 ? r + b : r;
}; }
/** /**
* Calculates the linearly interpolated value of x between a and b. * Calculates the linearly interpolated value of x between a and b.
@@ -195,7 +193,6 @@ _ol_math_.modulo = function(a, b) {
* @param {number} x Value to be interpolated. * @param {number} x Value to be interpolated.
* @return {number} Interpolated value. * @return {number} Interpolated value.
*/ */
_ol_math_.lerp = function(a, b, x) { export function lerp(a, b, x) {
return a + x * (b - a); return a + x * (b - a);
}; }
export default _ol_math_;

View File

@@ -3,7 +3,7 @@
*/ */
import Sphere from './Sphere.js'; import Sphere from './Sphere.js';
import {applyTransform} from './extent.js'; import {applyTransform} from './extent.js';
import math from './math.js'; import {modulo} from './math.js';
import EPSG3857 from './proj/EPSG3857.js'; import EPSG3857 from './proj/EPSG3857.js';
import EPSG4326 from './proj/EPSG4326.js'; import EPSG4326 from './proj/EPSG4326.js';
import Projection from './proj/Projection.js'; import Projection from './proj/Projection.js';
@@ -323,7 +323,7 @@ export function toLonLat(coordinate, opt_projection) {
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] = math.modulo(lon + 180, 360) - 180; lonLat[0] = modulo(lon + 180, 360) - 180;
} }
return lonLat; return lonLat;
} }

View File

@@ -2,7 +2,7 @@
* @module ol/proj/EPSG3857 * @module ol/proj/EPSG3857
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_math_ from '../math.js'; import {cosh} from '../math.js';
import _ol_proj_Projection_ from '../proj/Projection.js'; import _ol_proj_Projection_ from '../proj/Projection.js';
import _ol_proj_Units_ from '../proj/Units.js'; import _ol_proj_Units_ from '../proj/Units.js';
var _ol_proj_EPSG3857_ = {}; var _ol_proj_EPSG3857_ = {};
@@ -25,7 +25,7 @@ _ol_proj_EPSG3857_.Projection_ = function(code) {
global: true, global: true,
worldExtent: _ol_proj_EPSG3857_.WORLD_EXTENT, worldExtent: _ol_proj_EPSG3857_.WORLD_EXTENT,
getPointResolution: function(resolution, point) { getPointResolution: function(resolution, point) {
return resolution / _ol_math_.cosh(point[1] / _ol_proj_EPSG3857_.RADIUS); return resolution / cosh(point[1] / _ol_proj_EPSG3857_.RADIUS);
} }
}); });
}; };

View File

@@ -10,7 +10,7 @@ import TileRange from '../../TileRange.js';
import _ol_TileState_ from '../../TileState.js'; import _ol_TileState_ from '../../TileState.js';
import {numberSafeCompareFunction} from '../../array.js'; import {numberSafeCompareFunction} from '../../array.js';
import {createEmpty, intersects} from '../../extent.js'; import {createEmpty, intersects} from '../../extent.js';
import _ol_math_ from '../../math.js'; import {roundUpToPowerOfTwo} from '../../math.js';
import RendererType from '../Type.js'; import RendererType from '../Type.js';
import _ol_renderer_webgl_Layer_ from '../webgl/Layer.js'; import _ol_renderer_webgl_Layer_ from '../webgl/Layer.js';
import _ol_renderer_webgl_tilelayershader_ from '../webgl/tilelayershader.js'; import _ol_renderer_webgl_tilelayershader_ from '../webgl/tilelayershader.js';
@@ -201,7 +201,7 @@ _ol_renderer_webgl_TileLayer_.prototype.prepareFrame = function(frameState, laye
var maxDimension = Math.max( var maxDimension = Math.max(
tileRangeSize[0] * tilePixelSize[0], tileRangeSize[0] * tilePixelSize[0],
tileRangeSize[1] * tilePixelSize[1]); tileRangeSize[1] * tilePixelSize[1]);
var framebufferDimension = _ol_math_.roundUpToPowerOfTwo(maxDimension); var framebufferDimension = roundUpToPowerOfTwo(maxDimension);
var framebufferExtentDimension = tilePixelResolution * framebufferDimension; var framebufferExtentDimension = tilePixelResolution * framebufferDimension;
var origin = tileGrid.getOrigin(z); var origin = tileGrid.getOrigin(z);
var minX = origin[0] + var minX = origin[0] +

View File

@@ -3,7 +3,7 @@
*/ */
import {createCanvasContext2D} from './dom.js'; import {createCanvasContext2D} 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 {solveLinearSystem} from './math.js';
import {getPointResolution, transform} from './proj.js'; import {getPointResolution, transform} from './proj.js';
var _ol_reproj_ = {}; var _ol_reproj_ = {};
@@ -181,7 +181,7 @@ _ol_reproj_.render = function(width, height, pixelRatio,
[0, 0, x1, y1, v1 - v0], [0, 0, x1, y1, v1 - v0],
[0, 0, x2, y2, v2 - v0] [0, 0, x2, y2, v2 - v0]
]; ];
var affineCoefs = _ol_math_.solveLinearSystem(augmentedMatrix); var affineCoefs = solveLinearSystem(augmentedMatrix);
if (!affineCoefs) { if (!affineCoefs) {
return; return;
} }

View File

@@ -8,7 +8,7 @@ import _ol_TileState_ from '../TileState.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {getArea, getCenter, getIntersection} from '../extent.js'; import {getArea, getCenter, getIntersection} from '../extent.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
import _ol_reproj_ from '../reproj.js'; import _ol_reproj_ from '../reproj.js';
import _ol_reproj_Triangulation_ from '../reproj/Triangulation.js'; import _ol_reproj_Triangulation_ from '../reproj/Triangulation.js';
@@ -157,9 +157,9 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid,
if (maxSourceExtent) { if (maxSourceExtent) {
if (sourceProj.canWrapX()) { if (sourceProj.canWrapX()) {
sourceExtent[1] = _ol_math_.clamp( sourceExtent[1] = clamp(
sourceExtent[1], maxSourceExtent[1], maxSourceExtent[3]); sourceExtent[1], maxSourceExtent[1], maxSourceExtent[3]);
sourceExtent[3] = _ol_math_.clamp( sourceExtent[3] = clamp(
sourceExtent[3], maxSourceExtent[1], maxSourceExtent[3]); sourceExtent[3], maxSourceExtent[1], maxSourceExtent[3]);
} else { } else {
sourceExtent = getIntersection(sourceExtent, maxSourceExtent); sourceExtent = getIntersection(sourceExtent, maxSourceExtent);

View File

@@ -3,7 +3,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 {modulo} from '../math.js';
import {getTransform} from '../proj.js'; import {getTransform} from '../proj.js';
@@ -270,10 +270,10 @@ _ol_reproj_Triangulation_.prototype.addQuad_ = function(a, b, c, d,
var dx; var dx;
if (wrapsX) { if (wrapsX) {
var centerSrcEstimX = var centerSrcEstimX =
(_ol_math_.modulo(aSrc[0], sourceWorldWidth) + (modulo(aSrc[0], sourceWorldWidth) +
_ol_math_.modulo(cSrc[0], sourceWorldWidth)) / 2; modulo(cSrc[0], sourceWorldWidth)) / 2;
dx = centerSrcEstimX - dx = centerSrcEstimX -
_ol_math_.modulo(centerSrc[0], sourceWorldWidth); modulo(centerSrc[0], sourceWorldWidth);
} else { } else {
dx = (aSrc[0] + cSrc[0]) / 2 - centerSrc[0]; dx = (aSrc[0] + cSrc[0]) / 2 - centerSrc[0];
} }

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import {createEmpty} from '../extent.js'; import {createEmpty} from '../extent.js';
import _ol_math_ from '../math.js'; import {modulo} from '../math.js';
import _ol_obj_ from '../obj.js'; import _ol_obj_ from '../obj.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';
@@ -118,7 +118,7 @@ _ol_source_TileArcGISRest_.prototype.getRequestUrl_ = function(tileCoord, tileSi
if (urls.length == 1) { if (urls.length == 1) {
url = urls[0]; url = urls[0];
} else { } else {
var index = _ol_math_.modulo(_ol_tilecoord_.hash(tileCoord), urls.length); var index = modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
url = urls[index]; url = urls[index];
} }

View File

@@ -7,7 +7,7 @@ import {inherits} from '../index.js';
import {assert} from '../asserts.js'; import {assert} 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 {modulo} from '../math.js';
import {get as getProjection, transform, transformExtent} 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';
@@ -247,7 +247,7 @@ _ol_source_TileWMS_.prototype.getRequestUrl_ = function(tileCoord, tileSize, til
if (urls.length == 1) { if (urls.length == 1) {
url = urls[0]; url = urls[0];
} else { } else {
var index = _ol_math_.modulo(_ol_tilecoord_.hash(tileCoord), urls.length); var index = modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
url = urls[index]; url = urls[index];
} }
return _ol_uri_.appendParams(url, params); return _ol_uri_.appendParams(url, params);

View File

@@ -6,7 +6,7 @@ import {assert} from '../asserts.js';
import TileRange from '../TileRange.js'; import TileRange from '../TileRange.js';
import {isSorted, linearFindNearest} from '../array.js'; import {isSorted, linearFindNearest} from '../array.js';
import {createOrUpdate, getTopLeft} from '../extent.js'; import {createOrUpdate, getTopLeft} from '../extent.js';
import _ol_math_ from '../math.js'; import {clamp} from '../math.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
import _ol_tilecoord_ from '../tilecoord.js'; import _ol_tilecoord_ from '../tilecoord.js';
@@ -529,7 +529,7 @@ _ol_tilegrid_TileGrid_.prototype.getFullTileRange = function(z) {
_ol_tilegrid_TileGrid_.prototype.getZForResolution = function( _ol_tilegrid_TileGrid_.prototype.getZForResolution = function(
resolution, opt_direction) { resolution, opt_direction) {
var z = linearFindNearest(this.resolutions_, resolution, opt_direction || 0); var z = linearFindNearest(this.resolutions_, resolution, opt_direction || 0);
return _ol_math_.clamp(z, this.minZoom, this.maxZoom); return clamp(z, this.minZoom, this.maxZoom);
}; };

View File

@@ -2,7 +2,7 @@
* @module ol/tileurlfunction * @module ol/tileurlfunction
*/ */
import {assert} from './asserts.js'; import {assert} from './asserts.js';
import _ol_math_ from './math.js'; import {modulo} from './math.js';
import _ol_tilecoord_ from './tilecoord.js'; import _ol_tilecoord_ from './tilecoord.js';
@@ -81,7 +81,7 @@ export function createFromTileUrlFunctions(tileUrlFunctions) {
return undefined; return undefined;
} else { } else {
var h = _ol_tilecoord_.hash(tileCoord); var h = _ol_tilecoord_.hash(tileCoord);
var index = _ol_math_.modulo(h, tileUrlFunctions.length); var index = modulo(h, tileUrlFunctions.length);
return tileUrlFunctions[index](tileCoord, pixelRatio, projection); return tileUrlFunctions[index](tileCoord, pixelRatio, projection);
} }
} }

View File

@@ -1,26 +1,26 @@
import _ol_math_ from '../../../src/ol/math.js'; import {clamp, lerp, cosh, roundUpToPowerOfTwo, solveLinearSystem, toDegrees, toRadians, modulo} from '../../../src/ol/math.js';
describe('ol.math.clamp', function() { describe('ol.math.clamp', function() {
it('returns the correct value at -Infinity', function() { it('returns the correct value at -Infinity', function() {
expect(_ol_math_.clamp(-Infinity, 10, 20)).to.eql(10); expect(clamp(-Infinity, 10, 20)).to.eql(10);
}); });
it('returns the correct value at min', function() { it('returns the correct value at min', function() {
expect(_ol_math_.clamp(10, 10, 20)).to.eql(10); expect(clamp(10, 10, 20)).to.eql(10);
}); });
it('returns the correct value at mid point', function() { it('returns the correct value at mid point', function() {
expect(_ol_math_.clamp(15, 10, 20)).to.eql(15); expect(clamp(15, 10, 20)).to.eql(15);
}); });
it('returns the correct value at max', function() { it('returns the correct value at max', function() {
expect(_ol_math_.clamp(20, 10, 20)).to.eql(20); expect(clamp(20, 10, 20)).to.eql(20);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(_ol_math_.clamp(Infinity, 10, 20)).to.eql(20); expect(clamp(Infinity, 10, 20)).to.eql(20);
}); });
}); });
@@ -28,23 +28,23 @@ describe('ol.math.clamp', function() {
describe('ol.math.cosh', function() { describe('ol.math.cosh', function() {
it('returns the correct value at -Infinity', function() { it('returns the correct value at -Infinity', function() {
expect(_ol_math_.cosh(-Infinity)).to.eql(Infinity); expect(cosh(-Infinity)).to.eql(Infinity);
}); });
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(_ol_math_.cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9); expect(cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(_ol_math_.cosh(0)).to.eql(1); expect(cosh(0)).to.eql(1);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(_ol_math_.cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9); expect(cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(_ol_math_.cosh(Infinity)).to.eql(Infinity); expect(cosh(Infinity)).to.eql(Infinity);
}); });
}); });
@@ -53,37 +53,37 @@ describe('ol.math.roundUpToPowerOfTwo', function() {
it('raises an exception when x is negative', function() { it('raises an exception when x is negative', function() {
expect(function() { expect(function() {
_ol_math_.roundUpToPowerOfTwo(-1); roundUpToPowerOfTwo(-1);
}).to.throwException(); }).to.throwException();
}); });
it('raises an exception when x is zero', function() { it('raises an exception when x is zero', function() {
expect(function() { expect(function() {
_ol_math_.roundUpToPowerOfTwo(0); roundUpToPowerOfTwo(0);
}).to.throwException(); }).to.throwException();
}); });
it('returns the expected value for simple powers of two', function() { it('returns the expected value for simple powers of two', function() {
expect(_ol_math_.roundUpToPowerOfTwo(1)).to.be(1); expect(roundUpToPowerOfTwo(1)).to.be(1);
expect(_ol_math_.roundUpToPowerOfTwo(2)).to.be(2); expect(roundUpToPowerOfTwo(2)).to.be(2);
expect(_ol_math_.roundUpToPowerOfTwo(4)).to.be(4); expect(roundUpToPowerOfTwo(4)).to.be(4);
expect(_ol_math_.roundUpToPowerOfTwo(8)).to.be(8); expect(roundUpToPowerOfTwo(8)).to.be(8);
expect(_ol_math_.roundUpToPowerOfTwo(16)).to.be(16); expect(roundUpToPowerOfTwo(16)).to.be(16);
expect(_ol_math_.roundUpToPowerOfTwo(32)).to.be(32); expect(roundUpToPowerOfTwo(32)).to.be(32);
expect(_ol_math_.roundUpToPowerOfTwo(64)).to.be(64); expect(roundUpToPowerOfTwo(64)).to.be(64);
expect(_ol_math_.roundUpToPowerOfTwo(128)).to.be(128); expect(roundUpToPowerOfTwo(128)).to.be(128);
expect(_ol_math_.roundUpToPowerOfTwo(256)).to.be(256); expect(roundUpToPowerOfTwo(256)).to.be(256);
}); });
it('returns the expected value for simple powers of ten', function() { it('returns the expected value for simple powers of ten', function() {
expect(_ol_math_.roundUpToPowerOfTwo(1)).to.be(1); expect(roundUpToPowerOfTwo(1)).to.be(1);
expect(_ol_math_.roundUpToPowerOfTwo(10)).to.be(16); expect(roundUpToPowerOfTwo(10)).to.be(16);
expect(_ol_math_.roundUpToPowerOfTwo(100)).to.be(128); expect(roundUpToPowerOfTwo(100)).to.be(128);
expect(_ol_math_.roundUpToPowerOfTwo(1000)).to.be(1024); expect(roundUpToPowerOfTwo(1000)).to.be(1024);
expect(_ol_math_.roundUpToPowerOfTwo(10000)).to.be(16384); expect(roundUpToPowerOfTwo(10000)).to.be(16384);
expect(_ol_math_.roundUpToPowerOfTwo(100000)).to.be(131072); expect(roundUpToPowerOfTwo(100000)).to.be(131072);
expect(_ol_math_.roundUpToPowerOfTwo(1000000)).to.be(1048576); expect(roundUpToPowerOfTwo(1000000)).to.be(1048576);
expect(_ol_math_.roundUpToPowerOfTwo(10000000)).to.be(16777216); expect(roundUpToPowerOfTwo(10000000)).to.be(16777216);
}); });
}); });
@@ -91,7 +91,7 @@ describe('ol.math.roundUpToPowerOfTwo', function() {
describe('ol.math.solveLinearSystem', function() { describe('ol.math.solveLinearSystem', function() {
it('calculates correctly', function() { it('calculates correctly', function() {
var result = _ol_math_.solveLinearSystem([ var result = solveLinearSystem([
[2, 1, 3, 1], [2, 1, 3, 1],
[2, 6, 8, 3], [2, 6, 8, 3],
[6, 8, 18, 5] [6, 8, 18, 5]
@@ -102,7 +102,7 @@ describe('ol.math.solveLinearSystem', function() {
}); });
it('can handle singular matrix', function() { it('can handle singular matrix', function() {
var result = _ol_math_.solveLinearSystem([ var result = solveLinearSystem([
[2, 1, 3, 1], [2, 1, 3, 1],
[2, 6, 8, 3], [2, 6, 8, 3],
[2, 1, 3, 1] [2, 1, 3, 1]
@@ -114,60 +114,60 @@ describe('ol.math.solveLinearSystem', function() {
describe('ol.math.toDegrees', function() { describe('ol.math.toDegrees', function() {
it('returns the correct value at -π', function() { it('returns the correct value at -π', function() {
expect(_ol_math_.toDegrees(-Math.PI)).to.be(-180); expect(toDegrees(-Math.PI)).to.be(-180);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(_ol_math_.toDegrees(0)).to.be(0); expect(toDegrees(0)).to.be(0);
}); });
it('returns the correct value at π', function() { it('returns the correct value at π', function() {
expect(_ol_math_.toDegrees(Math.PI)).to.be(180); expect(toDegrees(Math.PI)).to.be(180);
}); });
}); });
describe('ol.math.toRadians', function() { describe('ol.math.toRadians', function() {
it('returns the correct value at -180', function() { it('returns the correct value at -180', function() {
expect(_ol_math_.toRadians(-180)).to.be(-Math.PI); expect(toRadians(-180)).to.be(-Math.PI);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(_ol_math_.toRadians(0)).to.be(0); expect(toRadians(0)).to.be(0);
}); });
it('returns the correct value at 180', function() { it('returns the correct value at 180', function() {
expect(_ol_math_.toRadians(180)).to.be(Math.PI); expect(toRadians(180)).to.be(Math.PI);
}); });
}); });
describe('ol.math.modulo', function() { describe('ol.math.modulo', function() {
it('256 / 8 returns 0', function() { it('256 / 8 returns 0', function() {
expect(_ol_math_.modulo(256, 8)).to.be(0); expect(modulo(256, 8)).to.be(0);
}); });
it('positive and positive returns a positive ', function() { it('positive and positive returns a positive ', function() {
expect(_ol_math_.modulo(7, 8)).to.be(7); expect(modulo(7, 8)).to.be(7);
}); });
it('same Dividend and Divisor returns 0', function() { it('same Dividend and Divisor returns 0', function() {
expect(_ol_math_.modulo(4, 4)).to.be(0); expect(modulo(4, 4)).to.be(0);
}); });
it('negative and positive returns positive', function() { it('negative and positive returns positive', function() {
expect(_ol_math_.modulo(-3, 4)).to.be(1); expect(modulo(-3, 4)).to.be(1);
}); });
it('negative and negative returns negative', function() { it('negative and negative returns negative', function() {
expect(_ol_math_.modulo(-4, -5)).to.be(-4); expect(modulo(-4, -5)).to.be(-4);
expect(_ol_math_.modulo(-3, -4)).to.be(-3); expect(modulo(-3, -4)).to.be(-3);
}); });
it('positive and negative returns negative', function() { it('positive and negative returns negative', function() {
expect(_ol_math_.modulo(3, -4)).to.be(-1); expect(modulo(3, -4)).to.be(-1);
expect(_ol_math_.modulo(1, -5)).to.be(-4); expect(modulo(1, -5)).to.be(-4);
expect(_ol_math_.modulo(6, -5)).to.be(-4); expect(modulo(6, -5)).to.be(-4);
}); });
}); });
describe('ol.math.lerp', function() { describe('ol.math.lerp', function() {
it('correctly interpolated numbers', function() { it('correctly interpolated numbers', function() {
expect(_ol_math_.lerp(0, 0, 0)).to.be(0); expect(lerp(0, 0, 0)).to.be(0);
expect(_ol_math_.lerp(0, 1, 0)).to.be(0); expect(lerp(0, 1, 0)).to.be(0);
expect(_ol_math_.lerp(1, 11, 5)).to.be(51); expect(lerp(1, 11, 5)).to.be(51);
}); });
it('correctly interpolates floats', function() { it('correctly interpolates floats', function() {
expect(_ol_math_.lerp(0, 1, 0.5)).to.be(0.5); expect(lerp(0, 1, 0.5)).to.be(0.5);
expect(_ol_math_.lerp(0.25, 0.75, 0.5)).to.be(0.5); expect(lerp(0.25, 0.75, 0.5)).to.be(0.5);
}); });
}); });