Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Compile OL3 and OL3-Cesium together
Browse files Browse the repository at this point in the history
Required following openlayers/ol-cesium#289.

Changes:
- Rename the 'ga' angular module to 'geoadmin' to prevent conflict with
  a 'ga' minified symbol from the OL3/OL3-Cesium compilation;
- Rename 'ga.GaRasterSynchronizer' to 'olcs.GaRasterSynchronizer' to
  prevent similar conflict;
- Rename production Cesium.js to Cesium.min.js to help spot
  unminified/minified mismatch and added an angular 'buildMode' config
  which is now tested to know which Cesium version to load (debug or
  prod);
- Remove 'ol' target. OL3 is now checkouted in 'ol3-cesium/ol3';
- Compile OL3 and OL3-Cesium together.

As a side note, the total size of app + ol3 + ol3-cesium is now
around 15K lighter (before gzip).
  • Loading branch information
gberaudo committed Dec 1, 2015
1 parent 1065191 commit ef42018
Show file tree
Hide file tree
Showing 13 changed files with 107,429 additions and 228,549 deletions.
61 changes: 27 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DEPLOY_ROOT_DIR := /var/www/vhosts/mf-geoadmin3/private/branch
DEPLOY_TARGET ?= 'dev'
LAST_DEPLOY_TARGET := $(shell if [ -f .build-artefacts/last-deploy-target ]; then cat .build-artefacts/last-deploy-target 2> /dev/null; else echo '-none-'; fi)
OL3_VERSION ?= 627abaf1a71d48627163eb00ea6a0b6fb8dede14
OL3_CESIUM_VERSION ?= c68901adc91bbc019d6cc70056c51c00aa2fe99f
OL3_CESIUM_VERSION ?= dbbc31dd2ec4751aab9e1892d78fdc1e7b55f7eb
CESIUM_VERSION ?= 3e3cf938786ee48b4b376ed932904541d798671d
DEFAULT_TOPIC_ID ?= ech
TRANSLATION_FALLBACK_CODE ?= de
Expand Down Expand Up @@ -129,7 +129,7 @@ deploydev:
./scripts/deploydev.sh -s; \
else \
./scripts/deploydev.sh; \
fi
fi

.PHONY: deploydemo
deploydemo: guard-SNAPSHOT
Expand Down Expand Up @@ -167,32 +167,25 @@ deploybranchdemo: deploybranch
.PHONY: preparebranch
preparebranch: rc_branch scripts/00-$(GIT_BRANCH).conf

.PHONY: ol
ol: OL_JS = ol.js ol-debug.js
ol: scripts/ol-geoadmin.json .build-artefacts/ol3
cd .build-artefacts/ol3; \
git reset HEAD --hard; \
git fetch -a; \
git checkout $(OL3_VERSION); \
git show; \
cat ../../scripts/ga-ol3-style.exports >> src/ol/style/style.js; \
cat ../../scripts/ga-ol3-tilegrid.exports >> src/ol/tilegrid/tilegrid.js; \
cat ../../scripts/ga-ol3-tilerange.exports >> src/ol/tilerange.js; \
cat ../../scripts/ga-ol3-view.exports >> src/ol/view.js; \
npm install; \
node tasks/build.js config/ol-debug.json build/ol-debug.js; \
node tasks/build.js ../../scripts/ol-geoadmin.json build/ol.js; \
cd ../../; \
cp $(addprefix .build-artefacts/ol3/build/,$(OL_JS)) src/lib/;

