Merge branch 'master' of github.com:openlayers/ol3 into vector
This commit is contained in:
@@ -34,6 +34,54 @@ describe('ol.Object', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#get()', function() {
|
||||
|
||||
it('does not return values that are not explicitly set', function() {
|
||||
var o = new ol.Object();
|
||||
expect(o.get('constructor')).toBeUndefined();
|
||||
expect(o.get('hasOwnProperty')).toBeUndefined();
|
||||
expect(o.get('isPrototypeOf')).toBeUndefined();
|
||||
expect(o.get('propertyIsEnumerable')).toBeUndefined();
|
||||
expect(o.get('toLocaleString')).toBeUndefined();
|
||||
expect(o.get('toString')).toBeUndefined();
|
||||
expect(o.get('valueOf')).toBeUndefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#set()', function() {
|
||||
it('can be used with arbitrary names', function() {
|
||||
var o = new ol.Object();
|
||||
|
||||
o.set('set', 'sat');
|
||||
expect(o.get('set')).toBe('sat');
|
||||
|
||||
o.set('get', 'got');
|
||||
expect(o.get('get')).toBe('got');
|
||||
|
||||
o.set('toString', 'string');
|
||||
expect(o.get('toString')).toBe('string');
|
||||
expect(typeof o.toString).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getKeys()', function() {
|
||||
|
||||
it('returns property names set at construction', function() {
|
||||
var o = new ol.Object({
|
||||
prop1: 'val1',
|
||||
prop2: 'val2',
|
||||
toString: 'string',
|
||||
get: 'foo'
|
||||
});
|
||||
|
||||
var keys = o.getKeys();
|
||||
expect(keys.length).toBe(4);
|
||||
expect(keys.sort()).toEqual(['get', 'prop1', 'prop2', 'toString']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('setValues', function() {
|
||||
|
||||
it('sets multiple values at once', function() {
|
||||
@@ -43,6 +91,9 @@ describe('ol.Object', function() {
|
||||
});
|
||||
expect(o.get('k1')).toEqual(1);
|
||||
expect(o.get('k2')).toEqual(2);
|
||||
|
||||
var keys = o.getKeys().sort();
|
||||
expect(keys).toEqual(['k1', 'k2']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -99,6 +150,9 @@ describe('ol.Object', function() {
|
||||
it('dispatches events to object', function() {
|
||||
o.set('k', 1);
|
||||
expect(listener1).toHaveBeenCalled();
|
||||
|
||||
expect(o.getKeys()).toEqual(['k']);
|
||||
expect(o2.getKeys()).toEqual(['k']);
|
||||
});
|
||||
|
||||
it('dispatches generic change events to object', function() {
|
||||
@@ -114,6 +168,9 @@ describe('ol.Object', function() {
|
||||
it('dispatches events to object bound to', function() {
|
||||
o2.set('k', 2);
|
||||
expect(listener1).toHaveBeenCalled();
|
||||
|
||||
expect(o.getKeys()).toEqual(['k']);
|
||||
expect(o2.getKeys()).toEqual(['k']);
|
||||
});
|
||||
|
||||
it('dispatches generic change events to object bound to', function() {
|
||||
@@ -137,6 +194,9 @@ describe('ol.Object', function() {
|
||||
o2.bindTo('k', o);
|
||||
expect(o.get('k')).toEqual(1);
|
||||
expect(o2.get('k')).toEqual(1);
|
||||
|
||||
expect(o.getKeys()).toEqual(['k']);
|
||||
expect(o2.getKeys()).toEqual(['k']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -147,6 +207,9 @@ describe('ol.Object', function() {
|
||||
o.set('k', 1);
|
||||
expect(o.get('k')).toEqual(1);
|
||||
expect(o2.get('k')).toEqual(1);
|
||||
|
||||
expect(o.getKeys()).toEqual(['k']);
|
||||
expect(o2.getKeys()).toEqual(['k']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -239,6 +302,9 @@ describe('ol.Object', function() {
|
||||
expect(o2.get('k1')).toBeUndefined();
|
||||
expect(listener1).toHaveBeenCalled();
|
||||
expect(listener2).toHaveBeenCalled();
|
||||
|
||||
expect(o.getKeys()).toEqual(['k1']);
|
||||
expect(o2.getKeys()).toEqual(['k2']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -257,6 +323,10 @@ describe('ol.Object', function() {
|
||||
expect(o.get('k1')).toEqual(1);
|
||||
expect(o2.get('k2')).toEqual(1);
|
||||
expect(o3.get('k3')).toEqual(1);
|
||||
|
||||
expect(o.getKeys()).toEqual(['k1']);
|
||||
expect(o2.getKeys()).toEqual(['k2']);
|
||||
expect(o3.getKeys()).toEqual(['k3']);
|
||||
});
|
||||
|
||||
describe('backward', function() {
|
||||
@@ -266,6 +336,10 @@ describe('ol.Object', function() {
|
||||
expect(o.get('k1')).toEqual(1);
|
||||
expect(o2.get('k2')).toEqual(1);
|
||||
expect(o3.get('k3')).toEqual(1);
|
||||
|
||||
expect(o.getKeys()).toEqual(['k1']);
|
||||
expect(o2.getKeys()).toEqual(['k2']);
|
||||
expect(o3.getKeys()).toEqual(['k3']);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -309,7 +383,7 @@ describe('ol.Object', function() {
|
||||
describe('setter', function() {
|
||||
beforeEach(function() {
|
||||
o.setX = function(x) {
|
||||
this.x = x;
|
||||
this.set('x', x);
|
||||
};
|
||||
spyOn(o, 'setX').andCallThrough();
|
||||
});
|
||||
@@ -319,6 +393,8 @@ describe('ol.Object', function() {
|
||||
o.set('x', 1);
|
||||
expect(o.get('x')).toEqual(1);
|
||||
expect(o.setX).not.toHaveBeenCalled();
|
||||
|
||||
expect(o.getKeys()).toEqual(['x']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -327,8 +403,11 @@ describe('ol.Object', function() {
|
||||
var o2 = new ol.Object();
|
||||
o2.bindTo('x', o);
|
||||
o2.set('x', 1);
|
||||
expect(o.get('x')).toEqual(1);
|
||||
expect(o.setX).toHaveBeenCalled();
|
||||
expect(o.get('x')).toEqual(1);
|
||||
|
||||
expect(o.getKeys()).toEqual(['x']);
|
||||
expect(o2.getKeys()).toEqual(['x']);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -354,6 +433,9 @@ describe('ol.Object', function() {
|
||||
o2.bindTo('x', o);
|
||||
expect(o2.get('x')).toEqual(1);
|
||||
expect(o.getX).toHaveBeenCalled();
|
||||
|
||||
expect(o.getKeys()).toEqual([]);
|
||||
expect(o2.getKeys()).toEqual(['x']);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -368,6 +450,8 @@ describe('ol.Object', function() {
|
||||
it('sets the property', function() {
|
||||
var o = new ol.Object({k: 1});
|
||||
expect(o.get('k')).toEqual(1);
|
||||
|
||||
expect(o.getKeys()).toEqual(['k']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -385,6 +469,8 @@ describe('ol.Object', function() {
|
||||
o.set('K', 1);
|
||||
expect(listener1).toHaveBeenCalled();
|
||||
expect(listener2).not.toHaveBeenCalled();
|
||||
|
||||
expect(o.getKeys()).toEqual(['K']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,93 +5,88 @@ describe('ol.parser.ogc.exceptionreport', function() {
|
||||
var parser = new ol.parser.ogc.ExceptionReport();
|
||||
|
||||
describe('test read exception', function() {
|
||||
var result, exceptions;
|
||||
var url = 'spec/ol/parser/ogc/xml/exceptionreport/wms1_3_0.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
exceptions = result.exceptionReport.exceptions;
|
||||
});
|
||||
it('OCG WMS 1.3.0 exceptions', function() {
|
||||
expect(exceptions.length).toBe(4);
|
||||
var str = 'Plain text message about an error.';
|
||||
expect(goog.string.trim(exceptions[0].text)).toBe(str);
|
||||
expect(exceptions[1].code).toBe('InvalidUpdateSequence');
|
||||
str = ' Another error message, this one with a service exception ' +
|
||||
'code supplied. ';
|
||||
expect(exceptions[1].text).toBe(str);
|
||||
str = 'Error in module <foo.c>, line 42A message that includes angle ' +
|
||||
'brackets in text must be enclosed in a Character Data Section as ' +
|
||||
'in this example. All XML-like markup is ignored except for this ' +
|
||||
'sequence of three closing characters:';
|
||||
expect(goog.string.trim(exceptions[2].text), str);
|
||||
str = '<Module>foo.c</Module> <Error>An error occurred</Error> ' +
|
||||
'<Explanation>Similarly, actual XML can be enclosed in a CDATA ' +
|
||||
'section. A generic parser will ignore that XML, but ' +
|
||||
'application-specific software may choose to process it.' +
|
||||
'</Explanation>';
|
||||
expect(goog.string.trim(exceptions[3].text), str);
|
||||
var result, exceptions;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/exceptionreport/wms1_3_0.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
exceptions = result.exceptionReport.exceptions;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (result !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(exceptions.length).toBe(4);
|
||||
var str = 'Plain text message about an error.';
|
||||
expect(goog.string.trim(exceptions[0].text)).toBe(str);
|
||||
expect(exceptions[1].code).toBe('InvalidUpdateSequence');
|
||||
str = ' Another error message, this one with a service exception ' +
|
||||
'code supplied. ';
|
||||
expect(exceptions[1].text).toBe(str);
|
||||
str = 'Error in module <foo.c>, line 42A message that includes angle ' +
|
||||
'brackets in text must be enclosed in a Character Data Section as' +
|
||||
' in this example. All XML-like markup is ignored except for this' +
|
||||
' sequence of three closing characters:';
|
||||
expect(goog.string.trim(exceptions[2].text), str);
|
||||
str = '<Module>foo.c</Module> <Error>An error occurred</Error> ' +
|
||||
'<Explanation>Similarly, actual XML can be enclosed in a CDATA ' +
|
||||
'section. A generic parser will ignore that XML, but ' +
|
||||
'application-specific software may choose to process it.' +
|
||||
'</Explanation>';
|
||||
expect(goog.string.trim(exceptions[3].text), str);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test read exception OWSCommon 1.0.0', function() {
|
||||
var result, report, exception;
|
||||
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_0_0.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
report = result.exceptionReport;
|
||||
exception = report.exceptions[0];
|
||||
it('test read exception OWSCommon 1.0.0', function() {
|
||||
var result, report, exception;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_0_0.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
report = result.exceptionReport;
|
||||
exception = report.exceptions[0];
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (result !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(report.version).toEqual('1.0.0');
|
||||
expect(report.language).toEqual('en');
|
||||
expect(exception.code).toEqual('InvalidParameterValue');
|
||||
expect(exception.locator).toEqual('foo');
|
||||
var msg = 'Update error: Error occured updating features';
|
||||
expect(exception.texts[0]).toEqual(msg);
|
||||
msg = 'Second exception line';
|
||||
expect(exception.texts[1]).toEqual(msg);
|
||||
});
|
||||
});
|
||||
it('Version parsed correctly', function() {
|
||||
expect(report.version).toEqual('1.0.0');
|
||||
});
|
||||
it('Language parsed correctly', function() {
|
||||
expect(report.language).toEqual('en');
|
||||
});
|
||||
it('exceptionCode properly parsed', function() {
|
||||
expect(exception.code).toEqual('InvalidParameterValue');
|
||||
});
|
||||
it('locator properly parsed', function() {
|
||||
expect(exception.locator).toEqual('foo');
|
||||
});
|
||||
it('ExceptionText correctly parsed', function() {
|
||||
var msg = 'Update error: Error occured updating features';
|
||||
expect(exception.texts[0]).toEqual(msg);
|
||||
});
|
||||
it('Second ExceptionText correctly parsed', function() {
|
||||
var msg = 'Second exception line';
|
||||
expect(exception.texts[1]).toEqual(msg);
|
||||
});
|
||||
});
|
||||
|
||||
describe('test read exception OWSCommon 1.1.0', function() {
|
||||
var result, report, exception;
|
||||
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_1_0.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
report = result.exceptionReport;
|
||||
exception = report.exceptions[0];
|
||||
});
|
||||
it('Version parsed correctly', function() {
|
||||
expect(report.version).toEqual('1.1.0');
|
||||
});
|
||||
it('Language parsed correctly', function() {
|
||||
expect(report.language).toEqual('en');
|
||||
});
|
||||
it('exceptionCode properly parsed', function() {
|
||||
expect(exception.code).toEqual('InvalidParameterValue');
|
||||
});
|
||||
it('locator properly parsed', function() {
|
||||
expect(exception.locator).toEqual('foo');
|
||||
});
|
||||
it('ExceptionText correctly parsed', function() {
|
||||
var msg = 'Update error: Error occured updating features';
|
||||
expect(exception.texts[0]).toEqual(msg);
|
||||
});
|
||||
it('Second ExceptionText correctly parsed', function() {
|
||||
expect(exception.texts[1]).toEqual('Second exception line');
|
||||
it('test read exception OWSCommon 1.1.0', function() {
|
||||
var result, report, exception;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_1_0.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
report = result.exceptionReport;
|
||||
exception = report.exceptions[0];
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (result !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(report.version).toEqual('1.1.0');
|
||||
expect(report.language).toEqual('en');
|
||||
expect(exception.code).toEqual('InvalidParameterValue');
|
||||
expect(exception.locator).toEqual('foo');
|
||||
var msg = 'Update error: Error occured updating features';
|
||||
expect(exception.texts[0]).toEqual(msg);
|
||||
expect(exception.texts[1]).toEqual('Second exception line');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,436 +5,307 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
|
||||
var parser = new ol.parser.ogc.WMSCapabilities();
|
||||
|
||||
describe('test read exception', function() {
|
||||
var obj, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/exceptionsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
});
|
||||
it('Error reported correctly', function() {
|
||||
expect(!!obj.error).toBeTruthy();
|
||||
var obj;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' +
|
||||
'exceptionsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(!!obj.error).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test read', function() {
|
||||
var obj, capability, getmap, describelayer, getfeatureinfo, layer, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
getmap = capability.request.getmap;
|
||||
describelayer = capability.request.describelayer;
|
||||
getfeatureinfo = capability.request.getfeatureinfo;
|
||||
layer = capability.layers[2];
|
||||
});
|
||||
it('object contains capability property', function() {
|
||||
expect(capability).toBeTruthy();
|
||||
});
|
||||
it('getmap formats parsed', function() {
|
||||
expect(getmap.formats.length).toEqual(28);
|
||||
});
|
||||
it('getmap href parsed', function() {
|
||||
var url = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(getmap.href).toEqual(url);
|
||||
});
|
||||
it('getmap.get.href parsed', function() {
|
||||
expect(getmap.get.href).toEqual(getmap.href);
|
||||
});
|
||||
it('getmap.post not available', function() {
|
||||
expect(getmap.post).toBeUndefined();
|
||||
});
|
||||
it('describelayer href parsed', function() {
|
||||
var url = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(describelayer.href).toEqual(url);
|
||||
});
|
||||
it('describelayer.get.href parsed', function() {
|
||||
expect(describelayer.get.href).toEqual(describelayer.href);
|
||||
});
|
||||
it('describelayer.post not available', function() {
|
||||
expect(describelayer.post).toBeUndefined();
|
||||
});
|
||||
it('getfeatureinfo href parsed', function() {
|
||||
var url = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(getfeatureinfo.href).toEqual(url);
|
||||
});
|
||||
it('getmap.get.href parsed', function() {
|
||||
expect(getfeatureinfo.get.href).toEqual(getfeatureinfo.href);
|
||||
});
|
||||
it('getfeatureinfo.post set correctly', function() {
|
||||
var url = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(getfeatureinfo.post.href).toEqual(url);
|
||||
});
|
||||
it('layers parsed', function() {
|
||||
expect(capability.layers).toBeTruthy();
|
||||
});
|
||||
it('correct number of layers parsed', function() {
|
||||
expect(capability.layers.length).toEqual(22);
|
||||
});
|
||||
it('infoFormats set on layer', function() {
|
||||
var infoFormats = ['text/plain', 'text/html', 'application/vnd.ogc.gml'];
|
||||
expect(layer.infoFormats).toEqual(infoFormats);
|
||||
});
|
||||
it('[2] correct layer name', function() {
|
||||
expect(layer.name).toEqual('tiger:tiger_roads');
|
||||
});
|
||||
it('[2] correct layer prefix', function() {
|
||||
expect(layer.prefix).toEqual('tiger');
|
||||
});
|
||||
it('[2] correct layer title', function() {
|
||||
expect(layer.title).toEqual('Manhattan (NY) roads');
|
||||
});
|
||||
it('[2] correct layer abstract', function() {
|
||||
var abstr = 'Highly simplified road layout of Manhattan in New York..';
|
||||
expect(layer['abstract']).toEqual(abstr);
|
||||
});
|
||||
it('[2] correct layer bbox', function() {
|
||||
var bbox = [-74.08769307536667, 40.660618924633326,
|
||||
-73.84653192463333, 40.90178007536667];
|
||||
expect(layer.llbbox).toEqual(bbox);
|
||||
});
|
||||
it('[2] correct styles length', function() {
|
||||
expect(layer.styles.length).toEqual(1);
|
||||
});
|
||||
it('[2] correct style name', function() {
|
||||
expect(layer.styles[0].name).toEqual('tiger_roads');
|
||||
});
|
||||
it('[2] correct legend url', function() {
|
||||
var url = 'http://publicus.opengeo.org:80/geoserver/wms/' +
|
||||
it('Test read', function() {
|
||||
var obj, capability, getmap, describelayer, getfeatureinfo, layer;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
getmap = capability.request.getmap;
|
||||
describelayer = capability.request.describelayer;
|
||||
getfeatureinfo = capability.request.getfeatureinfo;
|
||||
layer = capability.layers[2];
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(capability).toBeTruthy();
|
||||
expect(getmap.formats.length).toEqual(28);
|
||||
var get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(getmap.get.href).toEqual(get);
|
||||
expect(getmap.post).toBeUndefined();
|
||||
get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(describelayer.get.href).toEqual(get);
|
||||
expect(describelayer.post).toBeUndefined();
|
||||
get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(getfeatureinfo.get.href).toEqual(get);
|
||||
var post = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
|
||||
expect(getfeatureinfo.post.href).toEqual(post);
|
||||
expect(capability.layers).toBeTruthy();
|
||||
expect(capability.layers.length).toEqual(22);
|
||||
var infoFormats = ['text/plain', 'text/html',
|
||||
'application/vnd.ogc.gml'];
|
||||
expect(layer.infoFormats).toEqual(infoFormats);
|
||||
expect(layer.name).toEqual('tiger:tiger_roads');
|
||||
expect(layer.prefix).toEqual('tiger');
|
||||
expect(layer.title).toEqual('Manhattan (NY) roads');
|
||||
var abstr = 'Highly simplified road layout of Manhattan in New York..';
|
||||
expect(layer['abstract']).toEqual(abstr);
|
||||
var bbox = [-74.08769307536667, 40.660618924633326,
|
||||
-73.84653192463333, 40.90178007536667];
|
||||
expect(layer.llbbox).toEqual(bbox);
|
||||
expect(layer.styles.length).toEqual(1);
|
||||
expect(layer.styles[0].name).toEqual('tiger_roads');
|
||||
var legend = 'http://publicus.opengeo.org:80/geoserver/wms/' +
|
||||
'GetLegendGraphic?VERSION=1.0.0&FORMAT=image/png&WIDTH=20&' +
|
||||
'HEIGHT=20&LAYER=tiger:tiger_roads';
|
||||
expect(layer.styles[0].legend.href).toEqual(url);
|
||||
});
|
||||
it('[2] correct legend format', function() {
|
||||
expect(layer.styles[0].legend.format).toEqual('image/png');
|
||||
});
|
||||
it('[2] correct queryable attribute', function() {
|
||||
expect(layer.queryable).toBeTruthy();
|
||||
expect(layer.styles[0].legend.href).toEqual(legend);
|
||||
expect(layer.styles[0].legend.format).toEqual('image/png');
|
||||
expect(layer.queryable).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test layers', function() {
|
||||
var obj, capability, layers = {}, rootlayer, identifiers, authorities;
|
||||
var featurelist, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
for (var i = 0, len = capability.layers.length; i < len; i++) {
|
||||
if ('name' in capability.layers[i]) {
|
||||
layers[capability.layers[i].name] = capability.layers[i];
|
||||
}
|
||||
}
|
||||
rootlayer = capability.layers[capability.layers.length - 1];
|
||||
identifiers = layers['ROADS_RIVERS'].identifiers;
|
||||
authorities = layers['ROADS_RIVERS'].authorityURLs;
|
||||
featurelist = layers['ROADS_RIVERS'].featureListURL;
|
||||
});
|
||||
it('SRS parsed correctly for root layer', function() {
|
||||
expect(rootlayer.srs).toEqual({'EPSG:4326': true});
|
||||
});
|
||||
it('Inheritance of SRS handled correctly when adding SRSes', function() {
|
||||
var srs = {'EPSG:4326': true, 'EPSG:26986': true};
|
||||
expect(layers['ROADS_RIVERS'].srs).toEqual(srs);
|
||||
});
|
||||
var msg = 'Inheritance of SRS handled correctly when redeclaring an ' +
|
||||
'inherited SRS';
|
||||
it(msg, function() {
|
||||
expect(layers['Temperature'].srs).toEqual({'EPSG:4326': true});
|
||||
});
|
||||
it('Correct bbox and res from BoundingBox', function() {
|
||||
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
});
|
||||
it('Correct bbox and res from BoundingBox (override)', function() {
|
||||
bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326'];
|
||||
expect(bbox.bbox).toEqual([-71.63, 41.75, -70.78, 42.90]);
|
||||
expect(bbox.res).toEqual({x: 0.01, y: 0.01});
|
||||
});
|
||||
it('Correctly inherited bbox and resolution', function() {
|
||||
bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
});
|
||||
it('got identifiers from layer ROADS_RIVERS', function() {
|
||||
expect(identifiers).toBeTruthy();
|
||||
});
|
||||
it('authority attribute from Identifiers parsed correctly', function() {
|
||||
expect('DIF_ID' in identifiers).toBeTruthy();
|
||||
});
|
||||
it('Identifier value parsed correctly', function() {
|
||||
expect(identifiers['DIF_ID']).toEqual('123456');
|
||||
});
|
||||
it('AuthorityURLs parsed and inherited correctly', function() {
|
||||
expect('DIF_ID' in authorities).toBeTruthy();
|
||||
});
|
||||
it('OnlineResource in AuthorityURLs parsed correctly', function() {
|
||||
var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html';
|
||||
expect(authorities['DIF_ID']).toEqual(url);
|
||||
});
|
||||
it('layer has FeatureListURL', function() {
|
||||
expect(featurelist).toBeTruthy();
|
||||
});
|
||||
it('FeatureListURL format parsed correctly', function() {
|
||||
expect(featurelist.format).toEqual('application/vnd.ogc.se_xml');
|
||||
});
|
||||
it('FeatureListURL OnlineResource parsed correctly', function() {
|
||||
var url = 'http://www.university.edu/data/roads_rivers.gml';
|
||||
expect(featurelist.href).toEqual(url);
|
||||
});
|
||||
it('queryable property inherited correctly', function() {
|
||||
expect(layers['Pressure'].queryable).toBeTruthy();
|
||||
});
|
||||
it('queryable property has correct default value', function() {
|
||||
expect(layers['ozone_image'].queryable).toBeFalsy();
|
||||
});
|
||||
it('cascaded property parsed correctly', function() {
|
||||
expect(layers['population'].cascaded).toEqual(1);
|
||||
});
|
||||
it('fixedWidth property correctly parsed', function() {
|
||||
expect(layers['ozone_image'].fixedWidth).toEqual(512);
|
||||
});
|
||||
it('fixedHeight property correctly parsed', function() {
|
||||
expect(layers['ozone_image'].fixedHeight).toEqual(256);
|
||||
});
|
||||
it('opaque property parsed correctly', function() {
|
||||
expect(layers['ozone_image'].opaque).toBeTruthy();
|
||||
});
|
||||
it('noSubsets property parsed correctly', function() {
|
||||
expect(layers['ozone_image'].noSubsets).toBeTruthy();
|
||||
it('Test layers', function() {
|
||||
var obj, capability, layers = {}, rootlayer, identifiers, authorities;
|
||||
var featurelist;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
for (var i = 0, len = capability.layers.length; i < len; i++) {
|
||||
if ('name' in capability.layers[i]) {
|
||||
layers[capability.layers[i].name] = capability.layers[i];
|
||||
}
|
||||
}
|
||||
rootlayer = capability.layers[capability.layers.length - 1];
|
||||
identifiers = layers['ROADS_RIVERS'].identifiers;
|
||||
authorities = layers['ROADS_RIVERS'].authorityURLs;
|
||||
featurelist = layers['ROADS_RIVERS'].featureListURL;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(rootlayer.srs).toEqual({'EPSG:4326': true});
|
||||
var srs = {'EPSG:4326': true, 'EPSG:26986': true};
|
||||
expect(layers['ROADS_RIVERS'].srs).toEqual(srs);
|
||||
expect(layers['Temperature'].srs).toEqual({'EPSG:4326': true});
|
||||
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326'];
|
||||
expect(bbox.bbox).toEqual([-71.63, 41.75, -70.78, 42.90]);
|
||||
expect(bbox.res).toEqual({x: 0.01, y: 0.01});
|
||||
bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
expect(identifiers).toBeTruthy();
|
||||
expect('DIF_ID' in identifiers).toBeTruthy();
|
||||
expect(identifiers['DIF_ID']).toEqual('123456');
|
||||
expect('DIF_ID' in authorities).toBeTruthy();
|
||||
var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html';
|
||||
expect(authorities['DIF_ID']).toEqual(url);
|
||||
expect(featurelist).toBeTruthy();
|
||||
expect(featurelist.format).toEqual('application/vnd.ogc.se_xml');
|
||||
url = 'http://www.university.edu/data/roads_rivers.gml';
|
||||
expect(featurelist.href).toEqual(url);
|
||||
expect(layers['Pressure'].queryable).toBeTruthy();
|
||||
expect(layers['ozone_image'].queryable).toBeFalsy();
|
||||
expect(layers['population'].cascaded).toEqual(1);
|
||||
expect(layers['ozone_image'].fixedWidth).toEqual(512);
|
||||
expect(layers['ozone_image'].fixedHeight).toEqual(256);
|
||||
expect(layers['ozone_image'].opaque).toBeTruthy();
|
||||
expect(layers['ozone_image'].noSubsets).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test dimensions', function() {
|
||||
var obj, capability, layers = {}, time, elevation, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
for (var i = 0, len = capability.layers.length; i < len; i++) {
|
||||
if ('name' in capability.layers[i]) {
|
||||
layers[capability.layers[i].name] = capability.layers[i];
|
||||
}
|
||||
}
|
||||
time = layers['Clouds'].dimensions.time;
|
||||
elevation = layers['Pressure'].dimensions.elevation;
|
||||
});
|
||||
it('Default time value parsed correctly', function() {
|
||||
expect(time['default']).toEqual('2000-08-22');
|
||||
});
|
||||
it('Currect number of time extent values/periods', function() {
|
||||
expect(time.values.length).toEqual(1);
|
||||
});
|
||||
it('Time extent values parsed correctly', function() {
|
||||
expect(time.values[0]).toEqual('1999-01-01/2000-08-22/P1D');
|
||||
});
|
||||
it('Dimension units parsed correctly', function() {
|
||||
expect(elevation.units).toEqual('EPSG:5030');
|
||||
});
|
||||
it('Default elevation value parsed correctly', function() {
|
||||
expect(elevation['default']).toEqual('0');
|
||||
});
|
||||
it('NearestValue parsed correctly', function() {
|
||||
expect(elevation.nearestVal).toBeTruthy();
|
||||
});
|
||||
it('Absense of MultipleValues handled correctly', function() {
|
||||
expect(elevation.multipleVal).toBeFalsy();
|
||||
});
|
||||
it('Parsing of comma-separated values done correctly', function() {
|
||||
expect(elevation.values).toEqual(['0', '1000', '3000', '5000', '10000']);
|
||||
it('Test dimensions', function() {
|
||||
var obj, capability, layers = {}, time, elevation;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
for (var i = 0, len = capability.layers.length; i < len; i++) {
|
||||
if ('name' in capability.layers[i]) {
|
||||
layers[capability.layers[i].name] = capability.layers[i];
|
||||
}
|
||||
}
|
||||
time = layers['Clouds'].dimensions.time;
|
||||
elevation = layers['Pressure'].dimensions.elevation;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(time['default']).toEqual('2000-08-22');
|
||||
expect(time.values.length).toEqual(1);
|
||||
expect(time.values[0]).toEqual('1999-01-01/2000-08-22/P1D');
|
||||
expect(elevation.units).toEqual('EPSG:5030');
|
||||
expect(elevation['default']).toEqual('0');
|
||||
expect(elevation.nearestVal).toBeTruthy();
|
||||
expect(elevation.multipleVal).toBeFalsy();
|
||||
expect(elevation.values).toEqual(['0', '1000', '3000', '5000',
|
||||
'10000']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test contact info', function() {
|
||||
var obj, service, contactinfo, personPrimary, addr, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
service = obj.service;
|
||||
contactinfo = service.contactInformation;
|
||||
personPrimary = contactinfo.personPrimary;
|
||||
addr = contactinfo.contactAddress;
|
||||
});
|
||||
it('object contains contactInformation property', function() {
|
||||
expect(contactinfo).toBeTruthy();
|
||||
});
|
||||
it('object contains personPrimary property', function() {
|
||||
expect(personPrimary).toBeTruthy();
|
||||
});
|
||||
it('ContactPerson parsed correctly', function() {
|
||||
expect(personPrimary.person).toEqual('Jeff deLaBeaujardiere');
|
||||
});
|
||||
it('ContactOrganization parsed correctly', function() {
|
||||
expect(personPrimary.organization).toEqual('NASA');
|
||||
});
|
||||
it('ContactPosition parsed correctly', function() {
|
||||
expect(contactinfo.position).toEqual('Computer Scientist');
|
||||
});
|
||||
it('object contains contactAddress property', function() {
|
||||
expect(addr).toBeTruthy();
|
||||
});
|
||||
it('AddressType parsed correctly', function() {
|
||||
expect(addr.type).toEqual('postal');
|
||||
});
|
||||
it('Address parsed correctly', function() {
|
||||
var address = 'NASA Goddard Space Flight Center, Code 933';
|
||||
expect(addr.address).toEqual(address);
|
||||
});
|
||||
it('City parsed correctly', function() {
|
||||
expect(addr.city).toEqual('Greenbelt');
|
||||
});
|
||||
it('StateOrProvince parsed correctly', function() {
|
||||
expect(addr.stateOrProvince).toEqual('MD');
|
||||
});
|
||||
it('PostCode parsed correctly', function() {
|
||||
expect(addr.postcode).toEqual('20771');
|
||||
});
|
||||
it('Country parsed correctly', function() {
|
||||
expect(addr.country).toEqual('USA');
|
||||
});
|
||||
it('ContactVoiceTelephone parsed correctly', function() {
|
||||
expect(contactinfo.phone).toEqual('+1 301 286-1569');
|
||||
});
|
||||
it('ContactFacsimileTelephone parsed correctly', function() {
|
||||
expect(contactinfo.fax).toEqual('+1 301 286-1777');
|
||||
});
|
||||
it('ContactElectronicMailAddress parsed correctly', function() {
|
||||
expect(contactinfo.email).toEqual('delabeau@iniki.gsfc.nasa.gov');
|
||||
it('Test contact info', function() {
|
||||
var obj, service, contactinfo, personPrimary, addr;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' +
|
||||
'ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
service = obj.service;
|
||||
contactinfo = service.contactInformation;
|
||||
personPrimary = contactinfo.personPrimary;
|
||||
addr = contactinfo.contactAddress;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(contactinfo).toBeTruthy();
|
||||
expect(personPrimary).toBeTruthy();
|
||||
expect(personPrimary.person).toEqual('Jeff deLaBeaujardiere');
|
||||
expect(personPrimary.organization).toEqual('NASA');
|
||||
expect(contactinfo.position).toEqual('Computer Scientist');
|
||||
expect(addr).toBeTruthy();
|
||||
expect(addr.type).toEqual('postal');
|
||||
var address = 'NASA Goddard Space Flight Center, Code 933';
|
||||
expect(addr.address).toEqual(address);
|
||||
expect(addr.city).toEqual('Greenbelt');
|
||||
expect(addr.stateOrProvince).toEqual('MD');
|
||||
expect(addr.postcode).toEqual('20771');
|
||||
expect(addr.country).toEqual('USA');
|
||||
expect(contactinfo.phone).toEqual('+1 301 286-1569');
|
||||
expect(contactinfo.fax).toEqual('+1 301 286-1777');
|
||||
expect(contactinfo.email).toEqual('delabeau@iniki.gsfc.nasa.gov');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test fees and constraints', function() {
|
||||
var obj, service, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
service = obj.service;
|
||||
});
|
||||
it('Fees=none handled correctly', function() {
|
||||
expect('fees' in service).toBeFalsy();
|
||||
});
|
||||
it('AccessConstraints=none handled correctly', function() {
|
||||
expect('accessConstraints' in service).toBeFalsy();
|
||||
it('Test fees and constraints', function() {
|
||||
var obj, service;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
service = obj.service;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect('fees' in service).toBeFalsy();
|
||||
expect('accessConstraints' in service).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test requests', function() {
|
||||
var obj, request, exception, userSymbols, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
request = obj.capability.request;
|
||||
exception = obj.capability.exception;
|
||||
userSymbols = obj.capability.userSymbols;
|
||||
});
|
||||
it('request property exists', function() {
|
||||
expect(request).toBeTruthy();
|
||||
});
|
||||
it('got GetMap request', function() {
|
||||
expect('getmap' in request).toBeTruthy();
|
||||
});
|
||||
it('got GetFeatureInfo request', function() {
|
||||
expect('getfeatureinfo' in request).toBeTruthy();
|
||||
});
|
||||
it('GetFeatureInfo formats correctly parsed', function() {
|
||||
var formats = ['text/plain', 'text/html', 'application/vnd.ogc.gml'];
|
||||
expect(request.getfeatureinfo.formats).toEqual(formats);
|
||||
});
|
||||
it('got DescribeLayer request', function() {
|
||||
expect('describelayer' in request).toBeTruthy();
|
||||
});
|
||||
it('got GetLegendGraphic request', function() {
|
||||
expect('getlegendgraphic' in request).toBeTruthy();
|
||||
});
|
||||
it('exception property exists', function() {
|
||||
expect(exception).toBeTruthy();
|
||||
});
|
||||
it('Exception Format parsed', function() {
|
||||
expect(exception.formats).toEqual(['application/vnd.ogc.se_xml']);
|
||||
});
|
||||
it('userSymbols property exists', function() {
|
||||
expect(userSymbols).toBeTruthy();
|
||||
});
|
||||
it('supportSLD parsed', function() {
|
||||
expect(userSymbols.supportSLD).toBeTruthy();
|
||||
});
|
||||
it('userLayer parsed', function() {
|
||||
expect(userSymbols.userLayer).toBeTruthy();
|
||||
});
|
||||
it('userStyle parsed', function() {
|
||||
expect(userSymbols.userStyle).toBeTruthy();
|
||||
});
|
||||
it('remoteWFS parsed', function() {
|
||||
expect(userSymbols.remoteWFS).toBeTruthy();
|
||||
it('Test requests', function() {
|
||||
var obj, request, exception, userSymbols;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
request = obj.capability.request;
|
||||
exception = obj.capability.exception;
|
||||
userSymbols = obj.capability.userSymbols;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(request).toBeTruthy();
|
||||
expect('getmap' in request).toBeTruthy();
|
||||
expect('getfeatureinfo' in request).toBeTruthy();
|
||||
var formats = ['text/plain', 'text/html', 'application/vnd.ogc.gml'];
|
||||
expect(request.getfeatureinfo.formats).toEqual(formats);
|
||||
expect('describelayer' in request).toBeTruthy();
|
||||
expect('getlegendgraphic' in request).toBeTruthy();
|
||||
expect(exception).toBeTruthy();
|
||||
expect(exception.formats).toEqual(['application/vnd.ogc.se_xml']);
|
||||
expect(userSymbols).toBeTruthy();
|
||||
expect(userSymbols.supportSLD).toBeTruthy();
|
||||
expect(userSymbols.userLayer).toBeTruthy();
|
||||
expect(userSymbols.userStyle).toBeTruthy();
|
||||
expect(userSymbols.remoteWFS).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test ogc', function() {
|
||||
var obj, capability, attribution, keywords, metadataURLs, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
attribution = capability.layers[2].attribution;
|
||||
keywords = capability.layers[0].keywords;
|
||||
metadataURLs = capability.layers[0].metadataURLs;
|
||||
});
|
||||
it('attribution title parsed correctly.', function() {
|
||||
expect(attribution.title).toEqual('State College University');
|
||||
});
|
||||
it('attribution href parsed correctly.', function() {
|
||||
expect(attribution.href).toEqual('http://www.university.edu/');
|
||||
});
|
||||
it('attribution logo url parsed correctly.', function() {
|
||||
var url = 'http://www.university.edu/icons/logo.gif';
|
||||
expect(attribution.logo.href).toEqual(url);
|
||||
});
|
||||
it('attribution logo format parsed correctly.', function() {
|
||||
expect(attribution.logo.format).toEqual('image/gif');
|
||||
});
|
||||
it('attribution logo width parsed correctly.', function() {
|
||||
expect(attribution.logo.width).toEqual('100');
|
||||
});
|
||||
it('attribution logo height parsed correctly.', function() {
|
||||
expect(attribution.logo.height).toEqual('100');
|
||||
});
|
||||
it('layer has 3 keywords.', function() {
|
||||
expect(keywords.length).toEqual(3);
|
||||
});
|
||||
it('1st keyword parsed correctly.', function() {
|
||||
expect(keywords[0].value).toEqual('road');
|
||||
});
|
||||
it('layer has 2 metadata urls.', function() {
|
||||
expect(metadataURLs.length).toEqual(2);
|
||||
});
|
||||
it('type parsed correctly.', function() {
|
||||
expect(metadataURLs[0].type).toEqual('FGDC');
|
||||
});
|
||||
it('format parsed correctly.', function() {
|
||||
expect(metadataURLs[0].format).toEqual('text/plain');
|
||||
});
|
||||
it('href parsed correctly.', function() {
|
||||
var href = 'http://www.university.edu/metadata/roads.txt';
|
||||
expect(metadataURLs[0].href).toEqual(href);
|
||||
});
|
||||
it('layer.minScale is correct', function() {
|
||||
expect(Math.round(capability.layers[0].minScale)).toEqual(250000);
|
||||
});
|
||||
it('layer.maxScale is correct', function() {
|
||||
expect(Math.round(capability.layers[0].maxScale)).toEqual(1000);
|
||||
});
|
||||
it('layer.minScale for max="Infinity" is correct', function() {
|
||||
expect(capability.layers[1].minScale).toBeUndefined();
|
||||
});
|
||||
it('layer.maxScale for min="0" is correct', function() {
|
||||
expect(capability.layers[1].maxScale).toBeUndefined();
|
||||
it('Test ogc', function() {
|
||||
var obj, capability, attribution, keywords, metadataURLs;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
attribution = capability.layers[2].attribution;
|
||||
keywords = capability.layers[0].keywords;
|
||||
metadataURLs = capability.layers[0].metadataURLs;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(attribution.title).toEqual('State College University');
|
||||
expect(attribution.href).toEqual('http://www.university.edu/');
|
||||
var url = 'http://www.university.edu/icons/logo.gif';
|
||||
expect(attribution.logo.href).toEqual(url);
|
||||
expect(attribution.logo.format).toEqual('image/gif');
|
||||
expect(attribution.logo.width).toEqual('100');
|
||||
expect(attribution.logo.height).toEqual('100');
|
||||
expect(keywords.length).toEqual(3);
|
||||
expect(keywords[0].value).toEqual('road');
|
||||
expect(metadataURLs.length).toEqual(2);
|
||||
expect(metadataURLs[0].type).toEqual('FGDC');
|
||||
expect(metadataURLs[0].format).toEqual('text/plain');
|
||||
var href = 'http://www.university.edu/metadata/roads.txt';
|
||||
expect(metadataURLs[0].href).toEqual(href);
|
||||
expect(Math.round(capability.layers[0].minScale)).toEqual(250000);
|
||||
expect(Math.round(capability.layers[0].maxScale)).toEqual(1000);
|
||||
expect(capability.layers[1].minScale).toBeUndefined();
|
||||
expect(capability.layers[1].maxScale).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -8,63 +8,62 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
|
||||
});
|
||||
|
||||
describe('test read', function() {
|
||||
var obj, tilesets, tileset, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/wmsc.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
tilesets = obj.capability.vendorSpecific.tileSets;
|
||||
tileset = tilesets[0];
|
||||
});
|
||||
it('We expect 2 tilesets to be parsed', function() {
|
||||
expect(tilesets.length).toEqual(2);
|
||||
});
|
||||
it('BBOX correctly parsed', function() {
|
||||
var bbox = [-13697515.466796875, 5165920.118906248,
|
||||
-13619243.94984375, 5244191.635859374];
|
||||
expect(tileset.bbox['EPSG:900913'].bbox).toEqual(bbox);
|
||||
});
|
||||
it('Format correctly parsed', function() {
|
||||
expect(tileset.format).toEqual('image/png');
|
||||
});
|
||||
it('Height correctly parsed', function() {
|
||||
expect(tileset.height).toEqual(256);
|
||||
});
|
||||
it('Width correctly parsed', function() {
|
||||
expect(tileset.width).toEqual(256);
|
||||
});
|
||||
it('Layers correctly parsed', function() {
|
||||
expect(tileset.layers).toEqual('medford:hydro');
|
||||
});
|
||||
it('SRS correctly parsed', function() {
|
||||
expect(tileset.srs['EPSG:900913']).toBeTruthy();
|
||||
});
|
||||
it('Resolutions correctly parsed', function() {
|
||||
var resolutions = [156543.03390625, 78271.516953125, 39135.7584765625,
|
||||
19567.87923828125, 9783.939619140625, 4891.9698095703125,
|
||||
2445.9849047851562, 1222.9924523925781, 611.4962261962891,
|
||||
305.74811309814453, 152.87405654907226, 76.43702827453613,
|
||||
38.218514137268066, 19.109257068634033, 9.554628534317017,
|
||||
4.777314267158508, 2.388657133579254, 1.194328566789627,
|
||||
0.5971642833948135, 0.29858214169740677, 0.14929107084870338,
|
||||
0.07464553542435169, 0.037322767712175846, 0.018661383856087923,
|
||||
0.009330691928043961, 0.004665345964021981];
|
||||
expect(tileset.resolutions).toEqual(resolutions);
|
||||
});
|
||||
it('Styles correctly parsed', function() {
|
||||
expect(tileset.styles).toEqual('');
|
||||
it('Test read', function() {
|
||||
var obj, tilesets, tileset;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/wmsc.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
tilesets = obj.capability.vendorSpecific.tileSets;
|
||||
tileset = tilesets[0];
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(tilesets.length).toEqual(2);
|
||||
var bbox = [-13697515.466796875, 5165920.118906248,
|
||||
-13619243.94984375, 5244191.635859374];
|
||||
expect(tileset.bbox['EPSG:900913'].bbox).toEqual(bbox);
|
||||
expect(tileset.format).toEqual('image/png');
|
||||
expect(tileset.height).toEqual(256);
|
||||
expect(tileset.width).toEqual(256);
|
||||
expect(tileset.layers).toEqual('medford:hydro');
|
||||
expect(tileset.srs['EPSG:900913']).toBeTruthy();
|
||||
var resolutions = [156543.03390625, 78271.516953125, 39135.7584765625,
|
||||
19567.87923828125, 9783.939619140625, 4891.9698095703125,
|
||||
2445.9849047851562, 1222.9924523925781, 611.4962261962891,
|
||||
305.74811309814453, 152.87405654907226, 76.43702827453613,
|
||||
38.218514137268066, 19.109257068634033, 9.554628534317017,
|
||||
4.777314267158508, 2.388657133579254, 1.194328566789627,
|
||||
0.5971642833948135, 0.29858214169740677, 0.14929107084870338,
|
||||
0.07464553542435169, 0.037322767712175846, 0.018661383856087923,
|
||||
0.009330691928043961, 0.004665345964021981];
|
||||
expect(tileset.resolutions).toEqual(resolutions);
|
||||
expect(tileset.styles).toEqual('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test fallback', function() {
|
||||
var obj, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/fallback.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
});
|
||||
it('layers parsed with allowFallback true', function() {
|
||||
expect(obj.capability.layers.length).toEqual(2);
|
||||
it('Test fallback', function() {
|
||||
var obj;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/' +
|
||||
'fallback.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(obj.capability.layers.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -4,293 +4,152 @@ describe('ol.parser.ogc.wmscapabilities_v1_3_0', function() {
|
||||
|
||||
var parser = new ol.parser.ogc.WMSCapabilities();
|
||||
|
||||
var obj, capability, layers = {}, rootlayer, identifiers, authorities;
|
||||
var featurelist, time, elevation, service, contactinfo, personPrimary, addr;
|
||||
var request, exception, attribution, keywords, metadataURLs, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
for (var i = 0, len = capability.layers.length; i < len; i++) {
|
||||
if ('name' in capability.layers[i]) {
|
||||
layers[capability.layers[i].name] = capability.layers[i];
|
||||
}
|
||||
}
|
||||
rootlayer = capability.layers[capability.layers.length - 1];
|
||||
identifiers = layers['ROADS_RIVERS'].identifiers;
|
||||
authorities = layers['ROADS_RIVERS'].authorityURLs;
|
||||
featurelist = layers['ROADS_RIVERS'].featureListURL;
|
||||
time = layers['Clouds'].dimensions.time;
|
||||
elevation = layers['Pressure'].dimensions.elevation;
|
||||
service = obj.service;
|
||||
contactinfo = service.contactInformation;
|
||||
personPrimary = contactinfo.personPrimary;
|
||||
addr = contactinfo.contactAddress;
|
||||
request = obj.capability.request;
|
||||
exception = obj.capability.exception;
|
||||
attribution = capability.layers[2].attribution;
|
||||
keywords = capability.layers[0].keywords;
|
||||
metadataURLs = capability.layers[0].metadataURLs;
|
||||
});
|
||||
|
||||
describe('test read exception', function() {
|
||||
var result, url;
|
||||
url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/exceptionsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
});
|
||||
it('Error reported correctly', function() {
|
||||
expect(!!result.error).toBe(true);
|
||||
var result;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/' +
|
||||
'exceptionsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
result = parser.read(xhr.getResponseXml());
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (result !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(!!result.error).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test layers', function() {
|
||||
it('SRS parsed correctly for root layer', function() {
|
||||
expect(rootlayer.srs).toEqual({'CRS:84': true});
|
||||
});
|
||||
it('Inheritance of SRS handled correctly when adding SRSes', function() {
|
||||
var srs = {'CRS:84': true, 'EPSG:26986': true};
|
||||
expect(layers['ROADS_RIVERS'].srs).toEqual(srs);
|
||||
});
|
||||
it('Inheritance of SRS handled correctly when redeclaring an' +
|
||||
' inherited SRS', function() {
|
||||
describe('test read', function() {
|
||||
it('Test read', function() {
|
||||
var obj, capability, layers = {}, rootlayer, identifiers, authorities;
|
||||
var featurelist, time, elevation, service, contactinfo, personPrimary,
|
||||
addr, request, exception, attribution, keywords, metadataURLs;
|
||||
runs(function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
|
||||
goog.net.XhrIo.send(url, function(e) {
|
||||
var xhr = e.target;
|
||||
obj = parser.read(xhr.getResponseXml());
|
||||
capability = obj.capability;
|
||||
for (var i = 0, len = capability.layers.length; i < len; i++) {
|
||||
if ('name' in capability.layers[i]) {
|
||||
layers[capability.layers[i].name] = capability.layers[i];
|
||||
}
|
||||
}
|
||||
rootlayer = capability.layers[capability.layers.length - 1];
|
||||
identifiers = layers['ROADS_RIVERS'].identifiers;
|
||||
authorities = layers['ROADS_RIVERS'].authorityURLs;
|
||||
featurelist = layers['ROADS_RIVERS'].featureListURL;
|
||||
time = layers['Clouds'].dimensions.time;
|
||||
elevation = layers['Pressure'].dimensions.elevation;
|
||||
service = obj.service;
|
||||
contactinfo = service.contactInformation;
|
||||
personPrimary = contactinfo.personPrimary;
|
||||
addr = contactinfo.contactAddress;
|
||||
request = obj.capability.request;
|
||||
exception = obj.capability.exception;
|
||||
attribution = capability.layers[2].attribution;
|
||||
keywords = capability.layers[0].keywords;
|
||||
metadataURLs = capability.layers[0].metadataURLs;
|
||||
});
|
||||
});
|
||||
waitsFor(function() {
|
||||
return (obj !== undefined);
|
||||
}, 'XHR timeout', 1000);
|
||||
runs(function() {
|
||||
expect(rootlayer.srs).toEqual({'CRS:84': true});
|
||||
var srs = {'CRS:84': true, 'EPSG:26986': true};
|
||||
expect(layers['ROADS_RIVERS'].srs).toEqual(srs);
|
||||
expect(layers['Temperature'].srs).toEqual({'CRS:84': true});
|
||||
});
|
||||
it('infoFormats set correctly on layer', function() {
|
||||
var infoFormats = ['text/xml', 'text/plain', 'text/html'];
|
||||
expect(layers['Temperature'].infoFormats).toEqual(infoFormats);
|
||||
});
|
||||
it('Correct resolution and bbox from BoundingBox', function() {
|
||||
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
});
|
||||
it('Correct resolution and bbox from BoundingBox (override)', function() {
|
||||
var bbox = layers['ROADS_RIVERS'].bbox['CRS:84'];
|
||||
expect(bbox.bbox).toEqual([-71.63, 41.75, -70.78, 42.90]);
|
||||
expect(bbox.res).toEqual({x: 0.01, y: 0.01});
|
||||
});
|
||||
it('Correctly inherited bbox and resolution', function() {
|
||||
var bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
});
|
||||
it('got identifiers from layer ROADS_RIVERS', function() {
|
||||
expect(identifiers).toBeTruthy();
|
||||
});
|
||||
it('authority attribute from Identifiers parsed correctly', function() {
|
||||
expect('DIF_ID' in identifiers).toBeTruthy();
|
||||
});
|
||||
it('Identifier value parsed correctly', function() {
|
||||
expect(identifiers['DIF_ID']).toEqual('123456');
|
||||
});
|
||||
it('AuthorityURLs parsed and inherited correctly', function() {
|
||||
expect('DIF_ID' in authorities).toBeTruthy();
|
||||
});
|
||||
it('OnlineResource in AuthorityURLs parsed correctly', function() {
|
||||
var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html';
|
||||
expect(authorities['DIF_ID']).toEqual(url);
|
||||
});
|
||||
it('layer has FeatureListURL', function() {
|
||||
expect(featurelist).toBeTruthy();
|
||||
});
|
||||
it('FeatureListURL format parsed correctly', function() {
|
||||
expect(featurelist.format).toEqual('XML');
|
||||
});
|
||||
it('FeatureListURL OnlineResource parsed correctly', function() {
|
||||
var url = 'http://www.university.edu/data/roads_rivers.gml';
|
||||
expect(featurelist.href).toEqual(url);
|
||||
});
|
||||
it('queryable property inherited correctly', function() {
|
||||
expect(layers['Pressure'].queryable).toBeTruthy();
|
||||
});
|
||||
it('queryable property has correct default value', function() {
|
||||
expect(layers['ozone_image'].queryable).toBeFalsy();
|
||||
});
|
||||
it('cascaded property parsed correctly', function() {
|
||||
expect(layers['population'].cascaded).toEqual(1);
|
||||
});
|
||||
it('fixedWidth property correctly parsed', function() {
|
||||
expect(layers['ozone_image'].fixedWidth).toEqual(512);
|
||||
});
|
||||
it('fixedHeight property correctly parsed', function() {
|
||||
expect(layers['ozone_image'].fixedHeight).toEqual(256);
|
||||
});
|
||||
it('opaque property parsed correctly', function() {
|
||||
expect(layers['ozone_image'].opaque).toBeTruthy();
|
||||
});
|
||||
it('noSubsets property parsed correctly', function() {
|
||||
expect(layers['ozone_image'].noSubsets).toBeTruthy();
|
||||
var infoFormats = ['text/xml', 'text/plain', 'text/html'];
|
||||
expect(layers['Temperature'].infoFormats).toEqual(infoFormats);
|
||||
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
bbox = layers['ROADS_RIVERS'].bbox['CRS:84'];
|
||||
expect(bbox.bbox).toEqual([-71.63, 41.75, -70.78, 42.90]);
|
||||
expect(bbox.res).toEqual({x: 0.01, y: 0.01});
|
||||
bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
|
||||
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]);
|
||||
expect(bbox.res).toEqual({x: 1, y: 1});
|
||||
expect(identifiers).toBeTruthy();
|
||||
expect('DIF_ID' in identifiers).toBeTruthy();
|
||||
expect(identifiers['DIF_ID']).toEqual('123456');
|
||||
expect('DIF_ID' in authorities).toBeTruthy();
|
||||
var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html';
|
||||
expect(authorities['DIF_ID']).toEqual(url);
|
||||
expect(featurelist).toBeTruthy();
|
||||
expect(featurelist.format).toEqual('XML');
|
||||
url = 'http://www.university.edu/data/roads_rivers.gml';
|
||||
expect(featurelist.href).toEqual(url);
|
||||
expect(layers['Pressure'].queryable).toBeTruthy();
|
||||
expect(layers['ozone_image'].queryable).toBeFalsy();
|
||||
expect(layers['population'].cascaded).toEqual(1);
|
||||
expect(layers['ozone_image'].fixedWidth).toEqual(512);
|
||||
expect(layers['ozone_image'].fixedHeight).toEqual(256);
|
||||
expect(layers['ozone_image'].opaque).toBeTruthy();
|
||||
expect(layers['ozone_image'].noSubsets).toBeTruthy();
|
||||
expect(time['default']).toEqual('2000-08-22');
|
||||
expect(time.values.length).toEqual(1);
|
||||
expect(time.values[0]).toEqual('1999-01-01/2000-08-22/P1D');
|
||||
expect(elevation.units).toEqual('CRS:88');
|
||||
expect(elevation['default']).toEqual('0');
|
||||
expect(elevation.nearestVal).toBeTruthy();
|
||||
expect(elevation.multipleVal).toBeFalsy();
|
||||
expect(elevation.values).toEqual(['0', '1000', '3000', '5000',
|
||||
'10000']);
|
||||
expect(contactinfo).toBeTruthy();
|
||||
expect(personPrimary).toBeTruthy();
|
||||
expect(personPrimary.person).toEqual('Jeff Smith');
|
||||
expect(personPrimary.organization).toEqual('NASA');
|
||||
expect(contactinfo.position).toEqual('Computer Scientist');
|
||||
expect(addr).toBeTruthy();
|
||||
expect(addr.type).toEqual('postal');
|
||||
expect(addr.address).toEqual('NASA Goddard Space Flight Center');
|
||||
expect(addr.city).toEqual('Greenbelt');
|
||||
expect(addr.stateOrProvince).toEqual('MD');
|
||||
expect(addr.postcode).toEqual('20771');
|
||||
expect(addr.country).toEqual('USA');
|
||||
expect(contactinfo.phone).toEqual('+1 301 555-1212');
|
||||
expect(contactinfo.email).toEqual('user@host.com');
|
||||
expect('fees' in service).toBeFalsy();
|
||||
expect('accessConstraints' in service).toBeFalsy();
|
||||
expect(request).toBeTruthy();
|
||||
expect('getmap' in request).toBeTruthy();
|
||||
expect('getfeatureinfo' in request).toBeTruthy();
|
||||
var formats = ['text/xml', 'text/plain', 'text/html'];
|
||||
expect(request.getfeatureinfo.formats).toEqual(formats);
|
||||
expect(exception).toBeTruthy();
|
||||
formats = ['XML', 'INIMAGE', 'BLANK'];
|
||||
expect(exception.formats).toEqual(formats);
|
||||
expect(attribution.title).toEqual('State College University');
|
||||
expect(attribution.href).toEqual('http://www.university.edu/');
|
||||
url = 'http://www.university.edu/icons/logo.gif';
|
||||
expect(attribution.logo.href).toEqual(url);
|
||||
expect(attribution.logo.format).toEqual('image/gif');
|
||||
expect(attribution.logo.width).toEqual('100');
|
||||
expect(attribution.logo.height).toEqual('100');
|
||||
expect(keywords.length).toEqual(3);
|
||||
expect(keywords[0].value).toEqual('road');
|
||||
expect(metadataURLs.length).toEqual(2);
|
||||
expect(metadataURLs[0].type).toEqual('FGDC:1998');
|
||||
expect(metadataURLs[0].format).toEqual('text/plain');
|
||||
url = 'http://www.university.edu/metadata/roads.txt';
|
||||
expect(metadataURLs[0].href).toEqual(url);
|
||||
var minScale = 250000;
|
||||
expect(capability.layers[0].minScale).toEqual(minScale.toPrecision(16));
|
||||
var maxScale = 1000;
|
||||
expect(capability.layers[0].maxScale).toEqual(maxScale.toPrecision(16));
|
||||
expect(obj.service.layerLimit).toEqual(16);
|
||||
expect(obj.service.maxHeight).toEqual(2048);
|
||||
expect(obj.service.maxWidth).toEqual(2048);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test dimensions', function() {
|
||||
it('Default time value parsed correctly', function() {
|
||||
expect(time['default']).toEqual('2000-08-22');
|
||||
});
|
||||
it('Currect number of time extent values/periods', function() {
|
||||
expect(time.values.length).toEqual(1);
|
||||
});
|
||||
it('Time extent values parsed correctly', function() {
|
||||
expect(time.values[0]).toEqual('1999-01-01/2000-08-22/P1D');
|
||||
});
|
||||
it('Dimension units parsed correctly', function() {
|
||||
expect(elevation.units).toEqual('CRS:88');
|
||||
});
|
||||
it('Default elevation value parsed correctly', function() {
|
||||
expect(elevation['default']).toEqual('0');
|
||||
});
|
||||
it('NearestValue parsed correctly', function() {
|
||||
expect(elevation.nearestVal).toBeTruthy();
|
||||
});
|
||||
it('Absense of MultipleValues handled correctly', function() {
|
||||
expect(elevation.multipleVal).toBeFalsy();
|
||||
});
|
||||
it('Parsing of comma-separated values done correctly', function() {
|
||||
expect(elevation.values).toEqual(['0', '1000', '3000', '5000', '10000']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('test contact info', function() {
|
||||
it('object contains contactInformation property', function() {
|
||||
expect(contactinfo).toBeTruthy();
|
||||
});
|
||||
it('object contains personPrimary property', function() {
|
||||
expect(personPrimary).toBeTruthy();
|
||||
});
|
||||
it('ContactPerson parsed correctly', function() {
|
||||
expect(personPrimary.person).toEqual('Jeff Smith');
|
||||
});
|
||||
it('ContactOrganization parsed correctly', function() {
|
||||
expect(personPrimary.organization).toEqual('NASA');
|
||||
});
|
||||
it('ContactPosition parsed correctly', function() {
|
||||
expect(contactinfo.position).toEqual('Computer Scientist');
|
||||
});
|
||||
it('object contains contactAddress property', function() {
|
||||
expect(addr).toBeTruthy();
|
||||
});
|
||||
it('AddressType parsed correctly', function() {
|
||||
expect(addr.type).toEqual('postal');
|
||||
});
|
||||
it('Address parsed correctly', function() {
|
||||
expect(addr.address).toEqual('NASA Goddard Space Flight Center');
|
||||
});
|
||||
it('City parsed correctly', function() {
|
||||
expect(addr.city).toEqual('Greenbelt');
|
||||
});
|
||||
it('StateOrProvince parsed correctly', function() {
|
||||
expect(addr.stateOrProvince).toEqual('MD');
|
||||
});
|
||||
it('PostCode parsed correctly', function() {
|
||||
expect(addr.postcode).toEqual('20771');
|
||||
});
|
||||
it('Country parsed correctly', function() {
|
||||
expect(addr.country).toEqual('USA');
|
||||
});
|
||||
it('ContactVoiceTelephone parsed correctly', function() {
|
||||
expect(contactinfo.phone).toEqual('+1 301 555-1212');
|
||||
});
|
||||
it('ContactElectronicMailAddress parsed correctly', function() {
|
||||
expect(contactinfo.email).toEqual('user@host.com');
|
||||
});
|
||||
});
|
||||
|
||||
describe('test fees and constraints', function() {
|
||||
it('Fees=none handled correctly', function() {
|
||||
expect('fees' in service).toBeFalsy();
|
||||
});
|
||||
it('AccessConstraints=none handled correctly', function() {
|
||||
expect('accessConstraints' in service).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('test requests', function() {
|
||||
it('request property exists', function() {
|
||||
expect(request).toBeTruthy();
|
||||
});
|
||||
it('got GetMap request', function() {
|
||||
expect('getmap' in request).toBeTruthy();
|
||||
});
|
||||
it('got GetFeatureInfo request', function() {
|
||||
expect('getfeatureinfo' in request).toBeTruthy();
|
||||
});
|
||||
it('GetFeatureInfo formats correctly parsed', function() {
|
||||
var formats = ['text/xml', 'text/plain', 'text/html'];
|
||||
expect(request.getfeatureinfo.formats).toEqual(formats);
|
||||
});
|
||||
it('exception property exists', function() {
|
||||
expect(exception).toBeTruthy();
|
||||
});
|
||||
it('Exception Format parsed', function() {
|
||||
var formats = ['XML', 'INIMAGE', 'BLANK'];
|
||||
expect(exception.formats).toEqual(formats);
|
||||
});
|
||||
});
|
||||
|
||||
describe('test ogc', function() {
|
||||
it('attribution title parsed correctly.', function() {
|
||||
expect(attribution.title).toEqual('State College University');
|
||||
});
|
||||
it('attribution href parsed correctly.', function() {
|
||||
expect(attribution.href).toEqual('http://www.university.edu/');
|
||||
});
|
||||
it('attribution logo url parsed correctly.', function() {
|
||||
var url = 'http://www.university.edu/icons/logo.gif';
|
||||
expect(attribution.logo.href).toEqual(url);
|
||||
});
|
||||
it('attribution logo format parsed correctly.', function() {
|
||||
expect(attribution.logo.format).toEqual('image/gif');
|
||||
});
|
||||
it('attribution logo width parsed correctly.', function() {
|
||||
expect(attribution.logo.width).toEqual('100');
|
||||
});
|
||||
it('attribution logo height parsed correctly.', function() {
|
||||
expect(attribution.logo.height).toEqual('100');
|
||||
});
|
||||
it('layer has 3 keywords.', function() {
|
||||
expect(keywords.length).toEqual(3);
|
||||
});
|
||||
it('1st keyword parsed correctly.', function() {
|
||||
expect(keywords[0].value).toEqual('road');
|
||||
});
|
||||
it('layer has 2 metadata urls.', function() {
|
||||
expect(metadataURLs.length).toEqual(2);
|
||||
});
|
||||
it('type parsed correctly.', function() {
|
||||
expect(metadataURLs[0].type).toEqual('FGDC:1998');
|
||||
});
|
||||
it('format parsed correctly.', function() {
|
||||
expect(metadataURLs[0].format).toEqual('text/plain');
|
||||
});
|
||||
it('href parsed correctly.', function() {
|
||||
var url = 'http://www.university.edu/metadata/roads.txt';
|
||||
expect(metadataURLs[0].href).toEqual(url);
|
||||
});
|
||||
it('layer.minScale is correct', function() {
|
||||
var minScale = 250000;
|
||||
expect(capability.layers[0].minScale).toEqual(minScale.toPrecision(16));
|
||||
});
|
||||
it('layer.maxScale is correct', function() {
|
||||
var maxScale = 1000;
|
||||
expect(capability.layers[0].maxScale).toEqual(maxScale.toPrecision(16));
|
||||
});
|
||||
});
|
||||
|
||||
describe('test WMS 1.3 specials', function() {
|
||||
it('LayerLimit parsed correctly', function() {
|
||||
expect(obj.service.layerLimit).toEqual(16);
|
||||
});
|
||||
it('MaxHeight parsed correctly', function() {
|
||||
expect(obj.service.maxHeight).toEqual(2048);
|
||||
});
|
||||
it('MaxWidth parsed correctly', function() {
|
||||
expect(obj.service.maxWidth).toEqual(2048);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.net.XhrIo');
|
||||
|
||||
238
test/spec/ol/source/tilesource.test.js
Normal file
238
test/spec/ol/source/tilesource.test.js
Normal file
@@ -0,0 +1,238 @@
|
||||
goog.provide('ol.test.source.TileSource');
|
||||
|
||||
describe('ol.source.TileSource', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a tile source', function() {
|
||||
var source = new ol.source.TileSource({
|
||||
projection: ol.Projection.getFromCode('EPSG:4326')
|
||||
});
|
||||
expect(source).toBeA(ol.source.Source);
|
||||
expect(source).toBeA(ol.source.TileSource);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#findLoadedTiles()', function() {
|
||||
|
||||
function isLoaded(tile) {
|
||||
return !goog.isNull(tile) && tile.getState() === ol.TileState.LOADED;
|
||||
}
|
||||
|
||||
it('adds no tiles if none are already loaded', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({});
|
||||
|
||||
var loadedTilesByZ = {};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 3);
|
||||
source.findLoadedTiles(loadedTilesByZ, isLoaded, 3, range);
|
||||
|
||||
var keys = goog.object.getKeys(loadedTilesByZ);
|
||||
expect(keys.length).toBe(0);
|
||||
});
|
||||
|
||||
it('adds loaded tiles to the lookup (z: 0)', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({
|
||||
'0/0/0': true,
|
||||
'1/0/0': true
|
||||
});
|
||||
|
||||
var loadedTilesByZ = {};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 0);
|
||||
source.findLoadedTiles(loadedTilesByZ, isLoaded, 0, range);
|
||||
var keys = goog.object.getKeys(loadedTilesByZ);
|
||||
expect(keys.length).toBe(1);
|
||||
var tile = loadedTilesByZ['0']['0/0/0'];
|
||||
expect(tile).toBeA(ol.Tile);
|
||||
expect(tile.state).toBe(ol.TileState.LOADED);
|
||||
});
|
||||
|
||||
it('adds loaded tiles to the lookup (z: 1)', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({
|
||||
'0/0/0': true,
|
||||
'1/0/0': true
|
||||
});
|
||||
|
||||
var loadedTilesByZ = {};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1);
|
||||
source.findLoadedTiles(loadedTilesByZ, isLoaded, 1, range);
|
||||
var keys = goog.object.getKeys(loadedTilesByZ);
|
||||
expect(keys.length).toBe(1);
|
||||
var tile = loadedTilesByZ['1']['1/0/0'];
|
||||
expect(tile).toBeA(ol.Tile);
|
||||
expect(tile.state).toBe(ol.TileState.LOADED);
|
||||
});
|
||||
|
||||
it('returns true when all tiles are already loaded', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({
|
||||
'1/0/0': true,
|
||||
'1/0/1': true,
|
||||
'1/1/0': true,
|
||||
'1/1/1': true
|
||||
});
|
||||
|
||||
var loadedTilesByZ = {};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1);
|
||||
var loaded = source.findLoadedTiles(loadedTilesByZ, isLoaded, 1, range);
|
||||
expect(loaded).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when all tiles are already loaded (part 2)', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({});
|
||||
|
||||
var loadedTilesByZ = {
|
||||
'1': {
|
||||
'1/0/0': true,
|
||||
'1/0/1': true,
|
||||
'1/1/0': true,
|
||||
'1/1/1': true,
|
||||
'1/1/2': true
|
||||
}
|
||||
};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1);
|
||||
var loaded = source.findLoadedTiles(loadedTilesByZ, isLoaded, 1, range);
|
||||
expect(loaded).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when all tiles are already loaded', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({
|
||||
'1/0/0': true,
|
||||
'1/0/1': true,
|
||||
'1/1/0': true,
|
||||
'1/1/1': false
|
||||
});
|
||||
|
||||
var loadedTilesByZ = {};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1);
|
||||
var loaded = source.findLoadedTiles(loadedTilesByZ, isLoaded, 1, range);
|
||||
expect(loaded).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when all tiles are already loaded (part 2)', function() {
|
||||
// a source with no loaded tiles
|
||||
var source = new ol.test.source.MockTileSource({});
|
||||
|
||||
var loadedTilesByZ = {
|
||||
'1': {
|
||||
'1/0/0': true,
|
||||
'1/0/1': true,
|
||||
'1/1/0': true,
|
||||
'1/1/1': false
|
||||
}
|
||||
};
|
||||
var grid = source.getTileGrid();
|
||||
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1);
|
||||
var loaded = source.findLoadedTiles(loadedTilesByZ, isLoaded, 1, range);
|
||||
expect(loaded).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tile source for tests that uses a EPSG:4326 based grid with 4 resolutions and
|
||||
* 256x256 tiles.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.source.TileSource}
|
||||
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
|
||||
*/
|
||||
ol.test.source.MockTileSource = function(loaded) {
|
||||
var extent = new ol.Extent(-180, -180, 180, 180);
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
|
||||
extent: extent,
|
||||
origin: new ol.Coordinate(-180, -180),
|
||||
tileSize: new ol.Size(256, 256)
|
||||
});
|
||||
|
||||
goog.base(this, {
|
||||
extent: extent,
|
||||
projection: ol.Projection.getFromCode('EPSG:4326'),
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {Object.<string, boolean>}
|
||||
* @private
|
||||
*/
|
||||
this.loaded_ = loaded;
|
||||
|
||||
};
|
||||
goog.inherits(ol.test.source.MockTileSource, ol.source.TileSource);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.test.source.MockTileSource.prototype.getTile = function(tileCoord) {
|
||||
var tile = new ol.Tile(tileCoord);
|
||||
var key = tileCoord.toString();
|
||||
if (this.loaded_[key]) {
|
||||
tile.state = ol.TileState.LOADED;
|
||||
}
|
||||
return tile;
|
||||
};
|
||||
|
||||
|
||||
describe('ol.test.source.MockTileSource', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates a tile source', function() {
|
||||
var source = new ol.test.source.MockTileSource({});
|
||||
expect(source).toBeA(ol.source.TileSource);
|
||||
expect(source).toBeA(ol.test.source.MockTileSource);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getTile()', function() {
|
||||
it('returns a tile with state based on constructor arg', function() {
|
||||
var source = new ol.test.source.MockTileSource({
|
||||
'0/0/0': true,
|
||||
'1/0/0': true
|
||||
});
|
||||
var tile;
|
||||
|
||||
// check a loaded tile
|
||||
tile = source.getTile(new ol.TileCoord(0, 0, 0));
|
||||
expect(tile).toBeA(ol.Tile);
|
||||
expect(tile.state).toBe(ol.TileState.LOADED);
|
||||
|
||||
// check a tile that is not loaded
|
||||
tile = source.getTile(new ol.TileCoord(1, 0, -1));
|
||||
expect(tile).toBeA(ol.Tile);
|
||||
expect(tile.state).toBe(ol.TileState.IDLE);
|
||||
|
||||
// check another loaded tile
|
||||
tile = source.getTile(new ol.TileCoord(1, 0, 0));
|
||||
expect(tile).toBeA(ol.Tile);
|
||||
expect(tile.state).toBe(ol.TileState.LOADED);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.object');
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.source.TileSource');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
Reference in New Issue
Block a user