diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..87c921c4d --- /dev/null +++ b/.eslintrc @@ -0,0 +1,17 @@ +{ + "extends": "openlayers", + "rules": { + "no-console": 0, + "no-extra-boolean-cast": 0, + "brace-style": 0, + "no-multiple-empty-lines": 0, + "valid-jsdoc": 0 + }, + "globals": { + "ol": false, + "goog": false, + "Cesium": false, + "olcs": false, + "proj4": false + } +} diff --git a/.travis.yml b/.travis.yml index 15813002f..b559f2b9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -language: python sudo: false cache: directories: diff --git a/CHANGES.md b/CHANGES.md index 5af60a928..55628d06a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ # Changelog +## v 1.16 - 2016-05-30 + * Changes + * Switch to eslint. + * Update npm dependencies. + * Port to Cesium 1.21. + * Port to OL 3.16.0. * Add support for drawing rectangles according to the longitude and latitude curves instead of straight lines. This functionality can be activated by setting the olcs.polygon_kind property to 'rectangle' on the OpenLayers diff --git a/Makefile b/Makefile index dc56ac265..f17d40a45 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ dist-apidoc: node node_modules/.bin/jsdoc -c build/jsdoc/api/conf.json -d dist/apidoc .PHONY: lint -lint: .build/python-venv/bin/gjslint .build/gjslint.timestamp +lint: .build/node_modules.timestamp .build/eslint.timestamp @build/check-no-goog.sh .build/geojsonhint.timestamp: $(EXAMPLES_GEOJSON_FILES) @@ -81,8 +81,8 @@ cleanall: clean mkdir -p $(dir $@) touch $@ -.build/gjslint.timestamp: $(SRC_JS_FILES) - .build/python-venv/bin/gjslint --jslint_error=all --strict --custom_jsdoc_tags=api $? +.build/eslint.timestamp: $(SRC_JS_FILES) + ./node_modules/.bin/eslint $? touch $@ .build/dist-examples.timestamp: cesium/Build/Cesium/Cesium.js cesium/Build/CesiumUnminified/Cesium.js dist/ol3cesium.js $(EXAMPLES_JS_FILES) $(EXAMPLES_HTML_FILES) @@ -98,14 +98,6 @@ cleanall: clean for f in dist/examples/*.html; do $(SEDI) 'sY../ol3/css/ol.cssY../ol.cssY' $$f; done touch $@ -.build/python-venv: - mkdir -p $(dir $@) - virtualenv --no-site-packages $@ - -.build/python-venv/bin/gjslint: .build/python-venv - .build/python-venv/bin/pip install "http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz" - touch $@ - dist/ol3cesium-debug.js: build/ol3cesium-debug.json $(SRC_JS_FILES) Cesium.externs.js build/build.js npm-install mkdir -p $(dir $@) node build/build.js $< $@ diff --git a/README.md b/README.md index 58bc05007..16f9e2b7f 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,6 @@ Requirements for building OL3-Cesium: * [GNU Make](http://www.gnu.org/software/make/) * [Node.js](http://nodejs.org/) -* [Python](http://python.org/) -* [Ant](http://ant.apache.org/) To get started, clone the [OL3-Cesium repository](https://github.com/openlayers/ol3-cesium) with its submodules: diff --git a/build/ol3cesium.json b/build/ol3cesium.json index 80892727c..d9e3b9db6 100644 --- a/build/ol3cesium.json +++ b/build/ol3cesium.json @@ -31,7 +31,6 @@ ], "jscomp_off": [ "useOfGoogBase", - "unnecessaryCasts", "lintChecks", "analyzerChecks" ], diff --git a/cesium b/cesium index e49fb890e..b1b249fd2 160000 --- a/cesium +++ b/cesium @@ -1 +1 @@ -Subproject commit e49fb890e034edc4ad519eddf1feaf1dea75566a +Subproject commit b1b249fd2c90cbaa3f7e24a29e72bc4ab2656e21 diff --git a/ol3 b/ol3 index cd32875f3..1038b2abe 160000 --- a/ol3 +++ b/ol3 @@ -1 +1 @@ -Subproject commit cd32875f376ac85c5547f0afce1695dad4c66c8c +Subproject commit 1038b2abea136b029c9d4c2aecaaf4028a9de606 diff --git a/package.json b/package.json index 3617819d0..5e7262e93 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,13 @@ "htmlparser2": "3.9.0" }, "devDependencies": { - "closure-util": "1.13.0", - "geojsonhint": "1.2.0", - "fs-extra": "0.26.7", - "graceful-fs": "4.1.3", + "closure-util": "1.14.0", + "geojsonhint": "1.2.1", + "fs-extra": "0.30.0", + "graceful-fs": "4.1.4", "jsdoc": "~3.4.0", - "jshint": "2.9.1", + "eslint": "2.11.0", + "eslint-config-openlayers": "4.1.0", "nomnom": "1.8.1", "temp": "0.8.3", "walk": "2.3.9" diff --git a/src/abstractsynchronizer.js b/src/abstractsynchronizer.js index 067c40941..5099ffd4d 100644 --- a/src/abstractsynchronizer.js +++ b/src/abstractsynchronizer.js @@ -138,8 +138,7 @@ olcs.AbstractSynchronizer.prototype.addLayers_ = function(root) { * @return {boolean} counterpart destroyed * @private */ -olcs.AbstractSynchronizer.prototype.removeAndDestroySingleLayer_ = - function(layer) { +olcs.AbstractSynchronizer.prototype.removeAndDestroySingleLayer_ = function(layer) { var uid = goog.getUid(layer); var counterparts = this.layerMap[uid]; if (!!counterparts) { @@ -160,8 +159,7 @@ olcs.AbstractSynchronizer.prototype.removeAndDestroySingleLayer_ = * @param {ol.layer.Group} group * @private */ -olcs.AbstractSynchronizer.prototype.unlistenSingleGroup_ = - function(group) { +olcs.AbstractSynchronizer.prototype.unlistenSingleGroup_ = function(group) { if (group === this.mapLayerGroup) { return; } diff --git a/src/autorenderloop.js b/src/autorenderloop.js index 44fb5c09c..ea55da691 100644 --- a/src/autorenderloop.js +++ b/src/autorenderloop.js @@ -105,8 +105,7 @@ olcs.AutoRenderLoop.prototype.enable = function() { }; // Hacky way to force a repaint when a web worker sends something back. - Cesium.TaskProcessor.prototype.scheduleTask = - function(parameters, transferableObjects) { + Cesium.TaskProcessor.prototype.scheduleTask = function(parameters, transferableObjects) { var result = that._originalScheduleTask.call(this, parameters, transferableObjects); diff --git a/src/featureconverter.js b/src/featureconverter.js index 7936b6d5f..d020d50a5 100644 --- a/src/featureconverter.js +++ b/src/featureconverter.js @@ -73,8 +73,7 @@ olcs.FeatureConverter.prototype.onRemoveOrClearFeature_ = function(evt) { * @param {!Cesium.Primitive|Cesium.Label|Cesium.Billboard} primitive * @protected */ -olcs.FeatureConverter.prototype.setReferenceForPicking = - function(layer, feature, primitive) { +olcs.FeatureConverter.prototype.setReferenceForPicking = function(layer, feature, primitive) { primitive.olLayer = layer; primitive.olFeature = feature; }; @@ -92,8 +91,7 @@ olcs.FeatureConverter.prototype.setReferenceForPicking = * @return {Cesium.Primitive} * @protected */ -olcs.FeatureConverter.prototype.createColoredPrimitive = - function(layer, feature, olGeometry, geometry, color, opt_lineWidth) { +olcs.FeatureConverter.prototype.createColoredPrimitive = function(layer, feature, olGeometry, geometry, color, opt_lineWidth) { var createInstance = function(geometry, color) { return new Cesium.GeometryInstance({ // always update Cesium externs before adding a property @@ -157,8 +155,7 @@ olcs.FeatureConverter.prototype.createColoredPrimitive = * @return {!Cesium.Color} * @protected */ -olcs.FeatureConverter.prototype.extractColorFromOlStyle = - function(style, outline) { +olcs.FeatureConverter.prototype.extractColorFromOlStyle = function(style, outline) { var fillColor = style.getFill() ? style.getFill().getColor() : null; var strokeColor = style.getStroke() ? style.getStroke().getColor() : null; @@ -180,8 +177,7 @@ olcs.FeatureConverter.prototype.extractColorFromOlStyle = * @return {number} * @protected */ -olcs.FeatureConverter.prototype.extractLineWidthFromOlStyle = - function(style) { +olcs.FeatureConverter.prototype.extractLineWidthFromOlStyle = function(style) { var width = style.getStroke() ? style.getStroke().getWidth() : 1; return Math.min(width, this.scene.maximumAliasedLineWidth); }; @@ -199,28 +195,26 @@ olcs.FeatureConverter.prototype.extractLineWidthFromOlStyle = * @return {!Cesium.PrimitiveCollection} * @protected */ -olcs.FeatureConverter.prototype.wrapFillAndOutlineGeometries = - function(layer, feature, olGeometry, fillGeometry, outlineGeometry, - olStyle) { +olcs.FeatureConverter.prototype.wrapFillAndOutlineGeometries = function(layer, feature, olGeometry, fillGeometry, outlineGeometry, olStyle) { var fillColor = this.extractColorFromOlStyle(olStyle, false); var outlineColor = this.extractColorFromOlStyle(olStyle, true); var primitives = new Cesium.PrimitiveCollection(); if (olStyle.getFill()) { - var p = this.createColoredPrimitive(layer, feature, olGeometry, + var p1 = this.createColoredPrimitive(layer, feature, olGeometry, fillGeometry, fillColor); - goog.asserts.assert(!!p); - primitives.add(p); + goog.asserts.assert(!!p1); + primitives.add(p1); } if (olStyle.getStroke()) { var width = this.extractLineWidthFromOlStyle(olStyle); - var p = this.createColoredPrimitive(layer, feature, olGeometry, + var p2 = this.createColoredPrimitive(layer, feature, olGeometry, outlineGeometry, outlineColor, width); - if (p) { + if (p2) { // Some outline geometries are not supported by Cesium in clamp to ground // mode. These primitives are skipped. - primitives.add(p); + primitives.add(p2); } } @@ -240,8 +234,7 @@ olcs.FeatureConverter.prototype.wrapFillAndOutlineGeometries = * @return {!Cesium.PrimitiveCollection} * @protected */ -olcs.FeatureConverter.prototype.addTextStyle = - function(layer, feature, geometry, style, primitive) { +olcs.FeatureConverter.prototype.addTextStyle = function(layer, feature, geometry, style, primitive) { var primitives; if (!(primitive instanceof Cesium.PrimitiveCollection)) { primitives = new Cesium.PrimitiveCollection(); @@ -276,8 +269,7 @@ olcs.FeatureConverter.prototype.addTextStyle = * @return {!Cesium.Billboard} newly created billboard * @api */ -olcs.FeatureConverter.prototype.csAddBillboard = - function(billboards, bbOptions, layer, feature, geometry, style) { +olcs.FeatureConverter.prototype.csAddBillboard = function(billboards, bbOptions, layer, feature, geometry, style) { var bb = billboards.add(bbOptions); this.setReferenceForPicking(layer, feature, bb); return bb; @@ -294,8 +286,7 @@ olcs.FeatureConverter.prototype.csAddBillboard = * @return {!Cesium.PrimitiveCollection} primitives * @api */ -olcs.FeatureConverter.prototype.olCircleGeometryToCesium = - function(layer, feature, olGeometry, projection, olStyle) { +olcs.FeatureConverter.prototype.olCircleGeometryToCesium = function(layer, feature, olGeometry, projection, olStyle) { olGeometry = olcs.core.olGeometryCloneTo4326(olGeometry, projection); goog.asserts.assert(olGeometry.getType() == 'Circle'); @@ -345,8 +336,7 @@ olcs.FeatureConverter.prototype.olCircleGeometryToCesium = * @return {!Cesium.PrimitiveCollection} primitives * @api */ -olcs.FeatureConverter.prototype.olLineStringGeometryToCesium = - function(layer, feature, olGeometry, projection, olStyle) { +olcs.FeatureConverter.prototype.olLineStringGeometryToCesium = function(layer, feature, olGeometry, projection, olStyle) { olGeometry = olcs.core.olGeometryCloneTo4326(olGeometry, projection); goog.asserts.assert(olGeometry.getType() == 'LineString'); @@ -391,8 +381,7 @@ olcs.FeatureConverter.prototype.olLineStringGeometryToCesium = * @return {!Cesium.PrimitiveCollection} primitives * @api */ -olcs.FeatureConverter.prototype.olPolygonGeometryToCesium = - function(layer, feature, olGeometry, projection, olStyle) { +olcs.FeatureConverter.prototype.olPolygonGeometryToCesium = function(layer, feature, olGeometry, projection, olStyle) { olGeometry = olcs.core.olGeometryCloneTo4326(olGeometry, projection); goog.asserts.assert(olGeometry.getType() == 'Polygon'); @@ -476,8 +465,7 @@ olcs.FeatureConverter.prototype.olPolygonGeometryToCesium = * @return {!Cesium.HeightReference} * @api */ -olcs.FeatureConverter.prototype.getHeightReference = - function(layer, feature, geometry) { +olcs.FeatureConverter.prototype.getHeightReference = function(layer, feature, geometry) { // Read from the geometry var altitudeMode = geometry.get('altitudeMode'); @@ -516,8 +504,7 @@ olcs.FeatureConverter.prototype.getHeightReference = * @return {Cesium.Primitive} primitives * @api */ -olcs.FeatureConverter.prototype.olPointGeometryToCesium = - function(layer, feature, olGeometry, projection, style, billboards, +olcs.FeatureConverter.prototype.olPointGeometryToCesium = function(layer, feature, olGeometry, projection, style, billboards, opt_newBillboardCallback) { goog.asserts.assert(olGeometry.getType() == 'Point'); olGeometry = olcs.core.olGeometryCloneTo4326(olGeometry, projection); @@ -631,8 +618,7 @@ olcs.FeatureConverter.prototype.olPointGeometryToCesium = * @return {Cesium.Primitive} primitives * @api */ -olcs.FeatureConverter.prototype.olMultiGeometryToCesium = - function(layer, feature, geometry, projection, olStyle, billboards, +olcs.FeatureConverter.prototype.olMultiGeometryToCesium = function(layer, feature, geometry, projection, olStyle, billboards, opt_newBillboardCallback) { // Do not reproject to 4326 now because it will be done later. @@ -693,8 +679,7 @@ olcs.FeatureConverter.prototype.olMultiGeometryToCesium = * @return {Cesium.LabelCollection} Cesium primitive * @api */ -olcs.FeatureConverter.prototype.olGeometry4326TextPartToCesium = - function(layer, feature, geometry, style) { +olcs.FeatureConverter.prototype.olGeometry4326TextPartToCesium = function(layer, feature, geometry, style) { var text = style.getText(); goog.asserts.assert(goog.isDef(text)); @@ -795,8 +780,7 @@ olcs.FeatureConverter.prototype.olGeometry4326TextPartToCesium = * @return {Cesium.Material} * @api */ -olcs.FeatureConverter.prototype.olStyleToCesium = - function(feature, style, outline) { +olcs.FeatureConverter.prototype.olStyleToCesium = function(feature, style, outline) { var fill = style.getFill(); var stroke = style.getStroke(); if ((outline && !stroke) || (!outline && !fill)) { @@ -834,8 +818,7 @@ olcs.FeatureConverter.prototype.olStyleToCesium = * @return {ol.style.Style} null if no style is available * @api */ -olcs.FeatureConverter.prototype.computePlainStyle = - function(layer, feature, fallbackStyleFunction, resolution) { +olcs.FeatureConverter.prototype.computePlainStyle = function(layer, feature, fallbackStyleFunction, resolution) { /** * @type {ol.FeatureStyleFunction|undefined} */ @@ -877,8 +860,7 @@ olcs.FeatureConverter.prototype.computePlainStyle = * @return {Cesium.Primitive} primitives * @api */ -olcs.FeatureConverter.prototype.olFeatureToCesium = - function(layer, feature, style, context, opt_geom) { +olcs.FeatureConverter.prototype.olFeatureToCesium = function(layer, feature, style, context, opt_geom) { var geom = opt_geom || feature.getGeometry(); var proj = context.projection; if (!geom) { @@ -932,13 +914,13 @@ olcs.FeatureConverter.prototype.olFeatureToCesium = case 'MultiPoint': case 'MultiLineString': case 'MultiPolygon': - var result = this.olMultiGeometryToCesium(layer, feature, geom, proj, + var result2 = this.olMultiGeometryToCesium(layer, feature, geom, proj, style, context.billboards, newBillboardAddedCallback); - if (!result) { + if (!result2) { // no wrapping primitive return null; } else { - return result; + return result2; } case 'LinearRing': throw new Error('LinearRing should only be part of polygon.'); @@ -958,8 +940,7 @@ olcs.FeatureConverter.prototype.olFeatureToCesium = * @return {!olcs.core.VectorLayerCounterpart} * @api */ -olcs.FeatureConverter.prototype.olVectorLayerToCesium = - function(olLayer, olView, featurePrimitiveMap) { +olcs.FeatureConverter.prototype.olVectorLayerToCesium = function(olLayer, olView, featurePrimitiveMap) { var proj = olView.getProjection(); var resolution = olView.getResolution(); @@ -1025,8 +1006,7 @@ olcs.FeatureConverter.prototype.olVectorLayerToCesium = * @return {Cesium.Primitive} * @api */ -olcs.FeatureConverter.prototype.convert = - function(layer, view, feature, context) { +olcs.FeatureConverter.prototype.convert = function(layer, view, feature, context) { var proj = view.getProjection(); var resolution = view.getResolution(); diff --git a/src/ol3cesium.js b/src/ol3cesium.js index 3adfc3763..525eaed34 100644 --- a/src/ol3cesium.js +++ b/src/ol3cesium.js @@ -174,8 +174,7 @@ olcs.OLCesium = function(options) { }); var synchronizers = goog.isDef(options.createSynchronizers) ? - options.createSynchronizers(this.map_, this.scene_) : - [ + options.createSynchronizers(this.map_, this.scene_) : [ new olcs.RasterSynchronizer(this.map_, this.scene_), new olcs.VectorSynchronizer(this.map_, this.scene_) ]; @@ -319,10 +318,11 @@ olcs.OLCesium.prototype.setEnabled = function(enable) { // some Cesium operations are operating with canvas.clientWidth, // so we can't remove it from DOM or even make display:none; this.container_.style.visibility = this.enabled_ ? 'visible' : 'hidden'; + var interactions; if (this.enabled_) { this.throwOnUnitializedMap_(); if (this.isOverMap_) { - var interactions = this.map_.getInteractions(); + interactions = this.map_.getInteractions(); interactions.forEach(function(el, i, arr) { this.pausedInteractions_.push(el); }, this); @@ -338,7 +338,7 @@ olcs.OLCesium.prototype.setEnabled = function(enable) { this.cesiumRenderingDelay_.start(); } else { if (this.isOverMap_) { - var interactions = this.map_.getInteractions(); + interactions = this.map_.getInteractions(); this.pausedInteractions_.forEach(function(interaction) { interactions.push(interaction); }); diff --git a/src/rastersynchronizer.js b/src/rastersynchronizer.js index e27fbbf37..1b93b31bd 100644 --- a/src/rastersynchronizer.js +++ b/src/rastersynchronizer.js @@ -53,8 +53,7 @@ olcs.RasterSynchronizer.prototype.destroyCesiumObject = function(object) { /** * @inheritDoc */ -olcs.RasterSynchronizer.prototype.removeSingleCesiumObject = - function(object, destroy) { +olcs.RasterSynchronizer.prototype.removeSingleCesiumObject = function(object, destroy) { this.cesiumLayers_.remove(object, destroy); this.ourLayers_.remove(object, false); }; @@ -82,8 +81,7 @@ olcs.RasterSynchronizer.prototype.removeAllCesiumObjects = function(destroy) { * (or supported) * @protected */ -olcs.RasterSynchronizer.prototype.convertLayerToCesiumImageries = - function(olLayer, viewProj) { +olcs.RasterSynchronizer.prototype.convertLayerToCesiumImageries = function(olLayer, viewProj) { var result = olcs.core.tileLayerToImageryLayer(olLayer, viewProj); return result ? [result] : null; }; @@ -92,8 +90,7 @@ olcs.RasterSynchronizer.prototype.convertLayerToCesiumImageries = /** * @inheritDoc */ -olcs.RasterSynchronizer.prototype.createSingleLayerCounterparts = - function(olLayer) { +olcs.RasterSynchronizer.prototype.createSingleLayerCounterparts = function(olLayer) { var viewProj = this.view.getProjection(); var cesiumObjects = this.convertLayerToCesiumImageries(olLayer, viewProj); if (!goog.isNull(cesiumObjects)) { diff --git a/src/vectorsynchronizer.js b/src/vectorsynchronizer.js index 3aad33e8f..8a31f791b 100644 --- a/src/vectorsynchronizer.js +++ b/src/vectorsynchronizer.js @@ -58,8 +58,7 @@ olcs.VectorSynchronizer.prototype.destroyCesiumObject = function(object) { /** * @inheritDoc */ -olcs.VectorSynchronizer.prototype.removeSingleCesiumObject = - function(object, destroy) { +olcs.VectorSynchronizer.prototype.removeSingleCesiumObject = function(object, destroy) { object.destroy(); this.csAllPrimitives_.destroyPrimitives = destroy; this.csAllPrimitives_.remove(object.getRootPrimitive()); @@ -85,8 +84,7 @@ olcs.VectorSynchronizer.prototype.removeAllCesiumObjects = function(destroy) { /** * @inheritDoc */ -olcs.VectorSynchronizer.prototype.createSingleLayerCounterparts = - function(olLayer) { +olcs.VectorSynchronizer.prototype.createSingleLayerCounterparts = function(olLayer) { if (!(olLayer instanceof ol.layer.Vector) && !(olLayer instanceof ol.layer.Image && olLayer.getSource() instanceof ol.source.ImageVector)) {