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
+2 -1
View File
@@ -16,7 +16,8 @@
"define": { "define": {
// "goog.dom.ASSUME_STANDARDS_MODE": true, // "goog.dom.ASSUME_STANDARDS_MODE": true,
// "goog.userAgent.ASSUME_MOBILE_WEBKIT": true, // "goog.userAgent.ASSUME_MOBILE_WEBKIT": true,
"goog.DEBUG": false "goog.DEBUG": false,
"ol.API" : true
}, },
"mode": "ADVANCED", "mode": "ADVANCED",
+5 -5
View File
@@ -39,11 +39,11 @@ ol.bounds = function(opt_arg){
maxY = opt_arg[3]; maxY = opt_arg[3];
} else if (goog.isObject(opt_arg)) { } else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['minX', 'minY', 'maxX', 'maxY', 'projection']); ol.base.checkKeys(opt_arg, ['minX', 'minY', 'maxX', 'maxY', 'projection']);
minX = opt_arg['minX']; minX = ol.API ? opt_arg['minX'] : opt_arg.minX;
minY = opt_arg['minY']; minY = ol.API ? opt_arg['minY'] : opt_arg.minY;
maxX = opt_arg['maxX']; maxX = ol.API ? opt_arg['maxX'] : opt_arg.maxX;
maxY = opt_arg['maxY']; maxY = ol.API ? opt_arg['maxY'] : opt_arg.maxY;
projection = ol.projection(opt_arg['projection']); projection = ol.projection(ol.API ? opt_arg['projection'] : opt_arg.projection);
} }
else { else {
throw new Error('ol.bounds'); throw new Error('ol.bounds');
+3 -3
View File
@@ -31,9 +31,9 @@ ol.feature = function(opt_arg){
} }
else if (goog.isObject(opt_arg)) { else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['geometry', 'properties', 'type']); ol.base.checkKeys(opt_arg, ['geometry', 'properties', 'type']);
properties = opt_arg['properties']; properties = ol.API ? opt_arg['properties'] : opt_arg.properties;
geometry = opt_arg['geometry']; geometry = ol.API ? opt_arg['geometry'] : opt_arg.geometry;
type = opt_arg['type']; type = ol.API ? opt_arg['type'] : opt_arg.type;
} }
else { else {
throw new Error('ol.feature'); throw new Error('ol.feature');
+4 -4
View File
@@ -32,10 +32,10 @@ ol.geom.point = function(opt_arg){
projection = opt_arg[3]; projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) { } else if (goog.isObject(opt_arg)) {
x = opt_arg['x']; x = ol.API ? opt_arg['x'] : opt_arg.x;
y = opt_arg['y']; y = ol.API ? opt_arg['y'] : opt_arg.y;
z = opt_arg['z']; z = ol.API ? opt_arg['z'] : opt_arg.z;
projection = opt_arg['projection']; projection = ol.API ? opt_arg['projection'] : opt_arg.projection;
} else { } else {
throw new Error('ol.geom.point'); throw new Error('ol.geom.point');
} }
+3 -3
View File
@@ -21,9 +21,9 @@ ol.layer.wms = function(opt_arg) {
if (goog.isObject(opt_arg)) { if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['url', 'layers', 'format']); ol.base.checkKeys(opt_arg, ['url', 'layers', 'format']);
url = opt_arg['url']; url = ol.API ? opt_arg['url'] : opt_arg.url;
layers = opt_arg['layers']; layers = ol.API ? opt_arg['layers'] : opt_arg.layers;
format = opt_arg['format']; format = ol.API ? opt_arg['format'] : opt_arg.format;
} }
var msg; var msg;
+1 -1
View File
@@ -18,7 +18,7 @@ ol.layer.xyz = function(opt_arg) {
var usage = 'ol.layer.xyz accepts an object with a "url" property'; var usage = 'ol.layer.xyz accepts an object with a "url" property';
if (goog.isObject(opt_arg)) { if (goog.isObject(opt_arg)) {
url = opt_arg['url']; url = ol.API ? opt_arg['url'] : opt_arg.url;
} else { } else {
throw new Error(usage); throw new Error(usage);
} }
+4 -4
View File
@@ -44,10 +44,10 @@ ol.loc = function(opt_arg){
projection = opt_arg[3]; projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) { } else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['projection', 'x', 'y', 'z']); ol.base.checkKeys(opt_arg, ['projection', 'x', 'y', 'z']);
x = opt_arg['x']; x = ol.API ? opt_arg['x'] : opt_arg.x;
y = opt_arg['y']; y = ol.API ? opt_arg['y'] : opt_arg.y;
z = opt_arg['z']; z = ol.API ? opt_arg['z'] : opt_arg.z;
projection = opt_arg['projection']; projection = ol.API ? opt_arg['projection'] : opt_arg.projection;
} else { } else {
throw new Error(usage); throw new Error(usage);
} }
+11 -11
View File
@@ -50,17 +50,17 @@ ol.map = function(opt_arg) {
} }
else if (goog.isObject(opt_arg)) { else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['center', 'zoom', 'numZoomLevels', 'projection', 'userProjection', 'maxExtent', 'maxResolution', 'resolutions', 'renderTo', 'layers', 'controls']); ol.base.checkKeys(opt_arg, ['center', 'zoom', 'numZoomLevels', 'projection', 'userProjection', 'maxExtent', 'maxResolution', 'resolutions', 'renderTo', 'layers', 'controls']);
center = opt_arg['center']; center = ol.API ? opt_arg['center'] : opt_arg.center;
zoom = opt_arg['zoom']; zoom = ol.API ? opt_arg['zoom'] : opt_arg.zoom;
numZoomLevels = opt_arg['numZoomLevels']; numZoomLevels = ol.API ? opt_arg['numZoomLevels'] : opt_arg.numZoomLevels;
projection = opt_arg['projection']; projection = ol.API ? opt_arg['projection'] : opt_arg.projection;
userProjection = opt_arg['userProjection']; userProjection = ol.API ? opt_arg['userProjection'] : opt_arg.userProjection;
maxExtent = opt_arg['maxExtent']; maxExtent = ol.API ? opt_arg['maxExtent'] : opt_arg.maxExtent;
maxResolution = opt_arg['maxResolution']; maxResolution = ol.API ? opt_arg['maxResolution'] : opt_arg.maxResolution;
resolutions = opt_arg['resolutions']; resolutions = ol.API ? opt_arg['resolutions'] : opt_arg.resolutions;
renderTo = opt_arg['renderTo']; renderTo = ol.API ? opt_arg['renderTo'] : opt_arg.renderTo;
layers = opt_arg['layers']; layers = ol.API ? opt_arg['layers'] : opt_arg.layers;
controls = opt_arg['controls']; controls = ol.API ? opt_arg['controls'] : opt_arg.controls;
} }
else { else {
throw new Error('ol.map'); throw new Error('ol.map');
+5 -5
View File
@@ -39,11 +39,11 @@ ol.popup = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) { if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isObject(opt_arg)) { if (goog.isObject(opt_arg)) {
map = opt_arg['map']; map = ol.API ? opt_arg['map'] : opt_arg.map;
anchor = opt_arg['anchor']; anchor = ol.API ? opt_arg['anchor'] : opt_arg.anchor;
placement = opt_arg['placement']; placement = ol.API ? opt_arg['placement'] : opt_arg.placement;
content = opt_arg['content']; content = ol.API ? opt_arg['content'] : opt_arg.content;
template = opt_arg['template']; template = ol.API ? opt_arg['template'] : opt_arg.template;
} }
} }
+4 -4
View File
@@ -34,13 +34,13 @@ ol.projection = function(opt_arg){
} }
else if (goog.isObject(opt_arg)) { else if (goog.isObject(opt_arg)) {
ol.base.checkKeys(opt_arg, ['code', 'maxExtent', 'units']); ol.base.checkKeys(opt_arg, ['code', 'maxExtent', 'units']);
if (goog.isString(opt_arg['code'])) { if (goog.isString(ol.API ? opt_arg['code'] : opt_arg.code)) {
code = opt_arg['code']; code = ol.API ? opt_arg['code'] : opt_arg.code;
} else { } else {
throw new Error('Projection requires a string code.'); throw new Error('Projection requires a string code.');
} }
units = opt_arg['units']; units = ol.API ? opt_arg['units'] : opt_arg.units;
extent = opt_arg['maxExtent']; extent = ol.API ? opt_arg['maxExtent'] : opt_arg.maxExtent;
} }
else { else {
throw new Error('ol.projection'); throw new Error('ol.projection');
+7
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} * @define {boolean}
*/ */
ol.error.VERBOSE_ERRORS = true; ol.error.VERBOSE_ERRORS = true;
/** /**
* Options passed in the API from external world are checked for wrong keys
* @define {boolean} * @define {boolean}
*/ */
ol.CHECK_KEYS = true; ol.CHECK_KEYS = true;