Move to-be-merged code into attic

This commit is contained in:
Tom Payne
2012-08-07 12:11:25 +02:00
parent 1f5cda88c4
commit 9366ced2a8
36 changed files with 0 additions and 0 deletions

149
attic/src/api/bounds.js Normal file
View File

@@ -0,0 +1,149 @@
goog.provide('ol.bounds');
goog.require('ol.Bounds');
goog.require('ol.projection');
/**
* @typedef {ol.Bounds|Array.<number>|Object} bounds Location.
*/
ol.LocLike;
/**
* @export
* @param {ol.LocLike} opt_arg Location.
* @return {ol.Bounds} Location.
*/
ol.bounds = function(opt_arg){
if (opt_arg instanceof ol.Bounds) {
return opt_arg;
}
var minX = 0;
var minY = 0;
var maxX = 0;
var maxY = 0;
var projection;
var x = 0;
var y = 0;
var z;
if (goog.isArray(opt_arg)) {
minX = opt_arg[0];
minY = opt_arg[1];
maxX = opt_arg[2];
maxY = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['minX', 'minY', 'maxX', 'maxY', 'projection']);
minX = ol.API ? opt_arg['minX'] : opt_arg.minX;
minY = ol.API ? opt_arg['minY'] : opt_arg.minY;
maxX = ol.API ? opt_arg['maxX'] : opt_arg.maxX;
maxY = ol.API ? opt_arg['maxY'] : opt_arg.maxY;
projection = ol.projection(ol.API ? opt_arg['projection'] : opt_arg.projection);
}
else {
throw new Error('ol.bounds');
}
var bounds = new ol.Bounds(minX, minY, maxX, maxY, projection);
return bounds;
};
/**
* @export
* @param {ol.Projection=} opt_arg Projection.
* @return {ol.Bounds|ol.Projection|undefined} Result.
*/
ol.Bounds.prototype.projection = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setProjection(opt_arg);
return this;
}
else {
return this.getProjection();
}
};
/**
* @export
* @param {number=} opt_arg Minimum X.
* @return {!ol.Bounds|number} Result.
*/
ol.Bounds.prototype.minX = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setMinX(opt_arg);
return this;
}
else {
return this.getMinX();
}
};
/**
* @export
* @param {number=} opt_arg Minimum Y.
* @return {ol.Bounds|number} Result.
*/
ol.Bounds.prototype.minY = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setMinY(opt_arg);
return this;
}
else {
return this.getMinY();
}
};
/**
* @export
* @param {number=} opt_arg Maximum X.
* @return {ol.Bounds|number} Result.
*/
ol.Bounds.prototype.maxX = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setMaxX(opt_arg);
return this;
}
else {
return this.getMaxX();
}
};
/**
* @export
* @param {number=} opt_arg Maximum Y.
* @return {ol.Bounds|number} Result.
*/
ol.Bounds.prototype.maxY = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setMaxY(opt_arg);
return this;
}
else {
return this.getMaxY();
}
};
/**
* Transform this node into another coordinate reference system. Returns a new
* bounds instead of modifying this bounds.
*
* @param {ol.Projection|string} proj Target projection (or string identifier).
* @return {ol.Bounds} A new bounds in the target projection.
*/
ol.Bounds.prototype.transform = function(proj) {
if (goog.isString(proj)) {
proj = new ol.Projection(proj);
}
return this.doTransform(proj);
};

92
attic/src/api/feature.js Normal file
View File

@@ -0,0 +1,92 @@
goog.provide('ol.feature');
goog.require('ol.base');
goog.require('ol.Feature');
goog.require('ol.geom.Geometry');
/**
* @typedef {ol.Feature|Object|string}
*/
ol.FeatureLike;
/**
* @export
* @param {ol.FeatureLike=} opt_arg Argument.
* @return {ol.Feature} Feature.
*/
ol.feature = function(opt_arg){
/** @type {Object|undefined} */
var properties;
/** @type {ol.geom.Geometry|undefined} */
var geometry;
/** @type {string|undefined} */
var type;
if (arguments.length == 1) {
if (opt_arg instanceof ol.Feature) {
return opt_arg;
}
else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['geometry', 'properties', 'type']);
properties = ol.API ? opt_arg['properties'] : opt_arg.properties;
geometry = ol.API ? opt_arg['geometry'] : opt_arg.geometry;
type = ol.API ? opt_arg['type'] : opt_arg.type;
}
else {
throw new Error('ol.feature');
}
}
var feature = new ol.Feature();
if (goog.isDef(type) && type == 'Feature') {
//this means it is a GeoJSON object
//format.read(opt_arg);
} else {
if (goog.isDef(properties)) {
feature.setAttributes(properties);
}
if (goog.isDef(geometry)) {
feature.setGeometry(geometry);
}
}
return feature;
};
/**
* @export
* @param {!string} attr The name of the attribute to be set.
* @param {string|number|boolean} value The value of the attribute to be set.
* @returns {ol.Feature} The feature so calls can be chained
*/
ol.Feature.prototype.set = function(attr, value) {
this.setAttribute(attr, value);
return this;
};
/**
* @export
* @param {!string} attr The name of the attribute to be set.
* @returns {string|number|boolean|undefined} The attribute value requested.
*/
ol.Feature.prototype.get = function(attr) {
return this.getAttribute(attr);
};
/**
* @export
* @param {ol.geom.Geometry=} opt_arg
* @returns {ol.Feature|ol.geom.Geometry|undefined} get or set the geometry on a feature
*/
ol.Feature.prototype.geometry = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setGeometry(opt_arg);
return this;
} else {
return this.getGeometry();
}
};

