Remove attic

This commit is contained in:
Tom Payne
2012-08-30 13:53:47 +02:00
parent 211f93248c
commit 8ab2e5dfd2
36 changed files with 0 additions and 3202 deletions

View File

@@ -1,26 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>OL3 Hello World</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<script src="../api.js"></script>
<style type="text/css" media="screen">
html, body, #map { width: 100%; height: 100%; border: 0; margin:0; }
</style>
<script type="text/javascript" charset="utf-8">
var map;
function init() {
map = ol.map()
.renderTo('map')
.layers([ol.layer.osm()])
.center([45, 5])
.zoom(10);
}
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>OL3 Hello World</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<script src="hello-compiled.js"></script>
<style type="text/css" media="screen">
html, body, #map { width: 100%; height: 100%; border: 0; margin:0; }
</style>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

View File

@@ -1,42 +0,0 @@
{
"id": "hello",
"output-file": "hello-compiled.js",
"inputs": [
"hello.js",
"../src/ol.js"
],
"paths": [
"../src"
],
"define": {
// "goog.dom.ASSUME_STANDARDS_MODE": true,
"goog.DEBUG": false
},
"mode": "ADVANCED",
"level": "VERBOSE",
// "pretty-print": true,
// "debug": true,
// "experimental-compiler-options": {
// "generateExports": true
// },
"checks": {
// acceptable values are "ERROR", "WARNING", and "OFF"
"accessControls": "WARNING",
"visibility": "WARNING",
"checkTypes": "WARNING",
"checkRegExp": "WARNING",
"checkVars": "WARNING",
"deprecated": "WARNING",
"fileoverviewTags": "WARNING",
"invalidCasts": "WARNING",
"missingProperties": "WARNING",
"nonStandardJsDocs": "WARNING",
"undefinedVars": "WARNING"
}
}

View File

@@ -1,42 +0,0 @@
{
"id": "hello-epi",
"output-file": "hello-epi-compiled.js",
"inputs": [
"hello-epi.js"
],
"paths": [
"../src"
],
"define": {
// "goog.dom.ASSUME_STANDARDS_MODE": true,
"goog.DEBUG": false
},
"mode": "ADVANCED",
"level": "VERBOSE",
// "pretty-print": true,
// "debug": true,
// "experimental-compiler-options": {
// "generateExports": true
// },
"checks": {
// acceptable values are "ERROR", "WARNING", and "OFF"
"accessControls": "WARNING",
"visibility": "WARNING",
"checkTypes": "WARNING",
"checkRegExp": "WARNING",
"checkVars": "WARNING",
"deprecated": "WARNING",
"fileoverviewTags": "WARNING",
"invalidCasts": "WARNING",
"missingProperties": "WARNING",
"nonStandardJsDocs": "WARNING",
"undefinedVars": "WARNING"
}
}

View File

@@ -1,16 +0,0 @@
/* This is a code which is going to be compiled together with the library */
goog.require('ol.Map');
goog.require('ol.layer.OSM');
goog.require('ol.Loc');
goog.require('goog.dom');
function init() {
var map = new ol.Map();
map.setContainer(goog.dom.getElement('map'));
map.setLayers( [ new ol.layer.OSM() ] );
map.setCenter( new ol.Loc(45, 5));
map.setZoom(10);
}
window['init'] = init;

View File

@@ -1,10 +0,0 @@
/* This is a code which is going to be compiled together with the library */
function init() {
var map = ol.map()
.renderTo('map')
.layers([ol.layer.osm()])
.center([45, 5])
.zoom(10);
}
window['init'] = init;

View File

@@ -1,36 +0,0 @@
/**
Adds the plovr generated script to the document. The following default
values may be overridden with query string parameters:
* hostname - localhost
* port - 9810
* mode - SIMPLE
* id - ol
*/
(function() {
var search = window.location.search.substring(1);
var params = {
hostname: "localhost",
port: "9810",
mode: "SIMPLE",
id: "ol"
};
var chunks = search.split("&");
var pair;
for (var i=chunks.length-1; i>=0; --i) {
pair = chunks[i].split("=");
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
var host = params.hostname + ":" + params.port;
delete params.hostname;
delete params.port;
var pairs = [];
for (var key in params) {
pairs.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
}
var url = "http://" + host + "/compile?" + pairs.join("&");
document.write("<script type='text/javascript' src='" + url + "'></script>");
})();

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>OL3 Map</title>
<script type="text/javascript" src="loader.js"></script>
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<style type="text/css">
#map {
width: 512px; height: 350px;
}
</style>
</head>
<body>
</body>
<div id="map"></div>
<script type="text/javascript" src="map.js"></script>
</html>

View File

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

View File

@@ -1,39 +0,0 @@
/**
* Build configuration for the map.js example. Use following syntax:
*
* ol build map.json
*
* The output will be named map-compiled.js.
*/
{
"id": "hello",
"output-file": "map-compiled.js",
"inputs": ["../src/ol.js", "map.js"],
"paths": ["../src"],
"define": {
"goog.DEBUG": false
},
"mode": "ADVANCED",
"level": "VERBOSE",
// acceptable values are "ERROR", "WARNING", and "OFF"
"checks": {
"accessControls": "WARNING",
"visibility": "WARNING",
"checkTypes": "WARNING",
"checkRegExp": "WARNING",
"checkVars": "WARNING",
"deprecated": "WARNING",
"fileoverviewTags": "WARNING",
"invalidCasts": "WARNING",
"missingProperties": "WARNING",
"nonStandardJsDocs": "WARNING",
"undefinedVars": "WARNING"
}
}

View File

@@ -1,149 +0,0 @@
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);
};

View File

@@ -1,92 +0,0 @@
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

@@ -1,133 +0,0 @@
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

