Skip to content

Commit

Permalink
Merge pull request #289 from gberaudo/compile_with_ol3
Browse files Browse the repository at this point in the history
Compile OL3-Cesium together with OL3
  • Loading branch information
gberaudo committed Nov 19, 2015
2 parents 19be567 + 15575a0 commit dbbc31d
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 67 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.10

* Breaking changes
* OL3-Cesium is now compiled together with OL3. A custom closure compiler
build is no more required.

## v1.9 - 2015-10-22

* Breaking changes
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ where `<target>` is the name of the target you want to execute. For example:

$ make dist

## Compliler version

The version of the compiler may be changed by creating a file closure-util.json
at the root of the project. See [available options](https://github.com/openlayers/closure-util/blob/master/default-config.json)
and [available compilers](https://github.com/google/closure-compiler/wiki/Binary-Downloads).

## Pull request guidelines

Expand Down
31 changes: 12 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ help:
npm-install: .build/node_modules.timestamp

.PHONY: serve
serve: npm-install ol3/build/olX cesium/Build/Cesium/Cesium.js
serve: npm-install cesium/Build/Cesium/Cesium.js
node build/serve.js

.PHONY: dist
Expand Down Expand Up @@ -65,7 +65,6 @@ clean:
rm -f ol3/build/ol.js
rm -f ol3/build/ol-debug.js
rm -f ol3/build/ol.css
rm -f ol3/build/ol-externs.js
rm -rf cesium/Build/Cesium
rm -rf cesium/Build/CesiumUnminified
rm -rf dist/ol3
Expand All @@ -86,18 +85,12 @@ cleanall: clean
.build/python-venv/bin/gjslint --jslint_error=all --strict --custom_jsdoc_tags=api $?
touch $@

.build/dist-examples.timestamp: ol3/build/olX cesium/Build/Cesium/Cesium.js dist/ol3cesium.js $(EXAMPLES_JS_FILES) $(EXAMPLES_HTML_FILES)
.build/dist-examples.timestamp: cesium/Build/Cesium/Cesium.js dist/ol3cesium.js $(EXAMPLES_JS_FILES) $(EXAMPLES_HTML_FILES)
node build/parse-examples.js
mkdir -p $(dir $@)
mkdir -p dist/ol3
cp ol3/build/ol-debug.js dist/ol3/
cp ol3/build/ol.js dist/ol3/
mkdir -p dist/ol3/css
cp ol3/build/ol.css dist/ol3/css/
cp -R cesium/Build/Cesium dist/
cp -R examples dist/
for f in dist/examples/*.html; do $(SEDI) 'sY/@loaderY../ol3cesium.jsY' $$f; done
for f in dist/examples/*.html; do $(SEDI) 'sY../ol3/build/ol.jsY../ol3/ol-debug.jsY' $$f; done
for f in dist/examples/*.html; do $(SEDI) 'sY../cesium/Build/Y../Y' $$f; done
for f in dist/examples/*.js; do $(SEDI) 'sY../cesium/Build/Y../Y' $$f; done
touch $@
Expand All @@ -110,27 +103,27 @@ cleanall: clean
.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) ol3/build/ol-externs.js Cesium.externs.js build/build.js npm-install
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 $< $@


ol3/node_modules/rbush/package.json: ol3/package.json
(cd ol3 && npm install --production)

ol3/build/ol.ext/rbush.js: ol3/node_modules/rbush/package.json
(cd ol3 && node tasks/build-ext.js)


# A sourcemap is prepared, the source is exected to be deployed in 'source' directory
dist/ol3cesium.js: build/ol3cesium.json $(SRC_JS_FILES) ol3/build/ol-externs.js Cesium.externs.js build/build.js npm-install
dist/ol3cesium.js: build/ol3cesium.json $(SRC_JS_FILES) Cesium.externs.js build/build.js npm-install ol3/build/ol.ext/rbush.js
mkdir -p $(dir $@)
node build/build.js $< $@
$(SEDI) 's!$(shell pwd)/dist!source!g' dist/ol3cesium.js.map
$(SEDI) 's!$(shell pwd)!source!g' dist/ol3cesium.js.map
# echo '//# sourceMappingURL=ol3cesium.js.map' >> dist/ol3cesium.js
# -ln -s .. dist/source

.PHONY: ol3/build/ol-externs.js
ol3/build/ol-externs.js:
(cd ol3 && npm install && node tasks/generate-externs.js build/ol-externs.js)

.PHONY: ol3/build/olX
ol3/build/olX:
(cd ol3 && npm install && make build)

cesium/node_modules/.bin/gulp: cesium/package.json
cd cesium && npm install

Expand Down
1 change: 0 additions & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function getDependencies(config, exports, callback) {
cwd: root
};
}
options.ignoreRequires = config.ignoreRequires;
closure.getDependencies(options, function(err, paths) {
if (err) {
callback(err);
Expand Down
44 changes: 27 additions & 17 deletions build/generate-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ var async = require('async');
var fse = require('fs-extra');
var walk = require('walk').walk;

var sourceDir = path.join(__dirname, '..', 'src');
var sourceDirOL = path.join(__dirname, '..', 'ol3', 'src');
var sourceDirSelf = path.join(__dirname, '..', 'src');
var sourceDirs = [sourceDirOL, sourceDirSelf];
var infoPath = path.join(__dirname, '..', '.build', 'info.json');
var jsdoc = path.join(__dirname, '..', 'node_modules', '.bin', 'jsdoc');
var jsdocConfig = path.join(__dirname, 'jsdoc', 'info', 'conf.json');
Expand Down Expand Up @@ -40,25 +42,33 @@ function getInfoTime(callback) {
* error and the array of source paths (empty if none newer).
*/
function getNewer(date, callback) {
var paths = [];
var newer = false;
var paths = [];

var walker = walk(sourceDir, {followLinks: true});
walker.on('file', function(root, stats, next) {
var sourcePath = path.join(root, stats.name);
if (/\.js$/.test(sourcePath)) {
paths.push(sourcePath);
if (stats.mtime > date) {
newer = true;
}
}
next();
});
walker.on('errors', function() {
callback(new Error('Trouble walking ' + sourceDir));
var tasks = sourceDirs.map(function(sourceDir) {
return function(callback) {
var walker = walk(sourceDir, {followLinks: true});
walker.on('file', function(root, stats, next) {
var sourcePath = path.join(root, stats.name);
if (/\.js$/.test(sourcePath)) {
paths.push(sourcePath);
if (stats.mtime > date) {
newer = true;
}
}
next();
});
walker.on('errors', function() {
callback(new Error('Trouble walking ' + sourceDir));
});
walker.on('end', function() {
callback(null);
});
};
});
walker.on('end', function() {
callback(null, newer ? paths : []);

async.series(tasks, function(err, results) {
callback(err, newer ? paths : []);
});
}

Expand Down
6 changes: 5 additions & 1 deletion build/ol3cesium-debug.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"ignoreRequires": "^ol\\.",
"src": [
"src/**/*.js",
"ol3/src/**/*.js",
"ol3/build/ol.ext/*.js"
],
"exports": ["*"]
}
19 changes: 15 additions & 4 deletions build/ol3cesium.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"exports": ["*"],
"src": ["src/**/*.js"],
"ignoreRequires": "^ol\\.",
"src": [
"src/**/*.js",
"ol3/src/**/*.js",
"ol3/build/ol.ext/*.js"
],
"compile": {
"externs": [
"ol3/build/ol-externs.js",
"ol3/externs/esrijson.js",
"externs/olcsx.js",
"ol3/externs/oli.js",
"ol3/externs/olx.js",
"ol3/externs/proj4js.js",
"ol3/externs/tilejson.js",
"ol3/externs/topojson.js",
"ol3/externs/esrijson.js",
"ol3/externs/geojson.js",
"ol3/externs/bingmaps.js",
"ol3/externs/closure-compiler.js",
"Cesium.externs.js"
],
"define": [
Expand All @@ -30,6 +40,7 @@
"language_in": "ECMASCRIPT5_STRICT",
"language_out": "ECMASCRIPT5_STRICT",
"warning_level": "VERBOSE",
"generate_exports": true,
"output_wrapper": "(function(){%output%}).call(window);",
"use_types_for_optimization": true,
"create_source_map": "dist/ol3cesium.js.map",
Expand Down
7 changes: 4 additions & 3 deletions build/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ log.info('ol3-cesium', 'Parsing dependencies ...');
var manager = new closure.Manager({
closure: true, // use the bundled Closure Library
lib: [
'src/**/*.js'
],
ignoreRequires: '^ol\\.'
'src/**/*.js',
'ol3/src/**/*.js',
'ol3/build/ol.ext/*.js'
]
});
manager.on('error', function(e) {
log.error('ol3-cesium', e.message);
Expand Down
4 changes: 0 additions & 4 deletions closure-util.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/dragbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<div id="map3d" style="width:600px;height:400px;float:left;position:relative;"></div>
<div>A zone may be selected in ol3 or Cesium map using maj+drag and trigger an event.
<br/>Then application code may react to the event by zooming, selecting features, ...</div>
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="dragbox.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/epsg-4326.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<body>
<div id="map2d" style="width:600px;height:400px;float:left;"></div>
<input type="button" value="Enable/disable" onclick="javascript:ol3d.setEnabled(!ol3d.getEnabled())" />
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="epsg-4326.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/exports.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<input type="button" value="lookAt([35, 40])" onclick="javascript:camera.lookAt(ol.proj.transform([35, 40], 'EPSG:4326', 'EPSG:3857'))" />
<input type="button" value="setCenter([40, 45])" onclick="javascript:camera.setCenter(ol.proj.transform([40, 45], 'EPSG:4326', 'EPSG:3857'))" />
<input type="button" value="setPosition([45, 50])" onclick="javascript:camera.setPosition(ol.proj.transform([45, 50], 'EPSG:4326', 'EPSG:3857'))" />
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="exports.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/kml.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<body>
<div id="map" style="width:600px;height:400px;"></div>
<input type="button" value="Enable/disable" onclick="javascript:ol3d.setEnabled(!ol3d.getEnabled())" />
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="kml.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/lazy.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<div>This is an experimental feature.</div>
<div id="map" style="width:600px;height:400px;"></div>
<input type="button" value="Enable/disable 3D" onclick="javascript:toggle3D()" />
<script src="../ol3/build/ol.js"></script>
<script src="/@loader"></script>
<script src="lazy.js"></script>
</body>
Expand Down
1 change: 0 additions & 1 deletion examples/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<body>
<div id="map" style="width:600px;height:400px;"></div>
<input type="button" value="Enable/disable" onclick="javascript:ol3d.setEnabled(!ol3d.getEnabled())" />
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="main.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/rastersync.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<label>Z-index</label>
<input type="range" min="-10" max="10" step="1" oninput="layer2.setZIndex(this.value)" />
</fieldset>
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="rastersync.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<div>A country may be highlighted by clicking it on the ol3 map.
<br/>It gets automatically selected in Cesium.
<br/>If you see flickering in Cesium, please check your graphic card drivers.</div>
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="selection.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/sidebyside.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<div id="map2d" style="width:600px;height:400px;float:left;"></div>
<div id="map3d" style="width:600px;height:400px;float:left;position:relative;"></div>
<input type="button" value="Enable/disable" onclick="javascript:ol3d.setEnabled(!ol3d.getEnabled())" />
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="sidebyside.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/synthvectors.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<div id="created"></div>
<div id="added"></div>
<input type="button" value="Clear" onclick="javascript:clearFeatures()" />
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="synthvectors.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/synthvectors_batch.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<input type="button" value="Clear" onclick="javascript:clearFeatures()" />
<div>Click to add a new layer of 1000 randomly colored circles.
<br />Other shapes or icons may be used in spite of the circles.
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="synthvectors_batch.js"></script>
Expand Down
1 change: 0 additions & 1 deletion examples/vectors.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
onclick="javascript:toggleClampToGround(); ol3d.getAutoRenderLoop().restartRenderLoop()" /></div>
<div>Vectors are synchronized from the ol3 map to the Cesium scene.
<br/>3D positioning and some styling is supported.<br />The render loop is automatically stopped when idle.</div>
<script src="../ol3/build/ol.js"></script>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<script src="/@loader"></script>
<script src="vectors.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"htmlparser2": "~3.7.1"
},
"devDependencies": {
"closure-util": "1.7.0",
"closure-util": "1.8.0",
"geojsonhint": "^1.0.0",
"fs-extra": "~0.8.1",
"graceful-fs": "~3.0.2",
Expand Down
14 changes: 9 additions & 5 deletions src/featureconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ goog.require('goog.asserts');
goog.require('ol.extent');
goog.require('ol.geom.SimpleGeometry');
goog.require('olcs.core.VectorLayerCounterpart');
goog.require('olcs.obj');



Expand Down Expand Up @@ -42,7 +43,7 @@ olcs.FeatureConverter.prototype.onRemoveOrClearFeature_ = function(evt) {
var source = evt.target;
goog.asserts.assertInstanceof(source, ol.source.Vector);

var cancellers = source['olcs_cancellers'];
var cancellers = olcs.obj(source)['olcs_cancellers'];
if (cancellers) {
var feature = evt.feature;
if (goog.isDef(feature)) {
Expand All @@ -60,7 +61,7 @@ olcs.FeatureConverter.prototype.onRemoveOrClearFeature_ = function(evt) {
cancellers[key]();
}
}
source['olcs_cancellers'] = {};
olcs.obj(source)['olcs_cancellers'] = {};
}
}
};
Expand Down Expand Up @@ -540,10 +541,13 @@ olcs.FeatureConverter.prototype.olPointGeometryToCesium =
};
source.on(['removefeature', 'clear'],
this.boundOnRemoveOrClearFeatureListener_);
source['olcs_cancellers'] = source['olcs_cancellers'] || {};
var cancellers = olcs.obj(source)['olcs_cancellers'];
if (!cancellers) {
cancellers = olcs.obj(source)['olcs_cancellers'] = {};
}

goog.asserts.assert(!source['olcs_cancellers'][goog.getUid(feature)]);
source['olcs_cancellers'][goog.getUid(feature)] = canceller;
goog.asserts.assert(!cancellers[goog.getUid(feature)]);
cancellers[goog.getUid(feature)] = canceller;

var listener = function() {
if (!billboards.isDestroyed() && !cancelled) {
Expand Down
11 changes: 11 additions & 0 deletions src/olcs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
goog.provide('olcs.obj');


/**
* Cast to object.
* @param {Object} param
* @return {Object}
*/
olcs.obj = function(param) {
return param;
};

0 comments on commit dbbc31d

Please sign in to comment.