View File

@@ -0,0 +1,133 @@
goog.provide('ol.geom.collection');
goog.require('ol.geom.Collection');
goog.require('ol.geom.point');
goog.require('ol.projection');
/**
* @export
* @param {Array.<ol.geom.Geometry>} opt_arg Components.
* @return {ol.geom.Collection} Collection.
*/
ol.geom.collection = function(opt_arg){
if (opt_arg instanceof ol.geom.Collection) {
return opt_arg;
}
var components = [];
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
var allValid = goog.array.every(opt_arg, function(geom){
if (geom instanceof ol.geom.Geometry) {
components.push(geom);
return true;
} else {
return false;
}
});
if (!allValid) {
var msg = 'ol.geom.collection: at least one component '
+ 'definition was no geometry.';
throw new Error(msg);
}
} else {
throw new Error('ol.geom.collection');
}
}
var c = new ol.geom.Collection(components);
return c;
};
goog.inherits(ol.geom.collection, ol.geom.geometry);
/**
* @export
* @param {Array.<ol.geom.Geometry>=} opt_arg An array of point specifications.
* @return {Array.<ol.geom.Geometry>|ol.geom.Collection|undefined} Result.
*/
ol.geom.Collection.prototype.components = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
var components = [],
allValid = false;
allValid = goog.array.every(opt_arg, function(geom){
if (geom instanceof ol.geom.Geometry) {
components.push(geom);
return true;
} else {
return false;
}
});
if (!allValid) {
components = [];
}
this.setComponents(components);
return this;
}
else {
return this.getComponents();
}
};
/**
* @export
* @param {ol.geom.Geometry} geom A geometry.
* @param {number=} opt_index An optional index to add the point(s) at. If not
* provided, the point(s) will be added to the end of the list of components.
* @return {ol.geom.Collection} The Collection instance.
*/
ol.geom.Collection.prototype.add = function(geom, opt_index){
var index = this.components_.length;
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
this.addComponent(geom, index);
return this;
};
/**
* @export
* @param {Array.<ol.geom.Geometry>} components Some point specifications.
* @param {number=} opt_index An optional index to add the components at. If not
* provided, the components will be added to the end of the list of
* components.
* @return {ol.geom.Collection} The Collection instance.
*/
ol.geom.Collection.prototype.addAll = function(components, opt_index){
var index = this.components_.length;
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
goog.array.every(components, function(c){
this.addComponent(c, index);
index++;
return true;
}, this);
return this;
};
/**
* @export
* @param {(ol.geom.Geometry|Array.<ol.geom.Geometry>)} components A point specification or
* an array of point specifications.
* @return {ol.geom.Collection} The Collection instance.
*/
ol.geom.Collection.prototype.remove = function(components){
var compArr = [];
if (!goog.isArray(components)) {
compArr.push(components);
} else {
compArr = components;
}
goog.array.every(compArr, function(c){
this.removeComponent(c);
return true;
}, this);
return this;
};

View File

@@ -0,0 +1,35 @@
goog.provide('ol.geom.geometry');
goog.require('ol.geom.Geometry');
/**
* @export
* @return {ol.geom.Geometry} Geometry..
*/
ol.geom.geometry = function(){
var g = new ol.geom.Geometry();
return g;
};
/**
* @export
* @param {ol.Bounds=} opt_arg new Bounds.
* @return {ol.geom.Geometry|ol.Bounds|undefined} either a Geometry (when used as
* setter) or a Bounds/undefined (if used as getter).
*/
ol.geom.Geometry.prototype.bounds = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setBounds(opt_arg);
} else {
return this.getBounds();
}
};
/**
* Returns the centroid of the geometry.
*
* @returns {ol.geom.Point} The centroid of the geometry.
*/
ol.geom.Geometry.prototype.centroid = function() {
return this.getCentroid();
};

View File

