Pass bounds spec.
This commit is contained in:
@@ -0,0 +1,135 @@
|
|||||||
|
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;
|
||||||
|
var projection;
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
minX = opt_arg['minX'];
|
||||||
|
minY = opt_arg['minY'];
|
||||||
|
maxX = opt_arg['maxX'];
|
||||||
|
maxY = opt_arg['maxY'];
|
||||||
|
projection = ol.projection(opt_arg['projection']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('ol.bounds');
|
||||||
|
}
|
||||||
|
|
||||||
|
var bounds = new ol.Bounds();
|
||||||
|
bounds.setMinX(minX);
|
||||||
|
bounds.setMinY(minY);
|
||||||
|
bounds.setMaxX(maxX);
|
||||||
|
bounds.setMaxY(maxY);
|
||||||
|
bounds.setProjection(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)) {
|
||||||
|
return this.setProjection(opt_arg);
|
||||||
|
}
|
||||||
|
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)) {
|
||||||
|
return this.setMinX(opt_arg);
|
||||||
|
}
|
||||||
|
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)) {
|
||||||
|
return this.setMinY(opt_arg);
|
||||||
|
}
|
||||||
|
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)) {
|
||||||
|
return this.setMaxX(opt_arg);
|
||||||
|
}
|
||||||
|
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)) {
|
||||||
|
return this.setMaxY(opt_arg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.getMaxY();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
goog.provide("ol");
|
goog.provide("ol");
|
||||||
|
goog.require('ol.bounds');
|
||||||
goog.require("ol.map");
|
goog.require("ol.map");
|
||||||
goog.require("ol.loc");
|
goog.require("ol.loc");
|
||||||
goog.require("ol.projection");
|
goog.require("ol.projection");
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
goog.provide('ol.Bounds');
|
||||||
|
|
||||||
|
goog.require('ol.Projection');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {number} minX Minimum X.
|
||||||
|
* @param {number} minY Minimum Y.
|
||||||
|
* @param {number} maxX Maximum X.
|
||||||
|
* @param {number} maxY Maximum Y.
|
||||||
|
* @param {ol.Projection=} opt_projection Projection.
|
||||||
|
*/
|
||||||
|
ol.Bounds = function(minX, minY, maxX, maxY, opt_projection) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.minX_ = minX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.minY_ = minY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.minX_ = minX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.minY_ = minY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Projection|undefined}
|
||||||
|
*/
|
||||||
|
this.projection_ = opt_projection;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Minimun X.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.getMinX = function() {
|
||||||
|
return this.minX_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Minimun Y.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.getMinY = function() {
|
||||||
|
return this.minY_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Maximun X.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.getMaxX = function() {
|
||||||
|
return this.maxX_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} Maximun Y.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.getMaxY = function() {
|
||||||
|
return this.maxY_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.Projection|undefined} Projection.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.getProjection = function() {
|
||||||
|
return this.projection_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} minX Minimum X.
|
||||||
|
* @return {ol.Bounds} This.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.setMinX = function(minX) {
|
||||||
|
this.minX_ = minX;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} minY Minimum Y.
|
||||||
|
* @return {ol.Bounds} This.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.setMinY = function(minY) {
|
||||||
|
this.minY_ = minY;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} maxX Maximum X.
|
||||||
|
* @return {ol.Bounds} This.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.setMaxX = function(maxX) {
|
||||||
|
this.maxX_ = maxX;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} maxY Maximum Y.
|
||||||
|
* @return {ol.Bounds} This.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.setMaxY = function(maxY) {
|
||||||
|
this.maxY_ = maxY;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Projection|undefined} projection Projection.
|
||||||
|
* @return {ol.Bounds} This.
|
||||||
|
*/
|
||||||
|
ol.Bounds.prototype.setProjection = function(projection) {
|
||||||
|
this.projection_ = projection;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user