merge with master - solving conflicts
This commit is contained in:
commit
1948233d1f
209 files changed
+14572
-1847
No files matched your search
@@ -68,6 +68,7 @@ describe('ol.control.ZoomSlider', function() {
|
||||
control.element.style.width = '1000px';
|
||||
control.element.style.height = '10px';
|
||||
control.setMap(map);
|
||||
control.initSlider_();
|
||||
|
||||
var horizontal = ol.control.ZoomSlider.direction.HORIZONTAL;
|
||||
expect(control.direction_).to.be(horizontal);
|
||||
|
||||
@@ -108,4 +108,39 @@ describe('ol.geom.LinearRing', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.geom.LinearRing.isClockwise()', function() {
|
||||
|
||||
var isClockwise = ol.geom.LinearRing.isClockwise;
|
||||
|
||||
it('returns true for clockwise coordinates', function() {
|
||||
var coordinates = [
|
||||
[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]
|
||||
];
|
||||
expect(isClockwise(coordinates)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for counter-clockwise coordinates', function() {
|
||||
var coordinates = [
|
||||
[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]
|
||||
];
|
||||
expect(isClockwise(coordinates)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns true for mostly clockwise, self-intersecting ring', function() {
|
||||
var coordinates = [
|
||||
[0, 0], [0, 1], [1.5, 1], [1.5, 1.5], [1, 1.5], [1, 0], [0, 0]
|
||||
];
|
||||
expect(isClockwise(coordinates)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for mostly counter-clockwise, intersecting', function() {
|
||||
var coordinates = [
|
||||
[0, 0], [1, 0], [1, 1.5], [1.5, 1.5], [1.5, 1], [0, 1], [0, 0]
|
||||
];
|
||||
expect(isClockwise(coordinates)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
goog.require('ol.geom.LinearRing');
|
||||
@@ -44,6 +44,28 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(poly.rings[2]).to.be.a(ol.geom.LinearRing);
|
||||
});
|
||||
|
||||
var isClockwise = ol.geom.LinearRing.isClockwise;
|
||||
|
||||
it('forces exterior ring to be clockwise', function() {
|
||||
var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
|
||||
expect(isClockwise(outer)).to.be(false);
|
||||
|
||||
var poly = new ol.geom.Polygon([outer]);
|
||||
var ring = poly.rings[0];
|
||||
expect(isClockwise(ring.getCoordinates())).to.be(true);
|
||||
});
|
||||
|
||||
it('forces interior ring to be counter-clockwise', function() {
|
||||
var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
|
||||
var inner = [[2, 2], [2, 8], [8, 8], [8, 2], [2, 2]];
|
||||
expect(isClockwise(inner)).to.be(true);
|
||||
|
||||
var poly = new ol.geom.Polygon([outer, inner]);
|
||||
var ring = poly.rings[1];
|
||||
expect(isClockwise(ring.getCoordinates())).to.be(false);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('#dimension', function() {
|
||||
|
||||
@@ -60,7 +60,8 @@ describe('ol.layer.Layer', function() {
|
||||
hue: 180,
|
||||
opacity: 0.5,
|
||||
saturation: 5,
|
||||
visible: false
|
||||
visible: false,
|
||||
foo: 42
|
||||
});
|
||||
|
||||
expect(layer.getBrightness()).to.be(0.5);
|
||||
@@ -69,6 +70,7 @@ describe('ol.layer.Layer', function() {
|
||||
expect(layer.getOpacity()).to.be(0.5);
|
||||
expect(layer.getSaturation()).to.be(5);
|
||||
expect(layer.getVisible()).to.be(false);
|
||||
expect(layer.get('foo')).to.be(42);
|
||||
|
||||
goog.dispose(layer);
|
||||
});
|
||||
|
||||
@@ -9,11 +9,12 @@ describe('ol.layer.Vector', function() {
|
||||
source: new ol.source.Vector({})
|
||||
});
|
||||
layer.addFeatures([new ol.Feature(), new ol.Feature()]);
|
||||
expect(layer.getFeatures().length).to.eql(2);
|
||||
expect(goog.object.getCount(layer.featureCache_.getFeaturesObject()))
|
||||
.to.eql(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getFeatures()', function() {
|
||||
describe('ol.layer.FeatureCache#getFeaturesObject()', function() {
|
||||
|
||||
var layer, features;
|
||||
|
||||
@@ -55,18 +56,18 @@ describe('ol.layer.Vector', function() {
|
||||
|
||||
it('can filter by geometry type using its GeometryType index', function() {
|
||||
sinon.spy(geomFilter, 'evaluate');
|
||||
var lineStrings = layer.getFeatures(geomFilter);
|
||||
var lineStrings = layer.featureCache_.getFeaturesObject(geomFilter);
|
||||
expect(geomFilter.evaluate).to.not.be.called();
|
||||
expect(lineStrings.length).to.eql(4);
|
||||
expect(lineStrings).to.contain(features[4]);
|
||||
expect(goog.object.getCount(lineStrings)).to.eql(4);
|
||||
expect(goog.object.getValues(lineStrings)).to.contain(features[4]);
|
||||
});
|
||||
|
||||
it('can filter by extent using its RTree', function() {
|
||||
sinon.spy(extentFilter, 'evaluate');
|
||||
var subset = layer.getFeatures(extentFilter);
|
||||
var subset = layer.featureCache_.getFeaturesObject(extentFilter);
|
||||
expect(extentFilter.evaluate).to.not.be.called();
|
||||
expect(subset.length).to.eql(4);
|
||||
expect(subset).not.to.contain(features[7]);
|
||||
expect(goog.object.getCount(subset)).to.eql(4);
|
||||
expect(goog.object.getValues(subset)).not.to.contain(features[7]);
|
||||
});
|
||||
|
||||
it('can filter by extent and geometry type using its index', function() {
|
||||
@@ -76,21 +77,21 @@ describe('ol.layer.Vector', function() {
|
||||
ol.expr.LogicalOp.AND, extentFilter, geomFilter);
|
||||
sinon.spy(filter1, 'evaluate');
|
||||
sinon.spy(filter2, 'evaluate');
|
||||
var subset1 = layer.getFeatures(filter1);
|
||||
var subset2 = layer.getFeatures(filter2);
|
||||
var subset1 = layer.featureCache_.getFeaturesObject(filter1);
|
||||
var subset2 = layer.featureCache_.getFeaturesObject(filter2);
|
||||
expect(filter1.evaluate).to.not.be.called();
|
||||
expect(filter2.evaluate).to.not.be.called();
|
||||
expect(subset1.length).to.eql(0);
|
||||
expect(subset2.length).to.eql(0);
|
||||
expect(goog.object.getCount(subset1)).to.eql(0);
|
||||
expect(goog.object.getCount(subset2)).to.eql(0);
|
||||
});
|
||||
|
||||
it('can handle query using the filter\'s evaluate function', function() {
|
||||
var filter = new ol.expr.Logical(
|
||||
ol.expr.LogicalOp.OR, geomFilter, extentFilter);
|
||||
sinon.spy(filter, 'evaluate');
|
||||
var subset = layer.getFeatures(filter);
|
||||
var subset = layer.featureCache_.getFeaturesObject(filter);
|
||||
expect(filter.evaluate).to.be.called();
|
||||
expect(subset.length).to.eql(8);
|
||||
expect(goog.object.getCount(subset)).to.eql(8);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -177,6 +178,7 @@ describe('ol.layer.Vector', function() {
|
||||
});
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Logical');
|
||||
|
||||
@@ -237,7 +237,8 @@ describe('ol.parser.GeoJSON', function() {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var result = parser.readFeaturesFromString(text, {callback: callback});
|
||||
var result = parser.readFeaturesFromString(text,
|
||||
{callback: callback}).features;
|
||||
expect(result.length).to.be(179);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(0);
|
||||
@@ -266,6 +267,267 @@ describe('ol.parser.GeoJSON', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#parseAsFeatureCollection_()', function() {
|
||||
|
||||
it('returns an array of features for FeatureCollection', function() {
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var parser = new ol.parser.GeoJSON();
|
||||
var json = {
|
||||
type: 'FeatureCollection',
|
||||
features: [{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
foo: 'bar'
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [1, 2]
|
||||
}
|
||||
}, {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
bam: 'baz'
|
||||
},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
coordinates: [[1, 2], [3, 4]]
|
||||
}
|
||||
}]
|
||||
};
|
||||
var features = parser.parseAsFeatureCollection_(json,
|
||||
{callback: callback});
|
||||
|
||||
expect(features.length).to.be(2);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first.get('foo')).to.be('bar');
|
||||
expect(first.getGeometry()).to.be.a(ol.geom.Point);
|
||||
|
||||
var second = features[1];
|
||||
expect(second).to.be.a(ol.Feature);
|
||||
expect(second.get('bam')).to.be('baz');
|
||||
expect(second.getGeometry()).to.be.a(ol.geom.LineString);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(2);
|
||||
expect(lineVertices.coordinates.length).to.be(4);
|
||||
expect(polygonVertices.coordinates.length).to.be(0);
|
||||
});
|
||||
|
||||
it('returns an array of features for Feature', function() {
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var parser = new ol.parser.GeoJSON();
|
||||
var json = {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
bam: 'baz'
|
||||
},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
coordinates: [[1, 2], [3, 4]]
|
||||
}
|
||||
};
|
||||
var features = parser.parseAsFeatureCollection_(json,
|
||||
{callback: callback});
|
||||
|
||||
expect(features.length).to.be(1);
|
||||
|
||||
var first = features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
expect(first.get('bam')).to.be('baz');
|
||||
expect(first.getGeometry()).to.be.a(ol.geom.LineString);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(0);
|
||||
expect(lineVertices.coordinates.length).to.be(4);
|
||||
expect(polygonVertices.coordinates.length).to.be(0);
|
||||
});
|
||||
|
||||
it('returns an array of features for GeometryCollection', function() {
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var parser = new ol.parser.GeoJSON();
|
||||
var json = {
|
||||
type: 'GeometryCollection',
|
||||
geometries: [{
|
||||
type: 'Point',
|
||||
coordinates: [1, 2]
|
||||
}, {
|
||||
type: 'LineString',
|
||||
coordinates: [[3, 4], [5, 6]]
|
||||
}, {
|
||||
type: 'Polygon',
|
||||
coordinates: [[[7, 8], [9, 10], [11, 12], [7, 8]]]
|
||||
}]
|
||||
};
|
||||
var features = parser.parseAsFeatureCollection_(json,
|
||||
{callback: callback});
|
||||
|
||||
expect(features.length).to.be(3);
|
||||
|
||||
expect(features[0].getGeometry()).to.be.a(ol.geom.Point);
|
||||
expect(features[1].getGeometry()).to.be.a(ol.geom.LineString);
|
||||
expect(features[2].getGeometry()).to.be.a(ol.geom.Polygon);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(2);
|
||||
expect(lineVertices.coordinates.length).to.be(4);
|
||||
expect(polygonVertices.coordinates.length).to.be(8);
|
||||
});
|
||||
|
||||
it('returns an array of features for Point', function() {
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var parser = new ol.parser.GeoJSON();
|
||||
var json = {
|
||||
type: 'Point',
|
||||
coordinates: [1, 2]
|
||||
};
|
||||
var features = parser.parseAsFeatureCollection_(json,
|
||||
{callback: callback});
|
||||
|
||||
expect(features.length).to.be(1);
|
||||
|
||||
expect(features[0].getGeometry()).to.be.a(ol.geom.Point);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(2);
|
||||
expect(lineVertices.coordinates.length).to.be(0);
|
||||
expect(polygonVertices.coordinates.length).to.be(0);
|
||||
});
|
||||
|
||||
it('returns an array of features for LineString', function() {
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var parser = new ol.parser.GeoJSON();
|
||||
var json = {
|
||||
type: 'LineString',
|
||||
coordinates: [[3, 4], [5, 6]]
|
||||
};
|
||||
var features = parser.parseAsFeatureCollection_(json,
|
||||
{callback: callback});
|
||||
|
||||
expect(features.length).to.be(1);
|
||||
|
||||
expect(features[0].getGeometry()).to.be.a(ol.geom.LineString);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(0);
|
||||
expect(lineVertices.coordinates.length).to.be(4);
|
||||
expect(polygonVertices.coordinates.length).to.be(0);
|
||||
});
|
||||
|
||||
it('returns an array of features for Polygon', function() {
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var parser = new ol.parser.GeoJSON();
|
||||
var json = {
|
||||
type: 'Polygon',
|
||||
coordinates: [[[7, 8], [9, 10], [11, 12], [7, 8]]]
|
||||
};
|
||||
var features = parser.parseAsFeatureCollection_(json,
|
||||
{callback: callback});
|
||||
|
||||
expect(features.length).to.be(1);
|
||||
|
||||
expect(features[0].getGeometry()).to.be.a(ol.geom.Polygon);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(0);
|
||||
expect(lineVertices.coordinates.length).to.be(0);
|
||||
expect(polygonVertices.coordinates.length).to.be(8);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Feature');
|
||||
|
||||
@@ -52,8 +52,8 @@ describe('ol.parser.kml', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.KML({maxDepth: 1});
|
||||
// we need to supply a callback to get visited NetworkLinks
|
||||
p.read(xml, function(features) {
|
||||
expect(features.length).to.eql(3);
|
||||
p.read(xml, function(obj) {
|
||||
expect(obj.features.length).to.eql(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -63,8 +63,8 @@ describe('ol.parser.kml', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.KML({maxDepth: 2});
|
||||
// we need to supply a callback to get visited NetworkLinks
|
||||
p.read(xml, function(features) {
|
||||
expect(features.length).to.eql(2);
|
||||
p.read(xml, function(obj) {
|
||||
expect(obj.features.length).to.eql(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -74,9 +74,9 @@ describe('ol.parser.kml', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.KML({maxDepth: 1});
|
||||
// we need to supply a callback to get visited NetworkLinks
|
||||
p.read(xml, function(features) {
|
||||
p.read(xml, function(obj) {
|
||||
// since maxDepth is 1, we will not get to the second feature
|
||||
expect(features.length).to.eql(1);
|
||||
expect(obj.features.length).to.eql(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -182,45 +182,49 @@ describe('ol.parser.kml', function() {
|
||||
var symbolizer = obj.features[0].getSymbolizerLiterals()[0];
|
||||
expect(symbolizer instanceof ol.style.LineLiteral).to.be.ok();
|
||||
expect(symbolizer.strokeColor).to.eql('#ff0000');
|
||||
expect(symbolizer.opacity).to.eql(0.5294117647058824);
|
||||
expect(symbolizer.strokeOpacity).to.eql(0.5294117647058824);
|
||||
expect(symbolizer.strokeWidth).to.eql(10);
|
||||
});
|
||||
it('Test style fill (read / write)', function() {
|
||||
var test_style_fill = '<kml xmlns="http://www.opengis.net/kml/2.2">' +
|
||||
it('reads PolyStyle fill', function() {
|
||||
var kml = '<kml xmlns="http://www.opengis.net/kml/2.2">' +
|
||||
'<Document><Placemark> <Style> <PolyStyle> <fill>1</fill> ' +
|
||||
'<color>870000ff</color> <width>10</width> </PolyStyle> </Style>' +
|
||||
'<color>870000ff</color></PolyStyle> </Style>' +
|
||||
'<Polygon><outerBoundaryIs><LinearRing><coordinates>' +
|
||||
'5.001370157823406,49.26855713824488 8.214706453896161,' +
|
||||
'49.630662409673505 8.397385910100951,48.45172350357396 ' +
|
||||
'5.001370157823406,49.26855713824488</coordinates></LinearRing>' +
|
||||
'</outerBoundaryIs></Polygon></Placemark><Placemark> <Style> ' +
|
||||
'<PolyStyle><fill>0</fill><color>870000ff</color><width>10</width> ' +
|
||||
'<PolyStyle><fill>0</fill><color>870000ff</color>' +
|
||||
'</PolyStyle> </Style>' +
|
||||
'<Polygon><outerBoundaryIs><LinearRing><coordinates>' +
|
||||
'5.001370157823406,49.26855713824488 8.214706453896161,' +
|
||||
'49.630662409673505 8.397385910100951,48.45172350357396 ' +
|
||||
'5.001370157823406,49.26855713824488</coordinates></LinearRing>' +
|
||||
'</outerBoundaryIs></Polygon></Placemark></Document></kml>';
|
||||
var style_fill_write = '<kml xmlns="http://www.opengis.net/kml/2.2" ' +
|
||||
var p = new ol.parser.KML({extractStyles: true});
|
||||
var obj = p.read(kml);
|
||||
var symbolizer1 = obj.features[0].getSymbolizerLiterals()[0];
|
||||
var symbolizer2 = obj.features[1].getSymbolizerLiterals()[0];
|
||||
expect(symbolizer1.strokeColor).to.be('#ff0000');
|
||||
expect(symbolizer2.fillOpacity).to.be(undefined);
|
||||
});
|
||||
it('writes PolyStyle fill and outline', function() {
|
||||
var kml = '<kml xmlns="http://www.opengis.net/kml/2.2" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.opengis.net/kml/2.2 ' +
|
||||
'http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd"> ' +
|
||||
'<Document><Placemark> <Style> <PolyStyle> <fill>1</fill> ' +
|
||||
'<color>870000ff</color> <width>10</width> </PolyStyle> </Style>' +
|
||||
'<Document><Placemark><Style><PolyStyle>' +
|
||||
'<fill>1</fill><outline>0</outline>' +
|
||||
'<color>870000ff</color></PolyStyle> </Style>' +
|
||||
'<Polygon><outerBoundaryIs><LinearRing><coordinates>' +
|
||||
'5.001370157823406,49.26855713824488 8.214706453896161,' +
|
||||
'49.630662409673505 8.397385910100951,48.45172350357396 ' +
|
||||
'5.001370157823406,49.26855713824488</coordinates></LinearRing>' +
|
||||
'</outerBoundaryIs></Polygon></Placemark></Document></kml>';
|
||||
var p = new ol.parser.KML({extractStyles: true});
|
||||
var obj = p.read(test_style_fill);
|
||||
var output = p.write(p.read(style_fill_write));
|
||||
expect(goog.dom.xml.loadXml(style_fill_write)).to.xmleql(
|
||||
var output = p.write(p.read(kml));
|
||||
expect(goog.dom.xml.loadXml(kml)).to.xmleql(
|
||||
goog.dom.xml.loadXml(output));
|
||||
var symbolizer1 = obj.features[0].getSymbolizerLiterals()[0];
|
||||
var symbolizer2 = obj.features[1].getSymbolizerLiterals()[0];
|
||||
expect(symbolizer1.fillColor).to.eql('#ff0000');
|
||||
expect(symbolizer2.opacity).to.eql(0);
|
||||
});
|
||||
it('Test iconStyle (read / write)', function(done) {
|
||||
var url = 'spec/ol/parser/kml/iconstyle.kml';
|
||||
@@ -238,14 +242,63 @@ describe('ol.parser.kml', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('parsing states.kml', function() {
|
||||
|
||||
var features;
|
||||
before(function(done) {
|
||||
afterLoadXml('spec/ol/parser/kml/states.kml', function(xml) {
|
||||
var parser = new ol.parser.KML();
|
||||
var obj;
|
||||
try {
|
||||
obj = parser.read(xml);
|
||||
} catch (err) {
|
||||
return done(err);
|
||||
}
|
||||
if (!obj.features) {
|
||||
return done(new Error('Failed to parse features from doc'));
|
||||
}
|
||||
features = obj.features;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('creates 50 features', function() {
|
||||
expect(features).to.have.length(50);
|
||||
});
|
||||
|
||||
it('creates features with heterogenous geometry collections', function() {
|
||||
// TODO: decide if we should instead create features with multiple geoms
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.GeometryCollection);
|
||||
});
|
||||
|
||||
it('parses Point and MultiPolygon for Alaska', function() {
|
||||
var alaska = goog.array.find(features, function(feature) {
|
||||
return feature.get('name') === 'Alaska';
|
||||
});
|
||||
expect(alaska).to.be.a(ol.Feature);
|
||||
var geometry = alaska.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.GeometryCollection);
|
||||
expect(geometry.components).to.have.length(2);
|
||||
expect(geometry.components[0]).to.be.a(ol.geom.Point);
|
||||
expect(geometry.components[1]).to.be.a(ol.geom.MultiPolygon);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.dom.xml');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.GeometryCollection');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.parser.KML');
|
||||
|
||||
@@ -1,34 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd">
|
||||
<Document>
|
||||
<name>Polygon.kml</name>
|
||||
<open>0</open>
|
||||
<Placemark id="KML.Polygon">
|
||||
<name>hollow box</name>
|
||||
<Polygon>
|
||||
<outerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>
|
||||
-122.366278,37.818844,30
|
||||
-122.365248,37.819267,30
|
||||
-122.36564,37.819861,30
|
||||
-122.366669,37.819429,30
|
||||
-122.366278,37.818844,30
|
||||
</coordinates>
|
||||
</LinearRing>
|
||||
</outerBoundaryIs>
|
||||
<innerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>
|
||||
-122.366212,37.818977,30
|
||||
-122.365424,37.819294,30
|
||||
-122.365704,37.819731,30
|
||||
-122.366488,37.819402,30
|
||||
-122.366212,37.818977,30
|
||||
</coordinates>
|
||||
</LinearRing>
|
||||
</innerBoundaryIs>
|
||||
</Polygon>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
<Document>
|
||||
<name>Polygon.kml</name>
|
||||
<open>0</open>
|
||||
<Placemark id="KML.Polygon">
|
||||
<name>hollow box</name>
|
||||
<Polygon>
|
||||
<outerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>-30,-20,0 -30,20,0 30,20,0 30,-20,0 -30,-20,0</coordinates>
|
||||
</LinearRing>
|
||||
</outerBoundaryIs>
|
||||
<innerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>-15,-10,0 15,-10,0 15,10,0 -15,10,0 -15,-10,0</coordinates>
|
||||
</LinearRing>
|
||||
</innerBoundaryIs>
|
||||
</Polygon>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -18,12 +18,13 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/point-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
parser.applyWriteOptions(obj);
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('point');
|
||||
expect(obj.geometry.coordinates).to.eql([1, 2]);
|
||||
done();
|
||||
@@ -46,12 +47,13 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipoint-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multipoint');
|
||||
expect(obj.geometry.parts.length).to.eql(3);
|
||||
expect(obj.geometry.parts[0].type).to.eql('point');
|
||||
@@ -75,12 +77,13 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/linestring-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('linestring');
|
||||
expect(obj.geometry.coordinates.length).to.eql(2);
|
||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
|
||||
@@ -103,12 +106,13 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/multilinestring-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multilinestring');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
expect(obj.geometry.parts[0].type).to.eql('linestring');
|
||||
@@ -137,22 +141,15 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/polygon-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('polygon');
|
||||
done();
|
||||
expect(obj.geometry.coordinates.length).to.eql(3);
|
||||
expect(obj.geometry.coordinates[0].length).to.eql(4);
|
||||
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
|
||||
[5, 6], [1, 2]]);
|
||||
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
|
||||
[6, 7], [2, 3]]);
|
||||
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
|
||||
[7, 8], [3, 4]]);
|
||||
});
|
||||
});
|
||||
it('MultiPolygon read correctly from coord', function(done) {
|
||||
@@ -169,12 +166,13 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/multipolygon-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multipolygon');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
expect(obj.geometry.parts[0].type).to.eql('polygon');
|
||||
@@ -185,12 +183,14 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/' +
|
||||
'geometrycollection-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v2({srsName: 'foo',
|
||||
featureNS: 'http://foo'});
|
||||
var p = new ol.parser.ogc.GML_v2({featureNS: 'http://foo'});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj);
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('geometrycollection');
|
||||
expect(obj.geometry.parts.length).to.eql(3);
|
||||
@@ -230,12 +230,13 @@ describe('ol.parser.gml_v2', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/linearring-coordinates.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('linearring');
|
||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
|
||||
[1, 2]]);
|
||||
@@ -245,18 +246,19 @@ describe('ol.parser.gml_v2', function() {
|
||||
it('FeatureCollection read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v2/topp-states.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var srsName = 'http://www.opengis.net/gml/srs/epsg.xml#4326';
|
||||
var schemaLoc = 'http://www.openplans.org/topp ' +
|
||||
'http://demo.opengeo.org/geoserver/wfs?service=WFS&version=' +
|
||||
'1.0.0&request=DescribeFeatureType&typeName=topp:states ' +
|
||||
'http://www.opengis.net/wfs http://demo.opengeo.org/' +
|
||||
'geoserver/schemas/wfs/1.0.0/WFS-basic.xsd';
|
||||
var p = new ol.parser.ogc.GML_v2({srsName: srsName,
|
||||
var p = new ol.parser.ogc.GML_v2({
|
||||
featureType: 'states',
|
||||
featureNS: 'http://www.openplans.org/topp',
|
||||
schemaLocation: schemaLoc});
|
||||
var obj = p.read(xml);
|
||||
var output = p.write(obj);
|
||||
// overwrite the axis orientation of the projection, since WFS 1.0.0
|
||||
// always uses enu
|
||||
var obj = p.read(xml, {axisOrientation: 'enu'});
|
||||
var output = p.write(obj, {axisOrientation: 'enu'});
|
||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||
expect(obj.features.length).to.eql(3);
|
||||
var feature = obj.features[0];
|
||||
@@ -269,6 +271,8 @@ describe('ol.parser.gml_v2', function() {
|
||||
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
||||
expect(attributes['STATE_ABBR']).to.eql('IL');
|
||||
expect(attributes['LAND_KM']).to.eql('143986.61');
|
||||
expect(ol.proj.get(obj.metadata.projection) instanceof ol.proj.EPSG4326)
|
||||
.to.be.ok();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -334,3 +338,5 @@ goog.require('ol.parser.ogc.GML_v2');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.EPSG4326');
|
||||
@@ -18,10 +18,11 @@ describe('ol.parser.gml_v3', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.srsName = 'foo';
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('linearring');
|
||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4], [5, 6],
|
||||
@@ -34,10 +35,11 @@ describe('ol.parser.gml_v3', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.srsName = 'foo';
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('linestring');
|
||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
|
||||
@@ -57,11 +59,14 @@ describe('ol.parser.gml_v3', function() {
|
||||
it('Curve read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/curve.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v3({curve: true, srsName: 'foo'});
|
||||
var p = new ol.parser.ogc.GML_v3({curve: true});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj);
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('linestring');
|
||||
expect(obj.geometry.coordinates).to.eql([[1, 2], [3, 4]]);
|
||||
@@ -82,11 +87,14 @@ describe('ol.parser.gml_v3', function() {
|
||||
it('MultiLineString singular read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multilinestring-singular.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v3({multiCurve: false, srsName: 'foo'});
|
||||
var p = new ol.parser.ogc.GML_v3({multiCurve: false});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj);
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multilinestring');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
@@ -98,12 +106,13 @@ describe('ol.parser.gml_v3', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-singular.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multilinestring');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
expect(obj.geometry.parts[0].type).to.eql('linestring');
|
||||
@@ -114,11 +123,14 @@ describe('ol.parser.gml_v3', function() {
|
||||
it('MultiCurve curve read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multicurve-curve.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v3({curve: true, srsName: 'foo'});
|
||||
var p = new ol.parser.ogc.GML_v3({curve: true});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj);
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multilinestring');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
@@ -142,12 +154,13 @@ describe('ol.parser.gml_v3', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipoint-singular.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multipoint');
|
||||
expect(obj.geometry.parts.length).to.eql(3);
|
||||
expect(obj.geometry.parts[0].type).to.eql('point');
|
||||
@@ -168,11 +181,14 @@ describe('ol.parser.gml_v3', function() {
|
||||
it('MultiPolygon singular read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multipolygon-singular.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v3({multiSurface: false, srsName: 'foo'});
|
||||
var p = new ol.parser.ogc.GML_v3({multiSurface: false});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj);
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multipolygon');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
@@ -194,12 +210,13 @@ describe('ol.parser.gml_v3', function() {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-singular.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
parser.srsName = 'foo';
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multipolygon');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
expect(obj.geometry.parts[0].type).to.eql('polygon');
|
||||
@@ -209,11 +226,14 @@ describe('ol.parser.gml_v3', function() {
|
||||
it('MultiSurface surface read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/multisurface-surface.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v3({surface: true, srsName: 'foo'});
|
||||
var p = new ol.parser.ogc.GML_v3({surface: true});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj);
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('multipolygon');
|
||||
expect(obj.geometry.parts.length).to.eql(2);
|
||||
@@ -226,10 +246,11 @@ describe('ol.parser.gml_v3', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.srsName = 'foo';
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('point');
|
||||
expect(obj.geometry.coordinates).to.eql([1, 2]);
|
||||
@@ -241,55 +262,41 @@ describe('ol.parser.gml_v3', function() {
|
||||
afterLoadXml(url, function(xml) {
|
||||
var obj = parser.read(xml);
|
||||
var geom = parser.createGeometry({geometry: obj.geometry});
|
||||
parser.srsName = 'foo';
|
||||
parser.applyWriteOptions(obj);
|
||||
var node = parser.featureNSWiters_['_geometry'].apply(parser,
|
||||
[geom]).firstChild;
|
||||
delete parser.srsName;
|
||||
delete parser.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(parser.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('polygon');
|
||||
expect(obj.geometry.coordinates.length).to.eql(3);
|
||||
expect(obj.geometry.coordinates[0].length).to.eql(4);
|
||||
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
|
||||
[5, 6], [1, 2]]);
|
||||
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
|
||||
[6, 7], [2, 3]]);
|
||||
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
|
||||
[7, 8], [3, 4]]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('Surface read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/surface.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var p = new ol.parser.ogc.GML_v3({surface: true, srsName: 'foo'});
|
||||
var p = new ol.parser.ogc.GML_v3({surface: true});
|
||||
var obj = p.read(xml);
|
||||
var geom = p.createGeometry({geometry: obj.geometry});
|
||||
p.applyWriteOptions(obj, {srsName: 'foo'});
|
||||
var node = p.featureNSWiters_['_geometry'].apply(p,
|
||||
[geom]).firstChild;
|
||||
delete p.srsName;
|
||||
delete p.axisOrientation;
|
||||
expect(goog.dom.xml.loadXml(p.serialize(node))).to.xmleql(xml);
|
||||
expect(obj.geometry.type).to.eql('polygon');
|
||||
expect(obj.geometry.coordinates.length).to.eql(3);
|
||||
expect(obj.geometry.coordinates[0].length).to.eql(4);
|
||||
expect(obj.geometry.coordinates[0]).to.eql([[1, 2], [3, 4],
|
||||
[5, 6], [1, 2]]);
|
||||
expect(obj.geometry.coordinates[1]).to.eql([[2, 3], [4, 5],
|
||||
[6, 7], [2, 3]]);
|
||||
expect(obj.geometry.coordinates[2]).to.eql([[3, 4], [5, 6],
|
||||
[7, 8], [3, 4]]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('FeatureCollection from GML read / written correctly', function(done) {
|
||||
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-gml.xml';
|
||||
afterLoadXml(url, function(xml) {
|
||||
var srsName = 'urn:x-ogc:def:crs:EPSG:4326';
|
||||
var schemaLoc = 'http://www.openplans.org/topp ' +
|
||||
'http://demo.opengeo.org/geoserver/wfs?service=WFS&version=' +
|
||||
'1.1.0&request=DescribeFeatureType&typeName=topp:states ' +
|
||||
'http://www.opengis.net/gml ' +
|
||||
'http://schemas.opengis.net/gml/3.2.1/gml.xsd';
|
||||
var p = new ol.parser.ogc.GML_v3({srsName: srsName,
|
||||
schemaLocation: schemaLoc});
|
||||
var p = new ol.parser.ogc.GML_v3({schemaLocation: schemaLoc});
|
||||
var obj = p.read(xml);
|
||||
var output = p.write(obj);
|
||||
expect(goog.dom.xml.loadXml(output)).to.xmleql(xml);
|
||||
@@ -305,6 +312,8 @@ describe('ol.parser.gml_v3', function() {
|
||||
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
||||
expect(attributes['STATE_ABBR']).to.eql('IL');
|
||||
expect(attributes['LAND_KM']).to.eql('143986.61');
|
||||
expect(ol.proj.get(obj.metadata.projection) instanceof ol.proj.EPSG4326)
|
||||
.to.be.ok();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -323,6 +332,8 @@ describe('ol.parser.gml_v3', function() {
|
||||
expect(attributes['SUB_REGION']).to.eql('E N Cen');
|
||||
expect(attributes['STATE_ABBR']).to.eql('IL');
|
||||
expect(attributes['LAND_KM']).to.eql('143986.61');
|
||||
expect(ol.proj.get(obj.metadata.projection) instanceof ol.proj.EPSG4326)
|
||||
.to.be.ok();
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -368,3 +379,5 @@ describe('ol.parser.gml_v3', function() {
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.parser.ogc.GML_v3');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.EPSG4326');
|
||||
@@ -13,17 +13,17 @@
|
||||
<gml:Polygon srsName="foo">
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,2 3,4 1,2</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
<gml:innerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">2,3 4,5 6,7 2,3</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">2,3 2,5 4,5 2,3</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:innerBoundaryIs>
|
||||
<gml:innerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">3,4 5,6 7,8 3,4</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">3,4 3,6 5,6 3,4</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:innerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>3</gml:X>
|
||||
<gml:Y>4</gml:Y>
|
||||
<gml:Y>2</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>5</gml:X>
|
||||
<gml:Y>6</gml:Y>
|
||||
<gml:X>3</gml:X>
|
||||
<gml:Y>4</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>1</gml:X>
|
||||
@@ -28,12 +28,12 @@
|
||||
<gml:Y>3</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>4</gml:X>
|
||||
<gml:X>2</gml:X>
|
||||
<gml:Y>5</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>6</gml:X>
|
||||
<gml:Y>7</gml:Y>
|
||||
<gml:X>4</gml:X>
|
||||
<gml:Y>5</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>2</gml:X>
|
||||
@@ -48,12 +48,12 @@
|
||||
<gml:Y>4</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>5</gml:X>
|
||||
<gml:X>3</gml:X>
|
||||
<gml:Y>6</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>7</gml:X>
|
||||
<gml:Y>8</gml:Y>
|
||||
<gml:X>5</gml:X>
|
||||
<gml:Y>6</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>3</gml:X>
|
||||
@@ -73,11 +73,11 @@
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>3</gml:X>
|
||||
<gml:Y>4</gml:Y>
|
||||
<gml:Y>2</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>5</gml:X>
|
||||
<gml:Y>6</gml:Y>
|
||||
<gml:X>3</gml:X>
|
||||
<gml:Y>4</gml:Y>
|
||||
</gml:coord>
|
||||
<gml:coord>
|
||||
<gml:X>1</gml:X>
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
<gml:Polygon>
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,2 3,4 1,2</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
<gml:innerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">2,3 4,5 6,7 2,3</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">2,3 2,5 4,5 2,3</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:innerBoundaryIs>
|
||||
<gml:innerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">3,4 5,6 7,8 3,4</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">3,4 3,6 5,6 3,4</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:innerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
@@ -22,7 +22,7 @@
|
||||
<gml:Polygon>
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,2 3,4 1,2</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="foo">
|
||||
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="FOO">
|
||||
<gml:coord>
|
||||
<gml:X>1</gml:X>
|
||||
<gml:Y>2</gml:Y>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
|
||||
<gml:outerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 3,4 5,6 1,2</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">1,2 5,2 5,6 1,2</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:outerBoundaryIs>
|
||||
<gml:innerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">2,3 4,5 6,7 2,3</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">2,3 2,5 4,5 2,3</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:innerBoundaryIs>
|
||||
<gml:innerBoundaryIs>
|
||||
<gml:LinearRing>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">3,4 5,6 7,8 3,4</gml:coordinates>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">3,4 3,6 5,6 3,4</gml:coordinates>
|
||||
</gml:LinearRing>
|
||||
</gml:innerBoundaryIs>
|
||||
</gml:Polygon>
|
||||
@@ -3,24 +3,24 @@
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:Polygon>
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
</gml:Polygon>
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:Polygon>
|
||||
@@ -22,7 +22,7 @@
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
</gml:Polygon>
|
||||
|
||||
@@ -3,24 +3,24 @@
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:Polygon>
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
</gml:Polygon>
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:Polygon>
|
||||
@@ -22,7 +22,7 @@
|
||||
<gml:Polygon>
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
</gml:Polygon>
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
<gml:PolygonPatch interpolation="planar">
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:PolygonPatch>
|
||||
@@ -28,7 +28,7 @@
|
||||
<gml:PolygonPatch interpolation="planar">
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
</gml:PolygonPatch>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="foo">
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:interior>
|
||||
</gml:Polygon>
|
||||
@@ -3,17 +3,17 @@
|
||||
<gml:PolygonPatch interpolation="planar">
|
||||
<gml:exterior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>1 2 3 4 5 6 1 2</gml:posList>
|
||||
<gml:posList>1 2 3 2 3 4 1 2</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:exterior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>2 3 4 5 6 7 2 3</gml:posList>
|
||||
<gml:posList>2 3 2 5 4 5 2 3</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
<gml:interior>
|
||||
<gml:LinearRing>
|
||||
<gml:posList>3 4 5 6 7 8 3 4</gml:posList>
|
||||
<gml:posList>3 4 3 6 5 6 3 4</gml:posList>
|
||||
</gml:LinearRing>
|
||||
</gml:interior>
|
||||
</gml:PolygonPatch>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gml:featureMembers xsi:schemaLocation="http://www.openplans.org/topp http://demo.opengeo.org/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=topp:states http://www.opengis.net/gml http://schemas.opengis.net/gml/3.2.1/gml.xsd" xmlns:topp="http://www.openplans.org/topp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml"><topp:states fid="states.1"><topp:the_geom><gml:MultiSurface srsName="urn:x-ogc:def:crs:EPSG:4326"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>37.5101 -88.0711 37.4761 -88.0871 37.4421 -88.3111 37.4091 -88.3591 37.4201 -88.4191 37.4001 -88.4671 37.2961 -88.5111 37.2571 -88.5011 37.2051 -88.4501 37.1561 -88.4221 37.0981 -88.4501 37.0721 -88.4761 37.0681 -88.4901 37.0641 -88.5171 37.0721 -88.5591 37.1091 -88.6141 37.1351 -88.6881 37.1411 -88.7391 37.1521 -88.7461 37.2021 -88.8631 37.2181 -88.9321 37.2201 -88.9931 37.1851 -89.0651 37.1121 -89.1161 37.0931 -89.1461 37.0641 -89.1691 37.0251 -89.1741 36.9981 -89.1501 36.9881 -89.1291 36.9861 -89.1931 37.0281 -89.2101 37.0411 -89.2371 37.0871 -89.2641 37.0911 -89.2841 37.0851 -89.3031 37.0601 -89.3091 37.0271 -89.2641 37.0081 -89.2621 36.9991 -89.2821 37.0091 -89.3101 37.0491 -89.3821 37.0991 -89.3791 37.1371 -89.4231 37.1651 -89.4401 37.2241 -89.4681 37.2531 -89.4651 37.2561 -89.4891 37.2761 -89.5131 37.3041 -89.5131 37.3291 -89.5001 37.3391 -89.4681 37.3551 -89.4351 37.4111 -89.4271 37.4531 -89.4531 37.4911 -89.4941 37.5711 -89.5241 37.6151 -89.5131 37.6501 -89.5191 37.6791 -89.5131 37.6941 -89.5211 37.7061 -89.5811 37.7451 -89.6661 37.7831 -89.6751 37.8041 -89.6911 37.8401 -89.7281 37.9051 -89.8511 37.9051 -89.8611 37.8911 -89.8661 37.8751 -89.9001 37.8781 -89.9371 37.9111 -89.9781 37.9631 -89.9581 37.9691 -90.0101 37.9931 -90.0411 38.0321 -90.1191 38.0531 -90.1341 38.0881 -90.2071 38.1221 -90.2541 38.1661 -90.2891 38.1881 -90.3361 38.2341 -90.3641 38.3231 -90.3691 38.3651 -90.3581 38.3901 -90.3391 38.4271 -90.3011 38.5181 -90.2651 38.5321 -90.2611 38.5621 -90.2401 38.6101 -90.1831 38.6581 -90.1831 38.7001 -90.2021 38.7231 -90.1961 38.7731 -90.1631 38.7851 -90.1351 38.8001 -90.1211 38.8301 -90.1131 38.8531 -90.1321 38.9141 -90.2431 38.9241 -90.2781 38.9241 -90.3191 38.9621 -90.4131 38.9591 -90.4691 38.8911 -90.5301 38.8711 -90.5701 38.8801 -90.6271 38.9351 -90.6681 39.0371 -90.7061 39.0581 -90.7071 39.0931 -90.6901 39.1441 -90.7161 39.1951 -90.7181 39.2241 -90.7321 39.2471 -90.7381 39.2961 -90.7791 39.3501 -90.8501 39.4001 -90.9471 39.4441 -91.0361 39.4731 -91.0641 39.5281 -91.0931 39.5521 -91.1561 39.6001 -91.2031 39.6851 -91.3171 39.7241 -91.3671 39.7611 -91.3731 39.8031 -91.3811 39.8631 -91.4491 39.8851 -91.4501 39.9011 -91.4341 39.9211 -91.4301 39.9461 -91.4471 40.0051 -91.4871 40.0661 -91.5041 40.1341 -91.5161 40.2001 -91.5061 40.2511 -91.4981 40.3091 -91.4861 40.3711 -91.4481 40.3861 -91.4181 40.3921 -91.3851 40.4021 -91.3721 40.4471 -91.3851 40.5031 -91.3741 40.5281 -91.3821 40.5471 -91.4121 40.5721 -91.4111 40.6031 -91.3751 40.6391 -91.2621 40.6431 -91.2141 40.6561 -91.1621 40.6821 -91.1291 40.7051 -91.1191 40.7611 -91.0921 40.8331 -91.0881 40.8791 -91.0491 40.9231 -90.9831 40.9501 -90.9601 41.0701 -90.9541 41.1041 -90.9571 41.1441 -90.9901 41.1651 -91.0181 41.1761 -91.0561 41.2311 -91.1011 41.2671 -91.1021 41.3341 -91.0731 41.4011 -91.0551 41.4231 -91.0271 41.4311 -91.0001 41.4211 -90.9491 41.4441 -90.8441 41.4491 -90.7791 41.4501 -90.7081 41.4621 -90.6581 41.5091 -90.6001 41.5251 -90.5401 41.5271 -90.4541 41.5431 -90.4341 41.5671 -90.4231 41.5861 -90.3481 41.6021 -90.3391 41.6491 -90.3411 41.7221 -90.3261 41.7561 -90.3041 41.7811 -90.2551 41.8061 -90.1951 41.9301 -90.1541 41.9831 -90.1421 42.0331 -90.1501 42.0611 -90.1681 42.1031 -90.1661 42.1201 -90.1761 42.1221 -90.1911 42.1591 -90.2301 42.1971 -90.3231 42.2101 -90.3671 42.2421 -90.4071 42.2631 -90.4171 42.3401 -90.4271 42.3601 -90.4411 42.3881 -90.4911 42.4211 -90.5631 42.4601 -90.6051 42.4751 -90.6481 42.4941 -90.6511 42.5091 -90.6381 42.5081 -90.4191 42.5041 -89.9231 42.5031 -89.8341 42.4971 -89.4001 42.4971 -89.3591 42.4901 -88.9391 42.4901 -88.7641 42.4891 -88.7061 42.4911 -88.2971 42.4891 -88.1941 42.4891 -87.7971 42.3141 -87.8361 42.1561 -87.7601 42.0591 -87.6701 41.8471 -87.6121 41.7231 -87.5291 41.4691 -87.5321 41.3011 -87.5321 41.1731 -87.5311 41.0091 -87.5321 40.7451 -87.5321 40.4941 -87.5371 40.4831 -87.5351 40.1661 -87.5351 39.8871 -87.5351 39.6091 -87.5351 39.4771 -87.5381 39.3501 -87.5401 39.3381 -87.5971 39.3071 -87.6251 39.2971 -87.6101 39.2811 -87.6151 39.2581 -87.6061 39.2481 -87.5841 39.2081 -87.5881 39.1981 -87.5941 39.1961 -87.6071 39.1681 -87.6441 39.1461 -87.6701 39.1301 -87.6591 39.1131 -87.6621 39.1031 -87.6311 39.0881 -87.6301 39.0841 -87.6121 39.0621 -87.5851 38.9951 -87.5811 38.9941 -87.5911 38.9771 -87.5471 38.9631 -87.5331 38.9311 -87.5301 38.9041 -87.5391 38.8691 -87.5591 38.8571 -87.5501 38.7951 -87.5071 38.7761 -87.5191 38.7691 -87.5081 3Line truncated
|
||||
<gml:featureMembers xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.openplans.org/topp http://demo.opengeo.org/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=topp:states http://www.opengis.net/gml http://schemas.opengis.net/gml/3.2.1/gml.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><feature:states xmlns:feature="http://www.openplans.org/topp" fid="states.1" xmlns="http://www.opengis.net/gml"><feature:the_geom><gml:MultiSurface srsName="urn:x-ogc:def:crs:EPSG:4326"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>37.5101 -88.0711 37.5831 -88.1341 37.6281 -88.1571 37.6601 -88.1591 37.7001 -88.1331 37.7351 -88.0721 37.8051 -88.0351 37.8171 -88.0861 37.8311 -88.0891 37.8271 -88.0421 37.8431 -88.0341 37.8671 -88.0751 37.8951 -88.1011 37.9061 -88.1001 37.8961 -88.0441 37.9051 -88.0261 37.9171 -88.0301 37.9231 -88.084 37.944 -88.0781 37.9291 -88.0641 37.9341 -88.0411 37.9561 -88.0421 37.9751 -88.0211 38.0081 -88.0291 38.0331 -88.0211 38.0381 -88.0411 38.0451 -88.0431 38.0541 -88.0341 38.0731 -87.9751 38.0961 -87.9641 38.0921 -88.0121 38.1031 -88.0181 38.1311 -87.9731 38.1361 -87.9501 38.1571 -87.9311 38.1711 -87.9321 38.2001 -87.9771 38.2341 -87.9861 38.2411 -87.9801 38.3041 -87.9251 38.3021 -87.9131 38.2811 -87.9141 38.3001 -87.8881 38.3151 -87.8831 38.3161 -87.8741 38.2851 -87.8631 38.2861 -87.8501 38.3521 -87.8341 38.3781 -87.7841 38.4171 -87.7481 38.4451 -87.7381 38.4571 -87.7581 38.4661 -87.7561 38.4811 -87.6921 38.5041 -87.6791 38.5001 -87.6531 38.5151 -87.6511 38.5471 -87.6721 38.5731 -87.6521 38.5931 -87.6401 38.5991 -87.6191 38.6221 -87.6281 38.6421 -87.6251 38.6721 -87.5881 38.6851 -87.5431 38.7361 -87.5081 38.7691 -87.5081 38.7761 -87.5191 38.7951 -87.5071 38.8571 -87.5501 38.8691 -87.5591 38.9041 -87.5391 38.9311 -87.5301 38.9631 -87.5331 38.9771 -87.5471 38.9941 -87.5911 38.9951 -87.5811 39.0621 -87.5851 39.0841 -87.6121 39.0881 -87.6301 39.1031 -87.6311 39.1131 -87.6621 39.1301 -87.6591 39.1461 -87.6701 39.1681 -87.6441 39.1961 -87.6071 39.1981 -87.5941 39.2081 -87.5881 39.2481 -87.5841 39.2581 -87.6061 39.2811 -87.6151 39.2971 -87.6101 39.3071 -87.6251 39.3381 -87.5971 39.3501 -87.5401 39.4771 -87.5381 39.6091 -87.5351 39.8871 -87.5351 40.1661 -87.5351 40.4831 -87.5351 40.4941 -87.5371 40.7451 -87.5321 41.0091 -87.5321 41.1731 -87.5311 41.3011 -87.5321 41.4691 -87.5321 41.7231 -87.5291 41.8471 -87.6121 42.0591 -87.6701 42.1561 -87.7601 42.3141 -87.8361 42.4891 -87.7971 42.4891 -88.1941 42.4911 -88.2971 42.4891 -88.7061 42.4901 -88.7641 42.4901 -88.9391 42.4971 -89.3591 42.4971 -89.4001 42.5031 -89.8341 42.5041 -89.9231 42.5081 -90.4191 42.5091 -90.6381 42.4941 -90.6511 42.4751 -90.6481 42.4601 -90.6051 42.4211 -90.5631 42.3881 -90.4911 42.3601 -90.4411 42.3401 -90.4271 42.2631 -90.4171 42.2421 -90.4071 42.2101 -90.3671 42.1971 -90.3231 42.1591 -90.2301 42.1221 -90.1911 42.1201 -90.1761 42.1031 -90.1661 42.0611 -90.1681 42.0331 -90.1501 41.9831 -90.1421 41.9301 -90.1541 41.8061 -90.1951 41.7811 -90.2551 41.7561 -90.3041 41.7221 -90.3261 41.6491 -90.3411 41.6021 -90.3391 41.5861 -90.3481 41.5671 -90.4231 41.5431 -90.4341 41.5271 -90.4541 41.5251 -90.5401 41.5091 -90.6001 41.4621 -90.6581 41.4501 -90.7081 41.4491 -90.7791 41.4441 -90.8441 41.4211 -90.9491 41.4311 -91.0001 41.4231 -91.0271 41.4011 -91.0551 41.3341 -91.0731 41.2671 -91.1021 41.2311 -91.1011 41.1761 -91.0561 41.1651 -91.0181 41.1441 -90.9901 41.1041 -90.9571 41.0701 -90.9541 40.9501 -90.9601 40.9231 -90.9831 40.8791 -91.0491 40.8331 -91.0881 40.7611 -91.0921 40.7051 -91.1191 40.6821 -91.1291 40.6561 -91.1621 40.6431 -91.2141 40.6391 -91.2621 40.6031 -91.3751 40.5721 -91.4111 40.5471 -91.4121 40.5281 -91.3821 40.5031 -91.3741 40.4471 -91.3851 40.4021 -91.3721 40.3921 -91.3851 40.3861 -91.4181 40.3711 -91.4481 40.3091 -91.4861 40.2511 -91.4981 40.2001 -91.5061 40.1341 -91.5161 40.0661 -91.5041 40.0051 -91.4871 39.9461 -91.4471 39.9211 -91.4301 39.9011 -91.4341 39.8851 -91.4501 39.8631 -91.4491 39.8031 -91.3811 39.7611 -91.3731 39.7241 -91.3671 39.6851 -91.3171 39.6001 -91.2031 39.5521 -91.1561 39.5281 -91.0931 39.4731 -91.0641 39.4441 -91.0361 39.4001 -90.9471 39.3501 -90.8501 39.2961 -90.7791 39.2471 -90.7381 39.2241 -90.7321 39.1951 -90.7181 39.1441 -90.7161 39.0931 -90.6901 39.0581 -90.7071 39.0371 -90.7061 38.9351 -90.6681 38.8801 -90.6271 38.8711 -90.5701 38.8911 -90.5301 38.9591 -90.4691 38.9621 -90.4131 38.9241 -90.3191 38.9241 -90.2781 38.9141 -90.2431 38.8531 -90.1321 38.8301 -90.1131 38.8001 -90.1211 38.7851 -90.1351 38.7731 -90.1631 38.7231 -90.1961 38.7001 -90.2021 38.6581 -90.1831 38.6101 -90.1831 38.5621 -90.2401 38.5321 -90.2611 38.5181 -90.2651 38.4271 -90.3011 38.3901 -90.3391 38.3651 -90.3581 38.3231 -90.3691 38.2341 -90.3641 38.1881 -90.3361 38.1661 -90.2891 38.1221 -90.2541 38.0881 -90.2071 38.0531 -90.1341 38.0321 -90.1191 37.9931 -90.0411 37.9691 -90.0101 37.9631 -89.9581 37.9111 -89.9781 37.8781 -89.9371 37.8751 -8Line truncated
|
||||
@@ -0,0 +1,118 @@
|
||||
goog.provide('ol.test.parser.TopoJSON');
|
||||
|
||||
var aruba = {
|
||||
type: 'Topology',
|
||||
transform: {
|
||||
scale: [0.036003600360036005, 0.017361589674592462],
|
||||
translate: [-180, -89.99892578124998]
|
||||
},
|
||||
objects: {
|
||||
aruba: {
|
||||
type: 'Polygon',
|
||||
arcs: [[0]],
|
||||
id: 533
|
||||
}
|
||||
},
|
||||
arcs: [
|
||||
[[3058, 5901], [0, -2], [-2, 1], [-1, 3], [-2, 3], [0, 3], [1, 1], [1, -3],
|
||||
[2, -5], [1, -1]]
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
describe('ol.parser.TopoJSON', function() {
|
||||
|
||||
var parser;
|
||||
before(function() {
|
||||
parser = new ol.parser.TopoJSON();
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates a new parser', function() {
|
||||
expect(parser).to.be.a(ol.parser.Parser);
|
||||
expect(parser).to.be.a(ol.parser.TopoJSON);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#readFeaturesFromTopology_()', function() {
|
||||
|
||||
it('creates an array of features from a topology', function() {
|
||||
var features = parser.readFeaturesFromTopology_(aruba);
|
||||
expect(features).to.have.length(1);
|
||||
|
||||
var feature = features[0];
|
||||
expect(feature).to.be.a(ol.Feature);
|
||||
|
||||
var geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
|
||||
expect(geometry.getBounds()).to.eql([
|
||||
-70.08100810081008,
|
||||
-69.9009900990099,
|
||||
12.417091709170947,
|
||||
12.608069195591469
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readFeaturesFromString()', function() {
|
||||
|
||||
it('parses world-110m.geojson with shared vertices', function(done) {
|
||||
afterLoadText('spec/ol/parser/topojson/world-110m.json', function(text) {
|
||||
|
||||
var pointVertices = new ol.geom.SharedVertices();
|
||||
var lineVertices = new ol.geom.SharedVertices();
|
||||
var polygonVertices = new ol.geom.SharedVertices();
|
||||
|
||||
var lookup = {
|
||||
'point': pointVertices,
|
||||
'linestring': lineVertices,
|
||||
'polygon': polygonVertices,
|
||||
'multipoint': pointVertices,
|
||||
'multilinstring': lineVertices,
|
||||
'multipolygon': polygonVertices
|
||||
};
|
||||
|
||||
var callback = function(feature, type) {
|
||||
return lookup[type];
|
||||
};
|
||||
|
||||
var result = parser.readFeaturesFromString(text, {callback: callback});
|
||||
expect(result.features.length).to.be(178);
|
||||
|
||||
expect(pointVertices.coordinates.length).to.be(0);
|
||||
expect(lineVertices.coordinates.length).to.be(0);
|
||||
expect(polygonVertices.coordinates.length).to.be(31400);
|
||||
|
||||
var first = result.features[0];
|
||||
expect(first).to.be.a(ol.Feature);
|
||||
var firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(ol.geom.MultiPolygon);
|
||||
expect(firstGeom.getBounds()).to.eql([
|
||||
-180, 180, -85.60903777459777, 83.64513000000002
|
||||
]);
|
||||
|
||||
var last = result.features[177];
|
||||
expect(last).to.be.a(ol.Feature);
|
||||
var lastGeom = last.getGeometry();
|
||||
expect(lastGeom).to.be.a(ol.geom.Polygon);
|
||||
expect(lastGeom.getBounds()).to.eql([
|
||||
25.26325263252633, 32.848528485284874,
|
||||
-22.271802279310577, -15.50833810039586
|
||||
]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.geom.MultiPolygon');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.geom.SharedVertices');
|
||||
goog.require('ol.parser.Parser');
|
||||
goog.require('ol.parser.TopoJSON');
|
||||
@@ -0,0 +1 @@
|
||||
{"type":"Topology","transform":{"scale":[0.0036000360003600037,0.0016925586033320111],"translate":[-180,-85.60903777459777]},"objects":{"land":{"type":"MultiPolygon","arcs":[[[0]],[[1]],[[2]],[[3]],[[4]],[[5]],[[6]],[[7,8,9]],[[10,11]],[[12]],[[13]],[[14]],[[15]],[[16]],[[17]],[[18]],[[19]],[[20]],[[21]],[[22]],[[23]],[[24]],[[25]],[[26]],[[27]],[[28]],[[29,30]],[[31]],[[32]],[[33]],[[34]],[[35]],[[36]],[[37]],[[38]],[[39]],[[40]],[[41]],[[42,43]],[[44]],[[45]],[[46]],[[47,48,49,50]],[[51]],[[52]],[[53]],[[54]],[[55]],[[56]],[[57]],[[58]],[[59]],[[60]],[[61]],[[62,63]],[[64]],[[65]],[[66]],[[67]],[[68]],[[69]],[[70]],[[71]],[[72]],[[73]],[[74]],[[75]],[[76,77]],[[78]],[[79]],[[80]],[[81]],[[82]],[[83]],[[84]],[[85]],[[86]],[[87]],[[88]],[[89]],[[90,91]],[[92]],[[93]],[[94]],[[95]],[[96]],[[97]],[[98]],[[99]],[[100]],[[101]],[[102]],[[103]],[[104]],[[105]],[[106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221]],[[222,223]],[[224]],[[225]],[[226]],[[227]],[[228]],[[229]],[[230,231,232,233]],[[234]],[[235]],[[236]],[[237]],[[238]],[[239]],[[240]],[[241]],[[242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477],[478,479,480,481,482,483,484]],[[485]],[[486]],[[487]],[[488]],[[489]],[[490]],[[491]],[[492]],[[493]],[[494]],[[495]],[[496]],[[497]],[[498]]]},"countries":{"type":"GeometryCollection","geometries":[{"type":"Polygon","arcs":[[499,500,501,502,503,504]],"id":4},{"type":"MultiPolygon","arcs":[[[505,506,352,507]],[[354,508,509]]],"id":24},{"type":"Polygon","arcs":[[510,511,414,512,513,514]],"id":8},{"type":"Polygon","arcs":[[312,515,314,516,517]],"id":784},{"type":"MultiPolygon","arcs":[[[518,11]],[[519,520,521,166,522,168,523,524]]],"id":32},{"type":"Polygon","arcs":[[525,526,527,528,529]],"id":51},{"type":"MultiPolygon","arcs":[[[0]],[[1]],[[2]],[[3]],[[4]],[[5]],[[6]],[[530,531]]],"id":10},{"type":"Polygon","arcs":[[13]],"id":260},{"type":"MultiPolygon","arcs":[[[14]],[[24]]],"id":36},{"type":"Polygon","arcs":[[532,533,534,535,536,537,538]],"id":40},{"type":"MultiPolygon","arcs":[[[539,-528]],[[484,540,479,541,-526,542,543]]],"id":31},{"type":"Polygon","arcs":[[544,545,546]],"id":108},{"type":"Polygon","arcs":[[547,548,549,550,437]],"id":56},{"type":"Polygon","arcs":[[551,552,553,554,366]],"id":204},{"type":"Polygon","arcs":[[555,556,557,-553,558,559]],"id":854},{"type":"Polygon","arcs":[[560,561,289,562]],"id":50},{"type":"Polygon","arcs":[[563,404,564,565,566,567]],"id":100},{"type":"MultiPolygon","arcs":[[[71]],[[73]],[[74]]],"id":44},{"type":"Polygon","arcs":[[568,569,570]],"id":70},{"type":"Polygon","arcs":[[571,572,573,574,575]],"id":112},{"type":"Polygon","arcs":[[576,145,577]],"id":84},{"type":"Polygon","arcs":[[578,579,580,581,-525]],"id":68},{"type":"Polygon","arcs":[[-521,582,-581,583,584,585,586,587,588,164,589]],"id":76},{"type":"Polygon","arcs":[[48,590]],"id":96},{"type":"Polygon","arcs":[[591,592]],"id":64},{"type":"Polygon","arcs":[[593,594,595,596]],"id":72},{"type":"Polygon","arcs":[[597,598,599,600,601,602,603]],"id":140},{"type":"MultiPolygon","arcs":[[[84]],[[85]],[[86]],[[87]],[[88]],[[96]],[[97]],[[99]],[[101]],[[103]],[[604,107,605,109,606,111,607,113,608,115,609,117,610,199,611,201,612,215,613,217,614,219,615,221]],[[616,223]],[[224]],[[225]],[[226]],[[227]],[[229]],[[230,617,232,618]],[[235]],[[237]],[[238]],[[240]],[[241]],[[485]],[[486]],[[488]],[[489]],[[490]],[[496]],[[497]]],"id":124},{"type":"Polygon","arcs":[[-536,619,620,621]],"id":756},{"type":"MultiPolygon","arcs":[[[-519,622,623,624]],[[-524,169,625,171,626,-579]]],"id":152},{"type":"MultiPolygon","arcs":[[[64]],[[627,274,628,276,629,278,630,280,631,632,633,634,635,-593,636,637,638,639,-503,640,641,642,643,644,645]]],"id":156},{"type":"PolLine truncated
|
||||
@@ -80,7 +80,9 @@ describe('ol.parser.WKT', function() {
|
||||
expect(geom.rings[0].getCoordinates()).to.eql(
|
||||
[[30, 10], [10, 20], [20, 40], [40, 40], [30, 10]]);
|
||||
expect(parser.write(geom)).to.eql(wkt);
|
||||
wkt = 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 35,30 20,20 30))';
|
||||
|
||||
// note that WKT doesn't care about winding order, we do
|
||||
wkt = 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,30 20,35 35,20 30))';
|
||||
geom = parser.read(wkt);
|
||||
expect(geom.getType()).to.eql(ol.geom.GeometryType.POLYGON);
|
||||
expect(geom.rings.length).to.eql(2);
|
||||
@@ -89,8 +91,9 @@ describe('ol.parser.WKT', function() {
|
||||
expect(geom.rings[0].getCoordinates()).to.eql(
|
||||
[[35, 10], [10, 20], [15, 40], [45, 45], [35, 10]]);
|
||||
expect(geom.rings[1].getCoordinates()).to.eql(
|
||||
[[20, 30], [35, 35], [30, 20], [20, 30]]);
|
||||
[[20, 30], [30, 20], [35, 35], [20, 30]]);
|
||||
expect(parser.write(geom)).to.eql(wkt);
|
||||
|
||||
// test whitespace when reading
|
||||
wkt = 'POLYGON ( (30 10, 10 20, 20 40, 40 40, 30 10) )';
|
||||
geom = parser.read(wkt);
|
||||
@@ -102,7 +105,8 @@ describe('ol.parser.WKT', function() {
|
||||
});
|
||||
|
||||
it('MultiPolygon read / written correctly', function() {
|
||||
var wkt = 'MULTIPOLYGON(((40 40,20 45,45 30,40 40)),' +
|
||||
// note that WKT doesn't care about winding order, we do
|
||||
var wkt = 'MULTIPOLYGON(((40 40,45 30,20 45,40 40)),' +
|
||||
'((20 35,45 20,30 5,10 10,10 30,20 35),(30 20,20 25,20 15,30 20)))';
|
||||
var geom = parser.read(wkt);
|
||||
expect(geom.getType()).to.eql(ol.geom.GeometryType.MULTIPOLYGON);
|
||||
@@ -112,16 +116,17 @@ describe('ol.parser.WKT', function() {
|
||||
expect(geom.components[0].rings.length).to.eql(1);
|
||||
expect(geom.components[1].rings.length).to.eql(2);
|
||||
expect(geom.components[0].rings[0].getCoordinates()).to.eql(
|
||||
[[40, 40], [20, 45], [45, 30], [40, 40]]);
|
||||
[[40, 40], [45, 30], [20, 45], [40, 40]]);
|
||||
expect(geom.components[1].rings[0].getCoordinates()).to.eql(
|
||||
[[20, 35], [45, 20], [30, 5], [10, 10], [10, 30], [20, 35]]);
|
||||
expect(geom.components[1].rings[1].getCoordinates()).to.eql(
|
||||
[[30, 20], [20, 25], [20, 15], [30, 20]]);
|
||||
expect(parser.write(geom)).to.eql(wkt);
|
||||
|
||||
// test whitespace when reading
|
||||
wkt = 'MULTIPOLYGON( ( (40 40, 20 45, 45 30, 40 40) ), ' +
|
||||
'( (20 35, 45 20, 30 5, 10 10, 10 30, 20 35 ), ( 30 20, 20 25, ' +
|
||||
'20 15, 30 20 ) ) )';
|
||||
wkt = 'MULTIPOLYGON( ( ( 40 40,45 30, 20 45 ,40 40 )) ,' +
|
||||
'( (20 35, 45 20,30 5,10 10,10 30,20 35), ' +
|
||||
'( 30 20, 20 25,20 15 ,30 20 ) ))';
|
||||
geom = parser.read(wkt);
|
||||
expect(geom.getType()).to.eql(ol.geom.GeometryType.MULTIPOLYGON);
|
||||
expect(geom.components.length).to.eql(2);
|
||||
@@ -130,7 +135,7 @@ describe('ol.parser.WKT', function() {
|
||||
expect(geom.components[0].rings.length).to.eql(1);
|
||||
expect(geom.components[1].rings.length).to.eql(2);
|
||||
expect(geom.components[0].rings[0].getCoordinates()).to.eql(
|
||||
[[40, 40], [20, 45], [45, 30], [40, 40]]);
|
||||
[[40, 40], [45, 30], [20, 45], [40, 40]]);
|
||||
expect(geom.components[1].rings[0].getCoordinates()).to.eql(
|
||||
[[20, 35], [45, 20], [30, 5], [10, 10], [10, 30], [20, 35]]);
|
||||
expect(geom.components[1].rings[1].getCoordinates()).to.eql(
|
||||
|
||||
@@ -11,7 +11,77 @@ describe('ol.source.Vector', function() {
|
||||
});
|
||||
});
|
||||
|
||||
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, 180, -90, 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, 180, -90, 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');
|
||||
@@ -26,8 +26,30 @@ describe('ol.source.wms', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.source.wms.getFeatureInfo', function() {
|
||||
it('calls a callback with a feature info IFRAME as result', function(done) {
|
||||
ol.source.wms.getFeatureInfo('?REQUEST=GetMap&VERSION=1.3&LAYERS=foo',
|
||||
[5, 10], {params: {'INFO_FORMAT': 'text/plain'}},
|
||||
function(info) {
|
||||
expect(info).to.eql('<iframe seamless src="' +
|
||||
'?REQUEST=GetFeatureInfo&VERSION=1.3&LAYERS=foo&QUERY_LAYERS=' +
|
||||
'foo&INFO_FORMAT=text%2Fplain&I=5&J=10"></iframe>');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('can do xhr to retrieve feature info', function(done) {
|
||||
ol.source.wms.getFeatureInfo('?REQUEST=GetMap&VERSION=1.1.1&LAYERS=foo',
|
||||
[5, 10], {method: ol.source.WMSGetFeatureInfoMethod.XHR_GET},
|
||||
function(info) {
|
||||
expect(info).to.contain('<html>');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.WMSGetFeatureInfoMethod');
|
||||
goog.require('ol.source.wms');
|
||||
@@ -0,0 +1,401 @@
|
||||
goog.provide('ol.test.style.Icon');
|
||||
|
||||
describe('ol.style.IconLiteral', function() {
|
||||
|
||||
describe('#equals()', function() {
|
||||
|
||||
it('identifies equal literals', function() {
|
||||
var literal = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
var equalLiteral = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
var differentLiteral1 = new ol.style.IconLiteral({
|
||||
height: 11,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
var differentLiteral2 = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 2,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
var differentLiteral3 = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 0.5,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
var differentLiteral4 = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.2,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
var differentLiteral5 = new ol.style.IconLiteral({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/2.png'
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral1)).to.be(false);
|
||||
expect(literal.equals(differentLiteral2)).to.be(false);
|
||||
expect(literal.equals(differentLiteral3)).to.be(false);
|
||||
expect(literal.equals(differentLiteral4)).to.be(false);
|
||||
expect(literal.equals(differentLiteral5)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.style.Icon', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('accepts literal values', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
height: 10,
|
||||
width: 20,
|
||||
opacity: 1,
|
||||
rotation: 0.1,
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
expect(symbolizer).to.be.a(ol.style.Icon);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
height: ol.expr.parse('10'),
|
||||
width: ol.expr.parse('20'),
|
||||
opacity: ol.expr.parse('1'),
|
||||
rotation: ol.expr.parse('0.1'),
|
||||
url: ol.expr.parse('"http://example.com/1.png"')
|
||||
});
|
||||
expect(symbolizer).to.be.a(ol.style.Icon);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#createLiteral()', function() {
|
||||
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
height: ol.expr.parse('heightAttr'),
|
||||
width: ol.expr.parse('widthAttr'),
|
||||
opacity: ol.expr.parse('opacityAttr'),
|
||||
rotation: ol.expr.parse('rotationAttr'),
|
||||
url: ol.expr.parse('urlAttr')
|
||||
});
|
||||
|
||||
var feature = new ol.Feature({
|
||||
heightAttr: 42,
|
||||
widthAttr: 0.42,
|
||||
opacityAttr: 0.5,
|
||||
rotationAttr: 123,
|
||||
urlAttr: 'http://example.com/1.png'
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.IconLiteral);
|
||||
expect(literal.height).to.be(42);
|
||||
expect(literal.width).to.be(.42);
|
||||
expect(literal.opacity).to.be(0.5);
|
||||
expect(literal.rotation).to.be(123);
|
||||
expect(literal.url).to.be('http://example.com/1.png');
|
||||
});
|
||||
|
||||
it('can be called without a feature', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
height: ol.expr.parse('10'),
|
||||
width: ol.expr.parse('20'),
|
||||
opacity: ol.expr.parse('1'),
|
||||
rotation: ol.expr.parse('0.1'),
|
||||
url: ol.expr.parse('"http://example.com/1.png"')
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).to.be.a(ol.style.IconLiteral);
|
||||
expect(literal.height).to.be(10);
|
||||
expect(literal.width).to.be(20);
|
||||
expect(literal.opacity).to.be(1);
|
||||
expect(literal.rotation).to.be(0.1);
|
||||
expect(literal.url).to.be('http://example.com/1.png');
|
||||
});
|
||||
|
||||
it('applies default type if none provided', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
height: ol.expr.parse('10'),
|
||||
width: ol.expr.parse('20'),
|
||||
url: ol.expr.parse('"http://example.com/1.png"')
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).to.be.a(ol.style.IconLiteral);
|
||||
expect(literal.opacity).to.be(1);
|
||||
expect(literal.rotation).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getHeight()', function() {
|
||||
|
||||
it('returns the icon height', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20
|
||||
});
|
||||
|
||||
var height = symbolizer.getHeight();
|
||||
expect(height).to.be.a(ol.expr.Literal);
|
||||
expect(height.getValue()).to.be(20);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getOpacity()', function() {
|
||||
|
||||
it('returns the icon opacity', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
opacity: 0.123
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getRotation()', function() {
|
||||
|
||||
it('returns the icon rotation', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
rotation: 0.123
|
||||
});
|
||||
|
||||
var rotation = symbolizer.getRotation();
|
||||
expect(rotation).to.be.a(ol.expr.Literal);
|
||||
expect(rotation.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getUrl()', function() {
|
||||
|
||||
it('returns the url', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
|
||||
var url = symbolizer.getUrl();
|
||||
expect(url).to.be.a(ol.expr.Literal);
|
||||
expect(url.getValue()).to.be('http://example.com/1.png');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('#getWidth()', function() {
|
||||
|
||||
it('returns the icon width', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10
|
||||
});
|
||||
|
||||
var width = symbolizer.getWidth();
|
||||
expect(width).to.be.a(ol.expr.Literal);
|
||||
expect(width.getValue()).to.be(10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('#setHeight()', function() {
|
||||
|
||||
it('sets the icon height', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20
|
||||
});
|
||||
symbolizer.setHeight(new ol.expr.Literal(30));
|
||||
|
||||
var height = symbolizer.getHeight();
|
||||
expect(height).to.be.a(ol.expr.Literal);
|
||||
expect(height.getValue()).to.be(30);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setHeight(30);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setOpacity()', function() {
|
||||
|
||||
it('sets the icon opacity', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20,
|
||||
opacity: 0.123
|
||||
});
|
||||
symbolizer.setOpacity(new ol.expr.Literal(0.321));
|
||||
|
||||
var opacity = symbolizer.getOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.321);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20,
|
||||
opacity: 0.123
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setOpacity(0.5);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setRotation()', function() {
|
||||
|
||||
it('sets the icon rotation', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20,
|
||||
rotation: 0.123
|
||||
});
|
||||
symbolizer.setRotation(new ol.expr.Literal(0.321));
|
||||
|
||||
var rotation = symbolizer.getRotation();
|
||||
expect(rotation).to.be.a(ol.expr.Literal);
|
||||
expect(rotation.getValue()).to.be(0.321);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10,
|
||||
height: 20,
|
||||
rotation: 0.123
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setRotation(0.5);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setUrl()', function() {
|
||||
|
||||
it('sets the url', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
|
||||
symbolizer.setUrl(new ol.expr.Literal('http://example.com/2.png'));
|
||||
|
||||
var url = symbolizer.getUrl();
|
||||
expect(url).to.be.a(ol.expr.Literal);
|
||||
expect(url.getValue()).to.be('http://example.com/2.png');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setUrl('http://example.com/2.png');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setWidth()', function() {
|
||||
|
||||
it('sets the icon width', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10
|
||||
});
|
||||
|
||||
symbolizer.setWidth(new ol.expr.Literal(20));
|
||||
|
||||
var width = symbolizer.getWidth();
|
||||
expect(width).to.be.a(ol.expr.Literal);
|
||||
expect(width.getValue()).to.be(20);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Icon({
|
||||
url: 'http://example.com/1.png',
|
||||
width: 10
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setWidth(40);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
goog.require('goog.asserts.AssertionError');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Icon');
|
||||
goog.require('ol.style.IconLiteral');
|
||||
@@ -8,17 +8,17 @@ describe('ol.style.LineLiteral', function() {
|
||||
var literal = new ol.style.LineLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#BADA55',
|
||||
opacity: 1
|
||||
strokeOpacity: 1
|
||||
});
|
||||
var equalLiteral = new ol.style.LineLiteral({
|
||||
strokeColor: '#BADA55',
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
strokeOpacity: 1
|
||||
});
|
||||
var differentLiteral = new ol.style.LineLiteral({
|
||||
strokeColor: '#013',
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
strokeOpacity: 1
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral)).to.be(false);
|
||||
@@ -42,7 +42,7 @@ describe('ol.style.Line', function() {
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
opacity: ol.expr.parse('value / 100'),
|
||||
strokeOpacity: ol.expr.parse('value / 100'),
|
||||
strokeWidth: ol.expr.parse('widthAttr')
|
||||
});
|
||||
expect(symbolizer).to.be.a(ol.style.Line);
|
||||
@@ -54,7 +54,7 @@ describe('ol.style.Line', function() {
|
||||
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
opacity: ol.expr.parse('value / 100'),
|
||||
strokeOpacity: ol.expr.parse('value / 100'),
|
||||
strokeWidth: ol.expr.parse('widthAttr')
|
||||
});
|
||||
|
||||
@@ -65,15 +65,142 @@ describe('ol.style.Line', function() {
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.LineLiteral);
|
||||
expect(literal.opacity).to.be(42 / 100);
|
||||
expect(literal.strokeOpacity).to.be(42 / 100);
|
||||
expect(literal.strokeWidth).to.be(1.5);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeColor()', function() {
|
||||
|
||||
it('returns the stroke color', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
var strokeColor = symbolizer.getStrokeColor();
|
||||
expect(strokeColor).to.be.a(ol.expr.Literal);
|
||||
expect(strokeColor.getValue()).to.be('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeWidth()', function() {
|
||||
|
||||
it('returns the stroke width', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeWidth: 10
|
||||
});
|
||||
|
||||
var strokeWidth = symbolizer.getStrokeWidth();
|
||||
expect(strokeWidth).to.be.a(ol.expr.Literal);
|
||||
expect(strokeWidth.getValue()).to.be(10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeOpacity()', function() {
|
||||
|
||||
it('returns the stroke opacity', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeOpacity: 0.123
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeColor()', function() {
|
||||
|
||||
it('sets the stroke color', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setStrokeColor(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var strokeColor = symbolizer.getStrokeColor();
|
||||
expect(strokeColor).to.be.a(ol.expr.Literal);
|
||||
expect(strokeColor.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeColor('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeWidth()', function() {
|
||||
|
||||
it('sets the stroke width', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeWidth: 10
|
||||
});
|
||||
symbolizer.setStrokeWidth(new ol.expr.Literal(20));
|
||||
|
||||
var strokeWidth = symbolizer.getStrokeWidth();
|
||||
expect(strokeWidth).to.be.a(ol.expr.Literal);
|
||||
expect(strokeWidth.getValue()).to.be(20);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeWidth: 10
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeWidth(10);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeOpacity()', function() {
|
||||
|
||||
it('sets the stroke opacity', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeOpacity: 0.123
|
||||
});
|
||||
symbolizer.setStrokeOpacity(new ol.expr.Literal(0.321));
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.321);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeOpacity: 1
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeOpacity(0.5);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.asserts.AssertionError');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Line');
|
||||
goog.require('ol.style.LineLiteral');
|
||||
@@ -8,23 +8,58 @@ describe('ol.style.PolygonLiteral', function() {
|
||||
var literal = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
opacity: 1
|
||||
fillOpacity: 0.3
|
||||
});
|
||||
var equalLiteral = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
strokeColor: '#013',
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
fillOpacity: 0.3
|
||||
});
|
||||
var differentLiteral = new ol.style.PolygonLiteral({
|
||||
fillColor: '#013',
|
||||
var differentStrokeWidth = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 5,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
});
|
||||
var differentStrokeColor = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
strokeColor: '#ffff00',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
});
|
||||
var differentStrokeOpacity = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.41,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.3
|
||||
});
|
||||
var differentFillColor = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#00ffff',
|
||||
fillOpacity: 0.3
|
||||
});
|
||||
var differentFillOpacity = new ol.style.PolygonLiteral({
|
||||
strokeWidth: 3,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.31
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral)).to.be(false);
|
||||
expect(literal.equals(differentStrokeWidth)).to.be(false);
|
||||
expect(literal.equals(differentStrokeColor)).to.be(false);
|
||||
expect(literal.equals(differentStrokeOpacity)).to.be(false);
|
||||
expect(literal.equals(differentFillColor)).to.be(false);
|
||||
expect(literal.equals(differentFillOpacity)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -45,7 +80,7 @@ describe('ol.style.Polygon', function() {
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
opacity: ol.expr.parse('value / 100'),
|
||||
fillOpacity: ol.expr.parse('value / 100'),
|
||||
fillColor: ol.expr.parse('fillAttr')
|
||||
});
|
||||
expect(symbolizer).to.be.a(ol.style.Polygon);
|
||||
@@ -57,7 +92,7 @@ describe('ol.style.Polygon', function() {
|
||||
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
opacity: ol.expr.parse('value / 100'),
|
||||
fillOpacity: ol.expr.parse('value / 100'),
|
||||
fillColor: ol.expr.parse('fillAttr')
|
||||
});
|
||||
|
||||
@@ -68,7 +103,7 @@ describe('ol.style.Polygon', function() {
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||
expect(literal.opacity).to.be(42 / 100);
|
||||
expect(literal.fillOpacity).to.be(42 / 100);
|
||||
expect(literal.fillColor).to.be('#ff0000');
|
||||
expect(literal.strokeColor).to.be(undefined);
|
||||
});
|
||||
@@ -87,9 +122,196 @@ describe('ol.style.Polygon', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#getFillColor()', function() {
|
||||
|
||||
it('returns the fill color', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
fillColor: '#ff0000'
|
||||
});
|
||||
|
||||
var fillColor = symbolizer.getFillColor();
|
||||
expect(fillColor).to.be.a(ol.expr.Literal);
|
||||
expect(fillColor.getValue()).to.be('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getFillOpacity()', function() {
|
||||
|
||||
it('returns the fill opacity', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
fillColor: '#ffffff',
|
||||
fillOpacity: 0.123
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getFillOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeColor()', function() {
|
||||
|
||||
it('returns the stroke color', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
var strokeColor = symbolizer.getStrokeColor();
|
||||
expect(strokeColor).to.be.a(ol.expr.Literal);
|
||||
expect(strokeColor.getValue()).to.be('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeWidth()', function() {
|
||||
|
||||
it('returns the stroke width', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeWidth: 10
|
||||
});
|
||||
|
||||
var strokeWidth = symbolizer.getStrokeWidth();
|
||||
expect(strokeWidth).to.be.a(ol.expr.Literal);
|
||||
expect(strokeWidth.getValue()).to.be(10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeOpacity()', function() {
|
||||
|
||||
it('returns the stroke opacity', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeWidth: 1,
|
||||
strokeOpacity: 0.123
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setFillColor()', function() {
|
||||
|
||||
it('sets the fill color', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
fillColor: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setFillColor(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var fillColor = symbolizer.getFillColor();
|
||||
expect(fillColor).to.be.a(ol.expr.Literal);
|
||||
expect(fillColor.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
fillColor: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setFillColor('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeColor()', function() {
|
||||
|
||||
it('sets the stroke color', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setStrokeColor(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var strokeColor = symbolizer.getStrokeColor();
|
||||
expect(strokeColor).to.be.a(ol.expr.Literal);
|
||||
expect(strokeColor.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeColor('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeWidth()', function() {
|
||||
|
||||
it('sets the stroke width', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeWidth: 10
|
||||
});
|
||||
symbolizer.setStrokeWidth(new ol.expr.Literal(20));
|
||||
|
||||
var strokeWidth = symbolizer.getStrokeWidth();
|
||||
expect(strokeWidth).to.be.a(ol.expr.Literal);
|
||||
expect(strokeWidth.getValue()).to.be(20);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeWidth: 10
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeWidth(10);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeOpacity()', function() {
|
||||
|
||||
it('sets the stroke opacity', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeWidth: 1,
|
||||
strokeOpacity: 0.123
|
||||
});
|
||||
symbolizer.setStrokeOpacity(new ol.expr.Literal(0.321));
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.321);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
strokeWidth: 1,
|
||||
strokeOpacity: 1
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeOpacity(0.5);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.asserts.AssertionError');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Polygon');
|
||||
goog.require('ol.style.PolygonLiteral');
|
||||
@@ -9,28 +9,81 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var equalLiteral = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var differentLiteral = new ol.style.ShapeLiteral({
|
||||
var differentSize = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 5,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var differentFillColor = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#013',
|
||||
fillColor: '#ffffff',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var differentFillOpacity = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.8,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var differentStrokeColor = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#ffffff',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var differentStrokeOpacity = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.7,
|
||||
strokeWidth: 3
|
||||
});
|
||||
var differentStrokeWidth = new ol.style.ShapeLiteral({
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 4,
|
||||
fillColor: '#BADA55',
|
||||
fillOpacity: 0.9,
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 0.8,
|
||||
strokeWidth: 4
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral)).to.be(false);
|
||||
expect(literal.equals(differentSize)).to.be(false);
|
||||
expect(literal.equals(differentFillColor)).to.be(false);
|
||||
expect(literal.equals(differentFillOpacity)).to.be(false);
|
||||
expect(literal.equals(differentStrokeColor)).to.be(false);
|
||||
expect(literal.equals(differentStrokeOpacity)).to.be(false);
|
||||
expect(literal.equals(differentStrokeWidth)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -64,7 +117,7 @@ describe('ol.style.Shape', function() {
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
size: ol.expr.parse('sizeAttr'),
|
||||
opacity: ol.expr.parse('opacityAttr'),
|
||||
fillOpacity: ol.expr.parse('opacityAttr'),
|
||||
fillColor: '#BADA55'
|
||||
});
|
||||
|
||||
@@ -76,51 +129,296 @@ describe('ol.style.Shape', function() {
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(42);
|
||||
expect(literal.opacity).to.be(0.4);
|
||||
expect(literal.fillOpacity).to.be(0.4);
|
||||
});
|
||||
|
||||
it('can be called without a feature', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
size: 10,
|
||||
opacity: 1,
|
||||
fillColor: '#BADA55',
|
||||
strokeColor: '#013',
|
||||
strokeOpacity: 1,
|
||||
strokeWidth: 2
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(10);
|
||||
expect(literal.opacity).to.be(1);
|
||||
expect(literal.fillColor).to.be('#BADA55');
|
||||
expect(literal.strokeColor).to.be('#013');
|
||||
expect(literal.strokeOpacity).to.be(1);
|
||||
expect(literal.strokeWidth).to.be(2);
|
||||
});
|
||||
|
||||
it('applies default type if none provided', function() {
|
||||
});
|
||||
|
||||
describe('#getFillColor()', function() {
|
||||
|
||||
it('returns the fill color', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
size: ol.expr.parse('sizeAttr'),
|
||||
opacity: ol.expr.parse('opacityAttr'),
|
||||
fillColor: '#BADA55'
|
||||
fillColor: '#ff0000'
|
||||
});
|
||||
|
||||
var feature = new ol.Feature({
|
||||
sizeAttr: 42,
|
||||
opacityAttr: 0.4
|
||||
var fillColor = symbolizer.getFillColor();
|
||||
expect(fillColor).to.be.a(ol.expr.Literal);
|
||||
expect(fillColor.getValue()).to.be('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getFillOpacity()', function() {
|
||||
|
||||
it('returns the fill opacity', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fillOpacity: 0.123
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(42);
|
||||
expect(literal.opacity).to.be(0.4);
|
||||
var opacity = symbolizer.getFillOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
it('returns the default if none provided', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fillColor: '#ffffff'
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getFillOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.4);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeColor()', function() {
|
||||
|
||||
it('returns the stroke color', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
var strokeColor = symbolizer.getStrokeColor();
|
||||
expect(strokeColor).to.be.a(ol.expr.Literal);
|
||||
expect(strokeColor.getValue()).to.be('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeOpacity()', function() {
|
||||
|
||||
it('returns the stroke opacity', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 1,
|
||||
strokeOpacity: 0.123
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
it('returns the default if none provided', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 1
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.8);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getStrokeWidth()', function() {
|
||||
|
||||
it('returns the stroke width', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 10
|
||||
});
|
||||
|
||||
var strokeWidth = symbolizer.getStrokeWidth();
|
||||
expect(strokeWidth).to.be.a(ol.expr.Literal);
|
||||
expect(strokeWidth.getValue()).to.be(10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getType()', function() {
|
||||
|
||||
it('returns the shape type', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 1,
|
||||
opacity: 0.123
|
||||
});
|
||||
|
||||
var type = symbolizer.getType();
|
||||
expect(type).to.be(ol.style.ShapeType.CIRCLE);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setFillColor()', function() {
|
||||
|
||||
it('sets the fill color', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fillColor: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setFillColor(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var fillColor = symbolizer.getFillColor();
|
||||
expect(fillColor).to.be.a(ol.expr.Literal);
|
||||
expect(fillColor.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fillColor: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setFillColor('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setFillOpacity()', function() {
|
||||
|
||||
it('sets the fill opacity', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fillOpacity: 0.5
|
||||
});
|
||||
|
||||
symbolizer.setFillOpacity(new ol.expr.Literal(0.6));
|
||||
|
||||
var fillOpacity = symbolizer.getFillOpacity();
|
||||
expect(fillOpacity).to.be.a(ol.expr.Literal);
|
||||
expect(fillOpacity.getValue()).to.be(0.6);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
fillOpacity: 0.5
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setFillOpacity(0.4);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeColor()', function() {
|
||||
|
||||
it('sets the stroke color', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setStrokeColor(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var strokeColor = symbolizer.getStrokeColor();
|
||||
expect(strokeColor).to.be.a(ol.expr.Literal);
|
||||
expect(strokeColor.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeColor: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeColor('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeOpacity()', function() {
|
||||
|
||||
it('sets the stroke opacity', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 1,
|
||||
strokeOpacity: 0.123
|
||||
});
|
||||
symbolizer.setStrokeOpacity(new ol.expr.Literal(0.321));
|
||||
|
||||
var opacity = symbolizer.getStrokeOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.321);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 1,
|
||||
strokeOpacity: 1
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeOpacity(0.5);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setStrokeWidth()', function() {
|
||||
|
||||
it('sets the stroke width', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 10
|
||||
});
|
||||
symbolizer.setStrokeWidth(new ol.expr.Literal(20));
|
||||
|
||||
var strokeWidth = symbolizer.getStrokeWidth();
|
||||
expect(strokeWidth).to.be.a(ol.expr.Literal);
|
||||
expect(strokeWidth.getValue()).to.be(20);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 10
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setStrokeWidth(10);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setType()', function() {
|
||||
|
||||
it('sets the shape type', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
strokeWidth: 1,
|
||||
opacity: 0.123
|
||||
});
|
||||
symbolizer.setType(ol.style.ShapeType.CIRCLE);
|
||||
|
||||
var type = symbolizer.getType();
|
||||
expect(type).to.be(ol.style.ShapeType.CIRCLE);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.asserts.AssertionError');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.ShapeLiteral');
|
||||
goog.require('ol.style.ShapeType');
|
||||
@@ -0,0 +1,367 @@
|
||||
goog.provide('ol.test.style.Text');
|
||||
|
||||
describe('ol.style.TextLiteral', function() {
|
||||
|
||||
describe('#equals()', function() {
|
||||
|
||||
it('identifies equal literals', function() {
|
||||
var literal = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
});
|
||||
var equalLiteral = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
});
|
||||
var differentLiteral1 = new ol.style.TextLiteral({
|
||||
color: '#0000ff',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
});
|
||||
var differentLiteral2 = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Dingbats',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
});
|
||||
var differentLiteral3 = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 12,
|
||||
text: 'Test',
|
||||
opacity: 0.5
|
||||
});
|
||||
var differentLiteral4 = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.6
|
||||
});
|
||||
var equalLiteral2 = new ol.style.TextLiteral({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Text is not compared for equality',
|
||||
opacity: 0.5
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral1)).to.be(false);
|
||||
expect(literal.equals(differentLiteral2)).to.be(false);
|
||||
expect(literal.equals(differentLiteral3)).to.be(false);
|
||||
expect(literal.equals(differentLiteral4)).to.be(false);
|
||||
expect(literal.equals(equalLiteral2)).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.style.Text', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('accepts literal values', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: '#ff0000',
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 11,
|
||||
text: 'Test',
|
||||
opacity: 0.6
|
||||
});
|
||||
expect(symbolizer).to.be.a(ol.style.Text);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: ol.expr.parse('"#ff0000"'),
|
||||
fontFamily: ol.expr.parse('"Arial"'),
|
||||
fontSize: ol.expr.parse('11'),
|
||||
text: ol.expr.parse('"Test"'),
|
||||
opacity: ol.expr.parse('0.6')
|
||||
});
|
||||
expect(symbolizer).to.be.a(ol.style.Text);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#createLiteral()', function() {
|
||||
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: ol.expr.parse('colorAttr'),
|
||||
fontFamily: ol.expr.parse('fontFamilyAttr'),
|
||||
fontSize: ol.expr.parse('fontSizeAttr'),
|
||||
text: ol.expr.parse('textAttr'),
|
||||
opacity: ol.expr.parse('opacityAttr')
|
||||
});
|
||||
|
||||
var feature = new ol.Feature({
|
||||
colorAttr: '#ff0000',
|
||||
fontFamilyAttr: 'Dingbats',
|
||||
fontSizeAttr: 43,
|
||||
textAttr: 'Test',
|
||||
opacityAttr: 0.4
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).to.be.a(ol.style.TextLiteral);
|
||||
expect(literal.color).to.be('#ff0000');
|
||||
expect(literal.fontFamily).to.be('Dingbats');
|
||||
expect(literal.fontSize).to.be(43);
|
||||
expect(literal.text).to.be('Test');
|
||||
expect(literal.opacity).to.be(0.4);
|
||||
});
|
||||
|
||||
it('can be called without a feature', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: ol.expr.parse('"#ff0000"'),
|
||||
fontFamily: ol.expr.parse('"Arial"'),
|
||||
fontSize: ol.expr.parse('11'),
|
||||
text: ol.expr.parse('"Test"'),
|
||||
opacity: ol.expr.parse('0.6')
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).to.be.a(ol.style.TextLiteral);
|
||||
expect(literal.color).to.be('#ff0000');
|
||||
expect(literal.fontFamily).to.be('Arial');
|
||||
expect(literal.fontSize).to.be(11);
|
||||
expect(literal.text).to.be('Test');
|
||||
expect(literal.opacity).to.be(0.6);
|
||||
});
|
||||
|
||||
it('applies default type if none provided', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
text: 'Test'
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).to.be.a(ol.style.TextLiteral);
|
||||
expect(literal.color).to.be('#000');
|
||||
expect(literal.fontFamily).to.be('sans-serif');
|
||||
expect(literal.fontSize).to.be(10);
|
||||
expect(literal.text).to.be('Test');
|
||||
expect(literal.opacity).to.be(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getColor()', function() {
|
||||
|
||||
it('returns the text color', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: '#ff0000'
|
||||
});
|
||||
|
||||
var color = symbolizer.getColor();
|
||||
expect(color).to.be.a(ol.expr.Literal);
|
||||
expect(color.getValue()).to.be('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('#getFontFamily()', function() {
|
||||
|
||||
it('returns the font family', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontFamily: 'Arial'
|
||||
});
|
||||
|
||||
var fontFamily = symbolizer.getFontFamily();
|
||||
expect(fontFamily).to.be.a(ol.expr.Literal);
|
||||
expect(fontFamily.getValue()).to.be('Arial');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getFontSize()', function() {
|
||||
|
||||
it('returns the font size', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 42
|
||||
});
|
||||
|
||||
var fontSize = symbolizer.getFontSize();
|
||||
expect(fontSize).to.be.a(ol.expr.Literal);
|
||||
expect(fontSize.getValue()).to.be(42);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getOpacity()', function() {
|
||||
|
||||
it('returns the opacity', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 1,
|
||||
opacity: 0.123
|
||||
});
|
||||
|
||||
var opacity = symbolizer.getOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.123);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setColor()', function() {
|
||||
|
||||
it('sets the text color', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setColor(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var color = symbolizer.getColor();
|
||||
expect(color).to.be.a(ol.expr.Literal);
|
||||
expect(color.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
color: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setColor('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setFontFamily()', function() {
|
||||
|
||||
it('sets the font family', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontFamily: '#ff0000'
|
||||
});
|
||||
|
||||
symbolizer.setFontFamily(new ol.expr.Literal('#0000ff'));
|
||||
|
||||
var fontFamily = symbolizer.getFontFamily();
|
||||
expect(fontFamily).to.be.a(ol.expr.Literal);
|
||||
expect(fontFamily.getValue()).to.be('#0000ff');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontFamily: '#ff0000'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setFontFamily('#0000ff');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setFontSize()', function() {
|
||||
|
||||
it('sets the font size', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 10
|
||||
});
|
||||
symbolizer.setFontSize(new ol.expr.Literal(20));
|
||||
|
||||
var fontSize = symbolizer.getFontSize();
|
||||
expect(fontSize).to.be.a(ol.expr.Literal);
|
||||
expect(fontSize.getValue()).to.be(20);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 10
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setFontSize(10);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setOpacity()', function() {
|
||||
|
||||
it('sets the opacity', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 1,
|
||||
opacity: 0.123
|
||||
});
|
||||
symbolizer.setOpacity(new ol.expr.Literal(0.321));
|
||||
|
||||
var opacity = symbolizer.getOpacity();
|
||||
expect(opacity).to.be.a(ol.expr.Literal);
|
||||
expect(opacity.getValue()).to.be(0.321);
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 1,
|
||||
opacity: 1
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setOpacity(0.5);
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setText()', function() {
|
||||
|
||||
it('sets the text', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 1,
|
||||
text: 'Initial Text'
|
||||
});
|
||||
symbolizer.setText(new ol.expr.Literal('New Text'));
|
||||
|
||||
var text = symbolizer.getText();
|
||||
expect(text).to.be.a(ol.expr.Literal);
|
||||
expect(text.getValue()).to.be('New Text');
|
||||
});
|
||||
|
||||
it('throws when not provided an expression', function() {
|
||||
var symbolizer = new ol.style.Text({
|
||||
fontSize: 1,
|
||||
text: 'Test'
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
symbolizer.setText('Bad');
|
||||
}).throwException(function(err) {
|
||||
expect(err).to.be.a(goog.asserts.AssertionError);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('goog.asserts.AssertionError');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Text');
|
||||
goog.require('ol.style.TextLiteral');
|
||||
@@ -8,7 +8,7 @@ describe('ol.View2D', function() {
|
||||
describe('with no options', function() {
|
||||
it('gives a correct resolution constraint function', function() {
|
||||
var options = {};
|
||||
var fn = ol.View2D.createResolutionConstraint_(options)[0];
|
||||
var fn = ol.View2D.createResolutionConstraint_(options).constraint;
|
||||
expect(fn(156543.03392804097, 0, 0))
|
||||
.to.roughlyEqual(156543.03392804097, 1e-9);
|
||||
expect(fn(78271.51696402048, 0, 0))
|
||||
@@ -24,12 +24,12 @@ describe('ol.View2D', function() {
|
||||
maxZoom: 3,
|
||||
zoomFactor: 3
|
||||
};
|
||||
var parts = ol.View2D.createResolutionConstraint_(options);
|
||||
var maxResolution = parts[1];
|
||||
var info = ol.View2D.createResolutionConstraint_(options);
|
||||
var maxResolution = info.maxResolution;
|
||||
expect(maxResolution).to.eql(81);
|
||||
var minResolution = parts[2];
|
||||
var minResolution = info.minResolution;
|
||||
expect(minResolution).to.eql(3);
|
||||
var fn = parts[0];
|
||||
var fn = info.constraint;
|
||||
expect(fn(82, 0, 0)).to.eql(81);
|
||||
expect(fn(81, 0, 0)).to.eql(81);
|
||||
expect(fn(27, 0, 0)).to.eql(27);
|
||||
@@ -44,12 +44,12 @@ describe('ol.View2D', function() {
|
||||
var options = {
|
||||
resolutions: [97, 76, 65, 54, 0.45]
|
||||
};
|
||||
var parts = ol.View2D.createResolutionConstraint_(options);
|
||||
var maxResolution = parts[1];
|
||||
var info = ol.View2D.createResolutionConstraint_(options);
|
||||
var maxResolution = info.maxResolution;
|
||||
expect(maxResolution).to.eql(97);
|
||||
var minResolution = parts[2];
|
||||
var minResolution = info.minResolution;
|
||||
expect(minResolution).to.eql(0.45);
|
||||
var fn = parts[0];
|
||||
var fn = info.constraint;
|
||||
expect(fn(97, 0, 0)).to.eql(97);
|
||||
expect(fn(76, 0, 0)).to.eql(76);
|
||||
expect(fn(65, 0, 0)).to.eql(65);
|
||||
@@ -70,6 +70,38 @@ describe('ol.View2D', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getZoom', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
view = new ol.View2D({
|
||||
resolutions: [512, 256, 128, 64, 32, 16]
|
||||
});
|
||||
});
|
||||
|
||||
it('returns correct zoom levels', function() {
|
||||
view.setResolution(undefined);
|
||||
expect(view.getZoom()).to.be(undefined);
|
||||
|
||||
view.setResolution(511);
|
||||
expect(view.getZoom()).to.be(undefined);
|
||||
|
||||
view.setResolution(512);
|
||||
expect(view.getZoom()).to.be(0);
|
||||
|
||||
view.setResolution(64);
|
||||
expect(view.getZoom()).to.be(3);
|
||||
|
||||
view.setResolution(65);
|
||||
expect(view.getZoom()).to.be(undefined);
|
||||
|
||||
view.setResolution(16);
|
||||
expect(view.getZoom()).to.be(5);
|
||||
|
||||
view.setResolution(15);
|
||||
expect(view.getZoom()).to.be(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
goog.require('ol.View2D');
|
||||
Reference in new issue
Block a user