@@ -0,0 +1,142 @@
goog.provide('ol.geom.linestring');
goog.require('ol.geom.LineString');
goog.require('ol.geom.point');
goog.require('ol.projection');
/**
* @typedef {Array.<ol.PointLike>} linestring LineString.
*/
ol.LineStringLike;
/**
* @export
* @param {ol.LineStringLike} opt_arg Points.
* @return {ol.geom.LineString} LineString.
*/
ol.geom.linestring = function(opt_arg){
if (opt_arg instanceof ol.geom.LineString) {
return opt_arg;
}
var vertices = [];
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
var allValid = goog.array.every(opt_arg, function(spec){
var v = ol.geom.point(spec);
if (v instanceof ol.geom.Point) {
vertices.push(v);
return true;
} else {
return false;
}
});
if (!allValid) {
var msg = 'ol.geom.linestring: at least one point '
+ 'definition was erroneous.';
throw new Error(msg);
}
} else {
throw new Error('ol.geom.linestring');
}
}
var ls = new ol.geom.LineString(vertices);
return ls;
};
goog.inherits(ol.geom.linestring, ol.geom.geometry);
/**
* @export
* @param {Array.<ol.PointLike>=} opt_arg An array of vertex specifications.
* @return {Array.<ol.geom.Point>|ol.geom.LineString|undefined} Result.
*/
ol.geom.LineString.prototype.vertices = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
var vertices = [],
allValid = false;
goog.array.every(opt_arg, function(spec){
var v = ol.geom.point(spec);
if (v instanceof ol.geom.Point) {
vertices.push(v);
return true;
} else {
return false;
}
});
if (!allValid) {
vertices = [];
}
this.setVertices(vertices);
return this;
}
else {
return this.getVertices();
}
};
/**
* @export
* @param {ol.PointLike} vertex A point specification.
* @param {number=} opt_index An optional index to add the vertices at. If not
* provided, the vertex will be added to the end of the list of vertices.
* @return {ol.geom.LineString} The LineString instance.
*/
ol.geom.LineString.prototype.add = function(vertex, opt_index){
var index = this.vertices_.length,
allValid = false,
v = ol.geom.point(vertex);
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
this.addVertex(v, index);
return this;
};
/**
* @export
* @param {Array.<ol.PointLike>} vertices Some vertex specifications.
* @param {number=} opt_index An optional index to add the vertices at. If not
* provided, the points will be added to the end of the list of vertices.
* @return {ol.geom.LineString} The LineString instance.
*/
ol.geom.LineString.prototype.addAll = function(vertices, opt_index){
var index = this.vertices_.length,
v;
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
goog.array.every(vertices, function(vertexSpec){
v = ol.geom.point(vertexSpec);
this.addVertex(v, index);
index++;
return true;
}, this);
return this;
};
/**
* @export
* @param {(ol.geom.Point|Array.<ol.geom.Point>)} vertices A point specification or
* an array of point specifications.
* @return {ol.geom.LineString} The MultiPoint instance.
*/
ol.geom.LineString.prototype.remove = function(vertices){
var vertexArr = [];
if (!goog.isArray(vertices)) {
vertexArr.push(vertices);
} else {
vertexArr = vertices;
}
goog.array.every(vertexArr, function(v){
this.removeVertex(v);
return true;
}, this);
return this;
};

View File

