Files
openlayers/test/spec/ol/source/vectorsource.test.js
Tim Schaub e806f51b3d Changing extent structure back to single array: [minX, minY, maxX, maxY]
This means we'll have to have a new structure and new methods for 3D envelopes.
2013-09-15 00:31:32 -06:00

88 lines
2.5 KiB
JavaScript

goog.provide('ol.test.source.Vector');
describe('ol.source.Vector', function() {
describe('constructor', function() {
it('creates an instance', function() {
var source = new ol.source.Vector({});
expect(source).to.be.a(ol.source.Vector);
expect(source).to.be.a(ol.source.Source);
});
});
describe('#prepareFeatures', function() {
it('loads and parses data from a file', function(done) {
var source = new ol.source.Vector({
url: 'spec/ol/parser/geojson/countries.geojson',
parser: new ol.parser.GeoJSON()
});
var layer = new ol.layer.Vector({
source: source
});
source.prepareFeatures(layer, [-180, -90, 180, 90],
ol.proj.get('EPSG:4326'),
function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
expect(goog.object.getCount(
layer.featureCache_.getFeaturesObject())).to.be(179);
done();
});
});
it('parses inline data', function() {
var source = new ol.source.Vector({
data: {
'type': 'FeatureCollection',
'features': [{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -6000000]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [-6000000, 0]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, 6000000]
}
}, {
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [6000000, 0]
}
}]
},
parser: new ol.parser.GeoJSON(),
projection: ol.proj.get('EPSG:4326')
});
var layer = new ol.layer.Vector({
source: source
});
source.prepareFeatures(layer, [-180, -90, 180, 90],
ol.proj.get('EPSG:4326'),
function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
expect(goog.object.getCount(
layer.featureCache_.getFeaturesObject())).to.be(4);
done();
});
});
});
});
goog.require('goog.object');
goog.require('ol.layer.Vector');
goog.require('ol.parser.GeoJSON');
goog.require('ol.proj');
goog.require('ol.source.Source');
goog.require('ol.source.Vector');