Remove ol namespace

This commit is contained in:
Tom Payne
2012-09-24 14:07:11 +02:00
parent 6e427a49ab
commit 6737220b83
8 changed files with 6 additions and 273 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
/bin/plovr*.jar
/build/ol.js
/build/ol3.js
/build/ol3-compiled.js
/build/webgl-debug.js

View File

@@ -1,5 +1,4 @@
PLOVR_JAR=bin/plovr-4b3caf2b7d84.jar
SRC_OL = $(shell find src/ol -name \*.js)
SRC_OL3 = $(shell find externs src/ol3 -name \*.js)
TARGETS = $(shell find demos -name advanced-optimizations.js -o -name simple-optimizations.js)
comma := ,
@@ -10,13 +9,7 @@ space := $(empty) $(empty)
all: build demos
.PHONY: build
build: build/ol.js build/ol3-compiled.js build/webgl-debug.js
build/ol.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
build/ol.json src/ol/ol.js
java -jar $(PLOVR_JAR) build build/ol.json >$@
@echo $@ "uncompressed:" $$(wc -c <$@) bytes
@echo $@ " compressed:" $$(gzip -9 -c <$@ | wc -c) bytes
build: build/ol3-compiled.js build/webgl-debug.js
build/ol3-compiled.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
build/ol3.json build/ol3.js
@@ -28,31 +21,18 @@ build/ol3.js: $(SRC_OL3)
( echo "goog.require('goog.dom');" ; find src/ol3 -name \*.js | xargs grep -rh ^goog.provide | sort | uniq | sed -e 's/provide/require/g' ) > $@
.PHONY: demos
demos: demos/api1 demos/proj4js demos/side-by-side demos/two-layers
.PHONY: demos/api1
demos/api1: \
build/ol.js \
demos/api1/build.html \
demos/api1/debug.html
demos/api1/build.html: demos/api1/index.html.in
sed -e 's|@SRC@|../../build/ol.js|' $< > $@
demos/api1/debug.html: demos/api1/index.html.in
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol|' $< > $@
demos: demos/proj4js demos/side-by-side demos/two-layers
.PHONY: demos/proj4js
demos/proj4js: \
build/ol.js \
demos/proj4js/build.html \
demos/proj4js/debug.html
demos/proj4js/build.html: demos/proj4js/index.html.in
sed -e 's|@SRC@|../../build/ol.js|' $< > $@
sed -e 's|@SRC@|../../build/ol3.js|' $< > $@
demos/proj4js/debug.html: demos/proj4js/index.html.in
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol|' $< > $@
sed -e 's|@SRC@|http://localhost:9810/compile?id=ol3|' $< > $@
.PHONY: demos/side-by-side
demos/side-by-side: \
@@ -116,11 +96,11 @@ demos/two-layers/simple-optimizations.js: $(PLOVR_JAR) $(SRC_OL3) base.json \
.PHONY: serve
serve: $(PLOVR_JAR)
java -jar $(PLOVR_JAR) serve build/ol.json build/ol3.json demos/*/*.json
java -jar $(PLOVR_JAR) serve build/ol3.json demos/*/*.json
.PHONY: lint
lint:
gjslint --strict --limited_doc_files=$(subst $(space),$(comma),$(shell find externs -name \*.js)) $(SRC_OL3) $(SRC_OL) $(filter-out $(TARGETS),$(shell find demos -name \*.js))
gjslint --strict --limited_doc_files=$(subst $(space),$(comma),$(shell find externs -name \*.js)) $(SRC_OL3) $(filter-out $(TARGETS),$(shell find demos -name \*.js))
build/webgl-debug.js:
curl https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/debug/webgl-debug.js > $@
@@ -130,7 +110,6 @@ $(PLOVR_JAR):
clean:
rm -f build/all.js
rm -f build/ol.js
rm -f build/ol3.js
rm -f build/ol3-compiled.js
rm -f demos/*/*.html

View File

@@ -1,11 +0,0 @@
{
"id": "ol",
"inherits": "../base.json",
"inputs": "src/ol/ol.js",
"output-wrapper": "(function(){%output%})();"
}

View File

@@ -1,6 +0,0 @@
var map = ol.map({
renderTo: 'map',
layers: [ol.layer.osm()],
center: [45, 5],
zoom: 10
});

View File

@@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<style type="text/css">
.map {
width: 400px;
height: 400px;
border: thin solid;
}
</style>
<script src="@SRC@" type="text/javascript"></script>
<title>ol3 api1 demo</title>
</head>
<body>
<h1>ol3 api1 demo</h1>
<div class="map" id="map"></div>
<script src="api1.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -1,22 +0,0 @@
goog.require('goog.testing.jsunit');
goog.require('ol');
goog.require('ol3.Collection');
function testCreateFromArray() {
var array = [0, 1, 2];
var collection = ol.collection(array);
assertTrue(collection instanceof ol3.Collection);
assertEquals(3, collection.getLength());
assertEquals(0, collection.getAt(0));
assertEquals(1, collection.getAt(1));
assertEquals(2, collection.getAt(2));
}
function testCreateFromCollection() {
var collection1 = new ol3.Collection();
var collection2 = ol.collection(collection1);
assertTrue(collection1 === collection2);
}

View File

@@ -1,19 +0,0 @@
goog.require('goog.testing.jsunit');
goog.require('ol');
goog.require('ol3.Object');
function testObject1() {
var obj = {k: 1};
obj = ol.object(obj);
assertTrue(obj instanceof ol3.Object);
assertEquals(1, obj.get('k'));
}
function testObject2() {
var obj1 = new ol3.Object();
var obj2 = ol.object(obj1);
assertTrue(obj2 === obj1);
}

View File

@@ -1,168 +0,0 @@
goog.provide('ol');
goog.provide('ol.layer');
goog.require('goog.dom');
goog.require('ol3.Collection');
goog.require('ol3.Coordinate');
goog.require('ol3.Layer');
goog.require('ol3.Map');
goog.require('ol3.Object');
goog.require('ol3.Projection');
goog.require('ol3.createMap');
goog.require('ol3.layer.OpenStreetMap');
goog.exportSymbol('ol', ol);
/**
* @typedef {Array|ol3.Collection}
*/
ol.Collection;
/**
* @typedef {Array.<number>|ol3.Coordinate|{x: number, y: number}}
*/
ol.Coordinate;
/**
* @typedef {{center: (ol.Coordinate|undefined),
* layers: (ol.Collection|undefined),
* renderTo: (Element|string|undefined),
* resolution: (number|undefined),
* zoom: (number|undefined)}}
*/
ol.MapOptions;
/**
* @typedef {Object|ol3.Object}
*/
ol.Object;
/**
* @typedef {ol3.Projection|string}
*/
ol.Projection;
/**
* @param {ol.Collection} collection Collection.
* @return {ol3.Collection} Collection.
*/
ol.collection = function(collection) {
if (collection instanceof ol3.Collection) {
return collection;
} else if (goog.isArray(collection)) {
var array = /** @type {Array} */ collection;
return new ol3.Collection(collection);
} else {
return null;
}
};
goog.exportProperty(ol, 'collection', ol.collection);
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @return {ol3.Coordinate} Coordinate.
*/
ol.coordinate = function(coordinate) {
if (coordinate instanceof ol3.Coordinate) {
return coordinate;
} else if (goog.isArray(coordinate)) {
var array = /** @type {Array.<number>} */ coordinate;
return new ol3.Coordinate(array[1], array[0]);
} else if (goog.isObject(coordinate)) {
var object = /** @type {{x: number, y: number}} */ coordinate;
return new ol3.Coordinate(object.x, object.y);
} else {
return null;
}
};
goog.exportProperty(ol, 'coordinate', ol.coordinate);
goog.exportProperty(ol, 'layer', ol.layer);
/**
* @return {ol3.Layer} Layer.
*/
ol.layer.osm = function() {
return new ol3.layer.OpenStreetMap();
};
goog.exportProperty(ol.layer, 'osm', ol.layer.osm);
/**
* @param {ol.MapOptions=} opt_mapOptions Options.
* @return {ol3.Map} Map.
*/
ol.map = function(opt_mapOptions) {
var options = opt_mapOptions || {};
var center = ol.coordinate(/** @type {ol.Coordinate} */
(goog.object.get(options, 'center', null)));
var layers = ol.collection(/** @type {ol.Collection} */
(goog.object.get(options, 'layers', null)));
var projection = ol.projection(/** @type {ol.Projection} */
(goog.object.get(options, 'projection', 'EPSG:3857')));
var resolution = /** @type {number|undefined} */
goog.object.get(options, 'resolution');
if (!goog.isDef(resolution) && goog.object.containsKey(options, 'zoom')) {
var zoom = /** @type {number} */ goog.object.get(options, 'zoom');
resolution = ol3.Projection.EPSG_3857_HALF_SIZE / (128 << zoom);
}
var target = goog.dom.getElement(/** @type {Element|string} */
(goog.object.get(options, 'renderTo', 'map')));
var userProjection = ol.projection(/** @type {ol.Projection} */
(goog.object.get(options, 'userProjection', 'EPSG:4326')));
var map = ol3.createMap(target, {
'layers': layers,
'projection': projection,
'resolution': resolution,
'userProjection': userProjection
});
if (!goog.isNull(center)) {
map.setUserCenter(center);
}
return map;
};
goog.exportProperty(ol, 'map', ol.map);
/**
* @param {ol.Object} object Object.
* @return {ol3.Object} Object.
*/
ol.object = function(object) {
if (object instanceof ol3.Object) {
return object;
} else if (goog.isObject(object)) {
var values = /** @type {Object} */ object;
return new ol3.Object(values);
} else {
return null;
}
};
goog.exportProperty(ol, 'object', ol.object);
/**
* @param {ol.Projection} projection Projection.
* @return {ol3.Projection} Projection.
*/
ol.projection = function(projection) {
if (projection instanceof ol3.Projection) {
return projection;
} else if (goog.isString(projection)) {
var code = /** @type {string} */ projection;
return ol3.Projection.getFromCode(code);
} else {
return null;
}
};
goog.exportProperty(ol, 'projection', ol.projection);