@@ -0,0 +1,138 @@
goog.provide('ol.geom.multilinestring');
goog.require('ol.geom.MultiLineString');
goog.require('ol.geom.point');
goog.require('ol.geom.collection');
goog.require('ol.projection');
/**
* @export
* @param {Array.<ol.LineStringLike>} opt_arg Point.
* @return {ol.geom.MultiLineString} MultiLineString.
*/
ol.geom.multilinestring = function(opt_arg){
if (opt_arg instanceof ol.geom.MultiLineString) {
return opt_arg;
}
var ls = [];
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
var allValid = goog.array.every(opt_arg, function(spec){
var l = ol.geom.linestring(spec);
if (l instanceof ol.geom.LineString) {
ls.push(l);
return true;
} else {
return false;
}
});
if (!allValid) {
var msg = 'ol.geom.linestring: at least one linestring '
+ 'definition was erroneous.';
throw new Error(msg);
}
} else {
throw new Error('ol.geom.multilinestring');
}
}
var mls = new ol.geom.MultiLineString(ls);
return mls;
};
goog.inherits(ol.geom.multilinestring, ol.geom.collection);
/**
* @export
* @param {Array.<ol.LineStringLike>=} opt_arg An array of point specifications.
* @return {Array.<ol.geom.LineString>|ol.geom.MultiLineString|undefined} Result.
*/
ol.geom.MultiLineString.prototype.linestrings = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
var ls = [],
allValid = false;
allValid = goog.array.every(opt_arg, function(spec){
var l = ol.geom.linestring(spec);
if (l instanceof ol.geom.LineString) {
ls.push(l);
return true;
} else {
return false;
}
});
if (!allValid) {
ls = [];
}
this.setComponents(ls);
return this;
}
else {
return this.getComponents();
}
};
/**
* @export
* @param {ol.LineStringLike} line A linestring specification.
* @param {number=} opt_index An optional index to add the point(s) at. If not
* provided, the point(s) will be added to the end of the list of points.
* @return {ol.geom.MultiLineString} The MultiPoint instance.
*/
ol.geom.MultiLineString.prototype.add = function(line, opt_index){
var index = this.getLineStrings().length,
l = ol.geom.linestring(line);
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
this.addLineString(l, index);
return this;
};
/**
* @export
* @param {Array.<ol.LineStringLike>} lines Some linestring specifications.
* @param {number=} opt_index An optional index to add the points at. If not
* provided, the linestrings will be added to the end of the list of
* linestrings.
* @return {ol.geom.MultiLineString} The MultiLineString instance.
*/
ol.geom.MultiLineString.prototype.addAll = function(lines, opt_index){
var index = this.getLineStrings().length,
l;
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
goog.array.every(lines, function(pointSpec){
l = ol.geom.linestring(pointSpec);
this.addLineString(l, index);
index++;
return true;
}, this);
return this;
};
/**
* @export
* @param {(ol.geom.LineString|Array.<ol.geom.LineString>)} lines A linestring
* specification or an array of linestring specifications.
* @return {ol.geom.MultiLineString} The MultiLineString instance.
*/
ol.geom.MultiLineString.prototype.remove = function(lines){
var lineArr = [];
if (!goog.isArray(lines)) {
lineArr.push(lines);
} else {
lineArr = lines;
}
goog.array.every(lineArr, function(l){
this.removeLineString(l);
return true;
}, this);
return this;
};

View File

@@ -0,0 +1,137 @@
goog.provide('ol.geom.multipoint');
goog.require('ol.geom.MultiPoint');
goog.require('ol.geom.point');
goog.require('ol.geom.collection');
goog.require('ol.projection');
/**
* @export
* @param {Array.<ol.PointLike>} opt_arg Point.
* @return {ol.geom.MultiPoint} MultiPoint.
*/
ol.geom.multipoint = function(opt_arg){
if (opt_arg instanceof ol.geom.MultiPoint) {
return opt_arg;
}
var points = [];
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
var allValid = goog.array.every(opt_arg, function(spec){
var p = ol.geom.point(spec);
if (p instanceof ol.geom.Point) {
points.push(p);
return true;
} else {
return false;
}
});
if (!allValid) {
var msg = 'ol.geom.multipoint: at least one point '
+ 'definition was erroneous.';
throw new Error(msg);
}
} else {
throw new Error('ol.geom.multipoint');
}
}
var mp = new ol.geom.MultiPoint(points);
return mp;
};
goog.inherits(ol.geom.multipoint, ol.geom.collection);
/**
* @export
* @param {Array.<ol.PointLike>=} opt_arg An array of point specifications.
* @return {Array.<ol.geom.Point>|ol.geom.MultiPoint|undefined} Result.
*/
ol.geom.MultiPoint.prototype.points = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
var points = [],
allValid = false;
allValid = goog.array.every(opt_arg, function(spec){
var p = ol.geom.point(spec);
if (p instanceof ol.geom.Point) {
points.push(p);
return true;
} else {
return false;
}
});
if (!allValid) {
points = [];
}
this.setComponents(points);
return this;
}
else {
return this.getComponents();
}
};
/**
* @export
* @param {ol.PointLike} point A point specification.
* @param {number=} opt_index An optional index to add the point(s) at. If not
* provided, the point(s) will be added to the end of the list of points.
* @return {ol.geom.MultiPoint} The MultiPoint instance.
*/
ol.geom.MultiPoint.prototype.add = function(point, opt_index){
var index = this.getPoints().length,
p = ol.geom.point(point);
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
this.addPoint(p, index);
return this;
};
/**
* @export
* @param {Array.<ol.PointLike>} points Some point specifications.
* @param {number=} opt_index An optional index to add the points at. If not
* provided, the points will be added to the end of the list of points.
* @return {ol.geom.MultiPoint} The MultiPoint instance.
*/
ol.geom.MultiPoint.prototype.addAll = function(points, opt_index){
var index = this.getPoints().length,
p;
if (arguments.length == 2 && goog.isDef(opt_index)) {
index = opt_index;
}
goog.array.every(points, function(pointSpec){
p = ol.geom.point(pointSpec);
this.addPoint(p, index);
index++;
return true;
}, this);
return this;
};
/**
* @export
* @param {(ol.geom.Point|Array.<ol.geom.Point>)} points A point specification or
* an array of point specifications.
* @return {ol.geom.MultiPoint} The MultiPoint instance.
*/
ol.geom.MultiPoint.prototype.remove = function(points){
var pointArr = [];
if (!goog.isArray(points)) {
pointArr.push(points);
} else {
pointArr = points;
}
goog.array.every(pointArr, function(p){
this.removePoint(p);
return true;
}, this);
return this;
};