.PHONY: ol3cesium
ol3cesium: ol .build-artefacts/ol3-cesium
ol3cesium: .build-artefacts/ol3-cesium
cd .build-artefacts/ol3-cesium; \
git reset HEAD --hard; \
git fetch --all; \
git checkout $(OL3_CESIUM_VERSION); \
git submodule update --recursive --init --force; \
cd cesium; \
cd ol3; \
git reset HEAD --hard; \
git fetch --all; \
git checkout $(OL3_VERSION); \
git show; \
cat ../../../scripts/ga-ol3-style.exports >> src/ol/style/style.js; \
cat ../../../scripts/ga-ol3-tilegrid.exports >> src/ol/tilegrid/tilegrid.js; \
cat ../../../scripts/ga-ol3-tilerange.exports >> src/ol/tilerange.js; \
cat ../../../scripts/ga-ol3-view.exports >> src/ol/view.js; \
npm install --production; \
node tasks/build-ext.js; \
cd ../cesium; \
git remote | grep c2c || git remote add c2c git://github.com/camptocamp/cesium; \
git fetch --all; \
git checkout $(CESIUM_VERSION); \
Expand All @@ -201,13 +194,15 @@ ol3cesium: ol .build-artefacts/ol3-cesium
ln -T -f -s ../../../../ol3-cesium-plugin/ src/plugins/geoadmin; \
( cd cesium; [ -f node_modules/.bin/gulp ] || npm install ); \
( cd cesium; if [ -f "Build/Cesium/Cesium.js" ] ; then echo 'Skipping Cesium minified build'; else node_modules/.bin/gulp minifyRelease; fi ); \
NO_CESIUM=1 make dist; \
( cd cesium; if [ -f "Build/CesiumUnminified/Cesium.js" ] ; then echo 'Skipping Cesium debug build'; else node_modules/.bin/gulp generateStubs combine; fi ); \
node build/build.js ../../scripts/ol3cesium-debug-geoadmin.json dist/ol3cesium-debug.js; \
npm install; \
node build/build.js build/ol3cesium-debug.json dist/ol3cesium-debug.js; \
node build/build.js ../../scripts/ol3cesium-geoadmin.json dist/ol3cesium.js; \
cp dist/ol3cesium-debug.js ../../src/lib/; \
cat cesium/Build/Cesium/Cesium.js dist/ol3cesium.js > ../../src/lib/ol3cesium.js; \
rm -rf ../../src/lib/Cesium/*; \
cp -r cesium/Build/CesiumUnminified/* ../../src/lib/Cesium;
cp dist/ol3cesium.js ../../src/lib/ol3cesium.js; \
rm -rf ../../src/lib/Cesium; \
cp -r cesium/Build/CesiumUnminified ../../src/lib/Cesium; \
cp cesium/Build/Cesium/Cesium.js ../../src/lib/Cesium.min.js;

.PHONY: fastclick
fastclick: .build-artefacts/fastclick .build-artefacts/closure-compiler/compiler.jar
Expand Down Expand Up @@ -239,8 +234,8 @@ datepicker: .build-artefacts/datepicker
translate:
${PYTHON_CMD} scripts/translation2json.py \
--files $(TRANSLATE_CSV_FILES) \
--languages "$(LANGUAGES)" \
--empty-json-file $(TRANSLATE_EMPTY_JSON) \
--languages "$(LANGUAGES)" \
--empty-json-file $(TRANSLATE_EMPTY_JSON) \
--output-folder $(TRANSLATE_OUTPUT)

.PHONY: fixrights
Expand All @@ -264,6 +259,7 @@ prd/lib/: src/lib/d3-3.3.1.min.js \
src/lib/IE9Fixes.js \
src/lib/jQuery.XDomainRequest.js \
src/lib/Cesium \
src/lib/Cesium.min.js \
src/lib/ol3cesium.js
mkdir -p $@
cp -rf $^ $@
Expand All @@ -277,7 +273,7 @@ prd/lib/build.js: src/lib/jquery-2.0.3.min.js \
src/lib/EPSG2056.js \
src/lib/EPSG32631.js \
src/lib/EPSG32632.js \
src/lib/ol.js \
src/lib/ol3cesium.js \
src/lib/angular-translate.min.js \
src/lib/angular-translate-loader-static-files.min.js \
src/lib/fastclick.min.js \
Expand Down Expand Up @@ -487,7 +483,7 @@ $(addprefix .build-artefacts/annotated/, $(SRC_JS_FILES) src/TemplateCacheModule
${PYTHON_CMD} .build-artefacts/closure-library/closure/bin/build/closurebuilder.py \
--root=.build-artefacts/annotated \
--root=.build-artefacts/closure-library \
--namespace="ga" \
--namespace="geoadmin" \
--namespace="__ga_template_cache__" \
--output_mode=list > $@

Expand Down Expand Up @@ -581,9 +577,6 @@ scripts/00-$(GIT_BRANCH).conf: scripts/00-branch.mako-dot-conf \
test $(DEPLOY_TARGET) != $(LAST_DEPLOY_TARGET) && \
echo $(DEPLOY_TARGET) > .build-artefacts/last-deploy-target || :

.build-artefacts/ol3:
git clone https://github.com/openlayers/ol3.git $@

.build-artefacts/ol3-cesium:
git clone --recursive https://github.com/openlayers/ol3-cesium.git $@

Expand Down
8 changes: 4 additions & 4 deletions ol3-cesium-plugin/garastersynchronizer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goog.provide('ga.GaRasterSynchronizer');
goog.provide('olcs.GaRasterSynchronizer');
goog.require('olcs.RasterSynchronizer');


Expand All @@ -11,16 +11,16 @@ goog.require('olcs.RasterSynchronizer');
* @extends {olcs.RasterSynchronizer}
* @api
*/
ga.GaRasterSynchronizer = function(map, scene) {
olcs.GaRasterSynchronizer = function(map, scene) {
goog.base(this, map, scene);
};
goog.inherits(ga.GaRasterSynchronizer, olcs.RasterSynchronizer);
goog.inherits(olcs.GaRasterSynchronizer, olcs.RasterSynchronizer);


/**
* @override
*/
ga.GaRasterSynchronizer.prototype.convertLayerToCesiumImageries =
olcs.GaRasterSynchronizer.prototype.convertLayerToCesiumImageries =
function(olLayer, viewProj) {

/**
Expand Down
182 changes: 182 additions & 0 deletions scripts/ol3cesium-geoadmin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"src": [
"src/**/*.js",
"ol3/src/**/*.js",
"ol3/build/ol.ext/*.js"
],
"exports": [
"olcs.*",
"ol.Collection",
"ol.Collection#*",
"ol.DeviceOrientation",
"ol.DeviceOrientation#*",
"ol.Feature",
"ol.Feature#*",
"ol.Geolocation",
"ol.Geolocation#*",
"ol.ImageTile#getImage",
"ol.Map",
"ol.Map#*",
"ol.MapBrowserEvent#*",
"ol.Observable.unByKey",
"ol.Overlay",
"ol.Overlay#*",
"ol.View",
"ol.View#*",
"ol.animation.bounce",
"ol.animation.pan",
"ol.animation.rotate",
"ol.animation.zoom",
"ol.color.asArray",
"ol.color.asString",
"ol.control.MousePosition",
"ol.control.MousePosition#*",
"ol.control.ScaleLine",
"ol.control.ScaleLine#*",
"ol.control.ZoomToExtent",
"ol.control.ZoomToExtent#*",
"ol.control.defaults",
"ol.coordinate.format",
"ol.coordinate.toStringHDMS",
"ol.coordinate.toStringXY",
"ol.easing.easeOut",
"ol.easing.linear",
"ol.extent.buffer",
"ol.extent.containsCoordinate",
"ol.extent.containsXY",
"ol.extent.getCenter",
"ol.extent.getHeight",
"ol.extent.getWidth",
"ol.extent.intersects",
"ol.format.GeoJSON",
"ol.format.GeoJSON#*",
"ol.format.KML",
"ol.format.KML#*",
"ol.format.WMSCapabilities",
"ol.format.WMSCapabilities#*",
"ol.geom.Circle",
"ol.geom.Circle#*",
"ol.geom.GeometryCollection",
"ol.geom.GeometryCollection#*",
"ol.geom.LinearRing",
"ol.geom.LinearRing#*",
"ol.geom.LineString",
"ol.geom.LineString#*",
"ol.geom.MultiLineString",
"ol.geom.MultiLineString#*",
"ol.geom.MultiPoint",
"ol.geom.MultiPoint#*",
"ol.geom.MultiPolygon",
"ol.geom.MultiPolygon#*",
"ol.geom.Point",
"ol.geom.Point#*",
"ol.geom.Polygon",
"ol.geom.Polygon#*",
"ol.has.DEVICE_ORIENTATION",
"ol.has.DEVICE_PIXEL_RATIO",
"ol.interaction.DragBox",
"ol.interaction.DragBox#*",
"ol.interaction.DragZoom",
"ol.interaction.DragZoom#*",
"ol.interaction.Draw",
"ol.interaction.Draw#*",
"ol.interaction.KeyboardPan",
"ol.interaction.KeyboardPan#*",
"ol.interaction.KeyboardZoom",
"ol.interaction.KeyboardZoom#*",
"ol.interaction.Modify",
"ol.interaction.Modify#*",
"ol.interaction.Select",
"ol.interaction.Select#*",
"ol.interaction.Snap",
"ol.interaction.Snap#*",
"ol.interaction.defaults",
"ol.layer.Group",
"ol.layer.Group#*",
"ol.layer.Image",
"ol.layer.Image#*",
"ol.layer.Layer",
"ol.layer.Layer#*",
"ol.layer.Tile",
"ol.layer.Tile#*",
"ol.layer.Vector",
"ol.layer.Vector#*",
"ol.proj.Projection",
"ol.proj.Projection#*",
"ol.proj.get",
"ol.proj.transform",
"ol.proj.transformExtent",
"ol.style.Circle",
"ol.style.Circle#*",
"ol.style.Fill",
"ol.style.Fill#*",
"ol.style.Icon",
"ol.style.Icon#*",
"ol.style.Image",
"ol.style.Image#*",
"ol.style.RegularShape",
"ol.style.RegularShape#*",
"ol.style.Stroke",
"ol.style.Stroke#*",
"ol.style.Style",
"ol.style.Style#*",
"ol.style.Text",
"ol.style.Text#*",
"ol.source.ImageVector",
"ol.source.ImageVector#*",
"ol.source.ImageWMS",
"ol.source.ImageWMS#*",
"ol.source.TileImage",
"ol.source.TileImage#*",
"ol.source.TileWMS",
"ol.source.TileWMS#*",
"ol.source.Vector",
"ol.source.Vector#*",
"ol.source.WMTS",
"ol.source.WMTS#*",
"ol.tilegrid.TileGrid",
"ol.tilegrid.TileGrid#*",
"ol.tilegrid.WMTS",
"ol.tilegrid.WMTS#*"
],
"umd": true,
"compile": {
"externs": [
"externs/olcsx.js",
"Cesium.externs.js",
"ol3/externs/bingmaps.js",
"ol3/externs/closure-compiler.js",
"ol3/externs/geojson.js",
"ol3/externs/oli.js",
"ol3/externs/olx.js",
"ol3/externs/proj4js.js",
"ol3/externs/tilejson.js",
"ol3/externs/topojson.js"
],
"define": [
"goog.array.ASSUME_NATIVE_FUNCTIONS=true",
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.json.USE_NATIVE_JSON=true",
"goog.DEBUG=false",
"ol.ENABLE_DOM=false",
"ol.ENABLE_WEBGL=false"
],
"jscomp_error": [
"*"
],
"jscomp_off": [
"useOfGoogBase",
"unnecessaryCasts",
"lintChecks"
],
"extra_annotation_name": [
"api", "observable"
],
"compilation_level": "ADVANCED",
"warning_level": "VERBOSE",
"use_types_for_optimization": true,
"manage_closure_dependencies": true,
"create_source_map": "dist/ol3cesium.js.map",
"source_map_format": "V3"
}
}
4 changes: 2 additions & 2 deletions src/TemplateCacheModule.mako.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
%>\
// Generated code. Do not edit.
goog.provide('__ga_template_cache__');
goog.require('ga');
goog.require('geoadmin');
(function() {
angular.module('ga').run(['$templateCache', function($templateCache) {
angular.module('geoadmin').run(['$templateCache', function($templateCache) {
% for partial in _partials:
$templateCache.put('${partial}', '${_partials[partial]}');
%endfor
Expand Down
7 changes: 4 additions & 3 deletions src/index.mako.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
<!DOCTYPE html>
<html ng-app="ga" ng-controller="GaMainController"
<html ng-app="geoadmin" ng-controller="GaMainController"
itemscope itemtype="http://schema.org/WebApplication"
% if device == 'mobile' and mode=='prod' :
manifest="geoadmin.appcache"
Expand Down Expand Up @@ -681,7 +681,7 @@
<script src="lib/ol3cesium-debug.js"></script>
<script src="deps.js"></script>
<script>
goog.require('ga');
goog.require('geoadmin');
</script>
% endif

Expand All @@ -708,7 +708,7 @@
cache: true
});

var module = angular.module('ga');
var module = angular.module('geoadmin');
var cacheAdd = '${version}' != '' ? '/' + '${version}' : '';
var pathname = location.pathname.replace(/(index|mobile|embed)\.html$/g, '');

Expand All @@ -719,6 +719,7 @@
% else:
dev3d: !!window.location.search.match(/(dev3d=true)/),
% endif
buildMode: '${mode}',
pegman: !!window.location.search.match(/(pegman=true)/),
mapUrl : location.origin + '${apache_base_path}',
apiUrl : location.protocol + '${api_url}',
Expand Down
Loading

0 comments on commit ef42018

Please sign in to comment.