@@ -1,35 +0,0 @@
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

@@ -1,142 +0,0 @@
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

@@ -1,138 +0,0 @@
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

@@ -1,137 +0,0 @@
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;
};

View File

@@ -1,122 +0,0 @@
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

@@ -1,11 +0,0 @@
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

@@ -1,41 +0,0 @@
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

@@ -1,31 +0,0 @@
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);
};

View File

@@ -1,146 +0,0 @@
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();
}
};

View File

@@ -1,249 +0,0 @@
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;
};

View File

@@ -1,139 +0,0 @@
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

@@ -1,88 +0,0 @@
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();
}
};

View File

@@ -1,163 +0,0 @@
goog.require('ol.base');
goog.require('ol.bounds');
goog.require('ol.control.Attribution');
goog.require('ol.control.Navigation');
goog.require('ol.control.Zoom');
goog.require('ol.event.Events');
goog.require('ol.event.Scroll');
goog.require('ol.handler.Drag');
goog.require("ol.map");
goog.require("ol.loc");
goog.require("ol.feature");
goog.require("ol.projection");
goog.require("ol.layer.xyz");
goog.require("ol.layer.osm");
goog.require("ol.layer.wms");
goog.require("ol.popup");
goog.require("ol.Tile");
goog.require("ol.TileSet");
goog.require("ol.TileCache");
goog.require("ol.geom.geometry");
goog.require("ol.geom.point");
goog.require("ol.geom.multipoint");
goog.require("ol.geom.linestring");
goog.require("ol.geom.multilinestring");
goog.require("ol.geom.collection");
goog.require('ol.layer.XYZ');
goog.require('ol.layer.OSM');
goog.require('ol.layer.WMS');
goog.require('ol.renderer.Composite');
goog.require('ol.renderer.TileLayerRenderer');
goog.require('ol.renderer.WebGL');
// ol.map
goog.exportSymbol('ol.map', ol.map );
goog.exportSymbol('ol.Map', ol.Map );
goog.exportProperty( ol.Map.prototype, 'renderTo', ol.Map.prototype.renderTo );
goog.exportProperty( ol.Map.prototype, 'center', ol.Map.prototype.center );
goog.exportProperty( ol.Map.prototype, 'projection', ol.Map.prototype.projection );
goog.exportProperty( ol.Map.prototype, 'userProjection', ol.Map.prototype.userProjection );
goog.exportProperty( ol.Map.prototype, 'zoom', ol.Map.prototype.zoom );
goog.exportProperty( ol.Map.prototype, 'numZoomLevels', ol.Map.prototype.numZoomLevels );
goog.exportProperty( ol.Map.prototype, 'resolutions', ol.Map.prototype.resolutions );
goog.exportProperty( ol.Map.prototype, 'layers', ol.Map.prototype.layers );
goog.exportProperty( ol.Map.prototype, 'controls', ol.Map.prototype.controls );
goog.exportProperty( ol.Map.prototype, 'maxExtent', ol.Map.prototype.maxExtent );
goog.exportProperty( ol.Map.prototype, 'destroy', ol.Map.prototype.destroy );
// ol.loc
goog.exportSymbol('ol.loc', ol.loc );
goog.exportSymbol('ol.Loc', ol.Loc ); // This is not required only for the tests with isInstanceOf
goog.exportProperty( ol.Loc.prototype, 'projection', ol.Loc.prototype.projection );
goog.exportProperty( ol.Loc.prototype, 'x', ol.Loc.prototype.x );
goog.exportProperty( ol.Loc.prototype, 'y', ol.Loc.prototype.y );
goog.exportProperty( ol.Loc.prototype, 'z', ol.Loc.prototype.z );
goog.exportProperty( ol.Loc.prototype, 'transform', ol.Loc.prototype.transform );
goog.exportProperty( ol.Loc.prototype, 'destroy', ol.Loc.prototype.destroy );
// ol.projection
goog.exportSymbol('ol.projection', ol.projection );
goog.exportSymbol('ol.Projection', ol.Projection );
goog.exportProperty( ol.Projection.prototype, 'code', ol.Projection.prototype.code );
goog.exportProperty( ol.Projection.prototype, 'units', ol.Projection.prototype.units );
// ol.bounds
goog.exportSymbol('ol.bounds', ol.bounds );
goog.exportSymbol('ol.Bounds', ol.Bounds );
goog.exportProperty( ol.Bounds.prototype, 'projection', ol.Bounds.prototype.projection );
goog.exportProperty( ol.Bounds.prototype, 'minX', ol.Bounds.prototype.minX );
goog.exportProperty( ol.Bounds.prototype, 'minY', ol.Bounds.prototype.minY );
goog.exportProperty( ol.Bounds.prototype, 'maxX', ol.Bounds.prototype.maxX );
goog.exportProperty( ol.Bounds.prototype, 'maxY', ol.Bounds.prototype.maxY );
// ol.layer.xyz
goog.exportSymbol('ol.layer.xyz', ol.layer.xyz);
goog.exportSymbol('ol.layer.XYZ', ol.layer.XYZ);
// ol.layer.osm
goog.exportSymbol('ol.layer.osm', ol.layer.osm);
goog.exportSymbol('ol.layer.OSM', ol.layer.OSM);
// ol.layer.wms
goog.exportSymbol('ol.layer.wms', ol.layer.wms);
goog.exportSymbol('ol.layer.WMS', ol.layer.WMS);
// ol.feature
goog.exportSymbol('ol.feature', ol.feature);
goog.exportSymbol('ol.Feature', ol.Feature);
goog.exportProperty(ol.Feature.prototype, 'set', ol.Feature.prototype.set);
goog.exportProperty(ol.Feature.prototype, 'get', ol.Feature.prototype.get);
goog.exportProperty(ol.Feature.prototype, 'geometry', ol.Feature.prototype.geometry);
// ol.geometry
goog.exportSymbol('ol.geom.geometry', ol.geom.geometry);
goog.exportSymbol('ol.geom.Geometry', ol.geom.Geometry);
goog.exportProperty(ol.geom.Geometry.prototype, 'bounds', ol.geom.Geometry.prototype.bounds);
goog.exportProperty(ol.geom.Geometry.prototype, 'centroid', ol.geom.Geometry.prototype.centroid);
// ol.geom.collection
goog.exportSymbol('ol.geom.collection', ol.geom.collection);
goog.exportSymbol('ol.geom.Collection', ol.geom.Collection);
goog.exportProperty(ol.geom.Collection.prototype, 'components', ol.geom.Collection.prototype.components);
goog.exportProperty(ol.geom.Collection.prototype, 'add', ol.geom.Collection.prototype.add);
goog.exportProperty(ol.geom.Collection.prototype, 'addAll', ol.geom.Collection.prototype.addAll);
goog.exportProperty(ol.geom.Collection.prototype, 'remove', ol.geom.Collection.prototype.remove);
goog.exportProperty(ol.geom.Collection.prototype, 'centroid', ol.geom.Collection.prototype.centroid);
// ol.geom.point
goog.exportSymbol('ol.geom.point', ol.geom.point);
goog.exportSymbol('ol.geom.Point', ol.geom.Point);
goog.exportProperty(ol.geom.Point.prototype, 'x', ol.geom.Point.prototype.x);
goog.exportProperty(ol.geom.Point.prototype, 'y', ol.geom.Point.prototype.y);
goog.exportProperty(ol.geom.Point.prototype, 'z', ol.geom.Point.prototype.z);
goog.exportProperty(ol.geom.Point.prototype, 'projection', ol.geom.Point.prototype.projection);
goog.exportProperty(ol.geom.Point.prototype, 'centroid', ol.geom.Point.prototype.centroid);
// ol.geom.linestring
goog.exportSymbol('ol.geom.linestring', ol.geom.linestring);
goog.exportSymbol('ol.geom.LineString', ol.geom.LineString);
goog.exportProperty(ol.geom.LineString.prototype, 'vertices', ol.geom.LineString.prototype.vertices);
goog.exportProperty(ol.geom.LineString.prototype, 'add', ol.geom.LineString.prototype.add);
goog.exportProperty(ol.geom.LineString.prototype, 'addAll', ol.geom.LineString.prototype.addAll);
goog.exportProperty(ol.geom.LineString.prototype, 'remove', ol.geom.LineString.prototype.remove);
goog.exportProperty(ol.geom.LineString.prototype, 'centroid', ol.geom.LineString.prototype.centroid);
// ol.geom.multipoint
goog.exportSymbol('ol.geom.multipoint', ol.geom.multipoint);
goog.exportSymbol('ol.geom.MultiPoint', ol.geom.MultiPoint);
goog.exportProperty(ol.geom.MultiPoint.prototype, 'points', ol.geom.MultiPoint.prototype.points);
goog.exportProperty(ol.geom.MultiPoint.prototype, 'add', ol.geom.MultiPoint.prototype.add);
goog.exportProperty(ol.geom.MultiPoint.prototype, 'addAll', ol.geom.MultiPoint.prototype.addAll);
goog.exportProperty(ol.geom.MultiPoint.prototype, 'remove', ol.geom.MultiPoint.prototype.remove);
goog.exportProperty(ol.geom.MultiPoint.prototype, 'centroid', ol.geom.MultiPoint.prototype.centroid);
// ol.geom.multilinestring
goog.exportSymbol('ol.geom.multilinestring', ol.geom.multilinestring);
goog.exportSymbol('ol.geom.MultiLineString', ol.geom.MultiLineString);
goog.exportProperty(ol.geom.MultiLineString.prototype, 'linestrings', ol.geom.MultiLineString.prototype.linestrings);
goog.exportProperty(ol.geom.MultiLineString.prototype, 'add', ol.geom.MultiLineString.prototype.add);
goog.exportProperty(ol.geom.MultiLineString.prototype, 'addAll', ol.geom.MultiLineString.prototype.addAll);
goog.exportProperty(ol.geom.MultiLineString.prototype, 'remove', ol.geom.MultiLineString.prototype.remove);
goog.exportProperty(ol.geom.MultiLineString.prototype, 'centroid', ol.geom.MultiLineString.prototype.centroid);
// ol.popup
goog.exportSymbol('ol.popup', ol.popup);
goog.exportSymbol('ol.Popup', ol.Popup);
goog.exportProperty(ol.Popup.prototype, 'anchor', ol.Popup.prototype.anchor);
goog.exportProperty(ol.Popup.prototype, 'map', ol.Popup.prototype.map);
goog.exportProperty(ol.Popup.prototype, 'content', ol.Popup.prototype.content);
goog.exportProperty(ol.Popup.prototype, 'template', ol.Popup.prototype.template);
goog.exportProperty(ol.Popup.prototype, 'open', ol.Popup.prototype.open);
/**
* Lookup for dynamically registered controls and renderers does not work in
* advanced compiled mode. For now, we duplicate the registration calls here.
*
* TODO: determine a good way for plugins to register
*/
goog.exportProperty(ol.renderer.Composite, 'isSupported', ol.renderer.Composite.isSupported);
goog.exportProperty(ol.renderer.TileLayerRenderer, 'isSupported', ol.renderer.TileLayerRenderer.isSupported);
goog.exportProperty(ol.renderer.TileLayerRenderer, 'canRender', ol.renderer.TileLayerRenderer.canRender);
goog.exportProperty(ol.renderer.TileLayerRenderer, 'getType', ol.renderer.TileLayerRenderer.getType);
ol.control.addControl('navigation', ol.control.Navigation);

