Merge pull request #7820 from raiyni/geom

ol/geom/flat/* exports
This commit is contained in:
Tim Schaub
2018-02-14 04:07:09 -07:00
committed by GitHub
45 changed files with 424 additions and 447 deletions

View File

@@ -6,9 +6,9 @@ import {extend} from '../array.js';
import {createOrUpdateFromCoordinate, createOrUpdateFromFlatCoordinates, getCenter, getHeight} from '../extent.js';
import GeometryType from '../geom/GeometryType.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';
import {getInteriorPointOfArray, getInteriorPointsOfMultiArray} from '../geom/flat/interiorpoint.js';
import {interpolatePoint} from '../geom/flat/interpolate.js';
import {transform2D} from '../geom/flat/transform.js';
import _ol_transform_ from '../transform.js';
/**
@@ -125,7 +125,7 @@ RenderFeature.prototype.getExtent = function() {
RenderFeature.prototype.getFlatInteriorPoint = function() {
if (!this.flatInteriorPoints_) {
const flatCenter = getCenter(this.getExtent());
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRings(
this.flatInteriorPoints_ = getInteriorPointOfArray(
this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0);
}
return this.flatInteriorPoints_;
@@ -139,7 +139,7 @@ RenderFeature.prototype.getFlatInteriorPoints = function() {
if (!this.flatInteriorPoints_) {
const flatCenters = linearRingssCenter(
this.flatCoordinates_, 0, this.ends_, 2);
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
}
return this.flatInteriorPoints_;
@@ -151,7 +151,7 @@ RenderFeature.prototype.getFlatInteriorPoints = function() {
*/
RenderFeature.prototype.getFlatMidpoint = function() {
if (!this.flatMidpoints_) {
this.flatMidpoints_ = _ol_geom_flat_interpolate_.lineString(
this.flatMidpoints_ = interpolatePoint(
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
}
return this.flatMidpoints_;
@@ -169,7 +169,7 @@ RenderFeature.prototype.getFlatMidpoints = function() {
const ends = this.ends_;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const midpoint = _ol_geom_flat_interpolate_.lineString(
const midpoint = interpolatePoint(
flatCoordinates, offset, end, 2, 0.5);
extend(this.flatMidpoints_, midpoint);
offset = end;
@@ -272,7 +272,7 @@ RenderFeature.prototype.transform = function(source, destination) {
projectedExtent[0], projectedExtent[3],
scale, -scale, 0,
0, 0);
_ol_geom_flat_transform_.transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
transform, this.flatCoordinates_);
};
export default RenderFeature;

View File

@@ -11,7 +11,7 @@ import {asColorLike} from '../../colorlike.js';
import {intersects} from '../../extent.js';
import GeometryType from '../../geom/GeometryType.js';
import SimpleGeometry from '../../geom/SimpleGeometry.js';
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
import {transform2D} from '../../geom/flat/transform.js';
import {CANVAS_LINE_DASH} from '../../has.js';
import VectorContext from '../VectorContext.js';
import _ol_render_canvas_ from '../canvas.js';
@@ -252,7 +252,7 @@ CanvasImmediateRenderer.prototype.drawImages_ = function(flatCoordinates, offset
if (!this.image_) {
return;
}
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
const pixelCoordinates = transform2D(
flatCoordinates, offset, end, 2, this.transform_,
this.pixelCoordinates_);
const context = this.context_;
@@ -313,7 +313,7 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
this.setContextStrokeState_(this.textStrokeState_);
}
this.setContextTextState_(this.textState_);
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
const pixelCoordinates = transform2D(
flatCoordinates, offset, end, stride, this.transform_,
this.pixelCoordinates_);
const context = this.context_;
@@ -356,7 +356,7 @@ CanvasImmediateRenderer.prototype.drawText_ = function(flatCoordinates, offset,
*/
CanvasImmediateRenderer.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) {
const context = this.context_;
const pixelCoordinates = _ol_geom_flat_transform_.transform2D(
const pixelCoordinates = transform2D(
flatCoordinates, offset, end, stride, this.transform_,
this.pixelCoordinates_);
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);

View File

@@ -3,7 +3,7 @@
*/
import {inherits} from '../../index.js';
import {asString} from '../../color.js';
import _ol_geom_flat_simplify_ from '../../geom/flat/simplify.js';
import {snap} from '../../geom/flat/simplify.js';
import _ol_render_canvas_ from '../canvas.js';
import CanvasInstruction, {
fillInstruction, strokeInstruction, beginPathInstruction, closePathInstruction
@@ -195,7 +195,7 @@ CanvasPolygonReplay.prototype.finish = function() {
if (tolerance !== 0) {
const coordinates = this.coordinates;
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
coordinates[i] = _ol_geom_flat_simplify_.snap(coordinates[i], tolerance);
coordinates[i] = snap(coordinates[i], tolerance);
}
}
};

View File

@@ -8,10 +8,10 @@ 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 _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';
import {inflateCoordinates, inflateCoordinatesArray, inflateMultiCoordinatesArray} from '../../geom/flat/inflate.js';
import {lineStringLength} from '../../geom/flat/length.js';
import {drawTextOnPath} from '../../geom/flat/textpath.js';
import {transform2D} from '../../geom/flat/transform.js';
import {CANVAS_LINE_DASH} from '../../has.js';
import {isEmpty} from '../../obj.js';
import VectorContext from '../VectorContext.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]);
@@ -549,7 +549,7 @@ CanvasReplay.prototype.replay_ = function(
if (!this.pixelCoordinates_) {
this.pixelCoordinates_ = [];
}
pixelCoordinates = _ol_geom_flat_transform_.transform2D(
pixelCoordinates = transform2D(
this.coordinates, 0, this.coordinates.length, 2,
transform, this.pixelCoordinates_);
_ol_transform_.setFromArray(this.renderedTransform_, transform);
@@ -710,12 +710,12 @@ CanvasReplay.prototype.replay_ = function(
const textKey = /** @type {string} */ (instruction[13]);
const textScale = /** @type {number} */ (instruction[14]);
const pathLength = _ol_geom_flat_length_.lineString(pixelCoordinates, begin, end, 2);
const pathLength = lineStringLength(pixelCoordinates, begin, end, 2);
const textLength = measure(text);
if (overflow || textLength <= pathLength) {
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
const parts = _ol_geom_flat_textpath_.lineString(
const parts = drawTextOnPath(
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
if (parts) {
let c, cc, chars, label, part;

View File

@@ -5,7 +5,7 @@ import {inherits} from '../../index.js';
import {numberSafeCompareFunction} from '../../array.js';
import {createCanvasContext2D} from '../../dom.js';
import {buffer, createEmpty, extendCoordinate} from '../../extent.js';
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
import {transform2D} from '../../geom/flat/transform.js';
import {isEmpty} from '../../obj.js';
import ReplayGroup from '../ReplayGroup.js';
import ReplayType from '../ReplayType.js';
@@ -407,7 +407,7 @@ CanvasReplayGroup.prototype.getClipCoords = function(transform) {
const maxX = maxExtent[2];
const maxY = maxExtent[3];
const flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
_ol_geom_flat_transform_.transform2D(
transform2D(
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
return flatClipCoords;
};

View File

@@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js';
import {asColorLike} from '../../colorlike.js';
import {createCanvasContext2D} from '../../dom.js';
import {intersects} from '../../extent.js';
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
import {matchingChunk} from '../../geom/flat/straightchunk.js';
import GeometryType from '../../geom/GeometryType.js';
import {CANVAS_LINE_DASH, SAFARI} from '../../has.js';
import _ol_render_canvas_ from '../canvas.js';
@@ -202,7 +202,7 @@ CanvasTextReplay.prototype.drawText = function(geometry, feature) {
let flatEnd;
for (let o = 0, oo = ends.length; o < oo; ++o) {
if (textAlign == undefined) {
const range = _ol_geom_flat_straightchunk_.lineString(
const range = matchingChunk(
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
flatOffset = range[0];
flatEnd = range[1];

View File

@@ -6,7 +6,7 @@ import {equals} from '../../array.js';
import {asArray} from '../../color.js';
import {intersects} from '../../extent.js';
import {isEmpty} from '../../obj.js';
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
import {translate} from '../../geom/flat/transform.js';
import {fragment, vertex} from '../webgl/circlereplay/defaultshader.js';
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
import WebGLReplay from '../webgl/Replay.js';
@@ -134,7 +134,7 @@ WebGLCircleReplay.prototype.drawCircle = function(circleGeometry, feature) {
this.radius_ = radius;
let flatCoordinates = circleGeometry.getFlatCoordinates();
flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, 2,
flatCoordinates = translate(flatCoordinates, 0, 2,
stride, -this.origin[0], -this.origin[1]);
this.drawCoordinates_(flatCoordinates, 0, 2, stride);
} else {

View File

@@ -5,8 +5,8 @@ import {getUid, inherits} from '../../index.js';
import {equals} from '../../array.js';
import {asArray} from '../../color.js';
import {intersects} from '../../extent.js';
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
import {linearRingIsClockwise} from '../../geom/flat/orient.js';
import {translate} from '../../geom/flat/transform.js';
import {lineStringIsClosed} from '../../geom/flat/topology.js';
import {isEmpty} from '../../obj.js';
import _ol_render_webgl_ from '../webgl.js';
@@ -252,7 +252,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
if (closed) {
n = n || numVertices / 7;
sign = _ol_geom_flat_orient_.linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2)
sign = linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2)
? 1 : -1;
numVertices = this.addVertices_(p0, p1, p2,
@@ -322,7 +322,7 @@ WebGLLineStringReplay.prototype.drawLineString = function(lineStringGeometry, fe
let flatCoordinates = lineStringGeometry.getFlatCoordinates();
const stride = lineStringGeometry.getStride();
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, flatCoordinates.length,
flatCoordinates = translate(flatCoordinates, 0, flatCoordinates.length,
stride, -this.origin[0], -this.origin[1]);
if (this.state_.changed) {
this.styleIndices_.push(this.indices.length);
@@ -349,7 +349,7 @@ WebGLLineStringReplay.prototype.drawMultiLineString = function(multiLineStringGe
if (ends.length > 1) {
for (i = 1, ii = ends.length; i < ii; ++i) {
if (this.isValid_(flatCoordinates, ends[i - 1], ends[i], stride)) {
const lineString = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1], ends[i],
const lineString = translate(flatCoordinates, ends[i - 1], ends[i],
stride, -this.origin[0], -this.origin[1]);
this.drawCoordinates_(
lineString, 0, lineString.length, stride);

View File

@@ -7,8 +7,8 @@ import {asArray} from '../../color.js';
import {intersects} from '../../extent.js';
import {isEmpty} from '../../obj.js';
import {linearRingContainsXY} from '../../geom/flat/contains.js';
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
import {linearRingIsClockwise} from '../../geom/flat/orient.js';
import {translate} from '../../geom/flat/transform.js';
import {fragment, vertex} from '../webgl/polygonreplay/defaultshader.js';
import Locations from '../webgl/polygonreplay/defaultshader/Locations.js';
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
@@ -140,7 +140,7 @@ WebGLPolygonReplay.prototype.drawCoordinates_ = function(
*/
WebGLPolygonReplay.prototype.processFlatCoordinates_ = function(
flatCoordinates, stride, list, rtree, clockwise) {
const isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates,
const isClockwise = linearRingIsClockwise(flatCoordinates,
0, flatCoordinates.length, stride);
let i, ii;
let n = this.vertices.length / 2;
@@ -404,7 +404,7 @@ WebGLPolygonReplay.prototype.clipEars_ = function(list, rtree, simple, ccw) {
variableCriterion) {
//The diagonal is completely inside the polygon
if (simple || p0.reflex === false || p2.reflex === false ||
_ol_geom_flat_orient_.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
p0.y, p1.x, p1.y, p2.x, p2.y, s3.p1.x, s3.p1.y], 0, 10, 2) === !ccw) {
//The diagonal is persumably valid, we have an ear
this.indices[numIndices++] = p0.i;
@@ -533,7 +533,7 @@ WebGLPolygonReplay.prototype.isClockwise_ = function(list) {
flatCoordinates[i++] = seg.p0.y;
seg = list.nextItem();
} while (seg !== start);
return _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, 0, length, 2);
return linearRingIsClockwise(flatCoordinates, 0, length, 2);
};
@@ -761,14 +761,14 @@ WebGLPolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, f
for (i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
if (ends.length > 0) {
const outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, start, ends[0],
const outerRing = translate(flatCoordinates, start, ends[0],
stride, -this.origin[0], -this.origin[1]);
if (outerRing.length) {
const holes = [];
let holeFlatCoords;
for (j = 1, jj = ends.length; j < jj; ++j) {
if (ends[j] !== ends[j - 1]) {
holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[j - 1],
holeFlatCoords = translate(flatCoordinates, ends[j - 1],
ends[j], stride, -this.origin[0], -this.origin[1]);
holes.push(holeFlatCoords);
}
@@ -801,14 +801,14 @@ WebGLPolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
const stride = polygonGeometry.getStride();
if (ends.length > 0) {
const flatCoordinates = polygonGeometry.getFlatCoordinates().map(Number);
const outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, 0, ends[0],
const outerRing = translate(flatCoordinates, 0, ends[0],
stride, -this.origin[0], -this.origin[1]);
if (outerRing.length) {
const holes = [];
let i, ii, holeFlatCoords;
for (i = 1, ii = ends.length; i < ii; ++i) {
if (ends[i] !== ends[i - 1]) {
holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1],
holeFlatCoords = translate(flatCoordinates, ends[i - 1],
ends[i], stride, -this.origin[0], -this.origin[1]);
holes.push(holeFlatCoords);
}