122
attic/src/api/geom/point.js Normal file
View File

@@ -0,0 +1,122 @@
goog.provide('ol.geom.point');
goog.require('ol.geom.Point');
goog.require('ol.projection');
/**
* @typedef {Array.<number>|Object} point Point.
*/
ol.PointLike;
/**
* @export
* @param {ol.PointLike} opt_arg Point.
* @return {ol.geom.Point} Point.
*/
ol.geom.point = function(opt_arg){
if (opt_arg instanceof ol.geom.Point) {
return opt_arg;
}
var x = 0;
var y = 0;
var z;
var projection;
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
x = opt_arg[0];
y = opt_arg[1];
z = opt_arg[2];
projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
x = ol.API ? opt_arg['x'] : opt_arg.x;
y = ol.API ? opt_arg['y'] : opt_arg.y;
z = ol.API ? opt_arg['z'] : opt_arg.z;
projection = ol.API ? opt_arg['projection'] : opt_arg.projection;
} else {
throw new Error('ol.geom.point');
}
}
if (goog.isDef(projection)) {
projection = ol.projection(projection);
}
var p = new ol.geom.Point(x,y,z,projection);
return p;
};
goog.inherits(ol.geom.point, ol.geom.geometry);
/**
* @export
* @param {number=} opt_arg X.
* @return {ol.geom.Point|number} Result.
*/
ol.geom.Point.prototype.x = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setX(opt_arg);
return this;
}
else {
return this.getX();
}
};
/**
* @export
* @param {number=} opt_arg Y.
* @return {ol.geom.Point|number} Result.
*/
ol.geom.Point.prototype.y = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setY(opt_arg);
return this;
}
else {
return this.getY();
}
};
/**
* @export
* @param {number=} opt_arg Z.
* @return {ol.geom.Point|number|undefined} Result.
*/
ol.geom.Point.prototype.z = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setZ(opt_arg);
return this;
}
else {
return this.getZ();
}
};
/**
* @export
* @param {ol.Projection=} opt_arg Projection.
* @return {ol.geom.Point|ol.Projection|undefined} Result.
*/
ol.geom.Point.prototype.projection = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setProjection(ol.projection(opt_arg));
return this;
}
else {
return this.getProjection();
}
};
/**
* Returns the centroid of this point; which is a clone of the point itself.
*
* @return {ol.geom.Point} The centroid.
*/
ol.geom.Point.prototype.centroid = function() {
return this.getCentroid();
};

View File

@@ -0,0 +1,11 @@
goog.provide('ol.layer.osm');
goog.require('ol.layer.OSM');
/**
* @export
* @return {ol.layer.OSM}
*/
ol.layer.osm = function() {
return new ol.layer.OSM();
};

View File

@@ -0,0 +1,41 @@
goog.provide('ol.layer.wms');
goog.require('ol.layer.WMS');
/**
* @export
* @param {Object} opt_arg Config object.
* @return {ol.layer.WMS}
*/
ol.layer.wms = function(opt_arg) {
if (opt_arg instanceof ol.layer.WMS) {
return opt_arg;
}
/** @type {string} */
var url;
/** @type {Array.<string>} */
var layers;
/** @type {string} */
var format;
if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['url', 'layers', 'format']);
url = ol.API ? opt_arg['url'] : opt_arg.url;
layers = ol.API ? opt_arg['layers'] : opt_arg.layers;
format = ol.API ? opt_arg['format'] : opt_arg.format;
}
var msg;
if (!goog.isDef(url)) {
msg = 'Cannot create WMS layer; option "url" is missing';
ol.error(msg);
}
if (!goog.isArray(layers)) {
msg = 'Cannot create WMS layer; option "layers" is missing, ' +
'or is not an array';
ol.error(msg);
}
return new ol.layer.WMS(url, layers, format);
};

View File

@@ -0,0 +1,31 @@
goog.provide('ol.layer.xyz');
goog.require('ol.layer.XYZ');
/**
* @export
* @param {Object} opt_arg Config object.
* @return {ol.layer.XYZ}
*/
ol.layer.xyz = function(opt_arg) {
if (opt_arg instanceof ol.layer.XYZ) {
return opt_arg;
}
/** @type {string} */
var url;
var usage = 'ol.layer.xyz accepts an object with a "url" property';
if (goog.isObject(opt_arg)) {
url = ol.API ? opt_arg['url'] : opt_arg.url;
} else {
throw new Error(usage);
}
if (!goog.isDef(url)) {
throw new Error(usage);
}
return new ol.layer.XYZ(url);
};

