Some simplifications
This commit is contained in:
@@ -186,7 +186,8 @@ class CanvasBuilder extends VectorContext {
|
|||||||
closed,
|
closed,
|
||||||
skipFirst
|
skipFirst
|
||||||
) {
|
) {
|
||||||
let myEnd = this.coordinates.length;
|
const coordinates = this.coordinates;
|
||||||
|
let myEnd = coordinates.length;
|
||||||
const extent = this.getBufferedMaxExtent();
|
const extent = this.getBufferedMaxExtent();
|
||||||
if (skipFirst) {
|
if (skipFirst) {
|
||||||
offset += stride;
|
offset += stride;
|
||||||
@@ -203,15 +204,15 @@ class CanvasBuilder extends VectorContext {
|
|||||||
nextRel = coordinateRelationship(extent, nextCoord);
|
nextRel = coordinateRelationship(extent, nextCoord);
|
||||||
if (nextRel !== lastRel) {
|
if (nextRel !== lastRel) {
|
||||||
if (skipped) {
|
if (skipped) {
|
||||||
this.coordinates[myEnd++] = lastXCoord;
|
coordinates[myEnd++] = lastXCoord;
|
||||||
this.coordinates[myEnd++] = lastYCoord;
|
coordinates[myEnd++] = lastYCoord;
|
||||||
|
skipped = false;
|
||||||
}
|
}
|
||||||
this.coordinates[myEnd++] = nextCoord[0];
|
coordinates[myEnd++] = nextCoord[0];
|
||||||
this.coordinates[myEnd++] = nextCoord[1];
|
coordinates[myEnd++] = nextCoord[1];
|
||||||
skipped = false;
|
|
||||||
} else if (nextRel === Relationship.INTERSECTING) {
|
} else if (nextRel === Relationship.INTERSECTING) {
|
||||||
this.coordinates[myEnd++] = nextCoord[0];
|
coordinates[myEnd++] = nextCoord[0];
|
||||||
this.coordinates[myEnd++] = nextCoord[1];
|
coordinates[myEnd++] = nextCoord[1];
|
||||||
skipped = false;
|
skipped = false;
|
||||||
} else {
|
} else {
|
||||||
skipped = true;
|
skipped = true;
|
||||||
@@ -223,8 +224,8 @@ class CanvasBuilder extends VectorContext {
|
|||||||
|
|
||||||
// Last coordinate equals first or only one point to append:
|
// Last coordinate equals first or only one point to append:
|
||||||
if ((closed && skipped) || i === offset + stride) {
|
if ((closed && skipped) || i === offset + stride) {
|
||||||
this.coordinates[myEnd++] = lastXCoord;
|
coordinates[myEnd++] = lastXCoord;
|
||||||
this.coordinates[myEnd++] = lastYCoord;
|
coordinates[myEnd++] = lastYCoord;
|
||||||
}
|
}
|
||||||
return myEnd;
|
return myEnd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,11 +169,11 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let begin = this.coordinates.length;
|
const coordinates = this.coordinates;
|
||||||
|
let begin = coordinates.length;
|
||||||
|
|
||||||
const geometryType = geometry.getType();
|
const geometryType = geometry.getType();
|
||||||
let flatCoordinates = null;
|
let flatCoordinates = null;
|
||||||
let end = 2;
|
|
||||||
let stride = geometry.getStride();
|
let stride = geometry.getStride();
|
||||||
let i, ii;
|
let i, ii;
|
||||||
|
|
||||||
@@ -217,9 +217,9 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
flatEnd = ends[o];
|
flatEnd = ends[o];
|
||||||
}
|
}
|
||||||
for (i = flatOffset; i < flatEnd; i += stride) {
|
for (i = flatOffset; i < flatEnd; i += stride) {
|
||||||
this.coordinates.push(flatCoordinates[i], flatCoordinates[i + 1]);
|
coordinates.push(flatCoordinates[i], flatCoordinates[i + 1]);
|
||||||
}
|
}
|
||||||
end = this.coordinates.length;
|
const end = coordinates.length;
|
||||||
flatOffset = ends[o];
|
flatOffset = ends[o];
|
||||||
const declutterGroup = this.declutterGroups_
|
const declutterGroup = this.declutterGroups_
|
||||||
? o === 0
|
? o === 0
|
||||||
@@ -231,15 +231,11 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
}
|
}
|
||||||
this.endGeometry(feature);
|
this.endGeometry(feature);
|
||||||
} else {
|
} else {
|
||||||
let geometryWidths = null;
|
const geometryWidths = textState.overflow ? null : [];
|
||||||
if (!textState.overflow) {
|
|
||||||
geometryWidths = [];
|
|
||||||
}
|
|
||||||
switch (geometryType) {
|
switch (geometryType) {
|
||||||
case GeometryType.POINT:
|
case GeometryType.POINT:
|
||||||
case GeometryType.MULTI_POINT:
|
case GeometryType.MULTI_POINT:
|
||||||
flatCoordinates = /** @type {import("../../geom/MultiPoint.js").default} */ (geometry).getFlatCoordinates();
|
flatCoordinates = /** @type {import("../../geom/MultiPoint.js").default} */ (geometry).getFlatCoordinates();
|
||||||
end = flatCoordinates.length;
|
|
||||||
break;
|
break;
|
||||||
case GeometryType.LINE_STRING:
|
case GeometryType.LINE_STRING:
|
||||||
flatCoordinates = /** @type {import("../../geom/LineString.js").default} */ (geometry).getFlatMidpoint();
|
flatCoordinates = /** @type {import("../../geom/LineString.js").default} */ (geometry).getFlatMidpoint();
|
||||||
@@ -250,7 +246,6 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
case GeometryType.MULTI_LINE_STRING:
|
case GeometryType.MULTI_LINE_STRING:
|
||||||
flatCoordinates = /** @type {import("../../geom/MultiLineString.js").default} */ (geometry).getFlatMidpoints();
|
flatCoordinates = /** @type {import("../../geom/MultiLineString.js").default} */ (geometry).getFlatMidpoints();
|
||||||
stride = 2;
|
stride = 2;
|
||||||
end = flatCoordinates.length;
|
|
||||||
break;
|
break;
|
||||||
case GeometryType.POLYGON:
|
case GeometryType.POLYGON:
|
||||||
flatCoordinates = /** @type {import("../../geom/Polygon.js").default} */ (geometry).getFlatInteriorPoint();
|
flatCoordinates = /** @type {import("../../geom/Polygon.js").default} */ (geometry).getFlatInteriorPoint();
|
||||||
@@ -268,20 +263,22 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
}
|
}
|
||||||
flatCoordinates.push(interiorPoints[i], interiorPoints[i + 1]);
|
flatCoordinates.push(interiorPoints[i], interiorPoints[i + 1]);
|
||||||
}
|
}
|
||||||
stride = 2;
|
if (flatCoordinates.length === 0) {
|
||||||
end = flatCoordinates.length;
|
|
||||||
if (end == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
stride = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
end = this.appendFlatPointCoordinates(
|
const end = this.appendFlatPointCoordinates(
|
||||||
flatCoordinates,
|
flatCoordinates,
|
||||||
0,
|
0,
|
||||||
end,
|
flatCoordinates.length,
|
||||||
stride
|
stride
|
||||||
);
|
);
|
||||||
|
if (end === begin) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.saveTextStates_();
|
this.saveTextStates_();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user