diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 1b479a9ae7..82df1c7604 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -1473,19 +1473,20 @@ class Modify extends PointerInteraction { * @private */ updateSegmentIndices_(geometry, index, depth, delta) { - this.rBush_.forEachInExtent(geometry.getExtent(), function ( - segmentDataMatch - ) { - if ( - segmentDataMatch.geometry === geometry && - (depth === undefined || - segmentDataMatch.depth === undefined || - equals(segmentDataMatch.depth, depth)) && - segmentDataMatch.index > index - ) { - segmentDataMatch.index += delta; + this.rBush_.forEachInExtent( + geometry.getExtent(), + function (segmentDataMatch) { + if ( + segmentDataMatch.geometry === geometry && + (depth === undefined || + segmentDataMatch.depth === undefined || + equals(segmentDataMatch.depth, depth)) && + segmentDataMatch.index > index + ) { + segmentDataMatch.index += delta; + } } - }); + ); } } diff --git a/test/spec/ol/format/geojson.test.js b/test/spec/ol/format/geojson.test.js index 9efcc8d6b6..884d217c2b 100644 --- a/test/spec/ol/format/geojson.test.js +++ b/test/spec/ol/format/geojson.test.js @@ -342,43 +342,44 @@ describe('ol.format.GeoJSON', function () { }); it('parses countries.geojson', function (done) { - afterLoadText('spec/ol/format/geojson/countries.geojson', function ( - text - ) { - const result = format.readFeatures(text); - expect(result.length).to.be(179); + afterLoadText( + 'spec/ol/format/geojson/countries.geojson', + function (text) { + const result = format.readFeatures(text); + expect(result.length).to.be(179); - const first = result[0]; - expect(first).to.be.a(Feature); - expect(first.get('name')).to.be('Afghanistan'); - expect(first.getId()).to.be('AFG'); - const firstGeom = first.getGeometry(); - expect(firstGeom).to.be.a(Polygon); - expect( - equals(firstGeom.getExtent(), [ - 60.52843, - 29.318572, - 75.158028, - 38.486282, - ]) - ).to.be(true); + const first = result[0]; + expect(first).to.be.a(Feature); + expect(first.get('name')).to.be('Afghanistan'); + expect(first.getId()).to.be('AFG'); + const firstGeom = first.getGeometry(); + expect(firstGeom).to.be.a(Polygon); + expect( + equals(firstGeom.getExtent(), [ + 60.52843, + 29.318572, + 75.158028, + 38.486282, + ]) + ).to.be(true); - const last = result[178]; - expect(last).to.be.a(Feature); - expect(last.get('name')).to.be('Zimbabwe'); - expect(last.getId()).to.be('ZWE'); - const lastGeom = last.getGeometry(); - expect(lastGeom).to.be.a(Polygon); - expect( - equals(lastGeom.getExtent(), [ - 25.264226, - -22.271612, - 32.849861, - -15.507787, - ]) - ).to.be(true); - done(); - }); + const last = result[178]; + expect(last).to.be.a(Feature); + expect(last.get('name')).to.be('Zimbabwe'); + expect(last.getId()).to.be('ZWE'); + const lastGeom = last.getGeometry(); + expect(lastGeom).to.be.a(Polygon); + expect( + equals(lastGeom.getExtent(), [ + 25.264226, + -22.271612, + 32.849861, + -15.507787, + ]) + ).to.be(true); + done(); + } + ); }); it('generates an array of features for Feature', function () { diff --git a/test/spec/ol/format/gml.test.js b/test/spec/ol/format/gml.test.js index e44c169d20..3b50b3d79d 100644 --- a/test/spec/ol/format/gml.test.js +++ b/test/spec/ol/format/gml.test.js @@ -1663,19 +1663,20 @@ describe('ol.format.GML3', function () { describe('when parsing multiple feature types', function () { let features; before(function (done) { - afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( - xml - ) { - try { - features = new GML({ - featureNS: 'http://localhost:8080/official', - featureType: ['planet_osm_polygon', 'planet_osm_line'], - }).readFeatures(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/gml/multiple-typenames.xml', + function (xml) { + try { + features = new GML({ + featureNS: 'http://localhost:8080/official', + featureType: ['planet_osm_polygon', 'planet_osm_line'], + }).readFeatures(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('reads all features', function () { @@ -1686,16 +1687,17 @@ describe('ol.format.GML3', function () { describe('when parsing multiple feature types', function () { let features; before(function (done) { - afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( - xml - ) { - try { - features = new GML().readFeatures(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/gml/multiple-typenames.xml', + function (xml) { + try { + features = new GML().readFeatures(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('reads all features with autoconfigure', function () { @@ -1750,20 +1752,21 @@ describe('ol.format.GML3', function () { describe('when parsing srsDimension from WFS (Geoserver)', function () { let features, feature; before(function (done) { - afterLoadText('spec/ol/format/gml/geoserver3DFeatures.xml', function ( - xml - ) { - try { - const config = { - 'featureNS': 'http://www.opengeospatial.net/cite', - 'featureType': 'geoserver_layer', - }; - features = new GML(config).readFeatures(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/gml/geoserver3DFeatures.xml', + function (xml) { + try { + const config = { + 'featureNS': 'http://www.opengeospatial.net/cite', + 'featureType': 'geoserver_layer', + }; + features = new GML(config).readFeatures(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('creates 3 features', function () { diff --git a/test/spec/ol/format/wfs.test.js b/test/spec/ol/format/wfs.test.js index a208a988f0..8fd73b9a7d 100644 --- a/test/spec/ol/format/wfs.test.js +++ b/test/spec/ol/format/wfs.test.js @@ -152,12 +152,13 @@ describe('ol.format.WFS', function () { describe('when parsing FeatureCollection', function () { let xml; before(function (done) { - afterLoadText('spec/ol/format/wfs/EmptyFeatureCollection.xml', function ( - _xml - ) { - xml = _xml; - done(); - }); + afterLoadText( + 'spec/ol/format/wfs/EmptyFeatureCollection.xml', + function (_xml) { + xml = _xml; + done(); + } + ); }); it('returns an empty array of features when none exist', function () { const result = new WFS().readFeatures(xml); @@ -215,16 +216,17 @@ describe('ol.format.WFS', function () { describe('when parsing TransactionResponse', function () { let response; before(function (done) { - afterLoadText('spec/ol/format/wfs/TransactionResponse.xml', function ( - xml - ) { - try { - response = new WFS().readTransactionResponse(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/wfs/TransactionResponse.xml', + function (xml) { + try { + response = new WFS().readTransactionResponse(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('returns the correct TransactionResponse object', function () { expect(response.transactionSummary.totalDeleted).to.equal(0); @@ -1241,12 +1243,13 @@ describe('ol.format.WFS', function () { describe('when writing out a Transaction request', function () { let text; before(function (done) { - afterLoadText('spec/ol/format/wfs/TransactionMulti_3D.xml', function ( - xml - ) { - text = xml; - done(); - }); + afterLoadText( + 'spec/ol/format/wfs/TransactionMulti_3D.xml', + function (xml) { + text = xml; + done(); + } + ); }); it('handles 3D in WFS 1.1.0', function () { @@ -1283,12 +1286,13 @@ describe('ol.format.WFS', function () { describe('when writing out a GetFeature request', function () { let text; before(function (done) { - afterLoadText('spec/ol/format/wfs/GetFeatureMultiple.xml', function ( - xml - ) { - text = xml; - done(); - }); + afterLoadText( + 'spec/ol/format/wfs/GetFeatureMultiple.xml', + function (xml) { + text = xml; + done(); + } + ); }); it('handles writing multiple Query elements', function () { @@ -1335,19 +1339,20 @@ describe('ol.format.WFS', function () { describe('when parsing multiple feature types', function () { let features; before(function (done) { - afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( - xml - ) { - try { - features = new WFS({ - featureNS: 'http://localhost:8080/official', - featureType: ['planet_osm_polygon', 'planet_osm_line'], - }).readFeatures(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/gml/multiple-typenames.xml', + function (xml) { + try { + features = new WFS({ + featureNS: 'http://localhost:8080/official', + featureType: ['planet_osm_polygon', 'planet_osm_line'], + }).readFeatures(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('reads all features', function () { @@ -1358,23 +1363,24 @@ describe('ol.format.WFS', function () { describe('when parsing multiple feature types separately', function () { let lineFeatures, polygonFeatures; before(function (done) { - afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( - xml - ) { - try { - lineFeatures = new WFS({ - featureNS: 'http://localhost:8080/official', - featureType: ['planet_osm_line'], - }).readFeatures(xml); - polygonFeatures = new WFS({ - featureNS: 'http://localhost:8080/official', - featureType: ['planet_osm_polygon'], - }).readFeatures(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/gml/multiple-typenames.xml', + function (xml) { + try { + lineFeatures = new WFS({ + featureNS: 'http://localhost:8080/official', + featureType: ['planet_osm_line'], + }).readFeatures(xml); + polygonFeatures = new WFS({ + featureNS: 'http://localhost:8080/official', + featureType: ['planet_osm_polygon'], + }).readFeatures(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('reads all features', function () { @@ -1386,16 +1392,17 @@ describe('ol.format.WFS', function () { describe('when parsing multiple feature types', function () { let features; before(function (done) { - afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function ( - xml - ) { - try { - features = new WFS().readFeatures(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/gml/multiple-typenames.xml', + function (xml) { + try { + features = new WFS().readFeatures(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('reads all features with autoconfigure', function () { diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index bc566a8047..8df76ac5d8 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -885,11 +885,12 @@ describe('ol.interaction.Modify', function () { let firstSegmentData; - firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( - node - ) { - return node; - }); + firstSegmentData = modify.rBush_.forEachInExtent( + [0, 0, 5, 5], + function (node) { + return node; + } + ); expect(firstSegmentData.segment[0]).to.eql([10, 10]); expect(firstSegmentData.segment[1]).to.eql([10, 10]); @@ -898,11 +899,12 @@ describe('ol.interaction.Modify', function () { center[1] = 1; feature.getGeometry().setCenter(center); - firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( - node - ) { - return node; - }); + firstSegmentData = modify.rBush_.forEachInExtent( + [0, 0, 5, 5], + function (node) { + return node; + } + ); expect(firstSegmentData.segment[0]).to.eql([1, 1]); expect(firstSegmentData.segment[1]).to.eql([1, 1]); @@ -924,11 +926,12 @@ describe('ol.interaction.Modify', function () { let firstSegmentData; - firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( - node - ) { - return node; - }); + firstSegmentData = modify.rBush_.forEachInExtent( + [0, 0, 5, 5], + function (node) { + return node; + } + ); expect(firstSegmentData.segment[0]).to.eql([0, 0]); expect(firstSegmentData.segment[1]).to.eql([10, 20]); @@ -938,11 +941,12 @@ describe('ol.interaction.Modify', function () { firstVertex[1] = 1; feature.getGeometry().setCoordinates(coordinates); - firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function ( - node - ) { - return node; - }); + firstSegmentData = modify.rBush_.forEachInExtent( + [0, 0, 5, 5], + function (node) { + return node; + } + ); expect(firstSegmentData.segment[0]).to.eql([1, 1]); expect(firstSegmentData.segment[1]).to.eql([10, 20]); diff --git a/test/spec/ol/source/wmts.test.js b/test/spec/ol/source/wmts.test.js index d6e47a405d..5c729455b0 100644 --- a/test/spec/ol/source/wmts.test.js +++ b/test/spec/ol/source/wmts.test.js @@ -354,16 +354,17 @@ describe('ol.source.WMTS', function () { const parser = new WMTSCapabilities(); let capabilities; before(function (done) { - afterLoadText('spec/ol/format/wmts/capabilities_wgs84.xml', function ( - xml - ) { - try { - capabilities = parser.read(xml); - } catch (e) { - done(e); + afterLoadText( + 'spec/ol/format/wmts/capabilities_wgs84.xml', + function (xml) { + try { + capabilities = parser.read(xml); + } catch (e) { + done(e); + } + done(); } - done(); - }); + ); }); it('returns correct bounding box', function () { diff --git a/test/spec/ol/tilegrid/tilegrid.test.js b/test/spec/ol/tilegrid/tilegrid.test.js index 8ca76b44ba..d37082401c 100644 --- a/test/spec/ol/tilegrid/tilegrid.test.js +++ b/test/spec/ol/tilegrid/tilegrid.test.js @@ -616,21 +616,21 @@ describe('ol.tilegrid.TileGrid', function () { const tileCoord = [5, 11, 21]; const zs = []; const tileRanges = []; - tileGrid.forEachTileCoordParentTileRange(tileCoord, function ( - z, - tileRange - ) { - zs.push(z); - tileRanges.push( - new TileRange( - tileRange.minX, - tileRange.maxX, - tileRange.minY, - tileRange.maxY - ) - ); - return false; - }); + tileGrid.forEachTileCoordParentTileRange( + tileCoord, + function (z, tileRange) { + zs.push(z); + tileRanges.push( + new TileRange( + tileRange.minX, + tileRange.maxX, + tileRange.minY, + tileRange.maxY + ) + ); + return false; + } + ); expect(zs.length).to.eql(5); expect(tileRanges.length).to.eql(5); @@ -1061,14 +1061,14 @@ describe('ol.tilegrid.TileGrid', function () { const zs = []; const tileRanges = []; - tileGrid.forEachTileCoordParentTileRange([3, 7, 3], function ( - z, - tileRange - ) { - zs.push(z); - tileRanges.push(tileRange); - return false; - }); + tileGrid.forEachTileCoordParentTileRange( + [3, 7, 3], + function (z, tileRange) { + zs.push(z); + tileRanges.push(tileRange); + return false; + } + ); expect(zs.length).to.eql(3); expect(tileRanges.length).to.eql(3); @@ -1219,17 +1219,17 @@ describe('ol.tilegrid.TileGrid', function () { }); const tileCoord = [15, 6239, 11751]; - tileGrid.forEachTileCoordParentTileRange(tileCoord, function ( - z, - tileRange - ) { - it(`works for level ${z}`, function () { - const range = tileGrid.getTileRangeForTileCoordAndZ(tileCoord, z); - expect(range.minX).to.be(tileRange.minX); - expect(range.maxX).to.be(tileRange.maxX); - expect(range.minY).to.be(tileRange.minY); - expect(range.maxY).to.be(tileRange.maxY); - }); - }); + tileGrid.forEachTileCoordParentTileRange( + tileCoord, + function (z, tileRange) { + it(`works for level ${z}`, function () { + const range = tileGrid.getTileRangeForTileCoordAndZ(tileCoord, z); + expect(range.minX).to.be(tileRange.minX); + expect(range.maxX).to.be(tileRange.maxX); + expect(range.minY).to.be(tileRange.minY); + expect(range.maxY).to.be(tileRange.maxY); + }); + } + ); }); });