146
attic/src/api/loc.js Normal file
View File

@@ -0,0 +1,146 @@
goog.provide('ol.loc');
goog.require('ol.Loc');
goog.require('ol.projection');
/**
* @typedef {ol.Loc|Array.<number>|Object} loc Location.
*/
ol.LocLike;
/**
* @export
* @param {ol.LocLike} opt_arg Location.
* @return {ol.Loc} Location.
*/
ol.loc = function(opt_arg){
if (opt_arg instanceof ol.Loc) {
return opt_arg;
}
/** @type {number|undefined} */
var x;
/** @type {number|undefined} */
var y;
/** @type {number|undefined} */
var z;
/** @type {Object|undefined} */
var projection;
var usage = 'ol.loc accepts a coordinate array or an object with x, y, and (optional) z properties';
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
x = opt_arg[0];
y = opt_arg[1];
z = opt_arg[2];
projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['projection', 'x', 'y', 'z']);
x = ol.API ? opt_arg['x'] : opt_arg.x;
y = ol.API ? opt_arg['y'] : opt_arg.y;
z = ol.API ? opt_arg['z'] : opt_arg.z;
projection = ol.API ? opt_arg['projection'] : opt_arg.projection;
} else {
throw new Error(usage);
}
}
if (!goog.isNumber(x) || !goog.isNumber(y)) {
throw new Error(usage);
}
if (goog.isDef(projection)) {
projection = ol.projection(projection);
}
var loc = new ol.Loc(x, y, z, projection);
return loc;
};
/**
* Transform this location to another coordinate reference system. This
* requires that this location has a projection set already (if not, an error
* will be thrown). Returns a new location object and does not modify this
* location.
*
* @export
* @param {string|ol.Projection} proj The destination projection. Can be
* supplied as a projection instance of a string identifier.
* @returns {ol.Loc} A new location.
*/
ol.Loc.prototype.transform = function(proj) {
if (goog.isString(proj)) {
proj = new ol.Projection(proj);
}
return this.doTransform(proj);
};
/**
* @export
* @param {ol.Projection=} opt_arg Projection.
* @return {ol.Loc|ol.Projection|undefined} Result.
*/
ol.Loc.prototype.projection = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setProjection(ol.projection(opt_arg));
}
else {
return this.getProjection();
}
};
/**
* @export
* @param {number=} opt_arg X.
* @return {ol.Loc|number} Result.
*/
ol.Loc.prototype.x = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setX(opt_arg);
return this;
}
else {
return this.getX();
}
};
/**
* @export
* @param {number=} opt_arg Y.
* @return {ol.Loc|number} Result.
*/
ol.Loc.prototype.y = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setY(opt_arg);
return this;
}
else {
return this.getY();
}
};
/**
* @export
* @param {number=} opt_arg Z.
* @return {ol.Loc|number|undefined} Result.
*/
ol.Loc.prototype.z = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setZ(opt_arg);
}
else {
return this.getZ();
}
};

249
attic/src/api/map.js Normal file
View File