View File

@@ -1,77 +0,0 @@
goog.provide('ol.Feature');
goog.require('ol.geom.Geometry');
/**
* @export
* @constructor
*/
ol.Feature = function() {
/**
* @private
* @type {ol.geom.Geometry}
*/
this.geometry_ = null;
/**
* @private
* @type {Object}
*/
this.attributes_ = {};
};
/**
* @return {ol.geom.Geometry} The geometry associated with the feature.
*/
ol.Feature.prototype.getGeometry = function() {
return this.geometry_;
};
/**
* @param {ol.geom.Geometry} geom the geometry for the feature.
*/
ol.Feature.prototype.setGeometry = function(geom) {
this.geometry_ = geom;
};
/**
* @param {!string} name the attribute value to retrieve.
@return {string|number|boolean} the attribute value.
*/
ol.Feature.prototype.getAttribute = function(name) {
return this.attributes_[name];
};
/**
* @param {!string} name of the attribute to set.
* @param {string|number|boolean} value the attribute value to set.
*/
ol.Feature.prototype.setAttribute = function(name, value) {
this.attributes_[name] = value;
};
/**
* @param {Object} attrs An json structure containing key/value pairs.
*/
ol.Feature.prototype.setAttributes = function(attrs) {
for (var key in attrs) {
this.setAttribute(key, attrs[key]);
}
};
/**
*/
ol.Feature.prototype.destroy = function() {
//remove attributes and geometry, etc.
for (var key in this) {
delete this[key];
}
};

