openlayers / workshop

http://openlayers.org/workshop/
72 stars 79 forks source link

Custom builds chapter / example isn't working w/ Openlayers v3.17.1 #56

Closed marcjansen closed 7 years ago

marcjansen commented 8 years ago

ddd6922f573879f6bdc253cef26cc0322a96a216 upgraded the workshop to use Openlayers v3.17.1.

With the ol-custom.json from the custom-builds-chapter the command node node_modules/openlayers/tasks/build.js ol-custom.json ol-custom.js fails as follows.

$ node node_modules/openlayers/tasks/build.js ol-custom.json ol-custom.js
info ol Parsing dependencies
info ol Compiling 287 sources
ERR! compile externs/olx.js:1263: ERROR - Bad type annotation. Unknown type ol.control.ScaleLineUnits
ERR! compile  *     units: (ol.control.ScaleLineUnits|string|undefined)}}
ERR! compile                ^
ERR! compile 
ERR! compile 
ERR! compile externs/olx.js:1303: ERROR - Bad type annotation. Unknown type ol.control.ScaleLineUnits
ERR! compile  * @type {ol.control.ScaleLineUnits|string|undefined}
ERR! compile           ^
ERR! compile 
ERR! compile externs/olx.js:1794: ERROR - Bad type annotation. Unknown type ol.format.IGCZ
ERR! compile  * @typedef {{altitudeMode: (ol.format.IGCZ|undefined)}}
ERR! compile                              ^
ERR! compile 
ERR! compile externs/olx.js:1802: ERROR - Bad type annotation. Unknown type ol.format.IGCZ
ERR! compile  * @type {ol.format.IGCZ|undefined}
ERR! compile           ^
ERR! compile 
ERR! compile externs/olx.js:5899: ERROR - Bad type annotation. Unknown type ol.source.WMTSRequestEncoding
ERR! compile  *     requestEncoding: (ol.source.WMTSRequestEncoding|string|undefined),
ERR! compile                          ^
ERR! compile 
ERR! compile externs/olx.js:5981: ERROR - Bad type annotation. Unknown type ol.source.WMTSRequestEncoding
ERR! compile  * @type {ol.source.WMTSRequestEncoding|string|undefined}
ERR! compile           ^
ERR! compile 
ERR! compile 
ERR! compile 6 error(s), 0
ERR! compile  warning(s)
ERR! compile 
ERR! Process exited with non-zero status, see log for more detail: 6 
Used `ol-custom.json`, click to expand ``` json { "exports": [ "ol.Map", "ol.View", "ol.format.KML", "ol.layer.Tile", "ol.layer.Vector", "ol.proj.fromLonLat", "ol.source.OSM", "ol.source.Vector", "ol.style.Fill", "ol.style.Stroke", "ol.style.Style", "ol.style.Text" ], "jvm": [], "umd": true, "compile": { "externs": [ "externs/bingmaps.js", "externs/closure-compiler.js", "externs/esrijson.js", "externs/geojson.js", "externs/oli.js", "externs/olx.js", "externs/proj4js.js", "externs/tilejson.js", "externs/topojson.js" ], "define": [ "goog.dom.ASSUME_STANDARDS_MODE=true", "goog.DEBUG=false", "ol.ENABLE_DOM=false", "ol.ENABLE_WEBGL=false", "ol.ENABLE_PROJ4JS=false", "ol.ENABLE_IMAGE=false" ], "jscomp_error": [ "*" ], "jscomp_off": [ "analyzerChecks", "lintChecks", "unnecessaryCasts", "useOfGoogBase" ], "extra_annotation_name": [ "api", "observable" ], "compilation_level": "ADVANCED", "warning_level": "VERBOSE", "use_types_for_optimization": true, "manage_closure_dependencies": true } } ```

Downgrading OpenLayers to v3.17.0 doesn't fixes it, same error.

Downgrading OpenLayers to v3.16.0 fixes this:

$ node node_modules/openlayers/tasks/build.js ol-custom.json ol-custom.js
info ol Parsing dependencies
info ol Compiling 311 source

/cc @bartvde, @tsauerwein Any idea how to fix this?

bartvde commented 8 years ago

I think I saw a ticket / comment by @ThomasG77 in the openlayers repo with similar contents?

bartvde commented 8 years ago

See: https://github.com/openlayers/ol3/issues/5564

bartvde commented 8 years ago

So it seems we should not upgrade to 3.17.1 ?

marcjansen commented 8 years ago

I think it is missing goog.provides:

adding

goog.provide('ol.control.ScaleLineUnits');
goog.provide('ol.control.ScaleLineProperty');

to scalelinecontrol.js removes the two related errors.

bartvde commented 8 years ago

Right that is also what was done in master.

marcjansen commented 8 years ago

OK, should we instead release v3.17.3? Or use latest master in the workshop :see_no_evil: :hear_no_evil: :speak_no_evil:

bartvde commented 8 years ago

I can do a 3.17.2 with that fix

marcjansen commented 8 years ago

Wait, just checking master

marcjansen commented 8 years ago

With

  "dependencies": {
    "openlayers": "git://github.com/openlayers/ol3.git#784be4099ef22abceffed183547c868ed9303126"
  }
