Named exports from ol/geom/flat/geodesic
This commit is contained in:
+5
-7
@@ -6,7 +6,7 @@ import {intersects, getCenter} from './extent.js';
|
|||||||
import GeometryLayout from './geom/GeometryLayout.js';
|
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 {meridian, parallel} from './geom/flat/geodesic.js';
|
||||||
import {clamp} 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';
|
||||||
@@ -565,9 +565,8 @@ Graticule.prototype.getMap = function() {
|
|||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, squaredTolerance, index) {
|
||||||
squaredTolerance, index) {
|
const flatCoordinates = meridian(lon,
|
||||||
const flatCoordinates = _ol_geom_flat_geodesic_.meridian(lon,
|
|
||||||
minLat, maxLat, this.projection_, squaredTolerance);
|
minLat, maxLat, this.projection_, squaredTolerance);
|
||||||
const lineString = this.meridians_[index] !== undefined ?
|
const lineString = this.meridians_[index] !== undefined ?
|
||||||
this.meridians_[index] : new LineString(null);
|
this.meridians_[index] : new LineString(null);
|
||||||
@@ -595,9 +594,8 @@ Graticule.prototype.getMeridians = function() {
|
|||||||
* @param {number} index Index.
|
* @param {number} index Index.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, squaredTolerance, index) {
|
||||||
squaredTolerance, index) {
|
const flatCoordinates = parallel(lat,
|
||||||
const flatCoordinates = _ol_geom_flat_geodesic_.parallel(lat,
|
|
||||||
minLon, maxLon, this.projection_, squaredTolerance);
|
minLon, maxLon, this.projection_, squaredTolerance);
|
||||||
const lineString = this.parallels_[index] !== undefined ?
|
const lineString = this.parallels_[index] !== undefined ?
|
||||||
this.parallels_[index] : new LineString(null);
|
this.parallels_[index] : new LineString(null);
|
||||||
|
|||||||
@@ -3,18 +3,16 @@
|
|||||||
*/
|
*/
|
||||||
import {squaredSegmentDistance, toRadians, toDegrees} 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';
|
||||||
const _ol_geom_flat_geodesic_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
|
||||||
* @param {function(number): ol.Coordinate} interpolate Interpolate function.
|
* @param {function(number): ol.Coordinate} interpolate Interpolate function.
|
||||||
* @param {ol.TransformFunction} transform Transform from longitude/latitude to
|
* @param {ol.TransformFunction} transform Transform from longitude/latitude to
|
||||||
* projected coordinates.
|
* projected coordinates.
|
||||||
* @param {number} squaredTolerance Squared tolerance.
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredTolerance) {
|
function line(interpolate, transform, squaredTolerance) {
|
||||||
// FIXME reduce garbage generation
|
// FIXME reduce garbage generation
|
||||||
// FIXME optimize stack operations
|
// FIXME optimize stack operations
|
||||||
|
|
||||||
@@ -77,22 +75,20 @@ _ol_geom_flat_geodesic_.line_ = function(interpolate, transform, squaredToleranc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return flatCoordinates;
|
return flatCoordinates;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a great-circle arcs between two lat/lon points.
|
* Generate a great-circle arcs between two lat/lon points.
|
||||||
* @param {number} lon1 Longitude 1 in degrees.
|
* @param {number} lon1 Longitude 1 in degrees.
|
||||||
* @param {number} lat1 Latitude 1 in degrees.
|
* @param {number} lat1 Latitude 1 in degrees.
|
||||||
* @param {number} lon2 Longitude 2 in degrees.
|
* @param {number} lon2 Longitude 2 in degrees.
|
||||||
* @param {number} lat2 Latitude 2 in degrees.
|
* @param {number} lat2 Latitude 2 in degrees.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
* @param {number} squaredTolerance Squared tolerance.
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_geodesic_.greatCircleArc = function(
|
export function greatCircleArc(lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
||||||
lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
|
||||||
|
|
||||||
const geoProjection = getProjection('EPSG:4326');
|
const geoProjection = getProjection('EPSG:4326');
|
||||||
|
|
||||||
const cosLat1 = Math.cos(toRadians(lat1));
|
const cosLat1 = Math.cos(toRadians(lat1));
|
||||||
@@ -103,11 +99,11 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
|||||||
const sinDeltaLon = Math.sin(toRadians(lon2 - lon1));
|
const sinDeltaLon = Math.sin(toRadians(lon2 - lon1));
|
||||||
const d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
|
const d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
|
||||||
|
|
||||||
return _ol_geom_flat_geodesic_.line_(
|
return line(
|
||||||
/**
|
/**
|
||||||
* @param {number} frac Fraction.
|
* @param {number} frac Fraction.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
function(frac) {
|
function(frac) {
|
||||||
if (1 <= d) {
|
if (1 <= d) {
|
||||||
return [lon2, lat2];
|
return [lon2, lat2];
|
||||||
@@ -124,7 +120,7 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
|||||||
cosD - sinLat1 * Math.sin(lat));
|
cosD - sinLat1 * Math.sin(lat));
|
||||||
return [toDegrees(lon), toDegrees(lat)];
|
return [toDegrees(lon), toDegrees(lat)];
|
||||||
}, getTransform(geoProjection, projection), squaredTolerance);
|
}, getTransform(geoProjection, projection), squaredTolerance);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,18 +132,18 @@ _ol_geom_flat_geodesic_.greatCircleArc = function(
|
|||||||
* @param {number} squaredTolerance Squared tolerance.
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squaredTolerance) {
|
export function meridian(lon, lat1, lat2, projection, squaredTolerance) {
|
||||||
const epsg4326Projection = getProjection('EPSG:4326');
|
const epsg4326Projection = getProjection('EPSG:4326');
|
||||||
return _ol_geom_flat_geodesic_.line_(
|
return line(
|
||||||
/**
|
/**
|
||||||
* @param {number} frac Fraction.
|
* @param {number} frac Fraction.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
function(frac) {
|
function(frac) {
|
||||||
return [lon, lat1 + ((lat2 - lat1) * frac)];
|
return [lon, lat1 + ((lat2 - lat1) * frac)];
|
||||||
},
|
},
|
||||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,16 +155,15 @@ _ol_geom_flat_geodesic_.meridian = function(lon, lat1, lat2, projection, squared
|
|||||||
* @param {number} squaredTolerance Squared tolerance.
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
*/
|
*/
|
||||||
_ol_geom_flat_geodesic_.parallel = function(lat, lon1, lon2, projection, squaredTolerance) {
|
export function parallel(lat, lon1, lon2, projection, squaredTolerance) {
|
||||||
const epsg4326Projection = getProjection('EPSG:4326');
|
const epsg4326Projection = getProjection('EPSG:4326');
|
||||||
return _ol_geom_flat_geodesic_.line_(
|
return line(
|
||||||
/**
|
/**
|
||||||
* @param {number} frac Fraction.
|
* @param {number} frac Fraction.
|
||||||
* @return {ol.Coordinate} Coordinate.
|
* @return {ol.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
function(frac) {
|
function(frac) {
|
||||||
return [lon1 + ((lon2 - lon1) * frac), lat];
|
return [lon1 + ((lon2 - lon1) * frac), lat];
|
||||||
},
|
},
|
||||||
getTransform(epsg4326Projection, projection), squaredTolerance);
|
getTransform(epsg4326Projection, projection), squaredTolerance);
|
||||||
};
|
}
|
||||||
export default _ol_geom_flat_geodesic_;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user