View File

@@ -1,342 +0,0 @@
goog.provide('ol.Popup');
goog.require('ol.Map');
goog.require('ol.Loc');
goog.require('ol.Feature');
/**
* @export
* @constructor
* @param {ol.Map} map the map on which the popup is placed.
* @param {ol.Loc|ol.Feature=} opt_anchor the anchor object for the popup.
* @param {string=} opt_placement the placement of the arrow on the popup.
* @param {boolean=} opt_close include a close button on the popup
*/
ol.Popup = function(map, opt_anchor, opt_placement, opt_close) {
/**
* @private
* @type {ol.Map}
*/
this.map_ = map;
/**
* @private
* @type {ol.Loc|ol.Feature|undefined}
*/
this.anchor_ = opt_anchor;
/**
* can be 'top','bottom','right','left','auto'
* TODO: 'auto' not yet implemented
* @private
* @type {!string}
*/
this.placement_ = goog.isDefAndNotNull(opt_placement)?opt_placement:'top';
/**
* include a close button on the popup - defaults to true.
* @private
* @type {boolean|undefined}
*/
this.closeButton_ = goog.isDefAndNotNull(opt_close) ? opt_close : true;
/**
* @private
* @type {string|undefined}
*/
this.content_ = undefined;
/**
* @private
* @type {string|undefined}
*/
this.template_ = undefined;
/**
* @private
* @type {Element}
*/
this.container_ = null;
/**
* @private
* @type {number}
*/
this.arrowOffset_ = 30; //FIXME: set this from CSS dynamically somehow?
/**
* if the CSS sets either width or height assume the app is specifying the
* size of the popup, if not auto size the popup.
* @private
* @type {boolean}
*/
this.autoSize_ = true;
};
/**
* @const
*/
ol.Popup.CLASS_NAME = 'ol-popup';
/**
* @return {ol.Map} Projection.
*/
ol.Popup.prototype.getMap = function() {
return this.map_;
};
/**
* @param {ol.Map} map the map object to hold this popup.
*/
ol.Popup.prototype.setMap = function(map) {
this.map_ = map;
};
/**
* @return {ol.Feature|ol.Loc|undefined} the anchor .
*/
ol.Popup.prototype.getAnchor = function() {
return this.anchor_;
};
/**
* @param {ol.Feature|ol.Loc} anchor the anchor location to place this popup.
*/
ol.Popup.prototype.setAnchor = function(anchor) {
this.anchor_ = anchor;
};
/**
* @return {string|undefined} the placement value relative to the anchor.
*/
ol.Popup.prototype.getPlacement = function() {
return this.placement_;
};
/**
* @param {string} placement where to place this popup relative to the anchor.
*/
ol.Popup.prototype.setPlacement = function(placement) {
if (!goog.isNull(this.container_)) {
goog.dom.classes.remove(this.container_,
ol.Popup.CLASS_NAME+'-'+this.placement_);
goog.dom.classes.add(this.container_,ol.Popup.CLASS_NAME+'-'+placement);
}
this.placement_ = placement;
};
/**
* @return {string|undefined} static content to be displayed in the popup (HTML)
*/
ol.Popup.prototype.getContent = function() {
return this.content_;
};
/**
* @param {string} content the content to be displayed this popup.
*/
ol.Popup.prototype.setContent = function(content) {
this.content_ = content;
};
/**
* @private
* @returns {string} generates the content
*/
ol.Popup.prototype.generateContent_ = function() {
//set the content
if ( goog.isDefAndNotNull(this.content_) ) {
return this.content_;
} else {
if ( goog.isDefAndNotNull(this.template_) &&
goog.isDefAndNotNull(this.anchor_) &&
(this.anchor_ instanceof ol.Feature)) {
//set content from feature attributes on the template
//TODO: this.setContent(template.apply(this.anchor_.getAttributes()));
return this.template_; //stub to return something
} else {
ol.error('ol.Popup unabale to generate any content');
return '<p>no content</p>';
}
}
};
/**
* @return {string|undefined} the anchor .
*/
ol.Popup.prototype.getTemplate = function() {
return this.template_;
};
/**
* @param {string} template the map object to hold this popup.
*/
ol.Popup.prototype.setTemplate = function(template) {
this.template_ = template;
};
/**
* Open the popup.
* @param {ol.Feature|ol.Loc} opt_arg feature or location for the anchor
*/
ol.Popup.prototype.doOpen = function(opt_arg) {
if (goog.isDef(opt_arg)) {
this.setAnchor(opt_arg);
}
//create popup container if it's not created already
if (goog.isNull(this.container_)) {
this.container_ = goog.dom.createElement('div');
goog.dom.classes.add(this.container_,
ol.Popup.CLASS_NAME, ol.Popup.CLASS_NAME+'-'+this.placement_);
//see if the style class sets width or height
if (goog.style.getStyle(this.container_, 'width').length>0 ||
goog.style.getStyle(this.container_, 'height').length>0 ) {
this.autoSize_ = false;
}
if (this.closeButton_) {
var closeButton = goog.dom.createElement('div');
goog.dom.appendChild(this.container_, closeButton);
goog.dom.classes.add(closeButton, ol.Popup.CLASS_NAME+'-close');
}
this.map_.getEvents().register('click', this.clickHandler, this);
goog.dom.appendChild(this.map_.getMapOverlay(), this.container_);
}
this.childContent_=goog.dom.htmlToDocumentFragment(this.generateContent_());
goog.dom.appendChild(this.container_, this.childContent_);
if (this.autoSize_) {
this.registerImageListeners();
}
this.setAnchorOffset_();
};
ol.Popup.prototype.setAnchorOffset_ = function() {
if (goog.isNull(this.container_.parentNode)) {
//this means the popup has already been closed, nothing to do here
//which might happen while waiting for images to load
return;
}
if (!goog.isDefAndNotNull(this.anchor_)) {
//must have an anchor when trying to set the position
ol.error("ol.Popup must have an anchor to set the position");
return;
}
//position the element
if (this.anchor_ instanceof ol.Feature) {
this.pos_ = this.anchor_.getGeometry().getCentroid();
} else {
this.pos_ = new ol.geom.Point(this.anchor_.getX(), this.anchor_.getY());
}
var pos = /** @type {ol.Loc} */ (this.pos_);
var popupPosPx = this.map_.getPixelForLoc(pos);
var popupSize = goog.style.getSize(this.container_);
switch(this.placement_) {
default:
case 'auto':
//TODO: switch based on map quadrant
break;
case 'top':
case 'bottom':
popupPosPx[0] -= popupSize.width / 2.0;
if (this.placement_ == "bottom") {
popupPosPx[1] -= popupSize.height + this.arrowOffset_;
} else {
popupPosPx[1] += this.arrowOffset_;
}
break;
case 'left':
case 'right':
popupPosPx[1] -= popupSize.height / 2.0;
if (this.placement_ == "right") {
popupPosPx[0] -= popupSize.width + this.arrowOffset_;
} else {
popupPosPx[0] += this.arrowOffset_;
}
break;
}
this.moveTo_(popupPosPx);
};
/**
* registerImageListeners
* Called when an image contained by the popup loaded. this function
* updates the popup size, then unregisters the image load listener.
*/
ol.Popup.prototype.registerImageListeners = function() {
// As the images load, this function will call setAnchorOffset_() to
// resize the popup to fit the content div (which presumably is now
// bigger than when the image was not loaded).
//
//cycle through the images and if their size is 0x0, that means that
// they haven't been loaded yet, so we attach the listener, which
// will fire when the images finish loading and will resize the
// popup accordingly to its new size.
var images = this.container_.getElementsByTagName("img");
for (var i = 0, len = images.length; i < len; i++) {
var img = images[i];
if (img.width == 0 || img.height == 0) {
goog.events.listenOnce(img, 'load',
goog.bind(this.setAnchorOffset_, this));
}
}
};
/**
* @param px - {goog.} the top and left position of the popup div.
*/
ol.Popup.prototype.moveTo_ = function(px) {
if (goog.isDefAndNotNull(px)) {
goog.style.setPosition(this.container_, px[0], px[1]);
}
};
/**
* Click handler
* @param {Event} evt the event generated by a click
*/
ol.Popup.prototype.clickHandler = function(evt) {
var target = /** @type {Node} */ evt.target;
if (goog.dom.classes.has(target,ol.Popup.CLASS_NAME+'-close')) {
this.close();
}
};
/**
* Clean up.
* @export
*/
ol.Popup.prototype.close = function() {
goog.dom.removeChildren(this.container_);
goog.dom.removeNode(this.container_);
};
/**
* Clean up.
* @export
*/
ol.Popup.prototype.destroy = function() {
for (var key in this) {
delete this[key];
}
};

