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
+4 -4
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]);
+2 -2
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);
}
}
};
+10 -10
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;
+2 -2
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;
};
+2 -2
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];