Introduced "ol.API" @define which will allow in future to compile HPI apps with the OL. Discussed in ol3-sprint mailing-list.

This commit is contained in:
Petr Pridal
2012-06-23 23:06:45 +02:00
parent b615eb94b7
commit 587512cac8
11 changed files with 49 additions and 41 deletions

View File

@@ -16,7 +16,8 @@
"define": {
// "goog.dom.ASSUME_STANDARDS_MODE": true,
// "goog.userAgent.ASSUME_MOBILE_WEBKIT": true,
"goog.DEBUG": false
"goog.DEBUG": false,
"ol.API" : true
},
"mode": "ADVANCED",

View File

@@ -39,11 +39,11 @@ ol.bounds = function(opt_arg){
maxY = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['minX', 'minY', 'maxX', 'maxY', 'projection']);
minX = opt_arg['minX'];
minY = opt_arg['minY'];
maxX = opt_arg['maxX'];
maxY = opt_arg['maxY'];
projection = ol.projection(opt_arg['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');

View File

@@ -31,9 +31,9 @@ ol.feature = function(opt_arg){
}
else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['geometry', 'properties', 'type']);
properties = opt_arg['properties'];
geometry = opt_arg['geometry'];
type = opt_arg['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');

View File

@@ -32,10 +32,10 @@ ol.geom.point = function(opt_arg){
projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
x = opt_arg['x'];
y = opt_arg['y'];
z = opt_arg['z'];
projection = opt_arg['projection'];
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');
}

View File

@@ -21,9 +21,9 @@ ol.layer.wms = function(opt_arg) {
if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['url', 'layers', 'format']);
url = opt_arg['url'];
layers = opt_arg['layers'];
format = opt_arg['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;

View File

@@ -18,7 +18,7 @@ ol.layer.xyz = function(opt_arg) {
var usage = 'ol.layer.xyz accepts an object with a "url" property';
if (goog.isObject(opt_arg)) {
url = opt_arg['url'];
url = ol.API ? opt_arg['url'] : opt_arg.url;
} else {
throw new Error(usage);
}

View File

@@ -44,10 +44,10 @@ ol.loc = function(opt_arg){
projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['projection', 'x', 'y', 'z']);
x = opt_arg['x'];
y = opt_arg['y'];
z = opt_arg['z'];
projection = opt_arg['projection'];
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);
}

View File

@@ -50,17 +50,17 @@ ol.map = function(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 = opt_arg['center'];
zoom = opt_arg['zoom'];
numZoomLevels = opt_arg['numZoomLevels'];
projection = opt_arg['projection'];
userProjection = opt_arg['userProjection'];
maxExtent = opt_arg['maxExtent'];
maxResolution = opt_arg['maxResolution'];
resolutions = opt_arg['resolutions'];
renderTo = opt_arg['renderTo'];
layers = opt_arg['layers'];
controls = opt_arg['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');

View File

@@ -39,11 +39,11 @@ ol.popup = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isObject(opt_arg)) {
map = opt_arg['map'];
anchor = opt_arg['anchor'];
placement = opt_arg['placement'];
content = opt_arg['content'];
template = opt_arg['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;
}
}

View File

@@ -34,13 +34,13 @@ ol.projection = function(opt_arg){
}
else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['code', 'maxExtent', 'units']);
if (goog.isString(opt_arg['code'])) {
code = opt_arg['code'];
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 = opt_arg['units'];
extent = opt_arg['maxExtent'];
units = ol.API ? opt_arg['units'] : opt_arg.units;
extent = ol.API ? opt_arg['maxExtent'] : opt_arg.maxExtent;
}
else {
throw new Error('ol.projection');

View File

@@ -12,12 +12,19 @@ ol.error = function(message) {
}
};
/**
* Compilation with public API, let's accept options from external world
* @define {boolean}
*/
ol.API = true;
/**
* @define {boolean}
*/
ol.error.VERBOSE_ERRORS = true;
/**
* Options passed in the API from external world are checked for wrong keys
* @define {boolean}
*/
ol.CHECK_KEYS = true;