Merge pull request #7933 from fredj/indent

Better code indentation
This commit is contained in:
Frédéric Junod
2018-03-05 16:32:40 +01:00
committed by GitHub
17 changed files with 71 additions and 123 deletions

View File

@@ -192,8 +192,7 @@ const Graticule = function(opt_options) {
* @type {number}
* @private
*/
this.targetSize_ = options.targetSize !== undefined ?
options.targetSize : 100;
this.targetSize_ = options.targetSize !== undefined ? options.targetSize : 100;
/**
* @type {number}
@@ -337,8 +336,7 @@ const Graticule = function(opt_options) {
* @private
*/
Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTolerance, extent, index) {
const lineString = this.getMeridian_(lon, minLat, maxLat,
squaredTolerance, index);
const lineString = this.getMeridian_(lon, minLat, maxLat, squaredTolerance, index);
if (intersects(lineString.getExtent(), extent)) {
if (this.meridiansLabels_) {
const textPoint = this.getMeridianPoint_(lineString, extent, index);
@@ -385,8 +383,7 @@ Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) {
* @private
*/
Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTolerance, extent, index) {
const lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance,
index);
const lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance, index);
if (intersects(lineString.getExtent(), extent)) {
if (this.parallelsLabels_) {
const textPoint = this.getParallelPoint_(lineString, extent, index);
@@ -457,8 +454,7 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
Math.min(extent[3], this.maxLatP_)
];
validExtent = transformExtent(validExtent, this.projection_,
'EPSG:4326');
validExtent = transformExtent(validExtent, this.projection_, 'EPSG:4326');
const maxLat = validExtent[3];
const maxLon = validExtent[2];
const minLat = validExtent[1];
@@ -572,10 +568,8 @@ Graticule.prototype.getMap = function() {
* @private
*/
Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, squaredTolerance, index) {
const flatCoordinates = meridian(lon,
minLat, maxLat, this.projection_, squaredTolerance);
const lineString = this.meridians_[index] !== undefined ?
this.meridians_[index] : new LineString(null);
const flatCoordinates = meridian(lon, minLat, maxLat, this.projection_, squaredTolerance);
const lineString = this.meridians_[index] !== undefined ? this.meridians_[index] : new LineString(null);
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
return lineString;
};
@@ -601,10 +595,8 @@ Graticule.prototype.getMeridians = function() {
* @private
*/
Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, squaredTolerance, index) {
const flatCoordinates = parallel(lat,
minLon, maxLon, this.projection_, squaredTolerance);
const lineString = this.parallels_[index] !== undefined ?
this.parallels_[index] : new LineString(null);
const flatCoordinates = parallel(lat, minLon, maxLon, this.projection_, squaredTolerance);
const lineString = this.parallels_[index] !== undefined ? this.parallels_[index] : new LineString(null);
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
return lineString;
};
@@ -685,8 +677,7 @@ Graticule.prototype.updateProjectionInfo_ = function(projection) {
const extent = projection.getExtent();
const worldExtent = projection.getWorldExtent();
const worldExtentP = transformExtent(worldExtent,
epsg4326Projection, projection);
const worldExtentP = transformExtent(worldExtent, epsg4326Projection, projection);
const maxLat = worldExtent[3];
const maxLon = worldExtent[2];

View File

@@ -18,8 +18,7 @@ import MapEvent from './MapEvent.js';
* @param {boolean=} opt_dragging Is the map currently being dragged?
* @param {?olx.FrameState=} opt_frameState Frame state.
*/
const MapBrowserEvent = function(type, map, browserEvent, opt_dragging,
opt_frameState) {
const MapBrowserEvent = function(type, map, browserEvent, opt_dragging, opt_frameState) {
MapEvent.call(this, type, map, opt_frameState);

View File

@@ -500,15 +500,11 @@ PluggableMap.prototype.addOverlayInternal_ = function(overlay) {
*/
PluggableMap.prototype.disposeInternal = function() {
this.mapBrowserEventHandler_.dispose();
unlisten(this.viewport_, EventType.CONTEXTMENU,
this.handleBrowserEvent, this);
unlisten(this.viewport_, EventType.WHEEL,
this.handleBrowserEvent, this);
unlisten(this.viewport_, EventType.MOUSEWHEEL,
this.handleBrowserEvent, this);
unlisten(this.viewport_, EventType.CONTEXTMENU, this.handleBrowserEvent, this);
unlisten(this.viewport_, EventType.WHEEL, this.handleBrowserEvent, this);
unlisten(this.viewport_, EventType.MOUSEWHEEL, this.handleBrowserEvent, this);
if (this.handleResize_ !== undefined) {
removeEventListener(EventType.RESIZE,
this.handleResize_, false);
removeEventListener(EventType.RESIZE, this.handleResize_, false);
this.handleResize_ = undefined;
}
if (this.animationDelayKey_) {
@@ -792,8 +788,7 @@ PluggableMap.prototype.getPixelFromCoordinate = function(coordinate) {
if (!frameState) {
return null;
} else {
return applyTransform(frameState.coordinateToPixelTransform,
coordinate.slice(0, 2));
return applyTransform(frameState.coordinateToPixelTransform, coordinate.slice(0, 2));
}
};
@@ -1010,8 +1005,7 @@ PluggableMap.prototype.handleTargetChanged_ = function() {
this.renderer_.removeLayerRenderers();
removeNode(this.viewport_);
if (this.handleResize_ !== undefined) {
removeEventListener(EventType.RESIZE,
this.handleResize_, false);
removeEventListener(EventType.RESIZE, this.handleResize_, false);
this.handleResize_ = undefined;
}
} else {
@@ -1020,16 +1014,13 @@ PluggableMap.prototype.handleTargetChanged_ = function() {
const keyboardEventTarget = !this.keyboardEventTarget_ ?
targetElement : this.keyboardEventTarget_;
this.keyHandlerKeys_ = [
listen(keyboardEventTarget, EventType.KEYDOWN,
this.handleBrowserEvent, this),
listen(keyboardEventTarget, EventType.KEYPRESS,
this.handleBrowserEvent, this)
listen(keyboardEventTarget, EventType.KEYDOWN, this.handleBrowserEvent, this),
listen(keyboardEventTarget, EventType.KEYPRESS, this.handleBrowserEvent, this)
];
if (!this.handleResize_) {
this.handleResize_ = this.updateSize.bind(this);
addEventListener(EventType.RESIZE,
this.handleResize_, false);
addEventListener(EventType.RESIZE, this.handleResize_, false);
}
}
@@ -1130,8 +1121,7 @@ PluggableMap.prototype.renderSync = function() {
*/
PluggableMap.prototype.render = function() {
if (this.animationDelayKey_ === undefined) {
this.animationDelayKey_ = requestAnimationFrame(
this.animationDelay_);
this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_);
}
};
@@ -1267,14 +1257,12 @@ PluggableMap.prototype.renderFrame_ = function(time) {
!equals(frameState.extent, this.previousExtent_);
if (idle) {
this.dispatchEvent(
new MapEvent(MapEventType.MOVEEND, this, frameState));
this.dispatchEvent(new MapEvent(MapEventType.MOVEEND, this, frameState));
clone(frameState.extent, this.previousExtent_);
}
}
this.dispatchEvent(
new MapEvent(MapEventType.POSTRENDER, this, frameState));
this.dispatchEvent(new MapEvent(MapEventType.POSTRENDER, this, frameState));
setTimeout(this.handlePostRender.bind(this), 0);

View File

@@ -543,8 +543,7 @@ View.prototype.constrainCenter = function(center) {
* @return {number|undefined} Constrained resolution.
* @api
*/
View.prototype.constrainResolution = function(
resolution, opt_delta, opt_direction) {
View.prototype.constrainResolution = function(resolution, opt_delta, opt_direction) {
const delta = opt_delta || 0;
const direction = opt_direction || 0;
return this.constraints_.resolution(resolution, delta, direction);

View File

@@ -109,9 +109,8 @@ function readGeometry(object, opt_options) {
}
}
const geometryReader = GEOMETRY_READERS[type];
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(
geometryReader(object), false, opt_options)
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
geometryReader(object), false, opt_options)
);
}
@@ -429,11 +428,9 @@ EsriJSON.prototype.readFeatures;
/**
* @inheritDoc
*/
EsriJSON.prototype.readFeatureFromObject = function(
object, opt_options) {
EsriJSON.prototype.readFeatureFromObject = function(object, opt_options) {
const esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
const geometry = readGeometry(esriJSONFeature.geometry,
opt_options);
const geometry = readGeometry(esriJSONFeature.geometry, opt_options);
const feature = new Feature();
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
@@ -441,8 +438,7 @@ EsriJSON.prototype.readFeatureFromObject = function(
feature.setGeometry(geometry);
if (opt_options && opt_options.idField &&
esriJSONFeature.attributes[opt_options.idField]) {
feature.setId(/** @type {number} */(
esriJSONFeature.attributes[opt_options.idField]));
feature.setId(/** @type {number} */(esriJSONFeature.attributes[opt_options.idField]));
}
if (esriJSONFeature.attributes) {
feature.setProperties(esriJSONFeature.attributes);
@@ -454,21 +450,17 @@ EsriJSON.prototype.readFeatureFromObject = function(
/**
* @inheritDoc
*/
EsriJSON.prototype.readFeaturesFromObject = function(
object, opt_options) {
EsriJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
const esriJSONObject = /** @type {EsriJSONObject} */ (object);
const options = opt_options ? opt_options : {};
if (esriJSONObject.features) {
const esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
(object);
const esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */ (object);
/** @type {Array.<ol.Feature>} */
const features = [];
const esriJSONFeatures = esriJSONFeatureCollection.features;
let i, ii;
options.idField = object.objectIdFieldName;
for (i = 0, ii = esriJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(esriJSONFeatures[i],
options));
for (let i = 0, ii = esriJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(esriJSONFeatures[i], options));
}
return features;
} else {
@@ -492,10 +484,8 @@ EsriJSON.prototype.readGeometry;
/**
* @inheritDoc
*/
EsriJSON.prototype.readGeometryFromObject = function(
object, opt_options) {
return readGeometry(
/** @type {EsriJSONGeometry} */(object), opt_options);
EsriJSON.prototype.readGeometryFromObject = function(object, opt_options) {
return readGeometry(/** @type {EsriJSONGeometry} */(object), opt_options);
};
@@ -557,10 +547,8 @@ EsriJSON.prototype.writeGeometry;
* @override
* @api
*/
EsriJSON.prototype.writeGeometryObject = function(geometry,
opt_options) {
return writeGeometry(geometry,
this.adaptOptions(opt_options));
EsriJSON.prototype.writeGeometryObject = function(geometry, opt_options) {
return writeGeometry(geometry, this.adaptOptions(opt_options));
};
@@ -585,14 +573,12 @@ EsriJSON.prototype.writeFeature;
* @override
* @api
*/
EsriJSON.prototype.writeFeatureObject = function(
feature, opt_options) {
EsriJSON.prototype.writeFeatureObject = function(feature, opt_options) {
opt_options = this.adaptOptions(opt_options);
const object = {};
const geometry = feature.getGeometry();
if (geometry) {
object['geometry'] =
writeGeometry(geometry, opt_options);
object['geometry'] = writeGeometry(geometry, opt_options);
if (opt_options && opt_options.featureProjection) {
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: getProjection(opt_options.featureProjection).getCode().split(':').pop()
@@ -634,8 +620,7 @@ EsriJSON.prototype.writeFeatures;
EsriJSON.prototype.writeFeaturesObject = function(features, opt_options) {
opt_options = this.adaptOptions(opt_options);
const objects = [];
let i, ii;
for (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));
}
return /** @type {EsriJSONFeatureCollection} */ ({

View File

@@ -479,8 +479,7 @@ GML2.prototype.writePoint_ = function(node, geometry, objectStack) {
* @param {Array.<*>} objectStack Node stack.
* @private
*/
GML2.prototype.writeMultiPoint_ = function(node, geometry,
objectStack) {
GML2.prototype.writeMultiPoint_ = function(node, geometry, objectStack) {
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];

View File

@@ -813,8 +813,7 @@ GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStac
* @param {Array.<*>} objectStack Node stack.
* @private
*/
GML3.prototype.writeMultiPoint_ = function(node, geometry,
objectStack) {
GML3.prototype.writeMultiPoint_ = function(node, geometry, objectStack) {
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
const hasZ = context['hasZ'];

View File

@@ -106,9 +106,8 @@ function readGeometry(object, opt_options) {
return null;
}
const geometryReader = GEOMETRY_READERS[object.type];
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(
geometryReader(object), false, opt_options)
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
geometryReader(object), false, opt_options)
);
}
@@ -121,9 +120,9 @@ function readGeometry(object, opt_options) {
function readGeometryCollectionGeometry(object, opt_options) {
const geometries = object.geometries.map(
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @return {ol.geom.Geometry} geometry Geometry.
*/
* @param {GeoJSONGeometry} geometry Geometry.
* @return {ol.geom.Geometry} geometry Geometry.
*/
function(geometry) {
return readGeometry(geometry, opt_options);
});
@@ -388,8 +387,7 @@ GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ (object);
features = [];
const geoJSONFeatures = geoJSONFeatureCollection.features;
let i, ii;
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(geoJSONFeatures[i], opt_options));
}
} else {
@@ -523,8 +521,7 @@ GeoJSON.prototype.writeFeatures;
GeoJSON.prototype.writeFeaturesObject = function(features, opt_options) {
opt_options = this.adaptOptions(opt_options);
const objects = [];
let i, ii;
for (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));
}
return /** @type {GeoJSONFeatureCollection} */ ({

View File

@@ -2192,8 +2192,7 @@ const DOCUMENT_SERIALIZERS = makeStructureNS(
* @param {string=} opt_nodeName Node name.
* @return {Node|undefined} Node.
*/
const DOCUMENT_NODE_FACTORY = function(value, objectStack,
opt_nodeName) {
const DOCUMENT_NODE_FACTORY = function(value, objectStack, opt_nodeName) {
const parentNode = objectStack[objectStack.length - 1].node;
return createElementNS(parentNode.namespaceURI, 'Placemark');
};

View File

@@ -319,13 +319,11 @@ Polyline.prototype.readGeometryFromText = function(text, opt_options) {
const stride = getStrideForLayout(this.geometryLayout_);
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
const coordinates = inflateCoordinates(
flatCoordinates, 0, flatCoordinates.length, stride);
const coordinates = inflateCoordinates(flatCoordinates, 0, flatCoordinates.length, stride);
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(
new LineString(coordinates, this.geometryLayout_), false,
this.adaptOptions(opt_options))
return /** @type {ol.geom.Geometry} */ (transformWithOptions(
new LineString(coordinates, this.geometryLayout_), false,
this.adaptOptions(opt_options))
);
};

View File

@@ -61,8 +61,7 @@ XMLFeature.prototype.readFeature = function(source, opt_options) {
* @param {olx.format.ReadOptions=} opt_options Options.
* @return {ol.Feature} Feature.
*/
XMLFeature.prototype.readFeatureFromDocument = function(
doc, opt_options) {
XMLFeature.prototype.readFeatureFromDocument = function(doc, opt_options) {
const features = this.readFeaturesFromDocument(doc, opt_options);
if (features.length > 0) {
return features[0];

View File

@@ -16,7 +16,9 @@ import {transform2D} from '../../geom/flat/transform.js';
import {CANVAS_LINE_DASH} from '../../has.js';
import {isEmpty} from '../../obj.js';
import VectorContext from '../VectorContext.js';
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle, defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset, defaultLineDash, defaultLineCap} from '../canvas.js';
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle,
defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset,
defaultLineDash, defaultLineCap} from '../canvas.js';
import CanvasInstruction from '../canvas/Instruction.js';
import {TEXT_ALIGN} from '../replay.js';
import {
@@ -581,8 +583,7 @@ CanvasReplay.prototype.replay_ = function(
// When the batch size gets too big, performance decreases. 200 is a good
// balance between batch size and number of fill/stroke instructions.
const batchSize =
this.instructions != instructions || this.overlaps ? 0 : 200;
const batchSize = this.instructions != instructions || this.overlaps ? 0 : 200;
let /** @type {ol.Feature|ol.render.Feature} */ feature;
let x, y;
while (i < ii) {

View File

@@ -96,8 +96,7 @@ Cluster.prototype.getSource = function() {
/**
* @inheritDoc
*/
Cluster.prototype.loadFeatures = function(extent, resolution,
projection) {
Cluster.prototype.loadFeatures = function(extent, resolution, projection) {
this.source.loadFeatures(extent, resolution, projection);
if (resolution !== this.resolution) {
this.clear();

View File

@@ -233,8 +233,7 @@ ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, size, project
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
* @api
*/
ImageMapGuide.prototype.setImageLoadFunction = function(
imageLoadFunction) {
ImageMapGuide.prototype.setImageLoadFunction = function(imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();

View File

@@ -326,8 +326,7 @@ ImageWMS.prototype.getUrl = function() {
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
* @api
*/
ImageWMS.prototype.setImageLoadFunction = function(
imageLoadFunction) {
ImageWMS.prototype.setImageLoadFunction = function(imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();

View File

@@ -490,10 +490,10 @@ VectorSource.prototype.forEachFeatureInExtent = function(extent, callback) {
VectorSource.prototype.forEachFeatureIntersectingExtent = function(extent, callback) {
return this.forEachFeatureInExtent(extent,
/**
* @param {ol.Feature} feature Feature.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
*/
* @param {ol.Feature} feature Feature.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
*/
function(feature) {
const geometry = feature.getGeometry();
if (geometry.intersectsExtent(extent)) {
@@ -754,17 +754,16 @@ VectorSource.prototype.isEmpty = function() {
* @param {number} resolution Resolution.
* @param {ol.proj.Projection} projection Projection.
*/
VectorSource.prototype.loadFeatures = function(
extent, resolution, projection) {
VectorSource.prototype.loadFeatures = function(extent, resolution, projection) {
const loadedExtentsRtree = this.loadedExtentsRtree_;
const extentsToLoad = this.strategy_(extent, resolution);
for (let i = 0, ii = extentsToLoad.length; i < ii; ++i) {
const extentToLoad = extentsToLoad[i];
const alreadyLoaded = loadedExtentsRtree.forEachInExtent(extentToLoad,
/**
* @param {{extent: ol.Extent}} object Object.
* @return {boolean} Contains.
*/
* @param {{extent: ol.Extent}} object Object.
* @return {boolean} Contains.
*/
function(object) {
return containsExtent(object.extent, extentToLoad);
});

View File

@@ -224,10 +224,8 @@ WebGLContext.prototype.getShader = function(shaderObject) {
* @param {ol.webgl.Vertex} vertexShaderObject Vertex shader.
* @return {WebGLProgram} Program.
*/
WebGLContext.prototype.getProgram = function(
fragmentShaderObject, vertexShaderObject) {
const programKey =
getUid(fragmentShaderObject) + '/' + getUid(vertexShaderObject);
WebGLContext.prototype.getProgram = function(fragmentShaderObject, vertexShaderObject) {
const programKey = getUid(fragmentShaderObject) + '/' + getUid(vertexShaderObject);
if (programKey in this.programCache_) {
return this.programCache_[programKey];
} else {