merge with master - solving conflicts
This commit is contained in:
@@ -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>
|
||||
4661
test/spec/ol/parser/kml/states.kml
Normal file
4661
test/spec/ol/parser/kml/states.kml
Normal file
File diff suppressed because one or more lines are too long
@@ -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>
|
||||
|
||||
File diff suppressed because one or more lines are too long
118
test/spec/ol/parser/topojson.test.js
Normal file
118
test/spec/ol/parser/topojson.test.js
Normal file
@@ -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');
|
||||
1
test/spec/ol/parser/topojson/world-110m.json
Normal file
1
test/spec/ol/parser/topojson/world-110m.json
Normal file
File diff suppressed because one or more lines are too long
@@ -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');
|
||||
|
||||
401
test/spec/ol/style/icon.test.js
Normal file
401
test/spec/ol/style/icon.test.js
Normal file
@@ -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');
|
||||
|
||||
367
test/spec/ol/style/text.test.js
Normal file
367
test/spec/ol/style/text.test.js
Normal file
@@ -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