Named exports from ol/geom/flat/center

This commit is contained in:
Frederic Junod
2018-01-26 16:24:41 +01:00
parent aea39782fb
commit d64b5c52a2
4 changed files with 10 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ import MultiPoint from '../geom/MultiPoint.js';
import Polygon from '../geom/Polygon.js';
import SimpleGeometry from '../geom/SimpleGeometry.js';
import {linearRingss as linearRingssArea} from '../geom/flat/area.js';
import _ol_geom_flat_center_ from '../geom/flat/center.js';
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';
@@ -207,7 +207,7 @@ MultiPolygon.prototype.getEndss = function() {
*/
MultiPolygon.prototype.getFlatInteriorPoints = function() {
if (this.flatInteriorPointsRevision_ != this.getRevision()) {
const flatCenters = _ol_geom_flat_center_.linearRingss(
const flatCenters = linearRingssCenter(
this.flatCoordinates, 0, this.endss_, this.stride);
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,

View File

@@ -2,7 +2,6 @@
* @module ol/geom/flat/center
*/
import {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js';
const _ol_geom_flat_center_ = {};
/**
@@ -12,7 +11,7 @@ const _ol_geom_flat_center_ = {};
* @param {number} stride Stride.
* @return {Array.<number>} Flat centers.
*/
_ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, stride) {
export function linearRingss(flatCoordinates, offset, endss, stride) {
const flatCenters = [];
let extent = createEmpty();
for (let i = 0, ii = endss.length; i < ii; ++i) {
@@ -22,5 +21,4 @@ _ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, st
offset = ends[ends.length - 1];
}
return flatCenters;
};
export default _ol_geom_flat_center_;
}

View File

@@ -5,7 +5,7 @@ import {nullFunction} from '../index.js';
import {extend} from '../array.js';
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
import GeometryType from '../geom/GeometryType.js';
import _ol_geom_flat_center_ from '../geom/flat/center.js';
import {linearRingss as linearRingssCenter} from '../geom/flat/center.js';
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
@@ -137,7 +137,7 @@ RenderFeature.prototype.getFlatInteriorPoint = function() {
*/
RenderFeature.prototype.getFlatInteriorPoints = function() {
if (!this.flatInteriorPoints_) {
const flatCenters = _ol_geom_flat_center_.linearRingss(
const flatCenters = linearRingssCenter(
this.flatCoordinates_, 0, this.ends_, 2);
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);

View File

@@ -1,4 +1,4 @@
import _ol_geom_flat_center_ from '../../../../../src/ol/geom/flat/center.js';
import {linearRingss as linearRingssCenter} from '../../../../../src/ol/geom/flat/center.js';
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
@@ -10,7 +10,7 @@ describe('ol.geom.flat.center', function() {
const squareMultiPoly = new MultiPolygon([[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
]]);
const got = _ol_geom_flat_center_.linearRingss(
const got = linearRingssCenter(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
@@ -28,7 +28,7 @@ describe('ol.geom.flat.center', function() {
[[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]]
]
]);
const got = _ol_geom_flat_center_.linearRingss(
const got = linearRingssCenter(
squareMultiPoly.flatCoordinates,
0,
squareMultiPoly.endss_,
@@ -42,7 +42,7 @@ describe('ol.geom.flat.center', function() {
[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]],
[[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]]
]]);
const got = _ol_geom_flat_center_.linearRingss(
const got = linearRingssCenter(
polywithHole.flatCoordinates,
0,
polywithHole.endss_,