-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15796 from ahocevar/vector-deferred-worlds-and-op…
…acity Fix deferred rendering of layer extents, multiple worlds and non-1 opacity
- Loading branch information
Showing
8 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+20.8 KB
test/rendering/cases/layer-vector-extent-rotation-declutter/expected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
test/rendering/cases/layer-vector-extent-rotation-declutter/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import GeoJSON from '../../../../src/ol/format/GeoJSON.js'; | ||
import Map from '../../../../src/ol/Map.js'; | ||
import VectorLayer from '../../../../src/ol/layer/Vector.js'; | ||
import VectorSource from '../../../../src/ol/source/Vector.js'; | ||
import View from '../../../../src/ol/View.js'; | ||
import {transformExtent} from '../../../../src/ol/proj.js'; | ||
|
||
new Map({ | ||
target: 'map', | ||
view: new View({ | ||
center: [0, 0], | ||
zoom: 1, | ||
rotation: Math.PI / 4, | ||
}), | ||
layers: [ | ||
new VectorLayer({ | ||
declutter: true, | ||
extent: transformExtent([-50, -45, 50, 45], 'EPSG:4326', 'EPSG:3857'), | ||
source: new VectorSource({ | ||
url: '/data/countries.json', | ||
format: new GeoJSON(), | ||
}), | ||
}), | ||
], | ||
}); | ||
|
||
render(); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions
70
test/rendering/cases/layer-vector-multi-world-declutter/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import Feature from '../../../../src/ol/Feature.js'; | ||
import Fill from '../../../../src/ol/style/Fill.js'; | ||
import Map from '../../../../src/ol/Map.js'; | ||
import Polygon from '../../../../src/ol/geom/Polygon.js'; | ||
import Style from '../../../../src/ol/style/Style.js'; | ||
import VectorLayer from '../../../../src/ol/layer/Vector.js'; | ||
import VectorSource from '../../../../src/ol/source/Vector.js'; | ||
import View from '../../../../src/ol/View.js'; | ||
import {Projection, addCoordinateTransforms} from '../../../../src/ol/proj.js'; | ||
import {fromEPSG4326, toEPSG4326} from '../../../../src/ol/proj/epsg3857.js'; | ||
|
||
const projection = new Projection({ | ||
code: 'custom', | ||
units: 'm', | ||
global: true, | ||
extent: [-40075016.68557849, -20037508.342789244, 0, 20037508.342789244], | ||
}); | ||
|
||
addCoordinateTransforms( | ||
'EPSG:4326', | ||
projection, | ||
function (coord) { | ||
const converted = fromEPSG4326(coord); | ||
converted[0] -= 20037508.342789244; | ||
return converted; | ||
}, | ||
function (coord) { | ||
return toEPSG4326([coord[0] + 20037508.342789244, coord[1]]); | ||
}, | ||
); | ||
|
||
const feature = new Feature({ | ||
geometry: new Polygon([ | ||
[ | ||
[-20037508.342789244, 20037508.342789244], | ||
[-20037508.342789244, -20037508.342789244], | ||
[-16037508.342789244, -20037508.342789244], | ||
[-16037508.342789244, 20037508.342789244], | ||
[-20037508.342789244, 20037508.342789244], | ||
], | ||
]), | ||
}); | ||
|
||
new Map({ | ||
pixelRatio: 1, | ||
layers: [ | ||
new VectorLayer({ | ||
renderBuffer: 0, | ||
declutter: true, | ||
source: new VectorSource({ | ||
features: [feature], | ||
}), | ||
style: new Style({ | ||
fill: new Fill({ | ||
color: 'black', | ||
}), | ||
}), | ||
}), | ||
], | ||
target: 'map', | ||
view: new View({ | ||
projection: projection, | ||
multiWorld: true, | ||
maxResolution: 485254.1017841229, | ||
zoom: 0, | ||
center: [2000000, 0], | ||
}), | ||
}); | ||
|
||
render(); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
test/rendering/cases/vector-layer-opacity-declutter/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Feature from '../../../../src/ol/Feature.js'; | ||
import Map from '../../../../src/ol/Map.js'; | ||
import View from '../../../../src/ol/View.js'; | ||
import {Polygon} from '../../../../src/ol/geom.js'; | ||
import {Vector as VectorLayer} from '../../../../src/ol/layer.js'; | ||
import {Vector as VectorSource} from '../../../../src/ol/source.js'; | ||
import {fromLonLat} from '../../../../src/ol/proj.js'; | ||
|
||
const center = fromLonLat([8.6, 50.2]); | ||
|
||
const geometry = new Polygon([ | ||
[ | ||
[center[0] - 10000, center[1] - 10000], | ||
[center[0] + 10000, center[1] - 10000], | ||
[center[0] + 10000, center[1] + 10000], | ||
[center[0] - 10000, center[1] + 10000], | ||
[center[0] - 10000, center[1] - 10000], | ||
], | ||
]); | ||
|
||
const map = new Map({ | ||
layers: [ | ||
new VectorLayer({ | ||
opacity: 0.9, | ||
declutter: true, | ||
style: { | ||
'stroke-color': 'red', | ||
'stroke-width': 3, | ||
}, | ||
source: new VectorSource({ | ||
features: [new Feature(geometry)], | ||
}), | ||
}), | ||
], | ||
target: 'map', | ||
view: new View({ | ||
center: center, | ||
zoom: 9, | ||
}), | ||
}); | ||
|
||
map.once('rendercomplete', function () { | ||
map.getView().setCenter(fromLonLat([8.5, 50.1])); | ||
map.renderSync(); | ||
render(); | ||
}); |