Better variables scoping
This commit is contained in:
@@ -69,13 +69,12 @@ GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const coordsGroups = s.trim().split(/\s+/);
|
const coordsGroups = s.trim().split(/\s+/);
|
||||||
let x, y, z;
|
|
||||||
const flatCoordinates = [];
|
const flatCoordinates = [];
|
||||||
for (let i = 0, ii = coordsGroups.length; i < ii; i++) {
|
for (let i = 0, ii = coordsGroups.length; i < ii; i++) {
|
||||||
const coords = coordsGroups[i].split(/,+/);
|
const coords = coordsGroups[i].split(/,+/);
|
||||||
x = parseFloat(coords[0]);
|
const x = parseFloat(coords[0]);
|
||||||
y = parseFloat(coords[1]);
|
const y = parseFloat(coords[1]);
|
||||||
z = (coords.length === 3) ? parseFloat(coords[2]) : 0;
|
const z = (coords.length === 3) ? parseFloat(coords[2]) : 0;
|
||||||
if (axisOrientation.substr(0, 2) === 'en') {
|
if (axisOrientation.substr(0, 2) === 'en') {
|
||||||
flatCoordinates.push(x, y, z);
|
flatCoordinates.push(x, y, z);
|
||||||
} else {
|
} else {
|
||||||
@@ -333,9 +332,8 @@ GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
|
|||||||
const points = value.getCoordinates();
|
const points = value.getCoordinates();
|
||||||
const len = points.length;
|
const len = points.length;
|
||||||
const parts = new Array(len);
|
const parts = new Array(len);
|
||||||
let point;
|
|
||||||
for (let i = 0; i < len; ++i) {
|
for (let i = 0; i < len; ++i) {
|
||||||
point = points[i];
|
const point = points[i];
|
||||||
parts[i] = this.getCoords_(point, srsName, hasZ);
|
parts[i] = this.getCoords_(point, srsName, hasZ);
|
||||||
}
|
}
|
||||||
writeStringTextNode(node, parts.join(' '));
|
writeStringTextNode(node, parts.join(' '));
|
||||||
@@ -349,8 +347,7 @@ GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) {
|
GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) {
|
||||||
const child = createElementNS(node.namespaceURI,
|
const child = createElementNS(node.namespaceURI, 'LineStringSegment');
|
||||||
'LineStringSegment');
|
|
||||||
node.appendChild(child);
|
node.appendChild(child);
|
||||||
this.writeCurveOrLineString_(child, line, objectStack);
|
this.writeCurveOrLineString_(child, line, objectStack);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -122,12 +122,11 @@ GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
|||||||
const context = objectStack[0];
|
const context = objectStack[0];
|
||||||
let featureType = context['featureType'];
|
let featureType = context['featureType'];
|
||||||
let featureNS = context['featureNS'];
|
let featureNS = context['featureNS'];
|
||||||
let i, ii;
|
|
||||||
const prefix = 'p';
|
const prefix = 'p';
|
||||||
const defaultPrefix = 'p0';
|
const defaultPrefix = 'p0';
|
||||||
if (!featureType && node.childNodes) {
|
if (!featureType && node.childNodes) {
|
||||||
featureType = [], featureNS = {};
|
featureType = [], featureNS = {};
|
||||||
for (i = 0, ii = node.childNodes.length; i < ii; ++i) {
|
for (let i = 0, ii = node.childNodes.length; i < ii; ++i) {
|
||||||
const child = node.childNodes[i];
|
const child = node.childNodes[i];
|
||||||
if (child.nodeType === 1) {
|
if (child.nodeType === 1) {
|
||||||
const ft = child.nodeName.split(':').pop();
|
const ft = child.nodeName.split(':').pop();
|
||||||
@@ -165,7 +164,7 @@ GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
|||||||
const featureTypes = Array.isArray(featureType) ? featureType : [featureType];
|
const featureTypes = Array.isArray(featureType) ? featureType : [featureType];
|
||||||
for (const p in featureNS) {
|
for (const p in featureNS) {
|
||||||
const parsers = {};
|
const parsers = {};
|
||||||
for (i = 0, ii = featureTypes.length; i < ii; ++i) {
|
for (let i = 0, ii = featureTypes.length; i < ii; ++i) {
|
||||||
const featurePrefix = featureTypes[i].indexOf(':') === -1 ?
|
const featurePrefix = featureTypes[i].indexOf(':') === -1 ?
|
||||||
defaultPrefix : featureTypes[i].split(':')[0];
|
defaultPrefix : featureTypes[i].split(':')[0];
|
||||||
if (featurePrefix === p) {
|
if (featurePrefix === p) {
|
||||||
|
|||||||
@@ -427,8 +427,7 @@ function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
|
|||||||
stride = 3;
|
stride = 3;
|
||||||
}
|
}
|
||||||
if (stride !== 4) {
|
if (stride !== 4) {
|
||||||
let i, ii;
|
for (let i = 0, ii = flatCoordinates.length / 4; i < ii; i++) {
|
||||||
for (i = 0, ii = flatCoordinates.length / 4; i < ii; i++) {
|
|
||||||
flatCoordinates[i * stride] = flatCoordinates[i * 4];
|
flatCoordinates[i * stride] = flatCoordinates[i * 4];
|
||||||
flatCoordinates[i * stride + 1] = flatCoordinates[i * 4 + 1];
|
flatCoordinates[i * stride + 1] = flatCoordinates[i * 4 + 1];
|
||||||
if (layoutOptions.hasZ) {
|
if (layoutOptions.hasZ) {
|
||||||
@@ -440,7 +439,7 @@ function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
|
|||||||
}
|
}
|
||||||
flatCoordinates.length = flatCoordinates.length / 4 * stride;
|
flatCoordinates.length = flatCoordinates.length / 4 * stride;
|
||||||
if (ends) {
|
if (ends) {
|
||||||
for (i = 0, ii = ends.length; i < ii; i++) {
|
for (let i = 0, ii = ends.length; i < ii; i++) {
|
||||||
ends[i] = ends[i] / 4 * stride;
|
ends[i] = ends[i] / 4 * stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -928,9 +928,7 @@ function readGxTrack(node, objectStack) {
|
|||||||
}
|
}
|
||||||
const flatCoordinates = gxTrackObject.flatCoordinates;
|
const flatCoordinates = gxTrackObject.flatCoordinates;
|
||||||
const whens = gxTrackObject.whens;
|
const whens = gxTrackObject.whens;
|
||||||
let i, ii;
|
for (let i = 0, ii = Math.min(flatCoordinates.length, whens.length); i < ii; ++i) {
|
||||||
for (i = 0, ii = Math.min(flatCoordinates.length, whens.length); i < ii;
|
|
||||||
++i) {
|
|
||||||
flatCoordinates[4 * i + 3] = whens[i];
|
flatCoordinates[4 * i + 3] = whens[i];
|
||||||
}
|
}
|
||||||
const lineString = new LineString(null);
|
const lineString = new LineString(null);
|
||||||
@@ -1081,8 +1079,8 @@ function readMultiGeometry(node, objectStack) {
|
|||||||
let multiGeometry;
|
let multiGeometry;
|
||||||
let homogeneous = true;
|
let homogeneous = true;
|
||||||
const type = geometries[0].getType();
|
const type = geometries[0].getType();
|
||||||
let geometry, i, ii;
|
let geometry;
|
||||||
for (i = 1, ii = geometries.length; i < ii; ++i) {
|
for (let i = 1, ii = geometries.length; i < ii; ++i) {
|
||||||
geometry = geometries[i];
|
geometry = geometries[i];
|
||||||
if (geometry.getType() != type) {
|
if (geometry.getType() != type) {
|
||||||
homogeneous = false;
|
homogeneous = false;
|
||||||
@@ -1096,7 +1094,7 @@ function readMultiGeometry(node, objectStack) {
|
|||||||
const point = geometries[0];
|
const point = geometries[0];
|
||||||
layout = point.getLayout();
|
layout = point.getLayout();
|
||||||
flatCoordinates = point.getFlatCoordinates();
|
flatCoordinates = point.getFlatCoordinates();
|
||||||
for (i = 1, ii = geometries.length; i < ii; ++i) {
|
for (let i = 1, ii = geometries.length; i < ii; ++i) {
|
||||||
geometry = geometries[i];
|
geometry = geometries[i];
|
||||||
extend(flatCoordinates, geometry.getFlatCoordinates());
|
extend(flatCoordinates, geometry.getFlatCoordinates());
|
||||||
}
|
}
|
||||||
@@ -1171,13 +1169,11 @@ function readPolygon(node, objectStack) {
|
|||||||
const polygon = new Polygon(null);
|
const polygon = new Polygon(null);
|
||||||
const flatCoordinates = flatLinearRings[0];
|
const flatCoordinates = flatLinearRings[0];
|
||||||
const ends = [flatCoordinates.length];
|
const ends = [flatCoordinates.length];
|
||||||
let i, ii;
|
for (let i = 1, ii = flatLinearRings.length; i < ii; ++i) {
|
||||||
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
|
|
||||||
extend(flatCoordinates, flatLinearRings[i]);
|
extend(flatCoordinates, flatLinearRings[i]);
|
||||||
ends.push(flatCoordinates.length);
|
ends.push(flatCoordinates.length);
|
||||||
}
|
}
|
||||||
polygon.setFlatCoordinates(
|
polygon.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates, ends);
|
||||||
GeometryLayout.XYZ, flatCoordinates, ends);
|
|
||||||
polygon.setProperties(properties);
|
polygon.setProperties(properties);
|
||||||
return polygon;
|
return polygon;
|
||||||
} else {
|
} else {
|
||||||
@@ -1251,16 +1247,15 @@ function readStyle(node, objectStack) {
|
|||||||
* multiGeometry A multi-geometry.
|
* multiGeometry A multi-geometry.
|
||||||
* @param {Array.<ol.geom.Geometry>} geometries List of geometries.
|
* @param {Array.<ol.geom.Geometry>} geometries List of geometries.
|
||||||
*/
|
*/
|
||||||
function setCommonGeometryProperties(multiGeometry,
|
function setCommonGeometryProperties(multiGeometry, geometries) {
|
||||||
geometries) {
|
|
||||||
const ii = geometries.length;
|
const ii = geometries.length;
|
||||||
const extrudes = new Array(geometries.length);
|
const extrudes = new Array(geometries.length);
|
||||||
const tessellates = new Array(geometries.length);
|
const tessellates = new Array(geometries.length);
|
||||||
const altitudeModes = new Array(geometries.length);
|
const altitudeModes = new Array(geometries.length);
|
||||||
let geometry, i, hasExtrude, hasTessellate, hasAltitudeMode;
|
let hasExtrude, hasTessellate, hasAltitudeMode;
|
||||||
hasExtrude = hasTessellate = hasAltitudeMode = false;
|
hasExtrude = hasTessellate = hasAltitudeMode = false;
|
||||||
for (i = 0; i < ii; ++i) {
|
for (let i = 0; i < ii; ++i) {
|
||||||
geometry = geometries[i];
|
const geometry = geometries[i];
|
||||||
extrudes[i] = geometry.get('extrude');
|
extrudes[i] = geometry.get('extrude');
|
||||||
tessellates[i] = geometry.get('tessellate');
|
tessellates[i] = geometry.get('tessellate');
|
||||||
altitudeModes[i] = geometry.get('altitudeMode');
|
altitudeModes[i] = geometry.get('altitudeMode');
|
||||||
@@ -1846,8 +1841,7 @@ KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
|||||||
}
|
}
|
||||||
} else if (localName == 'kml') {
|
} else if (localName == 'kml') {
|
||||||
features = [];
|
features = [];
|
||||||
let n;
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
|
||||||
const fs = this.readFeaturesFromNode(n, opt_options);
|
const fs = this.readFeaturesFromNode(n, opt_options);
|
||||||
if (fs) {
|
if (fs) {
|
||||||
extend(features, fs);
|
extend(features, fs);
|
||||||
@@ -1886,8 +1880,7 @@ KML.prototype.readName = function(source) {
|
|||||||
* @return {string|undefined} Name.
|
* @return {string|undefined} Name.
|
||||||
*/
|
*/
|
||||||
KML.prototype.readNameFromDocument = function(doc) {
|
KML.prototype.readNameFromDocument = function(doc) {
|
||||||
let n;
|
for (let n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
for (n = doc.firstChild; n; n = n.nextSibling) {
|
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
const name = this.readNameFromNode(n);
|
const name = this.readNameFromNode(n);
|
||||||
if (name) {
|
if (name) {
|
||||||
@@ -1904,14 +1897,13 @@ KML.prototype.readNameFromDocument = function(doc) {
|
|||||||
* @return {string|undefined} Name.
|
* @return {string|undefined} Name.
|
||||||
*/
|
*/
|
||||||
KML.prototype.readNameFromNode = function(node) {
|
KML.prototype.readNameFromNode = function(node) {
|
||||||
let n;
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
||||||
n.localName == 'name') {
|
n.localName == 'name') {
|
||||||
return readString(n);
|
return readString(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
if (includes(NAMESPACE_URIS, n.namespaceURI) &&
|
||||||
(localName == 'Document' ||
|
(localName == 'Document' ||
|
||||||
@@ -2078,8 +2070,7 @@ function writeColorTextNode(node, color) {
|
|||||||
const rgba = asArray(color);
|
const rgba = asArray(color);
|
||||||
const opacity = (rgba.length == 4) ? rgba[3] : 1;
|
const opacity = (rgba.length == 4) ? rgba[3] : 1;
|
||||||
const abgr = [opacity * 255, rgba[2], rgba[1], rgba[0]];
|
const abgr = [opacity * 255, rgba[2], rgba[1], rgba[0]];
|
||||||
let i;
|
for (let i = 0; i < 4; ++i) {
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
const hex = parseInt(abgr[i], 10).toString(16);
|
const hex = parseInt(abgr[i], 10).toString(16);
|
||||||
abgr[i] = (hex.length == 1) ? '0' + hex : hex;
|
abgr[i] = (hex.length == 1) ? '0' + hex : hex;
|
||||||
}
|
}
|
||||||
@@ -2109,17 +2100,16 @@ function writeCoordinatesTextNode(node, coordinates, objectStack) {
|
|||||||
assert(false, 34); // Invalid geometry layout
|
assert(false, 34); // Invalid geometry layout
|
||||||
}
|
}
|
||||||
|
|
||||||
let d, i;
|
|
||||||
const ii = coordinates.length;
|
const ii = coordinates.length;
|
||||||
let text = '';
|
let text = '';
|
||||||
if (ii > 0) {
|
if (ii > 0) {
|
||||||
text += coordinates[0];
|
text += coordinates[0];
|
||||||
for (d = 1; d < dimension; ++d) {
|
for (let d = 1; d < dimension; ++d) {
|
||||||
text += ',' + coordinates[d];
|
text += ',' + coordinates[d];
|
||||||
}
|
}
|
||||||
for (i = stride; i < ii; i += stride) {
|
for (let i = stride; i < ii; i += stride) {
|
||||||
text += ' ' + coordinates[i];
|
text += ' ' + coordinates[i];
|
||||||
for (d = 1; d < dimension; ++d) {
|
for (let d = 1; d < dimension; ++d) {
|
||||||
text += ',' + coordinates[i + d];
|
text += ',' + coordinates[i + d];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2501,8 +2491,7 @@ const GEOMETRY_TYPE_TO_NODENAME = {
|
|||||||
* @param {string=} opt_nodeName Node name.
|
* @param {string=} opt_nodeName Node name.
|
||||||
* @return {Node|undefined} Node.
|
* @return {Node|undefined} Node.
|
||||||
*/
|
*/
|
||||||
const GEOMETRY_NODE_FACTORY = function(value, objectStack,
|
const GEOMETRY_NODE_FACTORY = function(value, objectStack, opt_nodeName) {
|
||||||
opt_nodeName) {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
const parentNode = objectStack[objectStack.length - 1].node;
|
const parentNode = objectStack[objectStack.length - 1].node;
|
||||||
return createElementNS(parentNode.namespaceURI,
|
return createElementNS(parentNode.namespaceURI,
|
||||||
|
|||||||
@@ -372,12 +372,11 @@ MVT.prototype.readFeatures = function(source, opt_options) {
|
|||||||
const pbfLayers = pbf.readFields(layersPBFReader, {});
|
const pbfLayers = pbf.readFields(layersPBFReader, {});
|
||||||
/** @type {Array.<ol.Feature|ol.render.Feature>} */
|
/** @type {Array.<ol.Feature|ol.render.Feature>} */
|
||||||
const features = [];
|
const features = [];
|
||||||
let pbfLayer;
|
|
||||||
for (const name in pbfLayers) {
|
for (const name in pbfLayers) {
|
||||||
if (layers && layers.indexOf(name) == -1) {
|
if (layers && layers.indexOf(name) == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pbfLayer = pbfLayers[name];
|
const pbfLayer = pbfLayers[name];
|
||||||
|
|
||||||
for (let i = 0, ii = pbfLayer.length; i < ii; ++i) {
|
for (let i = 0, ii = pbfLayer.length; i < ii; ++i) {
|
||||||
const rawFeature = readRawFeature(pbf, pbfLayer, i);
|
const rawFeature = readRawFeature(pbf, pbfLayer, i);
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ export function encodeDeltas(numbers, stride, opt_factor) {
|
|||||||
lastNumbers[d] = 0;
|
lastNumbers[d] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii;) {
|
||||||
for (i = 0, ii = numbers.length; i < ii;) {
|
|
||||||
for (d = 0; d < stride; ++d, ++i) {
|
for (d = 0; d < stride; ++d, ++i) {
|
||||||
const num = numbers[i];
|
const num = numbers[i];
|
||||||
const delta = num - lastNumbers[d];
|
const delta = num - lastNumbers[d];
|
||||||
@@ -112,8 +111,7 @@ export function decodeDeltas(encoded, stride, opt_factor) {
|
|||||||
|
|
||||||
const numbers = decodeFloats(encoded, factor);
|
const numbers = decodeFloats(encoded, factor);
|
||||||
|
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii;) {
|
||||||
for (i = 0, ii = numbers.length; i < ii;) {
|
|
||||||
for (d = 0; d < stride; ++d, ++i) {
|
for (d = 0; d < stride; ++d, ++i) {
|
||||||
lastNumbers[d] += numbers[i];
|
lastNumbers[d] += numbers[i];
|
||||||
|
|
||||||
@@ -139,8 +137,7 @@ export function decodeDeltas(encoded, stride, opt_factor) {
|
|||||||
*/
|
*/
|
||||||
export function encodeFloats(numbers, opt_factor) {
|
export function encodeFloats(numbers, opt_factor) {
|
||||||
const factor = opt_factor ? opt_factor : 1e5;
|
const factor = opt_factor ? opt_factor : 1e5;
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = numbers.length; i < ii; ++i) {
|
|
||||||
numbers[i] = Math.round(numbers[i] * factor);
|
numbers[i] = Math.round(numbers[i] * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,8 +157,7 @@ export function encodeFloats(numbers, opt_factor) {
|
|||||||
export function decodeFloats(encoded, opt_factor) {
|
export function decodeFloats(encoded, opt_factor) {
|
||||||
const factor = opt_factor ? opt_factor : 1e5;
|
const factor = opt_factor ? opt_factor : 1e5;
|
||||||
const numbers = decodeSignedIntegers(encoded);
|
const numbers = decodeSignedIntegers(encoded);
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = numbers.length; i < ii; ++i) {
|
|
||||||
numbers[i] /= factor;
|
numbers[i] /= factor;
|
||||||
}
|
}
|
||||||
return numbers;
|
return numbers;
|
||||||
@@ -177,8 +173,7 @@ export function decodeFloats(encoded, opt_factor) {
|
|||||||
* @return {string} The encoded string.
|
* @return {string} The encoded string.
|
||||||
*/
|
*/
|
||||||
export function encodeSignedIntegers(numbers) {
|
export function encodeSignedIntegers(numbers) {
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = numbers.length; i < ii; ++i) {
|
|
||||||
const num = numbers[i];
|
const num = numbers[i];
|
||||||
numbers[i] = (num < 0) ? ~(num << 1) : (num << 1);
|
numbers[i] = (num < 0) ? ~(num << 1) : (num << 1);
|
||||||
}
|
}
|
||||||
@@ -194,8 +189,7 @@ export function encodeSignedIntegers(numbers) {
|
|||||||
*/
|
*/
|
||||||
export function decodeSignedIntegers(encoded) {
|
export function decodeSignedIntegers(encoded) {
|
||||||
const numbers = decodeUnsignedIntegers(encoded);
|
const numbers = decodeUnsignedIntegers(encoded);
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = numbers.length; i < ii; ++i) {
|
|
||||||
const num = numbers[i];
|
const num = numbers[i];
|
||||||
numbers[i] = (num & 1) ? ~(num >> 1) : (num >> 1);
|
numbers[i] = (num & 1) ? ~(num >> 1) : (num >> 1);
|
||||||
}
|
}
|
||||||
@@ -211,8 +205,7 @@ export function decodeSignedIntegers(encoded) {
|
|||||||
*/
|
*/
|
||||||
export function encodeUnsignedIntegers(numbers) {
|
export function encodeUnsignedIntegers(numbers) {
|
||||||
let encoded = '';
|
let encoded = '';
|
||||||
let i, ii;
|
for (let i = 0, ii = numbers.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = numbers.length; i < ii; ++i) {
|
|
||||||
encoded += encodeUnsignedInteger(numbers[i]);
|
encoded += encodeUnsignedInteger(numbers[i]);
|
||||||
}
|
}
|
||||||
return encoded;
|
return encoded;
|
||||||
@@ -229,8 +222,7 @@ export function decodeUnsignedIntegers(encoded) {
|
|||||||
const numbers = [];
|
const numbers = [];
|
||||||
let current = 0;
|
let current = 0;
|
||||||
let shift = 0;
|
let shift = 0;
|
||||||
let i, ii;
|
for (let i = 0, ii = encoded.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = encoded.length; i < ii; ++i) {
|
|
||||||
const b = encoded.charCodeAt(i) - 63;
|
const b = encoded.charCodeAt(i) - 63;
|
||||||
current |= (b & 0x1f) << shift;
|
current |= (b & 0x1f) << shift;
|
||||||
if (b < 0x20) {
|
if (b < 0x20) {
|
||||||
|
|||||||
@@ -78,9 +78,7 @@ function concatenateArcs(indices, arcs) {
|
|||||||
/** @type {Array.<ol.Coordinate>} */
|
/** @type {Array.<ol.Coordinate>} */
|
||||||
const coordinates = [];
|
const coordinates = [];
|
||||||
let index, arc;
|
let index, arc;
|
||||||
let i, ii;
|
for (let i = 0, ii = indices.length; i < ii; ++i) {
|
||||||
let j, jj;
|
|
||||||
for (i = 0, ii = indices.length; i < ii; ++i) {
|
|
||||||
index = indices[i];
|
index = indices[i];
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
// splicing together arcs, discard last point
|
// splicing together arcs, discard last point
|
||||||
@@ -96,7 +94,7 @@ function concatenateArcs(indices, arcs) {
|
|||||||
coordinates.push.apply(coordinates, arc);
|
coordinates.push.apply(coordinates, arc);
|
||||||
}
|
}
|
||||||
// provide fresh copies of coordinate arrays
|
// provide fresh copies of coordinate arrays
|
||||||
for (j = 0, jj = coordinates.length; j < jj; ++j) {
|
for (let j = 0, jj = coordinates.length; j < jj; ++j) {
|
||||||
coordinates[j] = coordinates[j].slice();
|
coordinates[j] = coordinates[j].slice();
|
||||||
}
|
}
|
||||||
return coordinates;
|
return coordinates;
|
||||||
@@ -130,9 +128,8 @@ function readPointGeometry(object, scale, translate) {
|
|||||||
*/
|
*/
|
||||||
function readMultiPointGeometry(object, scale, translate) {
|
function readMultiPointGeometry(object, scale, translate) {
|
||||||
const coordinates = object.coordinates;
|
const coordinates = object.coordinates;
|
||||||
let i, ii;
|
|
||||||
if (scale && translate) {
|
if (scale && translate) {
|
||||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||||
transformVertex(coordinates[i], scale, translate);
|
transformVertex(coordinates[i], scale, translate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,8 +159,7 @@ function readLineStringGeometry(object, arcs) {
|
|||||||
*/
|
*/
|
||||||
function readMultiLineStringGeometry(object, arcs) {
|
function readMultiLineStringGeometry(object, arcs) {
|
||||||
const coordinates = [];
|
const coordinates = [];
|
||||||
let i, ii;
|
for (let i = 0, ii = object.arcs.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = object.arcs.length; i < ii; ++i) {
|
|
||||||
coordinates[i] = concatenateArcs(object.arcs[i], arcs);
|
coordinates[i] = concatenateArcs(object.arcs[i], arcs);
|
||||||
}
|
}
|
||||||
return new MultiLineString(coordinates);
|
return new MultiLineString(coordinates);
|
||||||
@@ -179,8 +175,7 @@ function readMultiLineStringGeometry(object, arcs) {
|
|||||||
*/
|
*/
|
||||||
function readPolygonGeometry(object, arcs) {
|
function readPolygonGeometry(object, arcs) {
|
||||||
const coordinates = [];
|
const coordinates = [];
|
||||||
let i, ii;
|
for (let i = 0, ii = object.arcs.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = object.arcs.length; i < ii; ++i) {
|
|
||||||
coordinates[i] = concatenateArcs(object.arcs[i], arcs);
|
coordinates[i] = concatenateArcs(object.arcs[i], arcs);
|
||||||
}
|
}
|
||||||
return new Polygon(coordinates);
|
return new Polygon(coordinates);
|
||||||
@@ -196,13 +191,11 @@ function readPolygonGeometry(object, arcs) {
|
|||||||
*/
|
*/
|
||||||
function readMultiPolygonGeometry(object, arcs) {
|
function readMultiPolygonGeometry(object, arcs) {
|
||||||
const coordinates = [];
|
const coordinates = [];
|
||||||
let polyArray, ringCoords, j, jj;
|
for (let i = 0, ii = object.arcs.length; i < ii; ++i) {
|
||||||
let i, ii;
|
|
||||||
for (i = 0, ii = object.arcs.length; i < ii; ++i) {
|
|
||||||
// for each polygon
|
// for each polygon
|
||||||
polyArray = object.arcs[i];
|
const polyArray = object.arcs[i];
|
||||||
ringCoords = [];
|
const ringCoords = [];
|
||||||
for (j = 0, jj = polyArray.length; j < jj; ++j) {
|
for (let j = 0, jj = polyArray.length; j < jj; ++j) {
|
||||||
// for each ring
|
// for each ring
|
||||||
ringCoords[j] = concatenateArcs(polyArray[j], arcs);
|
ringCoords[j] = concatenateArcs(polyArray[j], arcs);
|
||||||
}
|
}
|
||||||
@@ -229,8 +222,7 @@ function readMultiPolygonGeometry(object, arcs) {
|
|||||||
function readFeaturesFromGeometryCollection(collection, arcs, scale, translate, property, name, opt_options) {
|
function readFeaturesFromGeometryCollection(collection, arcs, scale, translate, property, name, opt_options) {
|
||||||
const geometries = collection.geometries;
|
const geometries = collection.geometries;
|
||||||
const features = [];
|
const features = [];
|
||||||
let i, ii;
|
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
|
||||||
features[i] = readFeatureFromGeometry(
|
features[i] = readFeatureFromGeometry(
|
||||||
geometries[i], arcs, scale, translate, property, name, opt_options);
|
geometries[i], arcs, scale, translate, property, name, opt_options);
|
||||||
}
|
}
|
||||||
@@ -294,8 +286,7 @@ TopoJSON.prototype.readFeatures;
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
TopoJSON.prototype.readFeaturesFromObject = function(
|
TopoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
|
||||||
object, opt_options) {
|
|
||||||
if (object.type == 'Topology') {
|
if (object.type == 'Topology') {
|
||||||
const topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
|
const topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
|
||||||
let transform, scale = null, translate = null;
|
let transform, scale = null, translate = null;
|
||||||
|
|||||||
@@ -611,8 +611,7 @@ function encodeMultiLineStringGeometry(geom) {
|
|||||||
const array = [];
|
const array = [];
|
||||||
const components = geom.getLineStrings();
|
const components = geom.getLineStrings();
|
||||||
for (let i = 0, ii = components.length; i < ii; ++i) {
|
for (let i = 0, ii = components.length; i < ii; ++i) {
|
||||||
array.push('(' + encodeLineStringGeometry(
|
array.push('(' + encodeLineStringGeometry(components[i]) + ')');
|
||||||
components[i]) + ')');
|
|
||||||
}
|
}
|
||||||
return array.join(',');
|
return array.join(',');
|
||||||
}
|
}
|
||||||
@@ -626,8 +625,7 @@ function encodePolygonGeometry(geom) {
|
|||||||
const array = [];
|
const array = [];
|
||||||
const rings = geom.getLinearRings();
|
const rings = geom.getLinearRings();
|
||||||
for (let i = 0, ii = rings.length; i < ii; ++i) {
|
for (let i = 0, ii = rings.length; i < ii; ++i) {
|
||||||
array.push('(' + encodeLineStringGeometry(
|
array.push('(' + encodeLineStringGeometry(rings[i]) + ')');
|
||||||
rings[i]) + ')');
|
|
||||||
}
|
}
|
||||||
return array.join(',');
|
return array.join(',');
|
||||||
}
|
}
|
||||||
@@ -641,8 +639,7 @@ function encodeMultiPolygonGeometry(geom) {
|
|||||||
const array = [];
|
const array = [];
|
||||||
const components = geom.getPolygons();
|
const components = geom.getPolygons();
|
||||||
for (let i = 0, ii = components.length; i < ii; ++i) {
|
for (let i = 0, ii = components.length; i < ii; ++i) {
|
||||||
array.push('(' + encodePolygonGeometry(
|
array.push('(' + encodePolygonGeometry(components[i]) + ')');
|
||||||
components[i]) + ')');
|
|
||||||
}
|
}
|
||||||
return array.join(',');
|
return array.join(',');
|
||||||
}
|
}
|
||||||
@@ -768,9 +765,8 @@ WKT.prototype.readFeaturesFromText = function(text, opt_options) {
|
|||||||
geometries = [geometry];
|
geometries = [geometry];
|
||||||
}
|
}
|
||||||
const features = [];
|
const features = [];
|
||||||
let feature;
|
|
||||||
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||||
feature = new Feature();
|
const feature = new Feature();
|
||||||
feature.setGeometry(geometries[i]);
|
feature.setGeometry(geometries[i]);
|
||||||
features.push(feature);
|
features.push(feature);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ XMLFeature.prototype.getType = function() {
|
|||||||
*/
|
*/
|
||||||
XMLFeature.prototype.readFeature = function(source, opt_options) {
|
XMLFeature.prototype.readFeature = function(source, opt_options) {
|
||||||
if (isDocument(source)) {
|
if (isDocument(source)) {
|
||||||
return this.readFeatureFromDocument(
|
return this.readFeatureFromDocument(/** @type {Document} */ (source), opt_options);
|
||||||
/** @type {Document} */ (source), opt_options);
|
|
||||||
} else if (isNode(source)) {
|
} else if (isNode(source)) {
|
||||||
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
||||||
} else if (typeof source === 'string') {
|
} else if (typeof source === 'string') {
|
||||||
@@ -107,12 +106,10 @@ XMLFeature.prototype.readFeatures = function(source, opt_options) {
|
|||||||
* @protected
|
* @protected
|
||||||
* @return {Array.<ol.Feature>} Features.
|
* @return {Array.<ol.Feature>} Features.
|
||||||
*/
|
*/
|
||||||
XMLFeature.prototype.readFeaturesFromDocument = function(
|
XMLFeature.prototype.readFeaturesFromDocument = function(doc, opt_options) {
|
||||||
doc, opt_options) {
|
|
||||||
/** @type {Array.<ol.Feature>} */
|
/** @type {Array.<ol.Feature>} */
|
||||||
const features = [];
|
const features = [];
|
||||||
let n;
|
for (let n = doc.firstChild; n; n = n.nextSibling) {
|
||||||
for (n = doc.firstChild; n; n = n.nextSibling) {
|
|
||||||
if (n.nodeType == Node.ELEMENT_NODE) {
|
if (n.nodeType == Node.ELEMENT_NODE) {
|
||||||
extend(features, this.readFeaturesFromNode(n, opt_options));
|
extend(features, this.readFeaturesFromNode(n, opt_options));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user