View File

@@ -1,198 +0,0 @@
goog.provide('ol.geom.Collection');
goog.require('goog.array');
goog.require('ol.geom.Geometry');
goog.require('ol.Projection');
goog.require('ol.base');
/**
* Creates ol.geom.Collection objects.
*
* @export
* @extends {ol.geom.Geometry}
* @param {Array.<ol.geom.Geometry>} components An array of components.
*
* @constructor
*/
ol.geom.Collection = function(components) {
/**
* @private
* @type {Array.<Function>}
*/
this.typeBlacklist_ = [
ol.geom.Collection
];
/**
* @private
* @type {Array.<Function>}
*/
this.typeWhitelist_ = [
ol.geom.MultiPoint,
ol.geom.MultiLineString
// TODO uncomment when implemented
// ,ol.geom.MultiPolygon
];
/**
* @private
* @type {Array.<ol.geom.Geometry>}
*/
this.components_ = [];
if (arguments.length === 1 && goog.isDef(components)) {
this.setComponents(components);
}
};
goog.inherits(ol.geom.Collection, ol.geom.Geometry);
/**
* Sets the list of disallowed types for the collection.
* @param {Array.<Function>} typeBlacklist Array of constructors to disallow.
*/
ol.geom.Collection.prototype.setTypeBlacklist = function(typeBlacklist){
this.typeBlacklist_ = typeBlacklist;
};
/**
* Gets the list of disallowed types for the collection.
* @return {Array.<Function>} Array of constructors to disallow.
*/
ol.geom.Collection.prototype.getTypeBlacklist = function(){
return this.typeBlacklist_;
};
/**
* Sets the list of always allowed types for the collection.
* @param {Array.<Function>} typeWhitelist Array of constructors to allow.
*/
ol.geom.Collection.prototype.setTypeWhitelist = function(typeWhitelist){
this.typeWhitelist_ = typeWhitelist;
};
/**
* Gets the list of always allowed types for the collection.
* @return {Array.<Function>} Array of constructors to allow.
*/
ol.geom.Collection.prototype.getTypeWhitelist = function(){
return this.typeWhitelist_;
};
/**
* Sets the Collection's components.
*
* @return {Array.<ol.geom.Geometry>} An array of components.
*/
ol.geom.Collection.prototype.getComponents = function() {
return this.components_;
};
/**
* Gets the Collection's components.
*
* @param {Array.<ol.geom.Geometry>} components An array of components.
*/
ol.geom.Collection.prototype.setComponents = function(components) {
var allValidTypes = goog.array.every(
components,
this.isAllowedComponent,
this
);
if (allValidTypes) {
this.components_ = components;
} else {
var msg = 'ol.geom.Collection: at least one component passed to '
+ 'setComponents is not allowed.';
ol.error(msg);
}
};
/**
* Adds the given component to the list of components at the specified index.
*
* @param {ol.geom.Geometry} component A component to be added.
* @param {number} index The index where to add.
*/
ol.geom.Collection.prototype.addComponent = function(component, index) {
if (this.isAllowedComponent(component)) {
goog.array.insertAt(this.components_, component, index);
} else {
var msg = 'ol.geom.Collection: component is not allowed to be added.';
ol.error(msg);
}
};
/**
* Checks whether the passed component is an instance of any of the constructors
* listed in the passed list.
*
* @param {ol.geom.Geometry} component The component to check.
* @param {Array.<Function>} list The List of constructors to check the
* component against.
*
* @return {boolean} Whether the passed component is an instance of any of the
* constructors listed in the passed list.
*
* @private
*/
ol.geom.Collection.prototype.isOnList = function(component, list) {
var isOnList = !goog.array.every(list, function(listedConstr){
if (component instanceof listedConstr) {
return false;
} else {
return true;
}
});
return isOnList;
};
/**
* Checks whether the passed component is allowed according to the black and
* whitelists.
*
* @param {ol.geom.Geometry} component The component to check.
* @return {boolean} Whether the passed component is allowed as part of this
* collection according to black- and whitelist.
*/
ol.geom.Collection.prototype.isAllowedComponent = function(component){
var whitelist = this.getTypeWhitelist(),
blacklist = this.getTypeBlacklist(),
isOnWhitelist = this.isOnList(component, whitelist),
isOnBlacklist = this.isOnList(component, blacklist);
return (isOnWhitelist || !isOnBlacklist);
};
/**
* Removes the given component from the list of components.
*
* @param {ol.geom.Geometry} component A component to be removed.
*/
ol.geom.Collection.prototype.removeComponent = function(component) {
goog.array.remove(this.components_, component);
};
/**
* Compute the centroid for this geometry collection.
*
* @returns {ol.geom.Point} The centroid of the collection.
*/
ol.geom.Collection.prototype.getCentroid = function() {
var components = this.getComponents(),
len = components.length,
sum_x = 0, sum_y = 0,
centroid = null;
if (len > 0) {
goog.array.forEach(components, function(component){
var singleCentroid = component.getCentroid();
if (goog.isDefAndNotNull(singleCentroid)) {
sum_x += singleCentroid.getX();
sum_y += singleCentroid.getX();
} else {
len--;
}
});
centroid = new ol.geom.Point(sum_x / len, sum_y / len);
}
return centroid;
};