@@ -0,0 +1,249 @@
goog.provide('ol.map');
goog.require('ol.Loc');
goog.require('ol.Map');
goog.require('ol.Projection');
goog.require('ol.loc');
goog.require('ol.projection');
goog.require('ol.error');
/**
* @typedef {ol.Map|{center, zoom, numZoomLevels, projection, userProjection, maxExtent, maxResolution, resolutions, renderTo, layers, controls}|string}
*/
ol.MapLike;
/**
* @export
* @param {ol.MapLike=} opt_arg Argument.
* @return {ol.Map} Map.
*/
ol.map = function(opt_arg) {
/** @type {ol.Loc|undefined} */
var center;
/** @type {number|undefined} */
var zoom;
/** @type {number|undefined} */
var numZoomLevels;
/** @type {ol.Projection|undefined} */
var projection;
/** @type {ol.Projection|undefined} */
var userProjection;
/** @type {ol.Bounds|undefined} */
var maxExtent;
/** @type {number|undefined} */
var maxResolution;
/** @type {Array.<number>|undefined} */
var resolutions;
/** @type {Element|string|undefined} */
var renderTo;
/** @type {Array|undefined} */
var layers;
/** @type {Array|undefined} */
var controls;
if (arguments.length == 1) {
if (opt_arg instanceof ol.Map) {
return opt_arg;
}
else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['center', 'zoom', 'numZoomLevels', 'projection', 'userProjection', 'maxExtent', 'maxResolution', 'resolutions', 'renderTo', 'layers', 'controls']);
center = ol.API ? opt_arg['center'] : opt_arg.center;
zoom = ol.API ? opt_arg['zoom'] : opt_arg.zoom;
numZoomLevels = ol.API ? opt_arg['numZoomLevels'] : opt_arg.numZoomLevels;
projection = ol.API ? opt_arg['projection'] : opt_arg.projection;
userProjection = ol.API ? opt_arg['userProjection'] : opt_arg.userProjection;
maxExtent = ol.API ? opt_arg['maxExtent'] : opt_arg.maxExtent;
maxResolution = ol.API ? opt_arg['maxResolution'] : opt_arg.maxResolution;
resolutions = ol.API ? opt_arg['resolutions'] : opt_arg.resolutions;
renderTo = ol.API ? opt_arg['renderTo'] : opt_arg.renderTo;
layers = ol.API ? opt_arg['layers'] : opt_arg.layers;
controls = ol.API ? opt_arg['controls'] : opt_arg.controls;
}
else {
throw new Error('ol.map');
}
}
var map = new ol.Map();
if (goog.isDef(center)) {
map.center(center);
}
if (goog.isDef(zoom)) {
map.setZoom(zoom);
}
if (goog.isDef(numZoomLevels)) {
map.setNumZoomLevels(numZoomLevels);
}
if (goog.isDef(projection)) {
map.setProjection(ol.projection(projection));
}
if (goog.isDef(userProjection)) {
map.setUserProjection(ol.projection(userProjection));
}
if (goog.isDef(maxExtent)) {
map.setMaxExtent(ol.bounds(maxExtent));
}
if (goog.isDef(maxResolution)) {
map.setMaxResolution(maxResolution);
}
if (goog.isDef(resolutions)) {
map.setResolutions(resolutions);
}
if (goog.isDef(layers)) {
map.setLayers(layers);
}
if (goog.isDef(controls)) {
map.setControls(controls);
}
if (goog.isDef(renderTo)) {
map.renderTo(renderTo);
}
return map;
};
/**
* @export
* @param {ol.LocLike=} opt_arg
* @returns {ol.Map|ol.Loc|undefined} Map center.
*/
ol.Map.prototype.center = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
var loc = ol.loc(opt_arg);
var proj = loc.getProjection();
if (goog.isNull(proj)) {
proj = this.getUserProjection();
loc.setProjection(proj);
}
this.setCenter(loc);
return this;
} else {
var proj = this.getUserProjection();
return this.getCenter().doTransform(proj);
}
};
/**
* @export
* @param {ol.ProjectionLike=} opt_arg
* @returns {ol.Map|ol.Projection|undefined}
*/
ol.Map.prototype.projection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setProjection(ol.projection(opt_arg));
return this;
} else {
return this.getProjection();
}
};
/**
* @export
* @param {ol.ProjectionLike=} opt_arg
* @returns {ol.Map|ol.Projection|undefined}
*/
ol.Map.prototype.userProjection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setUserProjection(ol.projection(opt_arg));
return this;
} else {
return this.getUserProjection();
}
};
/**
* @export
* @param {number=} opt_arg
* @returns {ol.Map|number|undefined} Map center.
*/
ol.Map.prototype.zoom = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setZoom(opt_arg);
return this;
} else {
return this.getZoom();
}
};
/**
* @export
* @param {number=} opt_arg
* @returns {ol.Map|number|undefined} Map center.
*/
ol.Map.prototype.numZoomLevels = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setNumZoomLevels(opt_arg);
return this;
} else {
return this.getNumZoomLevels();
}
};
/**
* @export
* @param {Array=} opt_arg
* @returns {ol.Map|Array|undefined} Map center.
*/
ol.Map.prototype.resolutions = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setResolutions(opt_arg);
return this;
} else {
return this.getResolutions();
}
};
/**
* @export
* @param {Array=} opt_arg
* @returns {ol.Map|Array|undefined} Map center.
*/
ol.Map.prototype.layers = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setLayers(opt_arg);
return this;
} else {
return this.getLayers();
}
};
/**
* @export
* @param {Array=} opt_arg
* @returns {ol.Map|Array|undefined} Map center.
*/
ol.Map.prototype.controls = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setControls(opt_arg);
return this;
} else {
return this.getControls();
}
};
/**
* @export
* @param {Array=} opt_arg
* @returns {ol.Map|ol.Bounds|undefined} Map max extent.
*/
ol.Map.prototype.maxExtent = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setMaxExtent(ol.bounds(opt_arg));
return this;
} else {
return this.getMaxExtent();
}
};
/**
* @param {string|Element} arg Render the map to a container
* @returns {ol.Map}
*/
ol.Map.prototype.renderTo = function(arg) {
this.setContainer(goog.dom.getElement(arg));
return this;
};

139
attic/src/api/popup.js Normal file
View File