$ node node_modules/openlayers/tasks/build.js ol-custom.json ol-custom.js
info ol Parsing dependencies
info ol Compiling 308 sources
ERR! compile externs/olx.js:1263: ERROR - Bad type annotation. Unknown type ol.control.ScaleLine.Units
ERR! compile  *     units: (ol.control.ScaleLine.Units|string|undefined)}}
ERR! compile                ^
ERR! compile 
ERR! compile 
ERR! compile externs/olx.js:1303: ERROR - Bad type annotation. Unknown type ol.control.ScaleLine.Units
ERR! compile  * @type {ol.control.ScaleLine.Units|string|undefined}
ERR! compile           ^
ERR! compile 
ERR! compile 
ERR! compile 2 error(s), 0 warning(s)
ERR! compile 
ERR! Process exited with non-zero status, see log for more detail: 2 

Trying to fix this first…

marcjansen commented 8 years ago

I fear this is a can of worms… (not sure if thats the right idiom)

Changing

diff --git a/src/ol/control/scaleline.js b/src/ol/control/scaleline.js
index 9d3171e..6319c43 100644
--- a/src/ol/control/scaleline.js
+++ b/src/ol/control/scaleline.js
@@ -1,4 +1,5 @@
 goog.provide('ol.control.ScaleLine');
+goog.provide('ol.control.ScaleLine.Units');

 goog.require('ol');
 goog.require('ol.Object');

leads to

$ node node_modules/openlayers/tasks/build.js ol-custom.json ol-custom.js
info ol Parsing dependencies
info ol Compiling 308 sources
ERR! compile /home/jansen/eclipse-luna-workspace/openlayers3-workshop/node_modules/openlayers/src/ol/featureloader.js:89: ERROR - Property setProjection never defined on this
ERR! compile         this.setProjection(dataProjection);
ERR! compile              ^
ERR! compile 
ERR! compile /home/jansen/eclipse-luna-workspace/openlayers3-workshop/node_modules/openlayers/src/ol/featureloader.js:90: ERROR - Property setFeatures never defined on this
ERR! compile         this.setFeatures(features);
ERR! compile              ^
ERR! compile 
ERR! compile /home/jansen/eclipse-luna-workspace/openlayers3-workshop/node_modules/openlayers/src/ol/renderer/canvas/vectortilelayer.js:133: ERROR - Property getReplayState never defined on ol.Tile
ERR! compile     replayState = tile.getReplayState();
ERR! compile                        ^
ERR! compile 
ERR! compile /home/jansen/eclipse-luna-workspace/openlayers3-workshop/node_modules/openlayers/src/ol/renderer/canvas/vectortilelayer.js:137: ERROR - Property getProjection never defined on ol.Tile
ERR! compile     pixelSpace = tile.getProjection().getUnits() == ol.proj.Units.TILE_PIXELS;
ERR! compile                       ^
ERR! compile 
ERR! compile /home/jansen/eclipse-luna-workspace/openlayers3-workshop/node_modules/openlayers/src/ol/renderer/canvas/vectortilelayer.js:287: ERROR - Property getProjection never defined on ol.Tile
ERR! compile     if (tile.getProjection().getUnits() === ol.proj.Units.TILE_PIXELS) {
ERR! compile              ^
ERR! compile 
ERR! compile /home/jansen/eclipse-luna-workspace/openlayers3-workshop/node_modules/openlayers/src/ol/renderer/canvas/vectortilelayer.js:299: ERROR - Property getReplayState never defined on ol.Tile
ERR! compile     replayGroup = tile.getReplayState().replayGroup;
ERR! compile                        ^
ERR! compile 
ERR! compile 
ERR! compile 6 error(s), 0 warning(s), 
ERR! compile 96.6
ERR! compile % typed
ERR! compile 
ERR! compile 
ERR! Process exited with non-zero status, see log for more detail: 6 

…which -- right now -- i won't be able to fix within a reasonable amount of time.

I suggest we revert to v3.16.0, anfd look at this with more time, possibly during the FOSS4G codesprint.

Fine for you @bartvde ?

bartvde commented 8 years ago

I agree reverting to 3.16 makes sense

tsauerwein commented 8 years ago

The config in the custom build tutorial works, I am trying to figure out why...

marcjansen commented 8 years ago

Thanks, @tsauerwein

tsauerwein commented 8 years ago

The custom build tutorial works, because jscomp_error is not set to *.

Otherwise I see the same errors as you, Marc. It's related to this commit: https://github.com/openlayers/ol3/commit/907a65ab83ef86d9927f0fced17fab66d14f980a

For example:

ERR! compile /home/tsauerwein/projects/ol3/workshop/build/openlayers-workshop-en/node_modules/openlayers/src/ol/featureloader.js:89: ERROR - Property setProjection never defined on this
ERR! compile         this.setProjection(dataProjection);

The code is:

      /**
       * @param {Array.<ol.Feature>} features The loaded features.
       * @param {ol.proj.Projection} dataProjection Data projection.
       * @this {ol.VectorTile}
       */
      function(features, dataProjection) {
        this.setProjection(dataProjection);
        this.setFeatures(features);
      },

The compiler is complaining that setProjection is not defined. But ol.VectorTile does have such a method. But I think it is not included in the build. Before, there was a goog.require('ol.VectorTile') but it was removed because 'ol.VectorTile is only used in a typedef.

marcjansen commented 8 years ago

And if we had an assert in the last function? Then we could require it again??? Thinking out loudly here.

marcjansen commented 7 years ago

It is working now with v4.0.1