Merge branch 'master' of github.com:openlayers/ol3 into vector
This commit is contained in:
@@ -93,7 +93,7 @@ goog.inherits(ol.Collection, ol.Object);
|
||||
* Remove all elements from the collection.
|
||||
*/
|
||||
ol.Collection.prototype.clear = function() {
|
||||
while (this[ol.CollectionProperty.LENGTH]) {
|
||||
while (this.getLength() > 0) {
|
||||
this.pop();
|
||||
}
|
||||
};
|
||||
@@ -187,7 +187,7 @@ ol.Collection.prototype.removeAt = function(index) {
|
||||
* @param {*} elem Element.
|
||||
*/
|
||||
ol.Collection.prototype.setAt = function(index, elem) {
|
||||
var n = this[ol.CollectionProperty.LENGTH];
|
||||
var n = this.getLength();
|
||||
if (index < n) {
|
||||
var prev = this.array_[index];
|
||||
this.array_[index] = elem;
|
||||
|
||||
@@ -39,6 +39,13 @@ ol.ObjectProperty = {
|
||||
*/
|
||||
ol.Object = function(opt_values) {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Object.<string, *>}
|
||||
*/
|
||||
this.values_ = {};
|
||||
|
||||
if (goog.isDef(opt_values)) {
|
||||
this.setValues(opt_values);
|
||||
}
|
||||
@@ -91,7 +98,8 @@ ol.Object.getAccessors = function(obj) {
|
||||
* @return {string} Changed name.
|
||||
*/
|
||||
ol.Object.getChangedEventType = function(key) {
|
||||
return ol.Object.changedEventTypeCache_[key] ||
|
||||
return ol.Object.changedEventTypeCache_.hasOwnProperty(key) ?
|
||||
ol.Object.changedEventTypeCache_[key] :
|
||||
(ol.Object.changedEventTypeCache_[key] = key.toLowerCase() + '_changed');
|
||||
};
|
||||
|
||||
@@ -101,7 +109,8 @@ ol.Object.getChangedEventType = function(key) {
|
||||
* @return {string} Getter name.
|
||||
*/
|
||||
ol.Object.getGetterName = function(key) {
|
||||
return ol.Object.getterNameCache_[key] ||
|
||||
return ol.Object.getterNameCache_.hasOwnProperty(key) ?
|
||||
ol.Object.getterNameCache_[key] :
|
||||
(ol.Object.getterNameCache_[key] = 'get' + ol.Object.capitalize(key));
|
||||
};
|
||||
|
||||
@@ -121,7 +130,8 @@ ol.Object.getListeners = function(obj) {
|
||||
* @return {string} Setter name.
|
||||
*/
|
||||
ol.Object.getSetterName = function(key) {
|
||||
return ol.Object.setterNameCache_[key] ||
|
||||
return ol.Object.setterNameCache_.hasOwnProperty(key) ?
|
||||
ol.Object.setterNameCache_[key] :
|
||||
(ol.Object.setterNameCache_[key] = 'set' + ol.Object.capitalize(key));
|
||||
};
|
||||
|
||||
@@ -161,20 +171,34 @@ ol.Object.prototype.changed = goog.nullFunction;
|
||||
* @return {*} Value.
|
||||
*/
|
||||
ol.Object.prototype.get = function(key) {
|
||||
var value;
|
||||
var accessors = ol.Object.getAccessors(this);
|
||||
if (goog.object.containsKey(accessors, key)) {
|
||||
if (accessors.hasOwnProperty(key)) {
|
||||
var accessor = accessors[key];
|
||||
var target = accessor.target;
|
||||
var targetKey = accessor.key;
|
||||
var getterName = ol.Object.getGetterName(targetKey);
|
||||
if (target[getterName]) {
|
||||
return target[getterName]();
|
||||
value = target[getterName]();
|
||||
} else {
|
||||
return target.get(targetKey);
|
||||
value = target.get(targetKey);
|
||||
}
|
||||
} else {
|
||||
return this[key];
|
||||
} else if (this.values_.hasOwnProperty(key)) {
|
||||
value = this.values_[key];
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of object property names.
|
||||
* @return {Array.<string>} List of property names.
|
||||
*/
|
||||
ol.Object.prototype.getKeys = function() {
|
||||
var keys = goog.object.getKeys(ol.Object.getAccessors(this)).concat(
|
||||
goog.object.getKeys(this.values_));
|
||||
goog.array.removeDuplicates(keys);
|
||||
return keys;
|
||||
};
|
||||
|
||||
|
||||
@@ -183,7 +207,7 @@ ol.Object.prototype.get = function(key) {
|
||||
*/
|
||||
ol.Object.prototype.notify = function(key) {
|
||||
var accessors = ol.Object.getAccessors(this);
|
||||
if (goog.object.containsKey(accessors, key)) {
|
||||
if (accessors.hasOwnProperty(key)) {
|
||||
var accessor = accessors[key];
|
||||
var target = accessor.target;
|
||||
var targetKey = accessor.key;
|
||||
@@ -211,7 +235,7 @@ ol.Object.prototype.notifyInternal_ = function(key) {
|
||||
*/
|
||||
ol.Object.prototype.set = function(key, value) {
|
||||
var accessors = ol.Object.getAccessors(this);
|
||||
if (goog.object.containsKey(accessors, key)) {
|
||||
if (accessors.hasOwnProperty(key)) {
|
||||
var accessor = accessors[key];
|
||||
var target = accessor.target;
|
||||
var targetKey = accessor.key;
|
||||
@@ -222,7 +246,7 @@ ol.Object.prototype.set = function(key, value) {
|
||||
target.set(targetKey, value);
|
||||
}
|
||||
} else {
|
||||
this[key] = value;
|
||||
this.values_[key] = value;
|
||||
this.notifyInternal_(key);
|
||||
}
|
||||
};
|
||||
@@ -232,14 +256,16 @@ ol.Object.prototype.set = function(key, value) {
|
||||
* @param {Object.<string, *>} options Options.
|
||||
*/
|
||||
ol.Object.prototype.setOptions = function(options) {
|
||||
goog.object.forEach(options, function(value, key) {
|
||||
var setterName = ol.Object.getSetterName(key);
|
||||
var key, value, setterName;
|
||||
for (key in options) {
|
||||
value = options[key];
|
||||
setterName = ol.Object.getSetterName(key);
|
||||
if (this[setterName]) {
|
||||
this[setterName](value);
|
||||
} else {
|
||||
this.set(key, value);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -261,7 +287,7 @@ ol.Object.prototype.unbind = function(key) {
|
||||
var value = this.get(key);
|
||||
var accessors = ol.Object.getAccessors(this);
|
||||
delete accessors[key];
|
||||
this[key] = value;
|
||||
this.values_[key] = value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -270,9 +296,7 @@ ol.Object.prototype.unbind = function(key) {
|
||||
* Removes all bindings.
|
||||
*/
|
||||
ol.Object.prototype.unbindAll = function() {
|
||||
var listeners = ol.Object.getListeners(this);
|
||||
var keys = goog.object.getKeys(listeners);
|
||||
goog.array.forEach(keys, function(key) {
|
||||
for (var key in ol.Object.getListeners(this)) {
|
||||
this.unbind(key);
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,17 +19,17 @@ ol.parser.ogc.WMSCapabilities_v1 = function() {
|
||||
this.readChildNodes(node, obj['service']);
|
||||
},
|
||||
'Name': function(node, obj) {
|
||||
obj.name = this.getChildValue(node);
|
||||
obj['name'] = this.getChildValue(node);
|
||||
},
|
||||
'Title': function(node, obj) {
|
||||
obj.title = this.getChildValue(node);
|
||||
obj['title'] = this.getChildValue(node);
|
||||
},
|
||||
'Abstract': function(node, obj) {
|
||||
obj['abstract'] = this.getChildValue(node);
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
var bbox = {};
|
||||
bbox.bbox = [
|
||||
bbox['bbox'] = [
|
||||
parseFloat(node.getAttribute('minx')),
|
||||
parseFloat(node.getAttribute('miny')),
|
||||
parseFloat(node.getAttribute('maxx')),
|
||||
@@ -40,96 +40,96 @@ ol.parser.ogc.WMSCapabilities_v1 = function() {
|
||||
y: parseFloat(node.getAttribute('resy'))
|
||||
};
|
||||
if (! (isNaN(res.x) && isNaN(res.y))) {
|
||||
bbox.res = res;
|
||||
bbox['res'] = res;
|
||||
}
|
||||
// return the bbox so that descendant classes can set the
|
||||
// CRS and SRS and add it to the obj
|
||||
return bbox;
|
||||
},
|
||||
'OnlineResource': function(node, obj) {
|
||||
obj.href = this.getAttributeNS(node, 'http://www.w3.org/1999/xlink',
|
||||
obj['href'] = this.getAttributeNS(node, 'http://www.w3.org/1999/xlink',
|
||||
'href');
|
||||
},
|
||||
'ContactInformation': function(node, obj) {
|
||||
obj.contactInformation = {};
|
||||
this.readChildNodes(node, obj.contactInformation);
|
||||
obj['contactInformation'] = {};
|
||||
this.readChildNodes(node, obj['contactInformation']);
|
||||
},
|
||||
'ContactPersonPrimary': function(node, obj) {
|
||||
obj.personPrimary = {};
|
||||
this.readChildNodes(node, obj.personPrimary);
|
||||
obj['personPrimary'] = {};
|
||||
this.readChildNodes(node, obj['personPrimary']);
|
||||
},
|
||||
'ContactPerson': function(node, obj) {
|
||||
obj.person = this.getChildValue(node);
|
||||
obj['person'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactOrganization': function(node, obj) {
|
||||
obj.organization = this.getChildValue(node);
|
||||
obj['organization'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactPosition': function(node, obj) {
|
||||
obj.position = this.getChildValue(node);
|
||||
obj['position'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactAddress': function(node, obj) {
|
||||
obj.contactAddress = {};
|
||||
this.readChildNodes(node, obj.contactAddress);
|
||||
obj['contactAddress'] = {};
|
||||
this.readChildNodes(node, obj['contactAddress']);
|
||||
},
|
||||
'AddressType': function(node, obj) {
|
||||
obj.type = this.getChildValue(node);
|
||||
obj['type'] = this.getChildValue(node);
|
||||
},
|
||||
'Address': function(node, obj) {
|
||||
obj.address = this.getChildValue(node);
|
||||
obj['address'] = this.getChildValue(node);
|
||||
},
|
||||
'City': function(node, obj) {
|
||||
obj.city = this.getChildValue(node);
|
||||
obj['city'] = this.getChildValue(node);
|
||||
},
|
||||
'StateOrProvince': function(node, obj) {
|
||||
obj.stateOrProvince = this.getChildValue(node);
|
||||
obj['stateOrProvince'] = this.getChildValue(node);
|
||||
},
|
||||
'PostCode': function(node, obj) {
|
||||
obj.postcode = this.getChildValue(node);
|
||||
obj['postcode'] = this.getChildValue(node);
|
||||
},
|
||||
'Country': function(node, obj) {
|
||||
obj.country = this.getChildValue(node);
|
||||
obj['country'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactVoiceTelephone': function(node, obj) {
|
||||
obj.phone = this.getChildValue(node);
|
||||
obj['phone'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactFacsimileTelephone': function(node, obj) {
|
||||
obj.fax = this.getChildValue(node);
|
||||
obj['fax'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactElectronicMailAddress': function(node, obj) {
|
||||
obj.email = this.getChildValue(node);
|
||||
obj['email'] = this.getChildValue(node);
|
||||
},
|
||||
'Fees': function(node, obj) {
|
||||
var fees = this.getChildValue(node);
|
||||
if (fees && fees.toLowerCase() != 'none') {
|
||||
obj.fees = fees;
|
||||
obj['fees'] = fees;
|
||||
}
|
||||
},
|
||||
'AccessConstraints': function(node, obj) {
|
||||
var constraints = this.getChildValue(node);
|
||||
if (constraints && constraints.toLowerCase() != 'none') {
|
||||
obj.accessConstraints = constraints;
|
||||
obj['accessConstraints'] = constraints;
|
||||
}
|
||||
},
|
||||
'Capability': function(node, obj) {
|
||||
obj.capability = {
|
||||
nestedLayers: [],
|
||||
layers: []
|
||||
};
|
||||
this.readChildNodes(node, obj.capability);
|
||||
obj['capability'] = {};
|
||||
obj['capability']['nestedLayers'] = [];
|
||||
obj['capability']['layers'] = [];
|
||||
this.readChildNodes(node, obj['capability']);
|
||||
},
|
||||
'Request': function(node, obj) {
|
||||
obj.request = {};
|
||||
this.readChildNodes(node, obj.request);
|
||||
obj['request'] = {};
|
||||
this.readChildNodes(node, obj['request']);
|
||||
},
|
||||
'GetCapabilities': function(node, obj) {
|
||||
obj.getcapabilities = {formats: []};
|
||||
this.readChildNodes(node, obj.getcapabilities);
|
||||
obj['getcapabilities'] = {};
|
||||
obj['getcapabilities']['formats'] = [];
|
||||
this.readChildNodes(node, obj['getcapabilities']);
|
||||
},
|
||||
'Format': function(node, obj) {
|
||||
if (goog.isArray(obj.formats)) {
|
||||
obj.formats.push(this.getChildValue(node));
|
||||
if (goog.isArray(obj['formats'])) {
|
||||
obj['formats'].push(this.getChildValue(node));
|
||||
} else {
|
||||
obj.format = this.getChildValue(node);
|
||||
obj['format'] = this.getChildValue(node);
|
||||
}
|
||||
},
|
||||
'DCPType': function(node, obj) {
|
||||
@@ -139,37 +139,32 @@ ol.parser.ogc.WMSCapabilities_v1 = function() {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Get': function(node, obj) {
|
||||
obj.get = {};
|
||||
this.readChildNodes(node, obj.get);
|
||||
// backwards compatibility
|
||||
if (!obj.href) {
|
||||
obj.href = obj.get.href;
|
||||
}
|
||||
obj['get'] = {};
|
||||
this.readChildNodes(node, obj['get']);
|
||||
},
|
||||
'Post': function(node, obj) {
|
||||
obj.post = {};
|
||||
this.readChildNodes(node, obj.post);
|
||||
// backwards compatibility
|
||||
if (!obj.href) {
|
||||
obj.href = obj.get.href;
|
||||
}
|
||||
obj['post'] = {};
|
||||
this.readChildNodes(node, obj['post']);
|
||||
},
|
||||
'GetMap': function(node, obj) {
|
||||
obj.getmap = {formats: []};
|
||||
this.readChildNodes(node, obj.getmap);
|
||||
obj['getmap'] = {};
|
||||
obj['getmap']['formats'] = [];
|
||||
this.readChildNodes(node, obj['getmap']);
|
||||
},
|
||||
'GetFeatureInfo': function(node, obj) {
|
||||
obj.getfeatureinfo = {formats: []};
|
||||
this.readChildNodes(node, obj.getfeatureinfo);
|
||||
obj['getfeatureinfo'] = {};
|
||||
obj['getfeatureinfo']['formats'] = [];
|
||||
this.readChildNodes(node, obj['getfeatureinfo']);
|
||||
},
|
||||
'Exception': function(node, obj) {
|
||||
obj.exception = {formats: []};
|
||||
this.readChildNodes(node, obj.exception);
|
||||
obj['exception'] = {};
|
||||
obj['exception']['formats'] = [];
|
||||
this.readChildNodes(node, obj['exception']);
|
||||
},
|
||||
'Layer': function(node, obj) {
|
||||
var parentLayer, capability;
|
||||
if (obj.capability) {
|
||||
capability = obj.capability;
|
||||
if (obj['capability']) {
|
||||
capability = obj['capability'];
|
||||
parentLayer = obj;
|
||||
} else {
|
||||
capability = obj;
|
||||
@@ -188,113 +183,113 @@ ol.parser.ogc.WMSCapabilities_v1 = function() {
|
||||
var fixedHeight = node.getAttribute('fixedHeight');
|
||||
var parent = parentLayer || {};
|
||||
var layer = {
|
||||
nestedLayers: [],
|
||||
styles: parentLayer ? [].concat(parentLayer.styles) : [],
|
||||
srs: {},
|
||||
metadataURLs: [],
|
||||
bbox: {},
|
||||
llbbox: parent.llbbox,
|
||||
dimensions: {},
|
||||
authorityURLs: {},
|
||||
identifiers: {},
|
||||
keywords: [],
|
||||
queryable: (queryable && queryable !== '') ?
|
||||
'nestedLayers': [],
|
||||
'styles': parentLayer ? [].concat(parentLayer['styles']) : [],
|
||||
'srs': {},
|
||||
'metadataURLs': [],
|
||||
'bbox': {},
|
||||
'llbbox': parent['llbbox'],
|
||||
'dimensions': {},
|
||||
'authorityURLs': {},
|
||||
'identifiers': {},
|
||||
'keywords': [],
|
||||
'queryable': (queryable && queryable !== '') ?
|
||||
(queryable === '1' || queryable === 'true') :
|
||||
(parent.queryable || false),
|
||||
cascaded: (cascaded !== null) ? parseInt(cascaded, 10) :
|
||||
(parent.cascaded || 0),
|
||||
opaque: opaque ?
|
||||
(parent['queryable'] || false),
|
||||
'cascaded': (cascaded !== null) ? parseInt(cascaded, 10) :
|
||||
(parent['cascaded'] || 0),
|
||||
'opaque': opaque ?
|
||||
(opaque === '1' || opaque === 'true') :
|
||||
(parent.opaque || false),
|
||||
noSubsets: (noSubsets !== null) ?
|
||||
(parent['opaque'] || false),
|
||||
'noSubsets': (noSubsets !== null) ?
|
||||
(noSubsets === '1' || noSubsets === 'true') :
|
||||
(parent.noSubsets || false),
|
||||
fixedWidth: (fixedWidth !== null) ?
|
||||
parseInt(fixedWidth, 10) : (parent.fixedWidth || 0),
|
||||
fixedHeight: (fixedHeight !== null) ?
|
||||
parseInt(fixedHeight, 10) : (parent.fixedHeight || 0),
|
||||
minScale: parent.minScale,
|
||||
maxScale: parent.maxScale,
|
||||
attribution: parent.attribution
|
||||
(parent['noSubsets'] || false),
|
||||
'fixedWidth': (fixedWidth !== null) ?
|
||||
parseInt(fixedWidth, 10) : (parent['fixedWidth'] || 0),
|
||||
'fixedHeight': (fixedHeight !== null) ?
|
||||
parseInt(fixedHeight, 10) : (parent['fixedHeight'] || 0),
|
||||
'minScale': parent['minScale'],
|
||||
'maxScale': parent['maxScale'],
|
||||
'attribution': parent['attribution']
|
||||
};
|
||||
if (parentLayer) {
|
||||
goog.object.extend(layer.srs, parent.srs);
|
||||
goog.object.extend(layer.bbox, parent.bbox);
|
||||
goog.object.extend(layer.dimensions, parent.dimensions);
|
||||
goog.object.extend(layer.authorityURLs, parent.authorityURLs);
|
||||
goog.object.extend(layer['srs'], parent['srs']);
|
||||
goog.object.extend(layer['bbox'], parent['bbox']);
|
||||
goog.object.extend(layer['dimensions'], parent['dimensions']);
|
||||
goog.object.extend(layer['authorityURLs'], parent['authorityURLs']);
|
||||
}
|
||||
obj.nestedLayers.push(layer);
|
||||
layer.capability = capability;
|
||||
obj['nestedLayers'].push(layer);
|
||||
layer['capability'] = capability;
|
||||
this.readChildNodes(node, layer);
|
||||
delete layer.capability;
|
||||
if (layer.name) {
|
||||
var parts = layer.name.split(':'),
|
||||
request = capability.request,
|
||||
gfi = request.getfeatureinfo;
|
||||
delete layer['capability'];
|
||||
if (layer['name']) {
|
||||
var parts = layer['name'].split(':'),
|
||||
request = capability['request'],
|
||||
gfi = request['getfeatureinfo'];
|
||||
if (parts.length > 0) {
|
||||
layer.prefix = parts[0];
|
||||
layer['prefix'] = parts[0];
|
||||
}
|
||||
capability.layers.push(layer);
|
||||
if (layer.formats === undefined) {
|
||||
layer.formats = request.getmap.formats;
|
||||
capability['layers'].push(layer);
|
||||
if (layer['formats'] === undefined) {
|
||||
layer['formats'] = request['getmap']['formats'];
|
||||
}
|
||||
if (layer.infoFormats === undefined && gfi) {
|
||||
layer.infoFormats = gfi.formats;
|
||||
if (layer['infoFormats'] === undefined && gfi) {
|
||||
layer['infoFormats'] = gfi['formats'];
|
||||
}
|
||||
}
|
||||
},
|
||||
'Attribution': function(node, obj) {
|
||||
obj.attribution = {};
|
||||
this.readChildNodes(node, obj.attribution);
|
||||
obj['attribution'] = {};
|
||||
this.readChildNodes(node, obj['attribution']);
|
||||
},
|
||||
'LogoURL': function(node, obj) {
|
||||
obj.logo = {
|
||||
width: node.getAttribute('width'),
|
||||
height: node.getAttribute('height')
|
||||
obj['logo'] = {
|
||||
'width': node.getAttribute('width'),
|
||||
'height': node.getAttribute('height')
|
||||
};
|
||||
this.readChildNodes(node, obj.logo);
|
||||
this.readChildNodes(node, obj['logo']);
|
||||
},
|
||||
'Style': function(node, obj) {
|
||||
var style = {};
|
||||
obj.styles.push(style);
|
||||
obj['styles'].push(style);
|
||||
this.readChildNodes(node, style);
|
||||
},
|
||||
'LegendURL': function(node, obj) {
|
||||
var legend = {
|
||||
width: node.getAttribute('width'),
|
||||
height: node.getAttribute('height')
|
||||
'width': node.getAttribute('width'),
|
||||
'height': node.getAttribute('height')
|
||||
};
|
||||
obj.legend = legend;
|
||||
obj['legend'] = legend;
|
||||
this.readChildNodes(node, legend);
|
||||
},
|
||||
'MetadataURL': function(node, obj) {
|
||||
var metadataURL = {type: node.getAttribute('type')};
|
||||
obj.metadataURLs.push(metadataURL);
|
||||
var metadataURL = {'type': node.getAttribute('type')};
|
||||
obj['metadataURLs'].push(metadataURL);
|
||||
this.readChildNodes(node, metadataURL);
|
||||
},
|
||||
'DataURL': function(node, obj) {
|
||||
obj.dataURL = {};
|
||||
this.readChildNodes(node, obj.dataURL);
|
||||
obj['dataURL'] = {};
|
||||
this.readChildNodes(node, obj['dataURL']);
|
||||
},
|
||||
'FeatureListURL': function(node, obj) {
|
||||
obj.featureListURL = {};
|
||||
this.readChildNodes(node, obj.featureListURL);
|
||||
obj['featureListURL'] = {};
|
||||
this.readChildNodes(node, obj['featureListURL']);
|
||||
},
|
||||
'AuthorityURL': function(node, obj) {
|
||||
var name = node.getAttribute('name');
|
||||
var authority = {};
|
||||
this.readChildNodes(node, authority);
|
||||
obj.authorityURLs[name] = authority.href;
|
||||
obj['authorityURLs'][name] = authority['href'];
|
||||
},
|
||||
'Identifier': function(node, obj) {
|
||||
var authority = node.getAttribute('authority');
|
||||
obj.identifiers[authority] = this.getChildValue(node);
|
||||
obj['identifiers'][authority] = this.getChildValue(node);
|
||||
},
|
||||
'KeywordList': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'SRS': function(node, obj) {
|
||||
obj.srs[this.getChildValue(node)] = true;
|
||||
obj['srs'][this.getChildValue(node)] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,37 +15,37 @@ ol.parser.ogc.WMSCapabilities_v1_1 = function() {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Keyword': function(node, obj) {
|
||||
if (obj.keywords) {
|
||||
obj.keywords.push({value: this.getChildValue(node)});
|
||||
if (obj['keywords']) {
|
||||
obj['keywords'].push({'value': this.getChildValue(node)});
|
||||
}
|
||||
},
|
||||
'DescribeLayer': function(node, obj) {
|
||||
obj.describelayer = {formats: []};
|
||||
this.readChildNodes(node, obj.describelayer);
|
||||
obj['describelayer'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['describelayer']);
|
||||
},
|
||||
'GetLegendGraphic': function(node, obj) {
|
||||
obj.getlegendgraphic = {formats: []};
|
||||
this.readChildNodes(node, obj.getlegendgraphic);
|
||||
obj['getlegendgraphic'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['getlegendgraphic']);
|
||||
},
|
||||
'GetStyles': function(node, obj) {
|
||||
obj.getstyles = {formats: []};
|
||||
this.readChildNodes(node, obj.getstyles);
|
||||
obj['getstyles'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['getstyles']);
|
||||
},
|
||||
'PutStyles': function(node, obj) {
|
||||
obj.putstyles = {formats: []};
|
||||
this.readChildNodes(node, obj.putstyles);
|
||||
obj['putstyles'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['putstyles']);
|
||||
},
|
||||
'UserDefinedSymbolization': function(node, obj) {
|
||||
var userSymbols = {
|
||||
supportSLD: parseInt(node.getAttribute('SupportSLD'), 10) == 1,
|
||||
userLayer: parseInt(node.getAttribute('UserLayer'), 10) == 1,
|
||||
userStyle: parseInt(node.getAttribute('UserStyle'), 10) == 1,
|
||||
remoteWFS: parseInt(node.getAttribute('RemoteWFS'), 10) == 1
|
||||
'supportSLD': parseInt(node.getAttribute('SupportSLD'), 10) == 1,
|
||||
'userLayer': parseInt(node.getAttribute('UserLayer'), 10) == 1,
|
||||
'userStyle': parseInt(node.getAttribute('UserStyle'), 10) == 1,
|
||||
'remoteWFS': parseInt(node.getAttribute('RemoteWFS'), 10) == 1
|
||||
};
|
||||
obj.userSymbols = userSymbols;
|
||||
obj['userSymbols'] = userSymbols;
|
||||
},
|
||||
'LatLonBoundingBox': function(node, obj) {
|
||||
obj.llbbox = [
|
||||
obj['llbbox'] = [
|
||||
parseFloat(node.getAttribute('minx')),
|
||||
parseFloat(node.getAttribute('miny')),
|
||||
parseFloat(node.getAttribute('maxx')),
|
||||
@@ -54,8 +54,8 @@ ol.parser.ogc.WMSCapabilities_v1_1 = function() {
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
var bbox = bboxreader.apply(this, arguments);
|
||||
bbox.srs = node.getAttribute('SRS');
|
||||
obj.bbox[bbox.srs] = bbox;
|
||||
bbox['srs'] = node.getAttribute('SRS');
|
||||
obj['bbox'][bbox['srs']] = bbox;
|
||||
},
|
||||
'ScaleHint': function(node, obj) {
|
||||
var min = parseFloat(node.getAttribute('min'));
|
||||
@@ -64,33 +64,33 @@ ol.parser.ogc.WMSCapabilities_v1_1 = function() {
|
||||
var dpi = (25.4 / 0.28);
|
||||
var ipm = 39.37;
|
||||
if (min !== 0) {
|
||||
obj.maxScale = parseFloat((min / rad2) * ipm * dpi);
|
||||
obj['maxScale'] = parseFloat((min / rad2) * ipm * dpi);
|
||||
}
|
||||
if (max != Number.POSITIVE_INFINITY) {
|
||||
obj.minScale = parseFloat((max / rad2) * ipm * dpi);
|
||||
obj['minScale'] = parseFloat((max / rad2) * ipm * dpi);
|
||||
}
|
||||
},
|
||||
'Dimension': function(node, obj) {
|
||||
var name = node.getAttribute('name').toLowerCase();
|
||||
var dim = {
|
||||
name: name,
|
||||
units: node.getAttribute('units'),
|
||||
unitsymbol: node.getAttribute('unitSymbol')
|
||||
'name': name,
|
||||
'units': node.getAttribute('units'),
|
||||
'unitsymbol': node.getAttribute('unitSymbol')
|
||||
};
|
||||
obj.dimensions[dim.name] = dim;
|
||||
obj['dimensions'][dim.name] = dim;
|
||||
},
|
||||
'Extent': function(node, obj) {
|
||||
var name = node.getAttribute('name').toLowerCase();
|
||||
if (name in obj['dimensions']) {
|
||||
var extent = obj.dimensions[name];
|
||||
extent.nearestVal =
|
||||
var extent = obj['dimensions'][name];
|
||||
extent['nearestVal'] =
|
||||
node.getAttribute('nearestValue') === '1';
|
||||
extent.multipleVal =
|
||||
extent['multipleVal'] =
|
||||
node.getAttribute('multipleValues') === '1';
|
||||
extent.current = node.getAttribute('current') === '1';
|
||||
extent['current'] = node.getAttribute('current') === '1';
|
||||
extent['default'] = node.getAttribute('default') || '';
|
||||
var values = this.getChildValue(node);
|
||||
extent.values = values.split(',');
|
||||
extent['values'] = values.split(',');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ ol.parser.ogc.WMSCapabilities_v1_1_0 = function() {
|
||||
var srs = this.getChildValue(node);
|
||||
var values = srs.split(/ +/);
|
||||
for (var i = 0, len = values.length; i < len; i++) {
|
||||
obj.srs[values[i]] = true;
|
||||
obj['srs'][values[i]] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ ol.parser.ogc.WMSCapabilities_v1_1_1 = function() {
|
||||
this.version = '1.1.1';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'SRS': function(node, obj) {
|
||||
obj.srs[this.getChildValue(node)] = true;
|
||||
obj['srs'][this.getChildValue(node)] = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,11 +12,11 @@ ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC = function() {
|
||||
this.profile = 'WMSC';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'VendorSpecificCapabilities': function(node, obj) {
|
||||
obj.vendorSpecific = {tileSets: []};
|
||||
this.readChildNodes(node, obj.vendorSpecific);
|
||||
obj['vendorSpecific'] = {'tileSets': []};
|
||||
this.readChildNodes(node, obj['vendorSpecific']);
|
||||
},
|
||||
'TileSet': function(node, vendorSpecific) {
|
||||
var tileset = {srs: {}, bbox: {}, resolutions: []};
|
||||
var tileset = {'srs': {}, 'bbox': {}, 'resolutions': []};
|
||||
this.readChildNodes(node, tileset);
|
||||
vendorSpecific.tileSets.push(tileset);
|
||||
},
|
||||
@@ -24,21 +24,21 @@ ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC = function() {
|
||||
var res = this.getChildValue(node).split(' ');
|
||||
for (var i = 0, len = res.length; i < len; i++) {
|
||||
if (res[i] !== '') {
|
||||
tileset.resolutions.push(parseFloat(res[i]));
|
||||
tileset['resolutions'].push(parseFloat(res[i]));
|
||||
}
|
||||
}
|
||||
},
|
||||
'Width': function(node, tileset) {
|
||||
tileset.width = parseInt(this.getChildValue(node), 10);
|
||||
tileset['width'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'Height': function(node, tileset) {
|
||||
tileset.height = parseInt(this.getChildValue(node), 10);
|
||||
tileset['height'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'Layers': function(node, tileset) {
|
||||
tileset.layers = this.getChildValue(node);
|
||||
tileset['layers'] = this.getChildValue(node);
|
||||
},
|
||||
'Styles': function(node, tileset) {
|
||||
tileset.styles = this.getChildValue(node);
|
||||
tileset['styles'] = this.getChildValue(node);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -15,18 +15,18 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'LayerLimit': function(node, obj) {
|
||||
obj.layerLimit = parseInt(this.getChildValue(node), 10);
|
||||
obj['layerLimit'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'MaxWidth': function(node, obj) {
|
||||
obj.maxWidth = parseInt(this.getChildValue(node), 10);
|
||||
obj['maxWidth'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'MaxHeight': function(node, obj) {
|
||||
obj.maxHeight = parseInt(this.getChildValue(node), 10);
|
||||
obj['maxHeight'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
var bbox = bboxreader.apply(this, arguments);
|
||||
bbox.srs = node.getAttribute('CRS');
|
||||
obj.bbox[bbox.srs] = bbox;
|
||||
bbox['srs'] = node.getAttribute('CRS');
|
||||
obj['bbox'][bbox['srs']] = bbox;
|
||||
},
|
||||
'CRS': function(node, obj) {
|
||||
// CRS is the synonym of SRS
|
||||
@@ -34,8 +34,8 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
|
||||
},
|
||||
'EX_GeographicBoundingBox': function(node, obj) {
|
||||
// replacement of LatLonBoundingBox
|
||||
obj.llbbox = [];
|
||||
this.readChildNodes(node, obj.llbbox);
|
||||
obj['llbbox'] = [];
|
||||
this.readChildNodes(node, obj['llbbox']);
|
||||
},
|
||||
'westBoundLongitude': function(node, obj) {
|
||||
obj[0] = this.getChildValue(node);
|
||||
@@ -50,10 +50,10 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
|
||||
obj[3] = this.getChildValue(node);
|
||||
},
|
||||
'MinScaleDenominator': function(node, obj) {
|
||||
obj.maxScale = parseFloat(this.getChildValue(node)).toPrecision(16);
|
||||
obj['maxScale'] = parseFloat(this.getChildValue(node)).toPrecision(16);
|
||||
},
|
||||
'MaxScaleDenominator': function(node, obj) {
|
||||
obj.minScale = parseFloat(this.getChildValue(node)).toPrecision(16);
|
||||
obj['minScale'] = parseFloat(this.getChildValue(node)).toPrecision(16);
|
||||
},
|
||||
'Dimension': function(node, obj) {
|
||||
// dimension has extra attributes: default, multipleValues,
|
||||
@@ -61,27 +61,27 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
|
||||
// also contains the values.
|
||||
var name = node.getAttribute('name').toLowerCase();
|
||||
var dim = {
|
||||
name: name,
|
||||
units: node.getAttribute('units'),
|
||||
unitsymbol: node.getAttribute('unitSymbol'),
|
||||
nearestVal: node.getAttribute('nearestValue') === '1',
|
||||
multipleVal: node.getAttribute('multipleValues') === '1',
|
||||
'name': name,
|
||||
'units': node.getAttribute('units'),
|
||||
'unitsymbol': node.getAttribute('unitSymbol'),
|
||||
'nearestVal': node.getAttribute('nearestValue') === '1',
|
||||
'multipleVal': node.getAttribute('multipleValues') === '1',
|
||||
'default': node.getAttribute('default') || '',
|
||||
current: node.getAttribute('current') === '1',
|
||||
values: this.getChildValue(node).split(',')
|
||||
'current': node.getAttribute('current') === '1',
|
||||
'values': this.getChildValue(node).split(',')
|
||||
};
|
||||
// Theoretically there can be more dimensions with the same
|
||||
// name, but with a different unit. Until we meet such a case,
|
||||
// let's just keep the same structure as the WMS 1.1
|
||||
// GetCapabilities parser uses. We will store the last
|
||||
// one encountered.
|
||||
obj.dimensions[dim.name] = dim;
|
||||
obj['dimensions'][dim['name']] = dim;
|
||||
},
|
||||
'Keyword': function(node, obj) {
|
||||
var keyword = {value: this.getChildValue(node),
|
||||
vocabulary: node.getAttribute('vocabulary')};
|
||||
if (obj.keywords) {
|
||||
obj.keywords.push(keyword);
|
||||
var keyword = {'value': this.getChildValue(node),
|
||||
'vocabulary': node.getAttribute('vocabulary')};
|
||||
if (obj['keywords']) {
|
||||
obj['keywords'].push(keyword);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -91,9 +91,9 @@ ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
|
||||
readers.UserDefinedSymbolization.apply(this, arguments);
|
||||
// add the two extra attributes
|
||||
var value = node.getAttribute('InlineFeature');
|
||||
obj['userSymbols'].inlineFeature = parseInt(value, 10) == 1;
|
||||
obj['userSymbols']['inlineFeature'] = parseInt(value, 10) == 1;
|
||||
value = node.getAttribute('RemoteWCS');
|
||||
obj['userSymbols'].remoteWCS = parseInt(value, 10) == 1;
|
||||
obj['userSymbols']['remoteWCS'] = parseInt(value, 10) == 1;
|
||||
},
|
||||
'DescribeLayer': function(node, obj) {
|
||||
var readers = this.readers['http://www.opengis.net/wms'];
|
||||
|
||||
@@ -129,30 +129,11 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
var tilesToDrawByZ = {};
|
||||
tilesToDrawByZ[z] = {};
|
||||
|
||||
var findInterimTiles = function(z, tileRange) {
|
||||
// FIXME this could be more efficient about filling partial holes
|
||||
var fullyCovered = true;
|
||||
var tile, tileCoord, tileCoordKey, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tileCoordKey = tileCoord.toString();
|
||||
if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) {
|
||||
return;
|
||||
}
|
||||
tile = tileSource.getTile(tileCoord);
|
||||
if (!goog.isNull(tile) && tile.getState() == ol.TileState.LOADED) {
|
||||
if (!tilesToDrawByZ[z]) {
|
||||
tilesToDrawByZ[z] = {};
|
||||
}
|
||||
tilesToDrawByZ[z][tileCoordKey] = tile;
|
||||
} else {
|
||||
fullyCovered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullyCovered;
|
||||
};
|
||||
function isLoaded(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() == ol.TileState.LOADED;
|
||||
}
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, isLoaded);
|
||||
|
||||
var allTilesLoaded = true;
|
||||
var tile, tileCenter, tileCoord, tileState, x, y;
|
||||
@@ -180,7 +161,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
}
|
||||
|
||||
allTilesLoaded = false;
|
||||
tileGrid.forEachTileCoordParentTileRange(tileCoord, findInterimTiles);
|
||||
tileGrid.forEachTileCoordParentTileRange(tileCoord, findLoadedTiles);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,30 +93,11 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
var tilesToDrawByZ = {};
|
||||
tilesToDrawByZ[z] = {};
|
||||
|
||||
var findInterimTiles = function(z, tileRange) {
|
||||
// FIXME this could be more efficient about filling partial holes
|
||||
var fullyCovered = true;
|
||||
var tile, tileCoord, tileCoordKey, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tileCoordKey = tileCoord.toString();
|
||||
if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) {
|
||||
return;
|
||||
}
|
||||
tile = tileSource.getTile(tileCoord);
|
||||
if (!goog.isNull(tile) && tile.getState() == ol.TileState.LOADED) {
|
||||
if (!tilesToDrawByZ[z]) {
|
||||
tilesToDrawByZ[z] = {};
|
||||
}
|
||||
tilesToDrawByZ[z][tileCoordKey] = tile;
|
||||
} else {
|
||||
fullyCovered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullyCovered;
|
||||
};
|
||||
function isLoaded(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() == ol.TileState.LOADED;
|
||||
}
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, isLoaded);
|
||||
|
||||
var allTilesLoaded = true;
|
||||
var tile, tileCenter, tileCoord, tileState, x, y;
|
||||
@@ -144,7 +125,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
}
|
||||
|
||||
allTilesLoaded = false;
|
||||
tileGrid.forEachTileCoordParentTileRange(tileCoord, findInterimTiles);
|
||||
tileGrid.forEachTileCoordParentTileRange(tileCoord, findLoadedTiles);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -365,32 +365,12 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
var tilesToDrawByZ = {};
|
||||
tilesToDrawByZ[z] = {};
|
||||
|
||||
var findInterimTiles = function(z, tileRange) {
|
||||
// FIXME this could be more efficient about filling partial holes
|
||||
var fullyCovered = true;
|
||||
var tile, tileCoord, tileCoordKey, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tileCoordKey = tileCoord.toString();
|
||||
if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) {
|
||||
return;
|
||||
}
|
||||
tile = tileSource.getTile(tileCoord);
|
||||
if (!goog.isNull(tile) &&
|
||||
tile.getState() == ol.TileState.LOADED &&
|
||||
mapRenderer.isTileTextureLoaded(tile)) {
|
||||
if (!tilesToDrawByZ[z]) {
|
||||
tilesToDrawByZ[z] = {};
|
||||
}
|
||||
tilesToDrawByZ[z][tileCoordKey] = tile;
|
||||
} else {
|
||||
fullyCovered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullyCovered;
|
||||
};
|
||||
function isLoaded(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() == ol.TileState.LOADED &&
|
||||
mapRenderer.isTileTextureLoaded(tile);
|
||||
}
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, isLoaded);
|
||||
|
||||
var tilesToLoad = new goog.structs.PriorityQueue();
|
||||
|
||||
@@ -428,7 +408,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
}
|
||||
|
||||
allTilesLoaded = false;
|
||||
tileGrid.forEachTileCoordParentTileRange(tileCoord, findInterimTiles);
|
||||
tileGrid.forEachTileCoordParentTileRange(tileCoord, findLoadedTiles);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,46 @@ ol.source.TileSource.prototype.canExpireCache = goog.functions.FALSE;
|
||||
ol.source.TileSource.prototype.expireCache = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Look for loaded tiles over a given tile range and zoom level. Adds
|
||||
* properties to the provided lookup representing key/tile pairs for already
|
||||
* loaded tiles.
|
||||
*
|
||||
* @param {Object.<number, Object.<string, ol.Tile>>} loadedTilesByZ A lookup of
|
||||
* loaded tiles by zoom level.
|
||||
* @param {function(ol.Tile): boolean} isLoaded A function to determine if a
|
||||
* tile is fully loaded.
|
||||
* @param {number} z Zoom level.
|
||||
* @param {ol.TileRange} tileRange Tile range.
|
||||
* @return {boolean} The tile range is fully covered with loaded tiles.
|
||||
*/
|
||||
ol.source.TileSource.prototype.findLoadedTiles = function(loadedTilesByZ,
|
||||
isLoaded, z, tileRange) {
|
||||
// FIXME this could be more efficient about filling partial holes
|
||||
var fullyCovered = true;
|
||||
var tile, tileCoord, tileCoordKey, x, y;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
tileCoord = new ol.TileCoord(z, x, y);
|
||||
tileCoordKey = tileCoord.toString();
|
||||
if (loadedTilesByZ[z] && loadedTilesByZ[z][tileCoordKey]) {
|
||||
continue;
|
||||
}
|
||||
tile = this.getTile(tileCoord);
|
||||
if (isLoaded(tile)) {
|
||||
if (!loadedTilesByZ[z]) {
|
||||
loadedTilesByZ[z] = {};
|
||||
}
|
||||
loadedTilesByZ[z][tileCoordKey] = tile;
|
||||
} else {
|
||||
fullyCovered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fullyCovered;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,8 @@ ol.ViewHint = {
|
||||
*/
|
||||
ol.View = function() {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
|
||||
Reference in New Issue
Block a user