@@ -0,0 +1,139 @@
goog.provide('ol.popup');
goog.require('ol.Popup');
goog.require('ol.map');
/**
* @typedef {ol.Popup|{map, anchor, placement, content, template}} popup
*/
ol.PopupLike;
/**
* @export
* @param {ol.PopupLike} opt_arg popup object literal.
* @return {ol.Popup} the popup.
*/
ol.popup = function(opt_arg){
if (opt_arg instanceof ol.Popup) {
return opt_arg;
}
/** @type {ol.Map} */
var map;
/** @type {ol.Loc|ol.Feature|undefined} */
var anchor;
/** @type {string|undefined} */
var placement;
/** @type {string|undefined} */
var content;
/** @type {string|undefined} */
var template;
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['map', 'anchor', 'placement', 'content', 'template']);
map = ol.API ? opt_arg['map'] : opt_arg.map;
anchor = ol.API ? opt_arg['anchor'] : opt_arg.anchor;
placement = ol.API ? opt_arg['placement'] : opt_arg.placement;
content = ol.API ? opt_arg['content'] : opt_arg.content;
template = ol.API ? opt_arg['template'] : opt_arg.template;
}
}
var popup = new ol.Popup(map, anchor);
if (goog.isDef(anchor)) {
popup.setAnchor(anchor);
}
if (goog.isDef(placement)) {
popup.setPlacement(placement);
}
if (goog.isDef(content)) {
popup.setContent(content);
}
if (goog.isDef(template)) {
popup.setTemplate(template);
}
return popup;
};
/**
* @export
* @param {ol.Loc|ol.Feature=} opt_arg a feature or a location.
* @return {ol.Popup|ol.Feature|ol.Loc|undefined} Result.
*/
ol.Popup.prototype.anchor = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setAnchor(opt_arg);
return this;
}
else {
return this.getAnchor();
}
};
/**
* @export
* @param {ol.Map=} opt_arg the map .
* @return {ol.Popup|ol.Map|undefined} the map or the popup.
*/
ol.Popup.prototype.map = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setMap(opt_arg);
return this;
}
else {
return this.getMap();
}
};
/**
* @export
* @param {string=} opt_arg the content for the map (HTML makrkup)
* @return {ol.Popup|string|undefined} the content or the popup.
*/
ol.Popup.prototype.content = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setContent(opt_arg);
return this;
}
else {
return this.getContent();
}
};
/**
* @export
* @param {string=} opt_arg the template to be used to generate the content
* @return {ol.Popup|string|undefined} the template or the popup.
*/
ol.Popup.prototype.template = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setTemplate(opt_arg);
return this;
}
else {
return this.getTemplate();
}
};
/**
* Open the popup.
* @export
* @param {ol.Feature|ol.Loc} opt_arg feature or location for the anchor
*/
ol.Popup.prototype.open = function(opt_arg) {
this.doOpen(opt_arg);
};

View File

@@ -0,0 +1,88 @@
goog.provide('ol.projection');
goog.require('ol.base');
goog.require('ol.Projection');
/**
* @typedef {ol.Projection|Object|string}
*/
ol.ProjectionLike;
/**
* @export
* @param {ol.ProjectionLike=} opt_arg Argument.
* @return {ol.Projection} Projection.
*/
ol.projection = function(opt_arg){
/** @type {string} */
var code;
/** @type {undefined|number} */
var units;
/** @type {undefined|Array|ol.UnreferencedBounds} */
var extent;
if (arguments.length == 1 && goog.isDefAndNotNull(opt_arg)) {
if (opt_arg instanceof ol.Projection) {
return opt_arg;
}
else if (goog.isString(opt_arg)) {
code = opt_arg;
}
else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['code', 'maxExtent', 'units']);
if (goog.isString(ol.API ? opt_arg['code'] : opt_arg.code)) {
code = ol.API ? opt_arg['code'] : opt_arg.code;
} else {
throw new Error('Projection requires a string code.');
}
units = ol.API ? opt_arg['units'] : opt_arg.units;
extent = ol.API ? opt_arg['maxExtent'] : opt_arg.maxExtent;
}
else {
throw new Error('ol.projection');
}
}
var proj = new ol.Projection(code);
if (goog.isDef(units)) {
proj.setUnits(units);
}
if (goog.isDef(extent)) {
proj.setExtent(
new ol.UnreferencedBounds(extent[0],extent[1],extent[2],extent[3])
);
}
return proj;
};
/**
* @export
* @param {string=} opt_code Code.
* @return {!ol.Projection|string} Result.
*/
ol.Projection.prototype.code = function(opt_code){
if (arguments.length == 1 && goog.isDef(opt_code)) {
this.setCode(opt_code);
return this;
}
else {
return this.getCode();
}
};
/**
* @export
* @param {string=} opt_units Units abbreviation.
* @return {undefined|!ol.Projection|string} Result.
*/
ol.Projection.prototype.units = function(opt_units){
if (goog.isDef(opt_units)) {
return this.setUnits(opt_units);
}
else {
return this.getUnits();
}
};