Merge pull request #1027 from tschaub/closure-util
Use the closure-util package. Documentation will come when this is a more complete solution. See #1027 for basic usage instructions.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
|||||||
/examples/*.html.png
|
/examples/*.html.png
|
||||||
/examples/example-list.js
|
/examples/example-list.js
|
||||||
/examples/example-list.xml
|
/examples/example-list.xml
|
||||||
|
/node_modules/
|
||||||
|
|||||||
19
package.json
Normal file
19
package.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "openlayers",
|
||||||
|
"version": "3.0.0-beta",
|
||||||
|
"description": "Mapping library",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node tasks/serve.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/openlayers/ol3.git"
|
||||||
|
},
|
||||||
|
"license": "BSD",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/openlayers/ol3/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"closure-util": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -318,7 +318,16 @@ ol.parser.KML = function(opt_options) {
|
|||||||
value += ':00';
|
value += ':00';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container.whens.push(goog.date.fromIsoString(value).date_);
|
var date = goog.date.fromIsoString(value);
|
||||||
|
if (!goog.isNull(date)) {
|
||||||
|
/**
|
||||||
|
* Older Closure Library did not provide a date property on
|
||||||
|
* goog.date.DateTime. When we get rid of Plovr, this can be
|
||||||
|
* simplified to use the date property.
|
||||||
|
*/
|
||||||
|
date = new Date(date.getTime());
|
||||||
|
}
|
||||||
|
container.whens.push(date);
|
||||||
},
|
},
|
||||||
'_trackPointAttribute': function(node, container) {
|
'_trackPointAttribute': function(node, container) {
|
||||||
var name = node.nodeName.split(':').pop();
|
var name = node.nodeName.split(':').pop();
|
||||||
|
|||||||
46
tasks/serve.js
Normal file
46
tasks/serve.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* This task starts a dev server that provides a script loader for OpenLayers
|
||||||
|
* and Closure Library. In addition, a static server hosts all files in the
|
||||||
|
* repository.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var url = require('url');
|
||||||
|
|
||||||
|
var closure = require('closure-util');
|
||||||
|
var log = closure.log;
|
||||||
|
|
||||||
|
log.info('ol', 'Parsing dependencies ...');
|
||||||
|
var manager = new closure.Manager({
|
||||||
|
closure: true, // use the bundled Closure Library
|
||||||
|
lib: [
|
||||||
|
'src/**/*.js',
|
||||||
|
'test/spec/**/*.test.js'
|
||||||
|
],
|
||||||
|
main: 'examples/*.js'
|
||||||
|
});
|
||||||
|
manager.on('error', function(e) {
|
||||||
|
log.error('ol', e.message);
|
||||||
|
});
|
||||||
|
manager.on('ready', function() {
|
||||||
|
var server = new closure.Server({
|
||||||
|
manager: manager,
|
||||||
|
loader: /^\/\w+\/loader.js/,
|
||||||
|
getMain: function(req) {
|
||||||
|
var main;
|
||||||
|
var query = url.parse(req.url, true).query;
|
||||||
|
if (query.id) {
|
||||||
|
var referer = req.headers.referer;
|
||||||
|
if (referer) {
|
||||||
|
var from = path.join(process.cwd(),
|
||||||
|
path.dirname(url.parse(referer).pathname));
|
||||||
|
main = path.resolve(from, query.id + '.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return main;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
server.listen(3000, function() {
|
||||||
|
log.info('ol', 'Listening on http://localhost:3000/ (Ctrl+C to stop)');
|
||||||
|
});
|
||||||
|
});
|
||||||
58
test/index.html
Normal file
58
test/index.html
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OL Spec Runner</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="mocha-1.8.1/mocha.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="mocha"></div>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="jquery-1.9.1/jquery.min.js"></script>
|
||||||
|
<!-- Extended expect.js w/ various methods, see #374 for the differences to 0.2.0 -->
|
||||||
|
<script type="text/javascript" src="expect-0.2.0-ol3/expect.js"></script>
|
||||||
|
<script type="text/javascript" src="sinon-1.6.0/sinon.js"></script>
|
||||||
|
<script type="text/javascript" src="mocha-1.8.1/mocha.js"></script>
|
||||||
|
<script type="text/javascript" src="test-extensions.js"></script>
|
||||||
|
<script>
|
||||||
|
mocha.setup({
|
||||||
|
ui: 'bdd',
|
||||||
|
bail: false
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="../build/proj4js/lib/proj4js-combined.js"></script>
|
||||||
|
|
||||||
|
<!-- This script is provided by the debug server (start with `npm start`) -->
|
||||||
|
<script type="text/javascript" src="loader.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The goog.dom.ViewportSizeMonitor (used in map.js) creates a global leak
|
||||||
|
* by setting goog.UID_PROPERTY_ on the monitored window. In order to test
|
||||||
|
* that we don't have other global leaks, we preemptively set the property
|
||||||
|
* so Mocha can compare the global before and after our tests.
|
||||||
|
*
|
||||||
|
* In addition, calling goog.events.listen on the global object (as done
|
||||||
|
* in deviceorientation.js) creates a second leak by setting
|
||||||
|
* goog.events.LISTENER_MAP_PROP_ on the global object.
|
||||||
|
*
|
||||||
|
* We preemptively set both of these properties so Mocha can compare the
|
||||||
|
* global before and after tests. The call to goog.events.listen also
|
||||||
|
* calls goog.getUid.
|
||||||
|
*/
|
||||||
|
goog.events.listen(this, 'test', function() {});
|
||||||
|
|
||||||
|
if (window.mochaPhantomJS) {
|
||||||
|
mochaPhantomJS.run();
|
||||||
|
} else {
|
||||||
|
mocha.run();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<!--
|
||||||
|
Tests should not depend on any specific markup and should instead create
|
||||||
|
whatever elements are needed (cleaning up when done).
|
||||||
|
-->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -134,24 +134,24 @@ describe('ol.parser.KML', function() {
|
|||||||
var p = new ol.parser.KML({extractStyles: true,
|
var p = new ol.parser.KML({extractStyles: true,
|
||||||
trackAttributes: ['speed', 'num']});
|
trackAttributes: ['speed', 'num']});
|
||||||
var obj = p.read(xml);
|
var obj = p.read(xml);
|
||||||
expect(obj.features.length).to.eql(170);
|
expect(obj.features.length).to.be(170);
|
||||||
var attr = obj.features[4].getAttributes();
|
var attr = obj.features[4].getAttributes();
|
||||||
// standard track point attributes
|
// standard track point attributes
|
||||||
expect(attr['when'] instanceof Date).to.be.ok();
|
expect(attr.when).to.be.a(Date);
|
||||||
expect(attr['when'].getTime()).to.eql(1272736815000);
|
expect(attr.when.getTime()).to.be(1272736815000);
|
||||||
expect(attr['altitude']).to.eql(1006);
|
expect(attr.altitude).to.be(1006);
|
||||||
expect(attr['heading']).to.eql(230);
|
expect(attr.heading).to.be(230);
|
||||||
expect(attr['tilt']).to.eql(0);
|
expect(attr.tilt).to.be(0);
|
||||||
expect(attr['roll']).to.eql(0);
|
expect(attr.roll).to.be(0);
|
||||||
expect(attr['name']).to.eql('B752');
|
expect(attr.name).to.be('B752');
|
||||||
expect(attr['adflag']).to.eql('A');
|
expect(attr.adflag).to.be('A');
|
||||||
expect(attr['flightid']).to.eql('DAL2973');
|
expect(attr.flightid).to.be('DAL2973');
|
||||||
expect(attr['speed']).to.eql('166');
|
expect(attr.speed).to.be('166');
|
||||||
expect(attr['num']).to.eql('50');
|
expect(attr.num).to.be('50');
|
||||||
var geom = obj.features[4].getGeometry();
|
var geom = obj.features[4].getGeometry();
|
||||||
expect(geom.get(0)).to.eql(-93.0753620391713);
|
expect(geom.get(0)).to.be(-93.0753620391713);
|
||||||
expect(geom.get(1)).to.eql(44.9879724110872);
|
expect(geom.get(1)).to.be(44.9879724110872);
|
||||||
expect(geom.get(2)).to.eql(1006);
|
expect(geom.get(2)).to.be(1006);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ goog.provide('ol.test.proj.EPSG3857');
|
|||||||
|
|
||||||
describe('ol.proj.EPSG3857', function() {
|
describe('ol.proj.EPSG3857', function() {
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
ol.proj.common.add();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
ol.proj.clearAllProjections();
|
||||||
|
});
|
||||||
|
|
||||||
describe('getPointResolution', function() {
|
describe('getPointResolution', function() {
|
||||||
|
|
||||||
it('returns the correct point scale at the equator', function() {
|
it('returns the correct point scale at the equator', function() {
|
||||||
@@ -44,4 +52,5 @@ describe('ol.proj.EPSG3857', function() {
|
|||||||
|
|
||||||
|
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.proj.common');
|
||||||
goog.require('ol.proj.EPSG3857');
|
goog.require('ol.proj.EPSG3857');
|
||||||
|
|||||||
@@ -3,24 +3,11 @@ goog.provide('ol.test.proj');
|
|||||||
describe('ol.proj', function() {
|
describe('ol.proj', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.spy(ol.proj, 'addTransform');
|
ol.proj.common.add();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
var argsForCall = ol.proj.addTransform.args;
|
ol.proj.clearAllProjections();
|
||||||
for (var i = 0, ii = argsForCall.length; i < ii; ++i) {
|
|
||||||
try {
|
|
||||||
ol.proj.removeTransform.apply(ol.proj, argsForCall[i].splice(0, 2));
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof goog.asserts.AssertionError) {
|
|
||||||
// The removeTransform function may have been called explicitly by the
|
|
||||||
// tests, so we pass.
|
|
||||||
} else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ol.proj.addTransform.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('projection equivalence', function() {
|
describe('projection equivalence', function() {
|
||||||
@@ -364,7 +351,7 @@ describe('ol.proj', function() {
|
|||||||
|
|
||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts.AssertionError');
|
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.ProjectionUnits');
|
goog.require('ol.ProjectionUnits');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.proj.common');
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ describe('ol.renderer.webgl.ImageLayer', function() {
|
|||||||
var imageExtent;
|
var imageExtent;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
ol.proj.common.add();
|
||||||
|
|
||||||
map = new ol.Map({
|
map = new ol.Map({
|
||||||
target: document.createElement('div')
|
target: document.createElement('div')
|
||||||
});
|
});
|
||||||
@@ -80,6 +82,7 @@ goog.require('goog.dispose');
|
|||||||
goog.require('goog.vec.Mat4');
|
goog.require('goog.vec.Mat4');
|
||||||
goog.require('goog.vec.Vec4');
|
goog.require('goog.vec.Vec4');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.proj.common');
|
||||||
goog.require('ol.layer.Image');
|
goog.require('ol.layer.Image');
|
||||||
goog.require('ol.source.Image');
|
goog.require('ol.source.Image');
|
||||||
goog.require('ol.renderer.webgl.ImageLayer');
|
goog.require('ol.renderer.webgl.ImageLayer');
|
||||||
|
|||||||
Reference in New Issue
Block a user