diff --git a/.gitignore b/.gitignore
index 78d2adfe1c..2f70f4f045 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,8 @@
/build/ol.css
/build/ol.js
/build/ol-all.js
+/build/ol-simple.js
+/build/ol-whitespace.js
/build/src
/build/phantomjs-*-windows
/build/phantomjs-*-windows.zip
diff --git a/build.py b/build.py
index 1addb62c55..4fb0b399f5 100755
--- a/build.py
+++ b/build.py
@@ -98,7 +98,7 @@ virtual('all', 'build-all', 'build', 'examples', 'precommit')
virtual('precommit', 'lint', 'build-all', 'test', 'build', 'build-examples', 'doc')
-virtual('build', 'build/ol.css', 'build/ol.js')
+virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js')
virtual('todo', 'fixme')
@@ -115,6 +115,18 @@ def build_ol_js(t):
report_sizes(t)
+@target('build/ol-simple.js', PLOVR_JAR, SRC, EXTERNAL_SRC, 'base.json', 'build/ol.json', 'build/ol-simple.json')
+def build_ol_js(t):
+ t.output('%(JAVA)s', '-jar', PLOVR_JAR, 'build', 'build/ol-simple.json')
+ report_sizes(t)
+
+
+@target('build/ol-whitespace.js', PLOVR_JAR, SRC, EXTERNAL_SRC, 'base.json', 'build/ol.json', 'build/ol-whitespace.json')
+def build_ol_js(t):
+ t.output('%(JAVA)s', '-jar', PLOVR_JAR, 'build', 'build/ol-whitespace.json')
+ report_sizes(t)
+
+
virtual('build-all', 'build/ol-all.js')
@@ -229,6 +241,28 @@ def build_lint_src_timestamp(t):
t.touch()
+def _strip_comments(lines):
+ # FIXME this is a horribe hack, we should use a proper JavaScript parser here
+ in_comment = False
+ for line in lines:
+ if in_comment:
+ index = line.find('*/')
+ if index != -1:
+ in_comment = False
+ yield line[index + 2:]
+ else:
+ index = line.find('/*')
+ if index != -1:
+ yield line[:index]
+ in_comment = True
+ else:
+ index = line.find('//')
+ if index != -1:
+ yield line[:index]
+ else:
+ yield line
+
+
@target('build/check-requires-timestamp', SRC, INTERNAL_SRC, EXTERNAL_SRC, EXAMPLES_SRC)
def build_check_requires_timestamp(t):
unused_count = 0
@@ -267,7 +301,7 @@ def build_check_requires_timestamp(t):
requires = set()
uses = set()
lineno = 0
- for line in open(filename):
+ for line in _strip_comments(open(filename)):
lineno += 1
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
if m:
@@ -336,8 +370,10 @@ def hostexamples(t):
t.makedirs('build/gh-pages/%(BRANCH)s/examples')
t.makedirs('build/gh-pages/%(BRANCH)s/build')
t.cp(EXAMPLES, (path.replace('.html', '.js') for path in EXAMPLES), 'examples/style.css', 'build/gh-pages/%(BRANCH)s/examples/')
+ t.rm_rf('build/gh-pages/%(BRANCH)s/examples/data')
+ t.cp_r('examples/data', 'build/gh-pages/%(BRANCH)s/examples/data')
t.cp('build/loader_hosted_examples.js', 'build/gh-pages/%(BRANCH)s/examples/loader.js')
- t.cp('build/ol.js', 'build/ol.css', 'build/gh-pages/%(BRANCH)s/build/')
+ t.cp('build/ol.js', 'build/ol-simple.js', 'build/ol-whitespace.js', 'build/ol.css', 'build/gh-pages/%(BRANCH)s/build/')
t.cp('examples/example-list.html', 'build/gh-pages/%(BRANCH)s/examples/index.html')
t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/')
diff --git a/build/loader_hosted_examples.js b/build/loader_hosted_examples.js
index 9afe49715f..92cefa8e76 100644
--- a/build/loader_hosted_examples.js
+++ b/build/loader_hosted_examples.js
@@ -6,9 +6,9 @@
* This loader is used for the hosted examples. It is used in place of the
* development loader (examples/loader.js).
*
- * ol.css and ol.js are built with Plovr/Closure, based on build/ol.json.
- * (`build.py build` builds them). They are located in the ../build/
- * directory, relatively to this script.
+ * ol.css, ol.js, ol-simple.js, and ol-whitespace.js are built with
+ * Plovr/Closure. `build.py build` builds them. They are located in the
+ * ../build/ directory, relatively to this script.
*
* The script should be named loader.js. So it needs to be renamed to
* loader.js from loader_hosted_examples.js.
@@ -19,9 +19,27 @@
*/
(function() {
- var scripts = document.getElementsByTagName('script');
- var i, src, index, search, chunks, pair, params = {};
+ var i, pair;
+
+ var href = window.location.href, start, end, paramsString, pairs,
+ pageParams = {};
+ if (href.indexOf('?') > 0) {
+ start = href.indexOf('?') + 1;
+ end = href.indexOf('#') > 0 ? href.indexOf('#') : href.length;
+ paramsString = href.substring(start, end);
+ pairs = paramsString.split(/[&;]/);
+ for (i = 0; i < pairs.length; ++i) {
+ pair = pairs[i].split('=');
+ if (pair[0]) {
+ pageParams[decodeURIComponent(pair[0])] =
+ decodeURIComponent(pair[1]);
+ }
+ }
+ }
+
+ var scripts = document.getElementsByTagName('script');
+ var src, index, search, chunks, scriptParams = {};
for (i = scripts.length - 1; i >= 0; --i) {
src = scripts[i].getAttribute('src');
if (~(index = src.indexOf('loader.js?'))) {
@@ -29,18 +47,29 @@
chunks = search ? search.split('&') : [];
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
- params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
+ if (pair[0]) {
+ scriptParams[decodeURIComponent(pair[0])] =
+ decodeURIComponent(pair[1]);
+ }
}
break;
}
}
+ var oljs = 'ol.js', mode;
+ if ('mode' in pageParams) {
+ mode = pageParams.mode.toLowerCase();
+ if (mode != 'advanced') {
+ oljs = 'ol-' + mode + '.js';
+ }
+ }
+
document.write('');
document.write('' +
+ 'src="../build/' + oljs + '">' +
'');
document.write('' +
+ 'src="' + encodeURIComponent(scriptParams.id) + '.js">' +
'');
}());
diff --git a/build/ol-simple.json b/build/ol-simple.json
new file mode 100644
index 0000000000..27a982ee23
--- /dev/null
+++ b/build/ol-simple.json
@@ -0,0 +1,24 @@
+{
+
+ "id": "ol-simple",
+
+ "externs": [
+ "externs/bingmaps.js",
+ "externs/proj4js.js",
+ "externs/tilejson.js"
+ ],
+
+ "inherits": "ol.json",
+
+ "inputs": [
+ "build/src/internal/src/requireall.js",
+ "build/src/internal/src/types.js"
+ ],
+
+ "mode": "SIMPLE",
+
+ // Note: we can't have a (function(){%output%})() output wrapper with
+ // WHITESPACE and SIMPLE modes. See this link for explanations:
+ // https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
+ "output-wrapper": "%output%"
+}
diff --git a/build/ol-whitespace.json b/build/ol-whitespace.json
new file mode 100644
index 0000000000..83294ee47c
--- /dev/null
+++ b/build/ol-whitespace.json
@@ -0,0 +1,24 @@
+{
+
+ "id": "ol-whitespace",
+
+ "externs": [
+ "externs/bingmaps.js",
+ "externs/proj4js.js",
+ "externs/tilejson.js"
+ ],
+
+ "inherits": "ol.json",
+
+ "inputs": [
+ "build/src/internal/src/requireall.js",
+ "build/src/internal/src/types.js"
+ ],
+
+ "mode": "WHITESPACE",
+
+ // Note: we can't have a (function(){%output%})() output wrapper with
+ // WHITESPACE and SIMPLE modes. See this link for explanations:
+ // https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
+ "output-wrapper": "%output%"
+}
diff --git a/examples/anchored-elements.js b/examples/anchored-elements.js
index 2e0d0dd6c0..80a27bb4f5 100644
--- a/examples/anchored-elements.js
+++ b/examples/anchored-elements.js
@@ -1,6 +1,3 @@
-goog.require('goog.debug.Console');
-goog.require('goog.debug.Logger');
-goog.require('goog.debug.Logger.Level');
goog.require('ol.AnchoredElement');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
@@ -12,12 +9,6 @@ goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
-if (goog.DEBUG) {
- goog.debug.Console.autoInstall();
- goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
-}
-
-
var layer = new ol.layer.TileLayer({
source: new ol.source.MapQuestOpenAerial()
});
diff --git a/examples/data/ogcsample.xml b/examples/data/ogcsample.xml
new file mode 100644
index 0000000000..0d4c52da60
--- /dev/null
+++ b/examples/data/ogcsample.xml
@@ -0,0 +1,284 @@
+
+
+
+ WMS
+ Acme Corp. Map Server
+ Map Server maintained by Acme Corporation. Contact: webmaster@wmt.acme.com. High-quality maps showing roadrunner nests and possible ambush locations.
+
+
+ bird
+ roadrunner
+ ambush
+
+
+
+
+
+
+ Jeff Smith
+ NASA
+
+ Computer Scientist
+
+
+ postal
+ NASA Goddard Space Flight Center
+ Greenbelt
+ MD
+ 20771
+
+ USA
+
+ +1 301 555-1212
+ user@host.com
+
+
+ none
+
+ none
+ 16
+ 2048
+ 2048
+
+
+
+
+
+ text/xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+ image/gif
+ image/png
+ image/jpeg
+
+
+
+
+
+
+
+
+
+
+
+ text/xml
+ text/plain
+ text/html
+
+
+
+
+
+
+
+
+
+
+
+ XML
+
+ INIMAGE
+ BLANK
+
+
+ Acme Corp. Map Server
+ CRS:84
+
+
+
+
+
+
+
+ ROADS_RIVERS
+ Roads and Rivers
+
+ EPSG:26986
+
+ -71.63
+ -70.78
+ 41.75
+ 42.90
+
+
+
+
+
+ State College University
+
+
+
+ image/gif
+
+
+
+ 123456
+
+
+ XML
+
+
+
+ 1000
+ 250000
+
+ ROADS_1M
+ Roads at 1:1M scale
+ Roads at a scale of 1 to 1 million.
+
+
+ road
+ transportation
+ atlas
+
+ 123456
+
+
+ text/plain
+
+
+
+ text/xml
+
+
+
+
+
+
+ RIVERS_1M
+ Rivers at 1:1M scale
+ Rivers at a scale of 1 to 1 million.
+
+
+ river
+ canal
+ waterway
+
+
+
+
+
+ Weather Forecast Data
+ CRS:84
+
+
+ -180
+ 180
+
+ -90
+ 90
+
+ 1999-01-01/2000-08-22/P1D
+
+
+ Clouds
+ Forecast cloud cover
+
+
+ Temperature
+ Forecast temperature
+
+
+
+ Pressure
+ Forecast barometric pressure
+
+
+ 1999-01-01/2000-08-22/P1D
+
+ 0,1000,3000,5000,10000
+
+
+
+ ozone_image
+ Global ozone distribution (1992)
+
+
+ -180
+ 180
+ -90
+ 90
+
+ 1992
+
+
+
+ population
+ World population, annual
+
+ -180
+
+ 180
+ -90
+ 90
+
+ 1990/2000/P1Y
+
+
+
+
+
diff --git a/examples/full-screen.js b/examples/full-screen.js
index eb13bda2f2..e696c2fea1 100644
--- a/examples/full-screen.js
+++ b/examples/full-screen.js
@@ -1,7 +1,3 @@
-goog.require('goog.debug.Console');
-goog.require('goog.debug.Logger');
-goog.require('goog.debug.Logger.Level');
-goog.require('goog.style');
goog.require('ol.AnchoredElement');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
@@ -13,12 +9,6 @@ goog.require('ol.layer.TileLayer');
goog.require('ol.source.MapQuestOpenAerial');
-if (goog.DEBUG) {
- goog.debug.Console.autoInstall();
- goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
-}
-
-
var layer = new ol.layer.TileLayer({
source: new ol.source.MapQuestOpenAerial()
});
@@ -41,4 +31,9 @@ var marker = new ol.AnchoredElement({
element: element
});
marker.bindTo('position', geolocation);
-goog.style.showElement(element, true);
+
+// This is silly: gjslint generates a "No docs found for member
+// 'element.style.display'" without the auto-executing function.
+(function() {
+ element.style.display = 'block';
+})();
diff --git a/examples/side-by-side.js b/examples/side-by-side.js
index 44a25d9018..3a02b02e89 100644
--- a/examples/side-by-side.js
+++ b/examples/side-by-side.js
@@ -1,6 +1,3 @@
-goog.require('goog.debug.Console');
-goog.require('goog.debug.Logger');
-goog.require('goog.debug.Logger.Level');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Map');
@@ -15,12 +12,6 @@ goog.require('ol.projection');
goog.require('ol.source.MapQuestOpenAerial');
-if (goog.DEBUG) {
- goog.debug.Console.autoInstall();
- goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
-}
-
-
var LONDON = ol.projection.transformWithCodes(
new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857');
var MOSCOW = ol.projection.transformWithCodes(
diff --git a/examples/two-layers.js b/examples/two-layers.js
index d49dce6dbc..78451c0669 100644
--- a/examples/two-layers.js
+++ b/examples/two-layers.js
@@ -50,6 +50,8 @@ var canvasMap = new ol.Map({
canvasMap.bindTo('layers', webglMap);
canvasMap.bindTo('view', webglMap);
-goog.events.listen(goog.dom.getElement('canvas-export'), 'click', function(e) {
+// Handle clicks on the "canvas-export" element.
+var element = document.getElementById('canvas-export');
+element.addEventListener('click', function(e) {
e.target.href = canvasMap.getRenderer().getCanvas().toDataURL('image/jpeg');
-});
+}, false);
diff --git a/examples/wms-capabilities.js b/examples/wms-capabilities.js
index a9c708f982..09d8ed7061 100644
--- a/examples/wms-capabilities.js
+++ b/examples/wms-capabilities.js
@@ -1,7 +1,7 @@
goog.require('ol.parser.ogc.WMSCapabilities');
var parser = new ol.parser.ogc.WMSCapabilities(), result;
-var url = '../test/spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
+var url = 'data/ogcsample.xml';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
diff --git a/examples/wms-custom-proj.js b/examples/wms-custom-proj.js
index 1d0c6c970e..479114e3f5 100644
--- a/examples/wms-custom-proj.js
+++ b/examples/wms-custom-proj.js
@@ -1,6 +1,3 @@
-goog.require('goog.debug.Console');
-goog.require('goog.debug.Logger');
-goog.require('goog.debug.Logger.Level');
goog.require('ol.Attribution');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
@@ -17,11 +14,6 @@ goog.require('ol.source.SingleImageWMS');
goog.require('ol.source.TiledWMS');
-if (goog.DEBUG) {
- goog.debug.Console.autoInstall();
- goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
-}
-
var epsg21781 = new ol.Projection('EPSG:21781', ol.ProjectionUnits.METERS,
// Validity extent from http://spatialreference.org
new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864));
diff --git a/examples/wms.js b/examples/wms.js
index 603c1a0357..d71c133002 100644
--- a/examples/wms.js
+++ b/examples/wms.js
@@ -1,6 +1,3 @@
-goog.require('goog.debug.Console');
-goog.require('goog.debug.Logger');
-goog.require('goog.debug.Logger.Level');
goog.require('ol.Collection');
goog.require('ol.Coordinate');
goog.require('ol.Extent');
@@ -12,12 +9,6 @@ goog.require('ol.source.MapQuestOpenAerial');
goog.require('ol.source.TiledWMS');
-if (goog.DEBUG) {
- goog.debug.Console.autoInstall();
- goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
-}
-
-
var layers = new ol.Collection([
new ol.layer.TileLayer({
source: new ol.source.MapQuestOpenAerial()
diff --git a/src/ol/map.exports b/src/ol/map.exports
index 96ee6e3e29..656ef9cef4 100644
--- a/src/ol/map.exports
+++ b/src/ol/map.exports
@@ -2,6 +2,7 @@
@exportProperty ol.Map.prototype.addPreRenderFunction
@exportProperty ol.Map.prototype.addPreRenderFunctions
@exportProperty ol.Map.prototype.getInteractions
+@exportProperty ol.Map.prototype.getRenderer
@exportSymbol ol.RendererHint
@exportProperty ol.RendererHint.CANVAS
diff --git a/src/ol/renderer/canvas/map.exports b/src/ol/renderer/canvas/map.exports
new file mode 100644
index 0000000000..784a80737e
--- /dev/null
+++ b/src/ol/renderer/canvas/map.exports
@@ -0,0 +1 @@
+@exportProperty ol.renderer.canvas.Map.prototype.getCanvas