Merge branch 'master' of github.com:openlayers/ol3 into vector

This commit is contained in:
ahocevar
2013-03-03 18:37:02 +01:00
15 changed files with 423 additions and 60 deletions

2
.gitignore vendored
View File

@@ -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

View File

@@ -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/')

View File

@@ -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('<link rel="stylesheet" href="../build/ol.css" '+
'type="text/css">');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="../build/ol.js">' +
'src="../build/' + oljs + '">' +
'</scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="' + encodeURIComponent(params.id) + '.js">' +
'src="' + encodeURIComponent(scriptParams.id) + '.js">' +
'</scr' + 'ipt>');
}());

24
build/ol-simple.json Normal file
View File

@@ -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%"
}

24
build/ol-whitespace.json Normal file
View File

@@ -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%"
}

View File

@@ -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()
});

284
examples/data/ogcsample.xml Normal file
View File

@@ -0,0 +1,284 @@
<?xml version='1.0' encoding="UTF-8"?>
<WMS_Capabilities version="1.3.0" xmlns="http://www.opengis.net/wms"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd">
<Service>
<Name>WMS</Name>
<Title>Acme Corp. Map Server</Title>
<Abstract>Map Server maintained by Acme Corporation. Contact: webmaster@wmt.acme.com. High-quality maps showing roadrunner nests and possible ambush locations.</Abstract>
<KeywordList>
<Keyword>bird</Keyword>
<Keyword>roadrunner</Keyword>
<Keyword>ambush</Keyword>
</KeywordList>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="http://hostname/" />
<ContactInformation>
<ContactPersonPrimary>
<ContactPerson>Jeff Smith</ContactPerson>
<ContactOrganization>NASA</ContactOrganization>
</ContactPersonPrimary>
<ContactPosition>Computer Scientist</ContactPosition>
<ContactAddress>
<AddressType>postal</AddressType>
<Address>NASA Goddard Space Flight Center</Address>
<City>Greenbelt</City>
<StateOrProvince>MD</StateOrProvince>
<PostCode>20771</PostCode>
<Country>USA</Country>
</ContactAddress>
<ContactVoiceTelephone>+1 301 555-1212</ContactVoiceTelephone>
<ContactElectronicMailAddress>user@host.com</ContactElectronicMailAddress>
</ContactInformation>
<Fees>none</Fees>
<AccessConstraints>none</AccessConstraints>
<LayerLimit>16</LayerLimit>
<MaxWidth>2048</MaxWidth>
<MaxHeight>2048</MaxHeight>
</Service>
<Capability>
<Request>
<GetCapabilities>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://hostname/path?" />
</Get>
<Post>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://hostname/path?" />
</Post>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/gif</Format>
<Format>image/png</Format>
<Format>image/jpeg</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://hostname/path?" />
</Get>
</HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>text/xml</Format>
<Format>text/plain</Format>
<Format>text/html</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://hostname/path?" />
</Get>
</HTTP>
</DCPType>
</GetFeatureInfo>
</Request>
<Exception>
<Format>XML</Format>
<Format>INIMAGE</Format>
<Format>BLANK</Format>
</Exception>
<Layer>
<Title>Acme Corp. Map Server</Title>
<CRS>CRS:84</CRS>
<AuthorityURL name="DIF_ID">
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html" />
</AuthorityURL>
<BoundingBox CRS="CRS:84"
minx="-1" miny="-1" maxx="1" maxy="1" resx="0.0" resy="0.0"/>
<Layer>
<Name>ROADS_RIVERS</Name>
<Title>Roads and Rivers</Title>
<CRS>EPSG:26986</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-71.63</westBoundLongitude>
<eastBoundLongitude>-70.78</eastBoundLongitude>
<southBoundLatitude>41.75</southBoundLatitude>
<northBoundLatitude>42.90</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"
minx="-71.63" miny="41.75" maxx="-70.78" maxy="42.90" resx="0.01" resy="0.01"/>
<BoundingBox CRS="EPSG:26986"
minx="189000" miny="834000" maxx="285000" maxy="962000" resx="1" resy="1" />
<Attribution>
<Title>State College University</Title>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="http://www.university.edu/" />
<LogoURL width="100" height="100">
<Format>image/gif</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://www.university.edu/icons/logo.gif" />
</LogoURL>
</Attribution>
<Identifier authority="DIF_ID">123456</Identifier>
<FeatureListURL>
<Format>XML</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:href="http://www.university.edu/data/roads_rivers.gml" />
</FeatureListURL>
<Style>
<Name>USGS</Name>
<Title>USGS Topo Map Style</Title>
<Abstract>Features are shown in a style like that used in USGS topographic maps.</Abstract>
<LegendURL width="72" height="72">
<Format>image/gif</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://www.university.edu/legends/usgs.gif" />
</LegendURL>
<StyleSheetURL>
<Format>text/xsl</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://www.university.edu/stylesheets/usgs.xsl" />
</StyleSheetURL>
</Style>
<MinScaleDenominator>1000</MinScaleDenominator>
<MaxScaleDenominator>250000</MaxScaleDenominator>
<Layer queryable="1">
<Name>ROADS_1M</Name>
<Title>Roads at 1:1M scale</Title>
<Abstract>Roads at a scale of 1 to 1 million.</Abstract>
<KeywordList>
<Keyword>road</Keyword>
<Keyword>transportation</Keyword>
<Keyword>atlas</Keyword>
</KeywordList>
<Identifier authority="DIF_ID">123456</Identifier>
<MetadataURL type="FGDC:1998">
<Format>text/plain</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://www.university.edu/metadata/roads.txt" />
</MetadataURL>
<MetadataURL type="ISO19115:2003">
<Format>text/xml</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://www.university.edu/metadata/roads.xml" />
</MetadataURL>
<Style>
<Name>ATLAS</Name>
<Title>Road atlas style</Title>
<Abstract>Roads are shown in a style like that used in a commercial road atlas.</Abstract>
<LegendURL width="72" height="72">
<Format>image/gif</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="simple"
xlink:href="http://www.university.edu/legends/atlas.gif" />
</LegendURL>
</Style>
</Layer>
<Layer queryable="1">
<Name>RIVERS_1M</Name>
<Title>Rivers at 1:1M scale</Title>
<Abstract>Rivers at a scale of 1 to 1 million.</Abstract>
<KeywordList>
<Keyword>river</Keyword>
<Keyword>canal</Keyword>
<Keyword>waterway</Keyword>
</KeywordList>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Weather Forecast Data</Title>
<CRS>CRS:84</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-180</westBoundLongitude>
<eastBoundLongitude>180</eastBoundLongitude>
<southBoundLatitude>-90</southBoundLatitude>
<northBoundLatitude>90</northBoundLatitude>
</EX_GeographicBoundingBox>
<Dimension name="time" units="ISO8601" default="2000-08-22">1999-01-01/2000-08-22/P1D</Dimension>
<Layer>
<Name>Clouds</Name>
<Title>Forecast cloud cover</Title>
</Layer>
<Layer>
<Name>Temperature</Name>
<Title>Forecast temperature</Title>
</Layer>
<Layer>
<Name>Pressure</Name>
<Title>Forecast barometric pressure</Title>
<Dimension name="elevation" units="EPSG:5030" />
<Dimension name="time" units="ISO8601" default="2000-08-22">
1999-01-01/2000-08-22/P1D</Dimension>
<Dimension name="elevation" units="CRS:88" default="0" nearestValue="1">0,1000,3000,5000,10000</Dimension>
</Layer>
</Layer>
<Layer opaque="1" noSubsets="1" fixedWidth="512" fixedHeight="256">
<Name>ozone_image</Name>
<Title>Global ozone distribution (1992)</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>-180</westBoundLongitude>
<eastBoundLongitude>180</eastBoundLongitude>
<southBoundLatitude>-90</southBoundLatitude>
<northBoundLatitude>90</northBoundLatitude>
</EX_GeographicBoundingBox>
<Dimension name="time" units="ISO8601" default="1992">1992</Dimension>
</Layer>
<Layer cascaded="1">
<Name>population</Name>
<Title>World population, annual</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>-180</westBoundLongitude>
<eastBoundLongitude>180</eastBoundLongitude>
<southBoundLatitude>-90</southBoundLatitude>
<northBoundLatitude>90</northBoundLatitude>
</EX_GeographicBoundingBox>
<Dimension name="time" units="ISO8601" default="2000">1990/2000/P1Y</Dimension>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>

View File

@@ -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';
})();

View File

@@ -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(

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));

View File

@@ -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()

View File

@@ -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

View File

@@ -0,0 +1 @@
@exportProperty ol.renderer.canvas.Map.prototype.getCanvas