"Fossies" - the Fresh Open Source Software Archive

Source code changes of the file "spec/suites/layer/vector/PolylineSpec.js" betweenLeaflet-1.8.0.tar.gz and Leaflet-1.9.0.tar.gz

About: Leaflet is a JavaScript library for mobile-friendly interactive maps.

PolylineSpec.js  (Leaflet-1.8.0):PolylineSpec.js  (Leaflet-1.9.0)
skipping to change at line 113 skipping to change at line 113
expect(polyline._latlngs[1]).to.eql([L.latLng([11, 12]), L.latLng([13, 14]), L.latLng([15, 16])]); expect(polyline._latlngs[1]).to.eql([L.latLng([11, 12]), L.latLng([13, 14]), L.latLng([15, 16])]);
}); });
}); });
describe('#getCenter', function () { describe('#getCenter', function () {
it('should compute center of a big flat line on equator', functio n () { it('should compute center of a big flat line on equator', functio n () {
var polyline = L.polyline([[0, 0], [0, 90]]).addTo(map); var polyline = L.polyline([[0, 0], [0, 90]]).addTo(map);
expect(polyline.getCenter()).to.eql(L.latLng([0, 45])); expect(polyline.getCenter()).to.eql(L.latLng([0, 45]));
}); });
it('should compute center of a big flat line on equator with maxZ
oom', function () {
map.setMaxZoom(18);
var polyline = L.polyline([[0, 0], [0, 90]]).addTo(map);
expect(polyline.getCenter()).to.be.nearLatLng([0, 45]);
});
it('should compute center of a big flat line close to the pole', function () { it('should compute center of a big flat line close to the pole', function () {
var polyline = L.polyline([[80, 0], [80, 90]]).addTo(map) ; var polyline = L.polyline([[80, 0], [80, 90]]).addTo(map) ;
expect(polyline.getCenter()).to.be.nearLatLng([80, 45], 1 e-2); expect(polyline.getCenter()).to.be.nearLatLng([80, 45], 1 e-2);
}); });
it('should compute center of a big diagonal line', function () { it('should compute center of a big diagonal line', function () {
var polyline = L.polyline([[0, 0], [80, 80]]).addTo(map); var polyline = L.polyline([[0, 0], [80, 80]]).addTo(map);
expect(polyline.getCenter()).to.be.nearLatLng([57); expect(polyline.getCenter()).to.be.nearLatLng([57.0451646 7328689, 40], 1);
}); });
it('should compute center of a diagonal line close to the pole', function () { it('should compute center of a diagonal line close to the pole', function () {
var polyline = L.polyline([[70, 70], [84, 84]]).addTo(map ); var polyline = L.polyline([[70, 70], [84, 84]]).addTo(map );
expect(polyline.getCenter()).to.be.nearLatLng([79); expect(polyline.getCenter()).to.be.nearLatLng([79.0181006 0159328, 77], 1);
}); });
it('should compute center of a big multiline', function () { it('should compute center of a big multiline', function () {
var polyline = L.polyline([[10, -80], [0, 0], [0, 10], [1 0, 90]]).addTo(map); var polyline = L.polyline([[10, -80], [0, 0], [0, 10], [1 0, 90]]).addTo(map);
expect(polyline.getCenter()).to.be.nearLatLng([0, 5], 1); expect(polyline.getCenter()).to.be.nearLatLng([0, 5], 1);
}); });
it('should compute center of a small flat line', function () { it('should compute center of a small flat line', function () {
var polyline = L.polyline([[0, 0], [0, 0.090]]).addTo(map ); var polyline = L.polyline([[0, 0], [0, 0.090]]).addTo(map );
map.setZoom(0); // Make the line disappear in screen; map.setZoom(0); // Make the line disappear in screen;
expect(polyline.getCenter()).to.be.nearLatLng([0, 0; expect(polyline.getCenter()).to.be.nearLatLng([0, 0.045]) ;
}); });
it('throws error if not yet added to map', function () { it('throws error if not yet added to map', function () {
expect(function () { expect(function () {
var polyline = L.polyline([[0, 0], [0, 0.090]]); var polyline = L.polyline([[0, 0], [0, 0.090]]);
polyline.getCenter(); polyline.getCenter();
}).to.throwException('Must add layer to map before using getCenter()'); }).to.throwException('Must add layer to map before using getCenter()');
}); });
it('should compute same center for low and high zoom', function (
) {
var layer = L.polyline([[10, -80], [0, 0], [0, 10], [10,
map.setZoom(0);
var center = layer.getCenter();
map.setZoom(18);
expect(layer.getCenter()).to.be.nearLatLng(center);
});
it('should compute center of a zick-zack line', function () {
var polyline = L.polyline([[0, 0], [50, 50], [30, 30], [3