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

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