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
+2 -2
View File
@@ -10,7 +10,7 @@ import MultiPoint from '../geom/MultiPoint.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 {linearRingss as linearRingssArea} from '../geom/flat/area.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 _ol_geom_flat_closest_ from '../geom/flat/closest.js';
import {linearRingssContainsXY} from '../geom/flat/contains.js'; import {linearRingssContainsXY} from '../geom/flat/contains.js';
import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js'; import _ol_geom_flat_deflate_ from '../geom/flat/deflate.js';
@@ -207,7 +207,7 @@ MultiPolygon.prototype.getEndss = function() {
*/ */
MultiPolygon.prototype.getFlatInteriorPoints = function() { MultiPolygon.prototype.getFlatInteriorPoints = function() {
if (this.flatInteriorPointsRevision_ != this.getRevision()) { if (this.flatInteriorPointsRevision_ != this.getRevision()) {
const flatCenters = _ol_geom_flat_center_.linearRingss( const flatCenters = linearRingssCenter(
this.flatCoordinates, 0, this.endss_, this.stride); this.flatCoordinates, 0, this.endss_, this.stride);
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss( this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride, this.getOrientedFlatCoordinates(), 0, this.endss_, this.stride,
+2 -4
View File
@@ -2,7 +2,6 @@
* @module ol/geom/flat/center * @module ol/geom/flat/center
*/ */
import {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js'; import {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js';
const _ol_geom_flat_center_ = {};
/** /**
@@ -12,7 +11,7 @@ const _ol_geom_flat_center_ = {};
* @param {number} stride Stride. * @param {number} stride Stride.
* @return {Array.<number>} Flat centers. * @return {Array.<number>} Flat centers.
*/ */
_ol_geom_flat_center_.linearRingss = function(flatCoordinates, offset, endss, stride) { export function linearRingss(flatCoordinates, offset, endss, stride) {
const flatCenters = []; const flatCenters = [];
let extent = createEmpty(); let extent = createEmpty();
for (let i = 0, ii = endss.length; i < ii; ++i) { 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]; offset = ends[ends.length - 1];
} }
return flatCenters; return flatCenters;
}; }
export default _ol_geom_flat_center_;
+2 -2
View File
@@ -5,7 +5,7 @@ import {nullFunction} from '../index.js';
import {extend} from '../array.js'; import {extend} from '../array.js';
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js'; import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
import GeometryType from '../geom/GeometryType.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_interiorpoint_ from '../geom/flat/interiorpoint.js';
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js'; import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
import _ol_geom_flat_transform_ from '../geom/flat/transform.js'; import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
@@ -137,7 +137,7 @@ RenderFeature.prototype.getFlatInteriorPoint = function() {
*/ */
RenderFeature.prototype.getFlatInteriorPoints = function() { RenderFeature.prototype.getFlatInteriorPoints = function() {
if (!this.flatInteriorPoints_) { if (!this.flatInteriorPoints_) {
const flatCenters = _ol_geom_flat_center_.linearRingss( const flatCenters = linearRingssCenter(
this.flatCoordinates_, 0, this.ends_, 2); this.flatCoordinates_, 0, this.ends_, 2);
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss( this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
this.flatCoordinates_, 0, this.ends_, 2, flatCenters); this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
+4 -4
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'; import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
@@ -10,7 +10,7 @@ describe('ol.geom.flat.center', function() {
const squareMultiPoly = new MultiPolygon([[ const squareMultiPoly = new MultiPolygon([[
[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]] [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
]]); ]]);
const got = _ol_geom_flat_center_.linearRingss( const got = linearRingssCenter(
squareMultiPoly.flatCoordinates, squareMultiPoly.flatCoordinates,
0, 0,
squareMultiPoly.endss_, squareMultiPoly.endss_,
@@ -28,7 +28,7 @@ describe('ol.geom.flat.center', function() {
[[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]] [[3, 0], [3, 1], [4, 1], [4, 0], [3, 0]]
] ]
]); ]);
const got = _ol_geom_flat_center_.linearRingss( const got = linearRingssCenter(
squareMultiPoly.flatCoordinates, squareMultiPoly.flatCoordinates,
0, 0,
squareMultiPoly.endss_, squareMultiPoly.endss_,
@@ -42,7 +42,7 @@ describe('ol.geom.flat.center', function() {
[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]], [[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]],
[[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]] [[1, 1], [1, 4], [4, 4], [4, 1], [1, 1]]
]]); ]]);
const got = _ol_geom_flat_center_.linearRingss( const got = linearRingssCenter(
polywithHole.flatCoordinates, polywithHole.flatCoordinates,
0, 0,
polywithHole.endss_, polywithHole.endss_,