View File

@@ -1,58 +0,0 @@
goog.provide('ol.geom.Geometry');
goog.require('ol.geom.IGeometry');
goog.require('ol.Bounds');
/**
* Creates ol.Geometry objects.
*
* @export
* @implements {ol.geom.IGeometry}
* @constructor
*/
ol.geom.Geometry = function() {
/**
* @private
* @type {ol.Bounds|undefined}
*/
this.bounds_ = undefined;
};
/**
* @return {ol.Bounds|undefined} The ol.Bounds.
*/
ol.geom.Geometry.prototype.getBounds = function() {
return this.bounds_;
};
/**
* @param {ol.Bounds} bounds The new ol.Bounds.
* @return {ol.geom.Geometry} This.
*/
ol.geom.Geometry.prototype.setBounds = function(bounds) {
this.bounds_ = bounds;
return this;
};
/**
* Returns the centroid of the geometry.
*
* @returns {ol.geom.Point} The centroid of the geometry.
*/
ol.geom.Geometry.prototype.getCentroid = function() {
// throw an error to enforce subclasses to implement it properly
ol.error('ol.geom.Geometry: getCentroid must be implemented by subclasses');
return null;
};
/**
* Returns the area of the geometry.
*
* @returns {number} The area of the geometry.
*/
ol.geom.Geometry.prototype.getArea = function() {
// throw an error to enforce subclasses to implement it properly
ol.error('ol.geom.Geometry: getArea must be implemented by subclasses');
return 0;
};

View File

