ol/geom/flate/inflate exports
This commit is contained in:
@@ -10,7 +10,7 @@ import GeometryLayout from '../geom/GeometryLayout.js';
|
||||
import LineString from '../geom/LineString.js';
|
||||
import {getStrideForLayout} from '../geom/SimpleGeometry.js';
|
||||
import {flipXY} from '../geom/flat/flip.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
|
||||
/**
|
||||
@@ -327,7 +327,7 @@ Polyline.prototype.readGeometryFromText = function(text, opt_options) {
|
||||
const stride = getStrideForLayout(this.geometryLayout_);
|
||||
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
|
||||
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
|
||||
const coordinates = _ol_geom_flat_inflate_.coordinates(
|
||||
const coordinates = inflateCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
|
||||
return (
|
||||
|
||||
@@ -9,7 +9,7 @@ import GeometryType from '../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
||||
import _ol_geom_flat_length_ from '../geom/flat/length.js';
|
||||
@@ -155,7 +155,7 @@ LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
|
||||
* @api
|
||||
*/
|
||||
LineString.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinates(
|
||||
return inflateCoordinates(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import {linearRing as linearRingArea} from '../geom/flat/area.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ LinearRing.prototype.getArea = function() {
|
||||
* @api
|
||||
*/
|
||||
LinearRing.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinates(
|
||||
return inflateCoordinates(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import LineString from '../geom/LineString.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateCoordinatesArray} from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
||||
import _ol_geom_flat_simplify_ from '../geom/flat/simplify.js';
|
||||
@@ -144,7 +144,7 @@ MultiLineString.prototype.getCoordinateAtM = function(m, opt_extrapolate, opt_in
|
||||
* @api
|
||||
*/
|
||||
MultiLineString.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinatess(
|
||||
return inflateCoordinatesArray(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import GeometryType from '../geom/GeometryType.js';
|
||||
import Point from '../geom/Point.js';
|
||||
import SimpleGeometry from '../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateCoordinates} from '../geom/flat/inflate.js';
|
||||
import {squaredDistance as squaredDx} from '../math.js';
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ MultiPoint.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDis
|
||||
* @api
|
||||
*/
|
||||
MultiPoint.prototype.getCoordinates = function() {
|
||||
return _ol_geom_flat_inflate_.coordinates(
|
||||
return inflateCoordinates(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import {linearRingssContainsXY} from '../geom/flat/contains.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateMultiCoordinatesArray} from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
||||
import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
|
||||
@@ -189,7 +189,7 @@ MultiPolygon.prototype.getCoordinates = function(opt_right) {
|
||||
flatCoordinates = this.flatCoordinates;
|
||||
}
|
||||
|
||||
return _ol_geom_flat_inflate_.coordinatesss(
|
||||
return inflateMultiCoordinatesArray(
|
||||
flatCoordinates, 0, this.endss_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {linearRings as linearRingsArea} from '../geom/flat/area.js';
|
||||
import _ol_geom_flat_closest_ from '../geom/flat/closest.js';
|
||||
import {linearRingsContainsXY} from '../geom/flat/contains.js';
|
||||
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
|
||||
import _ol_geom_flat_inflate_ from '../geom/flat/inflate.js';
|
||||
import {inflateCoordinatesArray} from '../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
||||
import _ol_geom_flat_intersectsextent_ from '../geom/flat/intersectsextent.js';
|
||||
import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
|
||||
@@ -179,7 +179,7 @@ Polygon.prototype.getCoordinates = function(opt_right) {
|
||||
flatCoordinates = this.flatCoordinates;
|
||||
}
|
||||
|
||||
return _ol_geom_flat_inflate_.coordinatess(
|
||||
return inflateCoordinatesArray(
|
||||
flatCoordinates, 0, this.ends_, this.stride);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/inflate
|
||||
*/
|
||||
const _ol_geom_flat_inflate_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,7 +11,7 @@ const _ol_geom_flat_inflate_ = {};
|
||||
* @param {Array.<ol.Coordinate>=} opt_coordinates Coordinates.
|
||||
* @return {Array.<ol.Coordinate>} Coordinates.
|
||||
*/
|
||||
_ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stride, opt_coordinates) {
|
||||
export function inflateCoordinates(flatCoordinates, offset, end, stride, opt_coordinates) {
|
||||
const coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
|
||||
let i = 0;
|
||||
for (let j = offset; j < end; j += stride) {
|
||||
@@ -20,7 +19,7 @@ _ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stri
|
||||
}
|
||||
coordinates.length = i;
|
||||
return coordinates;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,18 +30,18 @@ _ol_geom_flat_inflate_.coordinates = function(flatCoordinates, offset, end, stri
|
||||
* @param {Array.<Array.<ol.Coordinate>>=} opt_coordinatess Coordinatess.
|
||||
* @return {Array.<Array.<ol.Coordinate>>} Coordinatess.
|
||||
*/
|
||||
_ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, stride, opt_coordinatess) {
|
||||
export function inflateCoordinatesArray(flatCoordinates, offset, ends, stride, opt_coordinatess) {
|
||||
const coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
|
||||
let i = 0;
|
||||
for (let j = 0, jj = ends.length; j < jj; ++j) {
|
||||
const end = ends[j];
|
||||
coordinatess[i++] = _ol_geom_flat_inflate_.coordinates(
|
||||
coordinatess[i++] = inflateCoordinates(
|
||||
flatCoordinates, offset, end, stride, coordinatess[i]);
|
||||
offset = end;
|
||||
}
|
||||
coordinatess.length = i;
|
||||
return coordinatess;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,16 +53,15 @@ _ol_geom_flat_inflate_.coordinatess = function(flatCoordinates, offset, ends, st
|
||||
* Coordinatesss.
|
||||
* @return {Array.<Array.<Array.<ol.Coordinate>>>} Coordinatesss.
|
||||
*/
|
||||
_ol_geom_flat_inflate_.coordinatesss = function(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
|
||||
export function inflateMultiCoordinatesArray(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
|
||||
const coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
|
||||
let i = 0;
|
||||
for (let j = 0, jj = endss.length; j < jj; ++j) {
|
||||
const ends = endss[j];
|
||||
coordinatesss[i++] = _ol_geom_flat_inflate_.coordinatess(
|
||||
coordinatesss[i++] = inflateCoordinatesArray(
|
||||
flatCoordinates, offset, ends, stride, coordinatesss[i]);
|
||||
offset = ends[ends.length - 1];
|
||||
}
|
||||
coordinatesss.length = i;
|
||||
return coordinatesss;
|
||||
};
|
||||
export default _ol_geom_flat_inflate_;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {buffer, clone, coordinateRelationship, createEmpty, createOrUpdate,
|
||||
createOrUpdateEmpty, extend, extendCoordinate, intersects} from '../../extent.js';
|
||||
import Relationship from '../../extent/Relationship.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import _ol_geom_flat_inflate_ from '../../geom/flat/inflate.js';
|
||||
import {inflateCoordinates, inflateCoordinatesArray, inflateMultiCoordinatesArray} from '../../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_length_ from '../../geom/flat/length.js';
|
||||
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
@@ -410,7 +410,7 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
||||
replayEndss.push(myEnds);
|
||||
}
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEndss, geometry, renderer, _ol_geom_flat_inflate_.coordinatesss]);
|
||||
replayBegin, replayEndss, geometry, renderer, inflateMultiCoordinatesArray]);
|
||||
} else if (type == GeometryType.POLYGON || type == GeometryType.MULTI_LINE_STRING) {
|
||||
replayEnds = [];
|
||||
flatCoordinates = (type == GeometryType.POLYGON) ?
|
||||
@@ -420,13 +420,13 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
||||
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
|
||||
stride, replayEnds);
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]);
|
||||
replayBegin, replayEnds, geometry, renderer, inflateCoordinatesArray]);
|
||||
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
replayEnd = this.appendFlatCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||
replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]);
|
||||
replayBegin, replayEnd, geometry, renderer, inflateCoordinates]);
|
||||
} else if (type == GeometryType.POINT) {
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_geom_flat_inflate_ from '../../../../../src/ol/geom/flat/inflate.js';
|
||||
import {inflateCoordinates, inflateCoordinatesArray} from '../../../../../src/ol/geom/flat/inflate.js';
|
||||
|
||||
|
||||
describe('ol.geom.flat.inflate', function() {
|
||||
@@ -6,7 +6,7 @@ describe('ol.geom.flat.inflate', function() {
|
||||
describe('ol.geom.flat.inflate.coordinates', function() {
|
||||
|
||||
it('inflates coordinates', function() {
|
||||
const coordinates = _ol_geom_flat_inflate_.coordinates([1, 2, 3, 4], 0, 4, 2);
|
||||
const coordinates = inflateCoordinates([1, 2, 3, 4], 0, 4, 2);
|
||||
expect(coordinates).to.eql([[1, 2], [3, 4]]);
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('ol.geom.flat.inflate', function() {
|
||||
describe('ol.geom.flat.inflate.coordinatess', function() {
|
||||
|
||||
it('inflates arrays of coordinates', function() {
|
||||
const coordinatess = _ol_geom_flat_inflate_.coordinatess(
|
||||
const coordinatess = inflateCoordinatesArray(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8], 0, [4, 8], 2);
|
||||
expect(coordinatess).to.eql([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user