Merge pull request #9056 from fredj/rm_typecast
Remove typecast for object literals
This commit is contained in:
+2
-2
@@ -163,13 +163,13 @@ export function listen(target, type, listener, opt_this, opt_once) {
|
|||||||
listenerObj.callOnce = false;
|
listenerObj.callOnce = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
listenerObj = /** @type {EventsKey} */ ({
|
listenerObj = {
|
||||||
bindTo: opt_this,
|
bindTo: opt_this,
|
||||||
callOnce: !!opt_once,
|
callOnce: !!opt_once,
|
||||||
listener: listener,
|
listener: listener,
|
||||||
target: target,
|
target: target,
|
||||||
type: type
|
type: type
|
||||||
});
|
};
|
||||||
/** @type {import("./events/Target.js").default} */ (target).
|
/** @type {import("./events/Target.js").default} */ (target).
|
||||||
addEventListener(type, bindListener(listenerObj));
|
addEventListener(type, bindListener(listenerObj));
|
||||||
listeners.push(listenerObj);
|
listeners.push(listenerObj);
|
||||||
|
|||||||
+39
-46
@@ -211,7 +211,7 @@ class EsriJSON extends JSONFeature {
|
|||||||
*
|
*
|
||||||
* @param {Array<import("../Feature.js").default>} features Features.
|
* @param {Array<import("../Feature.js").default>} features Features.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {Object} EsriJSON Object.
|
* @return {EsriJSONFeatureSet} EsriJSON Object.
|
||||||
* @override
|
* @override
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -221,9 +221,9 @@ class EsriJSON extends JSONFeature {
|
|||||||
for (let i = 0, ii = features.length; i < ii; ++i) {
|
for (let i = 0, ii = features.length; i < ii; ++i) {
|
||||||
objects.push(this.writeFeatureObject(features[i], opt_options));
|
objects.push(this.writeFeatureObject(features[i], opt_options));
|
||||||
}
|
}
|
||||||
return /** @type {EsriJSONFeatureSet} */ ({
|
return {
|
||||||
'features': objects
|
'features': objects
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,40 +414,41 @@ function readPolygonGeometry(object) {
|
|||||||
/**
|
/**
|
||||||
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
* @param {import("../geom/Geometry.js").default} geometry Geometry.
|
||||||
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
|
||||||
* @return {EsriJSONGeometry} EsriJSON geometry.
|
* @return {EsriJSONPoint} EsriJSON geometry.
|
||||||
*/
|
*/
|
||||||
function writePointGeometry(geometry, opt_options) {
|
function writePointGeometry(geometry, opt_options) {
|
||||||
const coordinates = /** @type {import("../geom/Point.js").default} */ (geometry).getCoordinates();
|
const coordinates = /** @type {import("../geom/Point.js").default} */ (geometry).getCoordinates();
|
||||||
|
/** @type {EsriJSONPoint} */
|
||||||
let esriJSON;
|
let esriJSON;
|
||||||
const layout = /** @type {import("../geom/Point.js").default} */ (geometry).getLayout();
|
const layout = /** @type {import("../geom/Point.js").default} */ (geometry).getLayout();
|
||||||
if (layout === GeometryLayout.XYZ) {
|
if (layout === GeometryLayout.XYZ) {
|
||||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
esriJSON = {
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1],
|
y: coordinates[1],
|
||||||
z: coordinates[2]
|
z: coordinates[2]
|
||||||
});
|
};
|
||||||
} else if (layout === GeometryLayout.XYM) {
|
} else if (layout === GeometryLayout.XYM) {
|
||||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
esriJSON = {
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1],
|
y: coordinates[1],
|
||||||
m: coordinates[2]
|
m: coordinates[2]
|
||||||
});
|
};
|
||||||
} else if (layout === GeometryLayout.XYZM) {
|
} else if (layout === GeometryLayout.XYZM) {
|
||||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
esriJSON = {
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1],
|
y: coordinates[1],
|
||||||
z: coordinates[2],
|
z: coordinates[2],
|
||||||
m: coordinates[3]
|
m: coordinates[3]
|
||||||
});
|
};
|
||||||
} else if (layout === GeometryLayout.XY) {
|
} else if (layout === GeometryLayout.XY) {
|
||||||
esriJSON = /** @type {EsriJSONPoint} */ ({
|
esriJSON = {
|
||||||
x: coordinates[0],
|
x: coordinates[0],
|
||||||
y: coordinates[1]
|
y: coordinates[1]
|
||||||
});
|
};
|
||||||
} else {
|
} else {
|
||||||
assert(false, 34); // Invalid geometry layout
|
assert(false, 34); // Invalid geometry layout
|
||||||
}
|
}
|
||||||
return /** @type {EsriJSONGeometry} */ (esriJSON);
|
return esriJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -474,15 +475,13 @@ function getHasZM(geometry) {
|
|||||||
function writeLineStringGeometry(geometry, opt_options) {
|
function writeLineStringGeometry(geometry, opt_options) {
|
||||||
const lineString = /** @type {import("../geom/LineString.js").default} */ (geometry);
|
const lineString = /** @type {import("../geom/LineString.js").default} */ (geometry);
|
||||||
const hasZM = getHasZM(lineString);
|
const hasZM = getHasZM(lineString);
|
||||||
return (
|
return {
|
||||||
/** @type {EsriJSONPolyline} */ {
|
hasZ: hasZM.hasZ,
|
||||||
hasZ: hasZM.hasZ,
|
hasM: hasZM.hasM,
|
||||||
hasM: hasZM.hasM,
|
paths: [
|
||||||
paths: [
|
/** @type {Array<EsriJSONPosition>} */ (lineString.getCoordinates())
|
||||||
/** @type {Array<EsriJSONPosition>} */ (lineString.getCoordinates())
|
]
|
||||||
]
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -495,13 +494,11 @@ function writePolygonGeometry(geometry, opt_options) {
|
|||||||
const polygon = /** @type {import("../geom/Polygon.js").default} */ (geometry);
|
const polygon = /** @type {import("../geom/Polygon.js").default} */ (geometry);
|
||||||
// Esri geometries use the left-hand rule
|
// Esri geometries use the left-hand rule
|
||||||
const hasZM = getHasZM(polygon);
|
const hasZM = getHasZM(polygon);
|
||||||
return (
|
return {
|
||||||
/** @type {EsriJSONPolygon} */ {
|
hasZ: hasZM.hasZ,
|
||||||
hasZ: hasZM.hasZ,
|
hasM: hasZM.hasM,
|
||||||
hasM: hasZM.hasM,
|
rings: /** @type {Array<Array<EsriJSONPosition>>} */ (polygon.getCoordinates(false))
|
||||||
rings: /** @type {Array<Array<EsriJSONPosition>>} */ (polygon.getCoordinates(false))
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -513,13 +510,11 @@ function writePolygonGeometry(geometry, opt_options) {
|
|||||||
function writeMultiLineStringGeometry(geometry, opt_options) {
|
function writeMultiLineStringGeometry(geometry, opt_options) {
|
||||||
const multiLineString = /** @type {import("../geom/MultiLineString.js").default} */ (geometry);
|
const multiLineString = /** @type {import("../geom/MultiLineString.js").default} */ (geometry);
|
||||||
const hasZM = getHasZM(multiLineString);
|
const hasZM = getHasZM(multiLineString);
|
||||||
return (
|
return {
|
||||||
/** @type {EsriJSONPolyline} */ {
|
hasZ: hasZM.hasZ,
|
||||||
hasZ: hasZM.hasZ,
|
hasM: hasZM.hasM,
|
||||||
hasM: hasZM.hasM,
|
paths: /** @type {Array<Array<EsriJSONPosition>>} */ (multiLineString.getCoordinates())
|
||||||
paths: /** @type {Array<Array<EsriJSONPosition>>} */ (multiLineString.getCoordinates())
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -531,13 +526,11 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
|
|||||||
function writeMultiPointGeometry(geometry, opt_options) {
|
function writeMultiPointGeometry(geometry, opt_options) {
|
||||||
const multiPoint = /** @type {import("../geom/MultiPoint.js").default} */ (geometry);
|
const multiPoint = /** @type {import("../geom/MultiPoint.js").default} */ (geometry);
|
||||||
const hasZM = getHasZM(multiPoint);
|
const hasZM = getHasZM(multiPoint);
|
||||||
return (
|
return {
|
||||||
/** @type {EsriJSONMultipoint} */ {
|
hasZ: hasZM.hasZ,
|
||||||
hasZ: hasZM.hasZ,
|
hasM: hasZM.hasM,
|
||||||
hasM: hasZM.hasM,
|
points: /** @type {Array<EsriJSONPosition>} */ (multiPoint.getCoordinates())
|
||||||
points: /** @type {Array<EsriJSONPosition>} */ (multiPoint.getCoordinates())
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -555,11 +548,11 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
|
|||||||
output.push(coordinates[i][x]);
|
output.push(coordinates[i][x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return /** @type {EsriJSONPolygon} */ ({
|
return {
|
||||||
hasZ: hasZM.hasZ,
|
hasZ: hasZM.hasZ,
|
||||||
hasM: hasZM.hasM,
|
hasM: hasZM.hasM,
|
||||||
rings: output
|
rings: /** @type {Array<Array<EsriJSONPosition>>} */ (output)
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+19
-21
@@ -451,13 +451,11 @@ class Snap extends PointerInteraction {
|
|||||||
vertexPixel = [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])];
|
vertexPixel = [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return {
|
||||||
/** @type {Result} */ ({
|
snapped: snapped,
|
||||||
snapped: snapped,
|
vertex: vertex,
|
||||||
vertex: vertex,
|
vertexPixel: vertexPixel
|
||||||
vertexPixel: vertexPixel
|
};
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -479,10 +477,10 @@ class Snap extends PointerInteraction {
|
|||||||
const coordinates = polygon.getCoordinates()[0];
|
const coordinates = polygon.getCoordinates()[0];
|
||||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||||
const segment = coordinates.slice(i, i + 2);
|
const segment = coordinates.slice(i, i + 2);
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: segment
|
segment: segment
|
||||||
});
|
};
|
||||||
this.rBush_.insert(boundingExtent(segment), segmentData);
|
this.rBush_.insert(boundingExtent(segment), segmentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -511,10 +509,10 @@ class Snap extends PointerInteraction {
|
|||||||
const coordinates = geometry.getCoordinates();
|
const coordinates = geometry.getCoordinates();
|
||||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||||
const segment = coordinates.slice(i, i + 2);
|
const segment = coordinates.slice(i, i + 2);
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: segment
|
segment: segment
|
||||||
});
|
};
|
||||||
this.rBush_.insert(boundingExtent(segment), segmentData);
|
this.rBush_.insert(boundingExtent(segment), segmentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -530,10 +528,10 @@ class Snap extends PointerInteraction {
|
|||||||
const coordinates = lines[j];
|
const coordinates = lines[j];
|
||||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||||
const segment = coordinates.slice(i, i + 2);
|
const segment = coordinates.slice(i, i + 2);
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: segment
|
segment: segment
|
||||||
});
|
};
|
||||||
this.rBush_.insert(boundingExtent(segment), segmentData);
|
this.rBush_.insert(boundingExtent(segment), segmentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,10 +546,10 @@ class Snap extends PointerInteraction {
|
|||||||
const points = geometry.getCoordinates();
|
const points = geometry.getCoordinates();
|
||||||
for (let i = 0, ii = points.length; i < ii; ++i) {
|
for (let i = 0, ii = points.length; i < ii; ++i) {
|
||||||
const coordinates = points[i];
|
const coordinates = points[i];
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: [coordinates, coordinates]
|
segment: [coordinates, coordinates]
|
||||||
});
|
};
|
||||||
this.rBush_.insert(geometry.getExtent(), segmentData);
|
this.rBush_.insert(geometry.getExtent(), segmentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -569,10 +567,10 @@ class Snap extends PointerInteraction {
|
|||||||
const coordinates = rings[j];
|
const coordinates = rings[j];
|
||||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||||
const segment = coordinates.slice(i, i + 2);
|
const segment = coordinates.slice(i, i + 2);
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: segment
|
segment: segment
|
||||||
});
|
};
|
||||||
this.rBush_.insert(boundingExtent(segment), segmentData);
|
this.rBush_.insert(boundingExtent(segment), segmentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -586,10 +584,10 @@ class Snap extends PointerInteraction {
|
|||||||
*/
|
*/
|
||||||
writePointGeometry_(feature, geometry) {
|
writePointGeometry_(feature, geometry) {
|
||||||
const coordinates = geometry.getCoordinates();
|
const coordinates = geometry.getCoordinates();
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: [coordinates, coordinates]
|
segment: [coordinates, coordinates]
|
||||||
});
|
};
|
||||||
this.rBush_.insert(geometry.getExtent(), segmentData);
|
this.rBush_.insert(geometry.getExtent(), segmentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,10 +602,10 @@ class Snap extends PointerInteraction {
|
|||||||
const coordinates = rings[j];
|
const coordinates = rings[j];
|
||||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||||
const segment = coordinates.slice(i, i + 2);
|
const segment = coordinates.slice(i, i + 2);
|
||||||
const segmentData = /** @type {SegmentData} */ ({
|
const segmentData = {
|
||||||
feature: feature,
|
feature: feature,
|
||||||
segment: segment
|
segment: segment
|
||||||
});
|
};
|
||||||
this.rBush_.insert(boundingExtent(segment), segmentData);
|
this.rBush_.insert(boundingExtent(segment), segmentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
const strokeKey = this.strokeKey_;
|
const strokeKey = this.strokeKey_;
|
||||||
if (strokeState) {
|
if (strokeState) {
|
||||||
if (!(strokeKey in this.strokeStates)) {
|
if (!(strokeKey in this.strokeStates)) {
|
||||||
this.strokeStates[strokeKey] = /** @type {import("../canvas.js").StrokeState} */ ({
|
this.strokeStates[strokeKey] = {
|
||||||
strokeStyle: strokeState.strokeStyle,
|
strokeStyle: strokeState.strokeStyle,
|
||||||
lineCap: strokeState.lineCap,
|
lineCap: strokeState.lineCap,
|
||||||
lineDashOffset: strokeState.lineDashOffset,
|
lineDashOffset: strokeState.lineDashOffset,
|
||||||
@@ -316,24 +316,24 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|||||||
lineJoin: strokeState.lineJoin,
|
lineJoin: strokeState.lineJoin,
|
||||||
miterLimit: strokeState.miterLimit,
|
miterLimit: strokeState.miterLimit,
|
||||||
lineDash: strokeState.lineDash
|
lineDash: strokeState.lineDash
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const textKey = this.textKey_;
|
const textKey = this.textKey_;
|
||||||
if (!(textKey in this.textStates)) {
|
if (!(textKey in this.textStates)) {
|
||||||
this.textStates[textKey] = /** @type {import("../canvas.js").TextState} */ ({
|
this.textStates[textKey] = {
|
||||||
font: textState.font,
|
font: textState.font,
|
||||||
textAlign: textState.textAlign || defaultTextAlign,
|
textAlign: textState.textAlign || defaultTextAlign,
|
||||||
textBaseline: textState.textBaseline || defaultTextBaseline,
|
textBaseline: textState.textBaseline || defaultTextBaseline,
|
||||||
scale: textState.scale
|
scale: textState.scale
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
const fillKey = this.fillKey_;
|
const fillKey = this.fillKey_;
|
||||||
if (fillState) {
|
if (fillState) {
|
||||||
if (!(fillKey in this.fillStates)) {
|
if (!(fillKey in this.fillStates)) {
|
||||||
this.fillStates[fillKey] = /** @type {import("../canvas.js").FillState} */ ({
|
this.fillStates[fillKey] = {
|
||||||
fillStyle: fillState.fillStyle
|
fillStyle: fillState.fillStyle
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,12 +261,12 @@ class LRUCache extends EventTarget {
|
|||||||
set(key, value) {
|
set(key, value) {
|
||||||
assert(!(key in this.entries_),
|
assert(!(key in this.entries_),
|
||||||
16); // Tried to set a value for a key that is used already
|
16); // Tried to set a value for a key that is used already
|
||||||
const entry = /** @type {Entry} */ ({
|
const entry = {
|
||||||
key_: key,
|
key_: key,
|
||||||
newer: null,
|
newer: null,
|
||||||
older: this.newest_,
|
older: this.newest_,
|
||||||
value_: value
|
value_: value
|
||||||
});
|
};
|
||||||
if (!this.newest_) {
|
if (!this.newest_) {
|
||||||
this.oldest_ = entry;
|
this.oldest_ = entry;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -152,14 +152,12 @@ class AtlasManager {
|
|||||||
* entry, or `null` if the entry is not part of the atlases.
|
* entry, or `null` if the entry is not part of the atlases.
|
||||||
*/
|
*/
|
||||||
mergeInfos_(info, hitInfo) {
|
mergeInfos_(info, hitInfo) {
|
||||||
return (
|
return {
|
||||||
/** @type {AtlasManagerInfo} */ ({
|
offsetX: info.offsetX,
|
||||||
offsetX: info.offsetX,
|
offsetY: info.offsetY,
|
||||||
offsetY: info.offsetY,
|
image: info.image,
|
||||||
image: info.image,
|
hitImage: hitInfo.image
|
||||||
hitImage: hitInfo.image
|
};
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user