@@ -1,27 +0,0 @@
goog.provide('ol.geom.IGeometry');
//goog.require('ol.geom.Point');
//goog.require('ol.Bounds');
/**
* Interface for geometry classes forcing ol.geom.* classes to implement
* expected functionality.
*
* @interface
*/
ol.geom.IGeometry = function(){};
/**
* @return {ol.geom.Point} The centroid of the geometry.
*/
ol.geom.IGeometry.prototype.getCentroid = function(){};
/**
* @return {ol.Bounds|undefined} The centroid of the geometry.
*/
ol.geom.IGeometry.prototype.getBounds = function(){};
/**
* @return {number} The area of the geometry.
*/
ol.geom.IGeometry.prototype.getArea = function(){};

View File

@@ -1,76 +0,0 @@
goog.provide('ol.geom.LineString');
goog.require('goog.array');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.Collection');
goog.require('ol.geom.Point');
goog.require('ol.Projection');
/**
* Creates ol.geom.LineString objects.
*
* @export
* @extends {ol.geom.Geometry}
* @param {Array.<ol.geom.Point>} vertices An array of points building the
* linestrings vertices.
*
* @constructor
*/
ol.geom.LineString = function(vertices) {
/**
* @private
* @type {Array.<ol.geom.Point>}
*/
this.vertices_ = vertices;
};
goog.inherits(ol.geom.LineString, ol.geom.Geometry);
/**
* Sets the LineString's points.
*
* @return {Array.<ol.geom.Point>} An array of points.
*/
ol.geom.LineString.prototype.getVertices = function() {
return this.vertices_;
};
/**
* Gets the LineString's points.
*
* @param {Array.<ol.geom.Point>} vertices An array of points.
*/
ol.geom.LineString.prototype.setVertices = function(vertices) {
this.vertices_ = vertices;
};
/**
* Adds the given vertex to the list of vertices at the specified index.
*
* @param {ol.geom.Point} vertex A point to be added.
* @param {number} index The index where to add.
*/
ol.geom.LineString.prototype.addVertex = function(vertex, index) {
goog.array.insertAt(this.vertices_,vertex,index);
};
/**
* Removes the given vertex from the list of vertices.
*
* @param {ol.geom.Point} vertex A point to be removed.
*/
ol.geom.LineString.prototype.removeVertex = function(vertex) {
goog.array.remove(this.vertices_, vertex);
};
/**
* Compute the centroid for this linestring.
*
* @returns {ol.geom.Point} The centroid of the linestring.
*/
ol.geom.LineString.prototype.getCentroid = function() {
var vertices = this.getVertices(),
collection = new ol.geom.Collection(vertices);
return collection.getCentroid();
};

View File

@@ -1,61 +0,0 @@
goog.provide('ol.geom.MultiLineString');
goog.require('goog.array');
goog.require('ol.geom.Collection');
/**
* Creates ol.geom.MultiLineString objects.
*
* @export
* @extends {ol.geom.Collection}
* @param {Array.<ol.geom.LineString>} linestrings An array of linestrings.
*
* @constructor
*/
ol.geom.MultiLineString = function(linestrings) {
this.setTypeWhitelist([ol.geom.LineString]);
this.setTypeBlacklist([ol.geom.Geometry]);
if (arguments.length === 1 && goog.isDef(linestrings)) {
this.setLineStrings(linestrings);
}
};
goog.inherits(ol.geom.MultiLineString, ol.geom.Collection);
/**
* Gets the MultiLineString's linestrings.
*
* @return {Array.<ol.geom.LineString>} An array of linestrings.
*/
ol.geom.MultiLineString.prototype.getLineStrings = function() {
return this.getComponents();
};
/**
* Sets the MultiLineString's linestrings.
*
* @param {Array.<ol.geom.LineString>} linestrings An array of linestrings.
*/
ol.geom.MultiLineString.prototype.setLineStrings = function(linestrings) {
this.setComponents(linestrings);
};
/**
* Adds the given linestring to the list of linestrings at the specified index.
*
* @param {ol.geom.LineString} linestring A linestring to be added.
* @param {number} index The index where to add.
*/
ol.geom.MultiLineString.prototype.addLineString = function(linestring, index) {
this.addComponent(linestring, index);
};
/**
* Removes the given linestring from the list of linestrings.
*
* @param {ol.geom.LineString} linestring A linestring to be removed.
*/
ol.geom.MultiLineString.prototype.removeLineString = function(linestring) {
this.removeComponent(linestring);
};

View File

@@ -1,61 +0,0 @@
goog.provide('ol.geom.MultiPoint');
goog.require('goog.array');
goog.require('ol.geom.Collection');
/**
* Creates ol.geom.MultiPoint objects.
*
* @export
* @extends {ol.geom.Collection}
* @param {Array.<ol.geom.Point>} points An array of points.
*
* @constructor
*/
ol.geom.MultiPoint = function(points) {
this.setTypeWhitelist([ol.geom.Point]);
this.setTypeBlacklist([ol.geom.Geometry]);
if (arguments.length === 1 && goog.isDef(points)) {
this.setPoints(points);
}
};
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
/**
* Sets the MultiPoint's points.
*
* @return {Array.<ol.geom.Point>} An array of points.
*/
ol.geom.MultiPoint.prototype.getPoints = function() {
return this.getComponents();
};
/**
* Gets the MultiPoint's points.
*
* @param {Array.<ol.geom.Point>} points An array of points.
*/
ol.geom.MultiPoint.prototype.setPoints = function(points) {
this.setComponents(points);
};
/**
* Adds the given point to the list of points at the specified index.
*
* @param {ol.geom.Point} point A point to be added.
* @param {number} index The index where to add.
*/
ol.geom.MultiPoint.prototype.addPoint = function(point, index) {
this.addComponent(point, index);
};
/**
* Removes the given point from the list of points.
*
* @param {ol.geom.Point} point A point to be removed.
*/
ol.geom.MultiPoint.prototype.removePoint = function(point) {
this.removeComponent(point);
};

View File

@@ -1,163 +0,0 @@
goog.provide('ol.geom.Point');
goog.require('ol.geom.Geometry');
goog.require('ol.Projection');
goog.require('ol.coord.AccessorInterface');
goog.require('ol.base');
/**
* Creates ol.geom.Point objects.
*
* @export
* @extends {ol.geom.Geometry}
* @param {number} x X.
* @param {number} y Y.
* @param {number=} opt_z Z.
* @param {ol.Projection=} opt_projection Projection.
*
* @implements {ol.coord.AccessorInterface}
*
* @constructor
*/
ol.geom.Point = function(x, y, opt_z, opt_projection) {
/**
* @private
* @type {number}
*/
this.x_ = x;
/**
* @private
* @type {number}
*/
this.y_ = y;
/**
* @private
* @type {number|undefined}
*/
this.z_ = opt_z;
/**
* @private
* @type {ol.Projection}
*/
this.projection_ = goog.isDef(opt_projection) ? opt_projection : null;
};
goog.inherits(ol.geom.Point, ol.geom.Geometry);
/**
* @return {number} X.
*/
ol.geom.Point.prototype.getX = function() {
return this.x_;
};
/**
* @return {number} Y.
*/
ol.geom.Point.prototype.getY = function() {
return this.y_;
};
/**
* @return {number|undefined} Z.
*/
ol.geom.Point.prototype.getZ = function() {
return this.z_;
};
/**
* @return {ol.Projection|undefined} Projection.
*/
ol.geom.Point.prototype.getProjection = function() {
return this.projection_;
};
/**
* @param {ol.Projection} projection Projection.
*/
ol.geom.Point.prototype.setProjection = function(projection) {
this.projection_ = projection;
};
/**
* @param {number} x X.
*/
ol.geom.Point.prototype.setX = function(x) {
this.x_ = x;
};
/**
* @param {number} y Y.
*/
ol.geom.Point.prototype.setY = function(y) {
this.y_ = y;
};
/**
* @param {number|undefined} z Z.
*/
ol.geom.Point.prototype.setZ = function(z) {
this.z_ = z;
};
/**
* Transform this point to another coordinate reference system. This
* requires that this point has a projection set already (if not, an error
* will be thrown). Returns a new point object and does not modify this
* point.
*
* @param {string|!ol.Projection} proj The destination projection. Can be
* supplied as a projection instance of a string identifier.
* @returns {!ol.geom.Point} A new location.
*/
ol.geom.Point.prototype.transform = function(proj) {
if (goog.isString(proj)) {
proj = new ol.Projection(proj);
}
return this._transform(proj);
};
/**
* Transform this point to a new location given a projection object.
*
* @param {!ol.Projection} proj The destination projection.
* @returns {!ol.geom.Point}
* @private
*/
ol.geom.Point.prototype._transform = function(proj) {
var point = {'x': this.x_, 'y': this.y_};
var sourceProj = this.projection_;
if (!goog.isDefAndNotNull(sourceProj)) {
var msg = 'Cannot transform a point without a source projection.';
ol.error(msg);
}
ol.Projection.transform(point, sourceProj, proj);
return new ol.geom.Point(point['x'], point['y'], this.z_, proj);
};
/**
* Returns the centroid of the point.
*
* @returns {ol.geom.Point} The centroid of the point.
*/
ol.geom.Point.prototype.getCentroid = function() {
return new ol.geom.Point(this.x_, this.y_, this.z_, this.projection_);
};
/**
* Returns the area of the geometry whcih is always 0.
*
* @returns {number} The area of the point (always 0).
*/
ol.geom.Point.prototype.getArea = function() {
return 0;
};

View File

@@ -1,74 +0,0 @@
goog.provide('ol.layer.WMS');
goog.require('goog.Uri');
goog.require('ol.layer.TileLayer');
/**
* Class for WMS layers.
*
* @export
* @constructor
* @extends {ol.layer.TileLayer}
* @param {string} url The WMS URL.
* @param {Array.<string>} layers List of layers.
* @param {string|undefined} format Image format (e.g. "image/jpeg")
*/
ol.layer.WMS = function(url, layers, format) {
goog.base(this);
this.setUrl(url);
/**
* @private
* @type {Array.<string>}
*/
this.layers_ = layers;
/**
* @private
* @type {string|undefined}
*/
this.format_ = format;
};
goog.inherits(ol.layer.WMS, ol.layer.TileLayer);
/**
* @const
* @type {Object}
*/
ol.layer.WMS.prototype.DEFAULT_PARAMS = {
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"STYLES": "",
"FORMAT": "image/png"
};
/**
* @inheritDoc
*/
ol.layer.WMS.prototype.getTileUrl = function(x, y, z) {
var tileOrigin = this.getTileOrigin(),
tileOriginX = tileOrigin[0],
tileOriginY = tileOrigin[1];
var resolution = this.getResolutions()[z];
var tileWidth = this.tileWidth_ * resolution,
tileHeight = this.tileHeight_ * resolution;
var minX = tileOriginX + (x * tileWidth),
maxY = tileOriginY - (y * tileHeight),
maxX = minX + tileWidth,
minY = maxY - tileHeight;
var qd = new goog.Uri.QueryData();
qd.extend(this.DEFAULT_PARAMS);
qd.set('WIDTH', this.tileWidth_);
qd.set('HEIGHT', this.tileHeight_);
qd.set('BBOX', [minX, minY, maxX, maxY].join(','));
qd.set('LAYERS', [this.layers_].join(','));
// FIXME this requires a projection in the layer, which should
// not be required
qd.set('SRS', this.projection_.getCode());
var uri = new goog.Uri(this.getUrl());
uri.setQueryData(qd);
return uri.toString();
};