Compare commits
250 Commits
v4.1.2-bet
...
v4.3.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cf01037aa | ||
|
|
89ec2dacad | ||
|
|
b97439cf8e | ||
|
|
b7b2ee0c57 | ||
|
|
fe39b5da1b | ||
|
|
bc0bc3f8a9 | ||
|
|
9c0d0c5681 | ||
|
|
b97daf844b | ||
|
|
f8237c9cd2 | ||
|
|
b317a4474e | ||
|
|
b1772dae44 | ||
|
|
c33383d248 | ||
|
|
645e359cde | ||
|
|
fa71593a2a | ||
|
|
2e903c0293 | ||
|
|
aced192bcd | ||
|
|
19b0b956f7 | ||
|
|
9f9355ac46 | ||
|
|
f28e6c2d95 | ||
|
|
e633380221 | ||
|
|
5f6f757bd0 | ||
|
|
b29fc52842 | ||
|
|
791ffaabeb | ||
|
|
c31d67fe57 | ||
|
|
a1710be335 | ||
|
|
2260d92436 | ||
|
|
4d0e106d98 | ||
|
|
8bc4bde5c3 | ||
|
|
429e2982d0 | ||
|
|
23f8540b4c | ||
|
|
59d8d749e3 | ||
|
|
cff9ef5e63 | ||
|
|
e6e0109a1b | ||
|
|
7739239e89 | ||
|
|
eb8d5bcade | ||
|
|
ff242ef28c | ||
|
|
4a0f97ac6a | ||
|
|
a0e0e76995 | ||
|
|
b5f9b88d0e | ||
|
|
339f048826 | ||
|
|
4f0bfbc1db | ||
|
|
db63cc1b23 | ||
|
|
f88d8b8a7d | ||
|
|
991328904d | ||
|
|
9d3539b3cb | ||
|
|
bd143c0ad1 | ||
|
|
970265acb0 | ||
|
|
36c80f61bc | ||
|
|
d86c7c22dc | ||
|
|
71b334d49c | ||
|
|
ee0eb8b1a0 | ||
|
|
cd4ed759ed | ||
|
|
c0e4da6d8c | ||
|
|
72f5ff917f | ||
|
|
4c9c9fa719 | ||
|
|
163e01a2dc | ||
|
|
79862ca8c2 | ||
|
|
aa8d7b0b36 | ||
|
|
8d0857fd7a | ||
|
|
67f69a32bb | ||
|
|
382674975e | ||
|
|
eaaa895b0a | ||
|
|
70b971d3a4 | ||
|
|
3ddb8712a3 | ||
|
|
533ca8b9fe | ||
|
|
0fc710bc48 | ||
|
|
fe18636ff9 | ||
|
|
c299bfcd0f | ||
|
|
3f5a6bca26 | ||
|
|
a6b35e7d8a | ||
|
|
619e85e737 | ||
|
|
b3407b0554 | ||
|
|
a4c421e699 | ||
|
|
a3a443324d | ||
|
|
7b9833fdce | ||
|
|
bd87ec7c83 | ||
|
|
26bfa7a172 | ||
|
|
f82bc15013 | ||
|
|
da60b96445 | ||
|
|
2ed5abed07 | ||
|
|
49dcda7794 | ||
|
|
9fc0fb5e74 | ||
|
|
d32006b324 | ||
|
|
feabb6440d | ||
|
|
87e9c9ad46 | ||
|
|
7d6929c710 | ||
|
|
887642e69c | ||
|
|
b9e6619b2d | ||
|
|
78b5fe5f8c | ||
|
|
72e9b74b3e | ||
|
|
c6aeda1511 | ||
|
|
eb501e1244 | ||
|
|
1f51c14e7e | ||
|
|
dee3ebdc54 | ||
|
|
d0ef05977b | ||
|
|
a17db4f45c | ||
|
|
20974fea55 | ||
|
|
416df98505 | ||
|
|
fb5891cd48 | ||
|
|
1d4a482c1a | ||
|
|
8d57a879ce | ||
|
|
3e7aecd094 | ||
|
|
c46bc1f02a | ||
|
|
0d0ed6c130 | ||
|
|
0045bed6e7 | ||
|
|
0982dc0551 | ||
|
|
e38efc7cbe | ||
|
|
ea4e5f2293 | ||
|
|
29d1590bc6 | ||
|
|
e14ee2ea72 | ||
|
|
68ca4b3c2a | ||
|
|
4ad85e52e2 | ||
|
|
4255e81b93 | ||
|
|
81e8cdc7ab | ||
|
|
b1b5b54fd0 | ||
|
|
109362f147 | ||
|
|
b5038c18e2 | ||
|
|
87d889f96c | ||
|
|
9b41ea4017 | ||
|
|
51658a0d7c | ||
|
|
2f45e14bea | ||
|
|
aa56afdab7 | ||
|
|
9fda131d37 | ||
|
|
b3ddcd4ed9 | ||
|
|
107792635d | ||
|
|
7ea8cf5fb3 | ||
|
|
1d6ce6db35 | ||
|
|
4e44a09072 | ||
|
|
dc6d0c091a | ||
|
|
af6aaf4bab | ||
|
|
e822731f8c | ||
|
|
a23246aca1 | ||
|
|
f31e45d7d2 | ||
|
|
34e61da366 | ||
|
|
451aef200f | ||
|
|
bb8a1b061c | ||
|
|
d4367cdd7d | ||
|
|
3b15bb80b9 | ||
|
|
399e11edf7 | ||
|
|
f97f370e5b | ||
|
|
070f2e181c | ||
|
|
9d9da4feb9 | ||
|
|
ce858a80ed | ||
|
|
4898c83590 | ||
|
|
d8ed2eb1be | ||
|
|
00c8a5845e | ||
|
|
d8dba61b0a | ||
|
|
b8117b3931 | ||
|
|
aface2f43e | ||
|
|
9691130b83 | ||
|
|
1fbf3caa50 | ||
|
|
e3128c204e | ||
|
|
1e6b27d42a | ||
|
|
c24bd209e6 | ||
|
|
df96cc6e56 | ||
|
|
641549c9ed | ||
|
|
66e0308028 | ||
|
|
22939abb0d | ||
|
|
dfc4bff579 | ||
|
|
588223915c | ||
|
|
5702670bd3 | ||
|
|
d79760e9dd | ||
|
|
21011d00ea | ||
|
|
23cb98272c | ||
|
|
b8b2712f73 | ||
|
|
8b6a29decf | ||
|
|
5475841ca0 | ||
|
|
e8a2ad1d1b | ||
|
|
54a62ea78d | ||
|
|
bcda41b508 | ||
|
|
c0fac0f5ca | ||
|
|
0faf0dd2a1 | ||
|
|
9a698ce1e8 | ||
|
|
a7683c60c9 | ||
|
|
9412b770bf | ||
|
|
29a6473c3d | ||
|
|
7ceed1f42d | ||
|
|
959367629e | ||
|
|
aeed1f79bb | ||
|
|
278d3a0313 | ||
|
|
5af9f71d38 | ||
|
|
b6f446e909 | ||
|
|
7804a2db86 | ||
|
|
0e4d2b50b4 | ||
|
|
b594cf0d74 | ||
|
|
074fdeb212 | ||
|
|
a1355ee766 | ||
|
|
c3e1bb40f4 | ||
|
|
661410a96e | ||
|
|
e272eced94 | ||
|
|
4ab901ed43 | ||
|
|
c1abe4a550 | ||
|
|
3fc76f9c10 | ||
|
|
1e304f56cb | ||
|
|
5929826c5f | ||
|
|
9dad36b117 | ||
|
|
8b9f994cea | ||
|
|
7ecb2c0185 | ||
|
|
342c49f0bb | ||
|
|
bb220b5c3b | ||
|
|
3455f00d23 | ||
|
|
992ab7120c | ||
|
|
5215722c78 | ||
|
|
56b3203fa9 | ||
|
|
3cc4a0c6e3 | ||
|
|
556ede5960 | ||
|
|
46c610f35e | ||
|
|
18357be938 | ||
|
|
a9f369479f | ||
|
|
8c00bbc91d | ||
|
|
9af01c515f | ||
|
|
567cc304ed | ||
|
|
98a1654b47 | ||
|
|
ddbe1986ad | ||
|
|
ac19d4d19c | ||
|
|
142f16afe4 | ||
|
|
07810818cc | ||
|
|
4664a19718 | ||
|
|
46f59acdce | ||
|
|
c61189121e | ||
|
|
8c14262efc | ||
|
|
fa398766d9 | ||
|
|
026fcc66c9 | ||
|
|
7c5a3ae311 | ||
|
|
feacf7614e | ||
|
|
8609e65fc2 | ||
|
|
3ff33699c8 | ||
|
|
df72d7b20f | ||
|
|
1d7144564c | ||
|
|
aced2e4e94 | ||
|
|
9b9ac03760 | ||
|
|
c052de2bbc | ||
|
|
85d0e9797c | ||
|
|
f975319d02 | ||
|
|
b8164df349 | ||
|
|
1458d77844 | ||
|
|
052f2ac321 | ||
|
|
4a6945ac17 | ||
|
|
c9ca9737a7 | ||
|
|
2e1495fc07 | ||
|
|
55de3020d3 | ||
|
|
ff91974345 | ||
|
|
e7dc09cf9f | ||
|
|
fcf9649ef9 | ||
|
|
55e3746554 | ||
|
|
a59a147dbd | ||
|
|
355ce9f679 | ||
|
|
785e7135a7 | ||
|
|
25aeb58c87 | ||
|
|
dd73ac8892 |
@@ -2,6 +2,36 @@
|
|||||||
|
|
||||||
### Next release
|
### Next release
|
||||||
|
|
||||||
|
#### `ol.animate` now takes the shortest arc for rotation animation
|
||||||
|
|
||||||
|
Usually rotation animations should animate along the shortest arc. There are rare occasions where a spinning animation effect is desired. So if you previously had something like
|
||||||
|
```js
|
||||||
|
map.getView().animate({
|
||||||
|
rotation: 2 * Math.PI,
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
```
|
||||||
|
we recommend to split the animation into two parts and use different easing functions. The code below results in the same effect as the snippet above did with previous versions:
|
||||||
|
```js
|
||||||
|
map.getView().animate({
|
||||||
|
rotation: Math.PI,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
|
rotation: 2 * Math.PI,
|
||||||
|
easing: ol.easing.easeOut
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### v4.2.0
|
||||||
|
|
||||||
|
#### Return values of two `ol.style.RegularShape` getters have changed
|
||||||
|
|
||||||
|
To provide a more consistent behaviour the following getters now return the same value that was given to constructor:
|
||||||
|
|
||||||
|
`ol.style.RegularShape#getPoints` does not return the double amount of points anymore if a radius2 is set.
|
||||||
|
|
||||||
|
`ol.style.RegularShape#getRadius2` will return `undefined` if no radius2 is set.
|
||||||
|
|
||||||
### v4.1.0
|
### v4.1.0
|
||||||
|
|
||||||
#### Adding duplicate layers to a map throws
|
#### Adding duplicate layers to a map throws
|
||||||
|
|||||||
151
changelog/v4.2.0.md
Normal file
151
changelog/v4.2.0.md
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
# 4.2.0
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
The v4.2.0 release includes features and fixes from 87 pull requests.
|
||||||
|
|
||||||
|
#### New `movestart` event on `ol.Map`
|
||||||
|
|
||||||
|
The map now has a `movestart` event, as countarpart to the already existing `moveend` event.
|
||||||
|
|
||||||
|
#### New `moveTolerance` option in `ol.Map`
|
||||||
|
|
||||||
|
Some touch devices do not play well with OpenLayers's way of detecting clicks. To overcome this, a new `moveTolerance` option was introduced, so users can override the 1 pixel threshold above which a touch-release sequence won't be considered a click any more.
|
||||||
|
|
||||||
|
#### Support for multiple layers in `ol.format.TopoJSON`
|
||||||
|
|
||||||
|
With the new `layerName` and `layers` options, applications can extract the layer as additional attribute for vector features from `ol.format.TopoJSON`. This can especially be useful for styling vector tile layers.
|
||||||
|
|
||||||
|
#### New `tileJSON` option for `ol.source.TileJSON`
|
||||||
|
|
||||||
|
Like `ol.source.TileUTFGrid`, `ol.source.TileJSON` now also has a `tileJSON` option to configue it with inline TileJSON instead of a TileJSON URL.
|
||||||
|
|
||||||
|
#### New `ol.format.filter.during` filter
|
||||||
|
|
||||||
|
Although OpenLayers has no support for WFS v2.0, we added `ol.format.filter.during` for the `During` temporal operator.
|
||||||
|
|
||||||
|
#### Improved vector tile rendering at non-native resolutions
|
||||||
|
|
||||||
|
The vector tile renderer now uses an internal tile grid for all resolutions to cache pre-rendered tiles, even if the tile source does not have tiles for the viewed resolution. This improves rendering quality and performance.
|
||||||
|
|
||||||
|
#### New `insertVertexCondition` for `ol.interaction.Modify`
|
||||||
|
|
||||||
|
Applications can now control whether a vertex will be inserted into the modified geometry. This makes it easier to modify custom geometries.
|
||||||
|
|
||||||
|
#### New `callback` option for `ol.View#fit()`
|
||||||
|
|
||||||
|
To allow applications to perform custom actions when an animation associated with `ol.View#fit()` is completed, that method now has a new `callback` option.
|
||||||
|
|
||||||
|
#### New `ol.View#getInteracting()` getter
|
||||||
|
|
||||||
|
Like `ol.View#getAnimating()` returns `true` during a view animation, `ol.View#getInteracting()` returns `true` while users are interacting with the view.
|
||||||
|
|
||||||
|
#### New `hasZ` option for `ol.format.WFS#writeTransaction()`
|
||||||
|
|
||||||
|
When the new `hasZ` option is set to `true`, 3D coordinates will be preserved and encoded when writing a WFS transaction.
|
||||||
|
|
||||||
|
#### New `wrapX` option for `ol.source.Stamen`
|
||||||
|
|
||||||
|
Like other tile sources, `ol.source.Stamen` now also has a `wrapX` option, which allows applications to turn off wrapping the world in x direction.
|
||||||
|
|
||||||
|
#### Label support for `ol.Graticule`
|
||||||
|
|
||||||
|
The `ol.Graticule` component has several new options to add and control the output of labels. To turn on labelling, configure `ol.Graticule` with `showLabels: true`. The new options to control label formatting are `lonLabelFormatter`, `latLabelFormatter`, `lonLabelPosition` and `latLabelPosition`.
|
||||||
|
|
||||||
|
#### Return values of two `ol.style.RegularShape` getters have changed
|
||||||
|
|
||||||
|
To provide a more consistent behaviour the following getters now return the same value that was given to constructor:
|
||||||
|
|
||||||
|
`ol.style.RegularShape#getPoints` does not return the double amount of points anymore if a radius2 is set.
|
||||||
|
|
||||||
|
`ol.style.RegularShape#getRadius2` will return `undefined` if no radius2 is set.
|
||||||
|
|
||||||
|
## Detailed changes
|
||||||
|
|
||||||
|
* [#6912](https://github.com/openlayers/openlayers/pull/6912) - Use class instead of style for Translate cursor ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6858](https://github.com/openlayers/openlayers/pull/6858) - Webgl vector improvements ([@GaborFarkas](https://github.com/GaborFarkas))
|
||||||
|
* [#6890](https://github.com/openlayers/openlayers/pull/6890) - Add a movestart event ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6910](https://github.com/openlayers/openlayers/pull/6910) - Avoid duplicates in Observables list ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6902](https://github.com/openlayers/openlayers/pull/6902) - Require minimum duration for kinetic animation ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6904](https://github.com/openlayers/openlayers/pull/6904) - chore(package): update sinon to version 2.3.4 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6901](https://github.com/openlayers/openlayers/pull/6901) - Added release note for changed methods of ol.style.regularShape ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
||||||
|
* [#6886](https://github.com/openlayers/openlayers/pull/6886) - Make ol.source.Cluster extensible ([@gberaudo](https://github.com/gberaudo))
|
||||||
|
* [#6887](https://github.com/openlayers/openlayers/pull/6887) - Disable rotation for views with enableRotation: false ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6900](https://github.com/openlayers/openlayers/pull/6900) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6897](https://github.com/openlayers/openlayers/pull/6897) - ProjectionLike in proj.getPointResolution ([@probins](https://github.com/probins))
|
||||||
|
* [#6888](https://github.com/openlayers/openlayers/pull/6888) - Add note about custom functions to getPointResolution ([@probins](https://github.com/probins))
|
||||||
|
* [#6893](https://github.com/openlayers/openlayers/pull/6893) - Fix decimals options when writing features ([@tchandelle](https://github.com/tchandelle))
|
||||||
|
* [#6759](https://github.com/openlayers/openlayers/pull/6759) - Regular shape points ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
||||||
|
* [#6892](https://github.com/openlayers/openlayers/pull/6892) - Accept a ol.ProjectionLike instead of ol.proj.Projection ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6883](https://github.com/openlayers/openlayers/pull/6883) - Remove unused ol.pointer.EventSource#getMapping function ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6870](https://github.com/openlayers/openlayers/pull/6870) - Center map on proper earth, not one to the left ([@kannes](https://github.com/kannes))
|
||||||
|
* [#6872](https://github.com/openlayers/openlayers/pull/6872) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6876](https://github.com/openlayers/openlayers/pull/6876) - Only test ol.interaction.DragAndDrop if FileReader is supported ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6874](https://github.com/openlayers/openlayers/pull/6874) - Remove unused var from ol.proj ([@probins](https://github.com/probins))
|
||||||
|
* [#6875](https://github.com/openlayers/openlayers/pull/6875) - chore(package): update sinon to version 2.3.2 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6867](https://github.com/openlayers/openlayers/pull/6867) - add getArea to api ([@cs09g](https://github.com/cs09g))
|
||||||
|
* [#6863](https://github.com/openlayers/openlayers/pull/6863) - change size to optional ([@cs09g](https://github.com/cs09g))
|
||||||
|
* [#6864](https://github.com/openlayers/openlayers/pull/6864) - fix(package): update closure-util to version 1.21.0 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6834](https://github.com/openlayers/openlayers/pull/6834) - Move tolerance option ([@notnotse](https://github.com/notnotse))
|
||||||
|
* [#6856](https://github.com/openlayers/openlayers/pull/6856) - Fix creation of new URL in readSharedStyle_ and readSharedStyleMap_ ([@oterral](https://github.com/oterral))
|
||||||
|
* [#6852](https://github.com/openlayers/openlayers/pull/6852) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6851](https://github.com/openlayers/openlayers/pull/6851) - Register/unregister listeners in setActive ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6832](https://github.com/openlayers/openlayers/pull/6832) - Force state of error tiles when usInterimTilesOnError is false ([@oterral](https://github.com/oterral))
|
||||||
|
* [#6849](https://github.com/openlayers/openlayers/pull/6849) - Create URL object only when we can ([@oterral](https://github.com/oterral))
|
||||||
|
* [#6845](https://github.com/openlayers/openlayers/pull/6845) - Snap on circles ([@tchandelle](https://github.com/tchandelle))
|
||||||
|
* [#6842](https://github.com/openlayers/openlayers/pull/6842) - add condition to check if active ([@cs09g](https://github.com/cs09g))
|
||||||
|
* [#6844](https://github.com/openlayers/openlayers/pull/6844) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6841](https://github.com/openlayers/openlayers/pull/6841) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6839](https://github.com/openlayers/openlayers/pull/6839) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6838](https://github.com/openlayers/openlayers/pull/6838) - fix(package): update handlebars to version 4.0.10 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6817](https://github.com/openlayers/openlayers/pull/6817) - Multiple layers in TopoJSON vector tiles ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6833](https://github.com/openlayers/openlayers/pull/6833) - Fix geojson-vt example for line and point geometries ([@oterral](https://github.com/oterral))
|
||||||
|
* [#6829](https://github.com/openlayers/openlayers/pull/6829) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6819](https://github.com/openlayers/openlayers/pull/6819) - Adjust/fix API for working with vector tile features ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6818](https://github.com/openlayers/openlayers/pull/6818) - Add tileJSON option to ol.source.TileJSON ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6805](https://github.com/openlayers/openlayers/pull/6805) - Display country name on click select ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6813](https://github.com/openlayers/openlayers/pull/6813) - Prepend the version with a v ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#6814](https://github.com/openlayers/openlayers/pull/6814) - Re-add ol.render.Feature#getGeometry() ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6812](https://github.com/openlayers/openlayers/pull/6812) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6786](https://github.com/openlayers/openlayers/pull/6786) - Add ol.format.filter.during ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6806](https://github.com/openlayers/openlayers/pull/6806) - Add note about features with the same id ([@drnextgis](https://github.com/drnextgis))
|
||||||
|
* [#6802](https://github.com/openlayers/openlayers/pull/6802) - Remove unused setFeatures and getFormat methods ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6801](https://github.com/openlayers/openlayers/pull/6801) - Add getId method for ol.render.Feature ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6778](https://github.com/openlayers/openlayers/pull/6778) - Add a small tolerance when testing pointer event positions ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6796](https://github.com/openlayers/openlayers/pull/6796) - Re-add accidently dropped condition ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6798](https://github.com/openlayers/openlayers/pull/6798) - chore(package): update clean-css-cli to version 4.1.2 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6795](https://github.com/openlayers/openlayers/pull/6795) - Fix ol.DrawGeometryFunctionType coordinates argument type ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6797](https://github.com/openlayers/openlayers/pull/6797) - Update clean-css-cli to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6779](https://github.com/openlayers/openlayers/pull/6779) - Decouple source and rendered tile grid of vector tile sources ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6785](https://github.com/openlayers/openlayers/pull/6785) - Add insertVertexCondition to ol.interaction.Modify options ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6792](https://github.com/openlayers/openlayers/pull/6792) - Create intermediate canvas when resolutions have changed ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6790](https://github.com/openlayers/openlayers/pull/6790) - Update resemblejs to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6784](https://github.com/openlayers/openlayers/pull/6784) - chore(package): update clean-css-cli to version 4.1.0 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6556](https://github.com/openlayers/openlayers/pull/6556) - Reading kml xunits/yunits insetPixels ([@KlausBenndorf](https://github.com/KlausBenndorf))
|
||||||
|
* [#6775](https://github.com/openlayers/openlayers/pull/6775) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6774](https://github.com/openlayers/openlayers/pull/6774) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6770](https://github.com/openlayers/openlayers/pull/6770) - Enforce the "no missing requires" rule ([@tschaub](https://github.com/tschaub))
|
||||||
|
* [#6772](https://github.com/openlayers/openlayers/pull/6772) - Remove html tag from shortdesc ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6769](https://github.com/openlayers/openlayers/pull/6769) - Update handlebars to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6757](https://github.com/openlayers/openlayers/pull/6757) - Fix crashing on creation of snap-interaction, if Circle is among the features to snap to. ([@hajjimurad](https://github.com/hajjimurad))
|
||||||
|
* [#6766](https://github.com/openlayers/openlayers/pull/6766) - Update sinon to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6765](https://github.com/openlayers/openlayers/pull/6765) - Add new callback function to view.FitOptions ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6764](https://github.com/openlayers/openlayers/pull/6764) - Added View#getInteracting() to the api ([@mblinsitu](https://github.com/mblinsitu))
|
||||||
|
* [#6760](https://github.com/openlayers/openlayers/pull/6760) - Update handlebars to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6761](https://github.com/openlayers/openlayers/pull/6761) - Update async to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6755](https://github.com/openlayers/openlayers/pull/6755) - Add missing goog.require ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6751](https://github.com/openlayers/openlayers/pull/6751) - Update coveralls to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6750](https://github.com/openlayers/openlayers/pull/6750) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6741](https://github.com/openlayers/openlayers/pull/6741) - Allow user selection in overlay container ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6744](https://github.com/openlayers/openlayers/pull/6744) - Update mocha to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6737](https://github.com/openlayers/openlayers/pull/6737) - Graticule labels ([@ahocevar](https://github.com/ahocevar))
|
||||||
|
* [#6740](https://github.com/openlayers/openlayers/pull/6740) - Fix spelling ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6730](https://github.com/openlayers/openlayers/pull/6730) - Update metalsmith-layouts to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6732](https://github.com/openlayers/openlayers/pull/6732) - Use firefox < 53 in travis ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6677](https://github.com/openlayers/openlayers/pull/6677) - Add an option to writeTransaction to support 3D geometries ([@Jenselme](https://github.com/Jenselme))
|
||||||
|
* [#6524](https://github.com/openlayers/openlayers/pull/6524) - Don't append feature prefix twice in WFS requests ([@Jenselme](https://github.com/Jenselme))
|
||||||
|
* [#6727](https://github.com/openlayers/openlayers/pull/6727) - Add default value in doc for the hitTolerance option ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6724](https://github.com/openlayers/openlayers/pull/6724) - Add wrapX option to Stamen source ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6728](https://github.com/openlayers/openlayers/pull/6728) - Fix tissot examples docs ([@fredj](https://github.com/fredj))
|
||||||
|
* [#6725](https://github.com/openlayers/openlayers/pull/6725) - Update dependencies to enable Greenkeeper 🌴 ([@openlayers](https://github.com/openlayers))
|
||||||
|
* [#6711](https://github.com/openlayers/openlayers/pull/6711) - Correct path to cleancss ([@tschaub](https://github.com/tschaub))
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"opts": {
|
"opts": {
|
||||||
"recurse": true,
|
"recurse": true,
|
||||||
"template": "config/jsdoc/api/template"
|
"template": "../../config/jsdoc/api/template"
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"allowUnknownTags": true
|
"allowUnknownTags": true
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"node_modules/jsdoc/plugins/markdown",
|
"plugins/markdown",
|
||||||
"config/jsdoc/api/plugins/inheritdoc",
|
"../../config/jsdoc/api/plugins/inheritdoc",
|
||||||
"config/jsdoc/api/plugins/typedefs",
|
"../../config/jsdoc/api/plugins/typedefs",
|
||||||
"config/jsdoc/api/plugins/events",
|
"../../config/jsdoc/api/plugins/events",
|
||||||
"config/jsdoc/api/plugins/observable",
|
"../../config/jsdoc/api/plugins/observable",
|
||||||
"config/jsdoc/api/plugins/api"
|
"../../config/jsdoc/api/plugins/api"
|
||||||
],
|
],
|
||||||
"markdown": {
|
"markdown": {
|
||||||
"parser": "gfm"
|
"parser": "gfm"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ exports.handlers = {
|
|||||||
cls.observables = [];
|
cls.observables = [];
|
||||||
}
|
}
|
||||||
observable = observables[doclet.observable];
|
observable = observables[doclet.observable];
|
||||||
if (cls.observables.indexOf(observable) == -1) {
|
if (observable.type && cls.observables.indexOf(observable) == -1) {
|
||||||
cls.observables.push(observable);
|
cls.observables.push(observable);
|
||||||
}
|
}
|
||||||
if (!cls.fires) {
|
if (!cls.fires) {
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?js
|
<?js
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var propsByName = {};
|
||||||
props.forEach(function(prop) {
|
props.forEach(function(prop) {
|
||||||
if (!prop) { return; }
|
if (!prop || propsByName[prop.name]) { return; }
|
||||||
|
propsByName[prop.name] = prop;
|
||||||
var setter = prop.readonly ? 'no' : 'yes';
|
var setter = prop.readonly ? 'no' : 'yes';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"opts": {
|
"opts": {
|
||||||
"recurse": true,
|
"recurse": true,
|
||||||
"template": "config/jsdoc/info"
|
"template": "../../config/jsdoc/info"
|
||||||
},
|
},
|
||||||
"tags": {
|
"tags": {
|
||||||
"allowUnknownTags": true
|
"allowUnknownTags": true
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
"includePattern": "\\.js$"
|
"includePattern": "\\.js$"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"config/jsdoc/info/api-plugin",
|
"../../config/jsdoc/info/api-plugin",
|
||||||
"config/jsdoc/info/define-plugin",
|
"../../config/jsdoc/info/define-plugin",
|
||||||
"config/jsdoc/info/virtual-plugin"
|
"../../config/jsdoc/info/virtual-plugin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* an api tag) and boolean defines (with a define tag and a default value).
|
* an api tag) and boolean defines (with a define tag and a default value).
|
||||||
*/
|
*/
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +88,6 @@ exports.publish = function(data, opts) {
|
|||||||
types: getTypes(doc.type.names)
|
types: getTypes(doc.type.names)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var types;
|
|
||||||
var symbol = {
|
var symbol = {
|
||||||
name: doc.longname,
|
name: doc.longname,
|
||||||
kind: doc.kind,
|
kind: doc.kind,
|
||||||
@@ -169,6 +167,7 @@ exports.publish = function(data, opts) {
|
|||||||
return (symbol.name in augments || symbol.virtual);
|
return (symbol.name in augments || symbol.virtual);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
process.stdout.write(
|
process.stdout.write(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
symbols: symbols,
|
symbols: symbols,
|
||||||
@@ -177,5 +176,6 @@ exports.publish = function(data, opts) {
|
|||||||
externs: externs,
|
externs: externs,
|
||||||
base: base
|
base: base
|
||||||
}, null, 2));
|
}, null, 2));
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
11
css/ol.css
11
css/ol.css
@@ -49,6 +49,17 @@
|
|||||||
-ms-user-select: auto;
|
-ms-user-select: auto;
|
||||||
user-select: auto;
|
user-select: auto;
|
||||||
}
|
}
|
||||||
|
.ol-grabbing {
|
||||||
|
cursor: -webkit-grabbing;
|
||||||
|
cursor: -moz-grabbing;
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
.ol-grab {
|
||||||
|
cursor: move;
|
||||||
|
cursor: -webkit-grab;
|
||||||
|
cursor: -moz-grab;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
.ol-control {
|
.ol-control {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: rgba(255,255,255,0.4);
|
background-color: rgba(255,255,255,0.4);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.easing');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
@@ -73,9 +74,16 @@ onClick('rotate-right', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick('rotate-around-rome', function() {
|
onClick('rotate-around-rome', function() {
|
||||||
|
// Rotation animation takes the shortest arc, so animate in two parts
|
||||||
|
var rotation = view.getRotation();
|
||||||
view.animate({
|
view.animate({
|
||||||
rotation: view.getRotation() + 2 * Math.PI,
|
rotation: rotation + Math.PI,
|
||||||
anchor: rome
|
anchor: rome,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
|
rotation: rotation + 2 * Math.PI,
|
||||||
|
anchor: rome,
|
||||||
|
easing: ol.easing.easeOut
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,10 +111,19 @@ onClick('bounce-to-istanbul', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onClick('spin-to-rome', function() {
|
onClick('spin-to-rome', function() {
|
||||||
|
// Rotation animation takes the shortest arc, so animate in two parts
|
||||||
|
var center = view.getCenter();
|
||||||
view.animate({
|
view.animate({
|
||||||
|
center: [
|
||||||
|
center[0] + (rome[0] - center[0]) / 2,
|
||||||
|
center[1] + (rome[1] - center[1]) / 2
|
||||||
|
],
|
||||||
|
rotation: Math.PI,
|
||||||
|
easing: ol.easing.easeIn
|
||||||
|
}, {
|
||||||
center: rome,
|
center: rome,
|
||||||
rotation: 2 * Math.PI,
|
rotation: 2 * Math.PI,
|
||||||
duration: 2000
|
easing: ol.easing.easeOut
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ cloak:
|
|||||||
<select id="layer-select">
|
<select id="layer-select">
|
||||||
<option value="Aerial">Aerial</option>
|
<option value="Aerial">Aerial</option>
|
||||||
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
<option value="AerialWithLabels" selected>Aerial with labels</option>
|
||||||
<option value="Road">Road</option>
|
<option value="Road">Road (static)</option>
|
||||||
|
<option value="RoadOnDemand">Road (dynamic)</option>
|
||||||
<option value="collinsBart">Collins Bart</option>
|
<option value="collinsBart">Collins Bart</option>
|
||||||
<option value="ordnanceSurvey">Ordnance Survey</option>
|
<option value="ordnanceSurvey">Ordnance Survey</option>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ goog.require('ol.source.BingMaps');
|
|||||||
|
|
||||||
var styles = [
|
var styles = [
|
||||||
'Road',
|
'Road',
|
||||||
|
'RoadOnDemand',
|
||||||
'Aerial',
|
'Aerial',
|
||||||
'AerialWithLabels',
|
'AerialWithLabels',
|
||||||
'collinsBart',
|
'collinsBart',
|
||||||
|
|||||||
@@ -45,29 +45,29 @@ var dragBox = new ol.interaction.DragBox({
|
|||||||
|
|
||||||
map.addInteraction(dragBox);
|
map.addInteraction(dragBox);
|
||||||
|
|
||||||
var infoBox = document.getElementById('info');
|
|
||||||
|
|
||||||
dragBox.on('boxend', function() {
|
dragBox.on('boxend', function() {
|
||||||
// features that intersect the box are added to the collection of
|
// features that intersect the box are added to the collection of
|
||||||
// selected features, and their names are displayed in the "info"
|
// selected features
|
||||||
// div
|
|
||||||
var info = [];
|
|
||||||
var extent = dragBox.getGeometry().getExtent();
|
var extent = dragBox.getGeometry().getExtent();
|
||||||
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
|
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
|
||||||
selectedFeatures.push(feature);
|
selectedFeatures.push(feature);
|
||||||
info.push(feature.get('name'));
|
|
||||||
});
|
});
|
||||||
if (info.length > 0) {
|
|
||||||
infoBox.innerHTML = info.join(', ');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// clear selection when drawing a new box and when clicking on the map
|
// clear selection when drawing a new box and when clicking on the map
|
||||||
dragBox.on('boxstart', function() {
|
dragBox.on('boxstart', function() {
|
||||||
selectedFeatures.clear();
|
selectedFeatures.clear();
|
||||||
infoBox.innerHTML = ' ';
|
|
||||||
});
|
});
|
||||||
map.on('click', function() {
|
|
||||||
selectedFeatures.clear();
|
var infoBox = document.getElementById('info');
|
||||||
infoBox.innerHTML = ' ';
|
|
||||||
|
selectedFeatures.on(['add', 'remove'], function() {
|
||||||
|
var names = selectedFeatures.getArray().map(function(feature) {
|
||||||
|
return feature.get('name');
|
||||||
|
});
|
||||||
|
if (names.length > 0) {
|
||||||
|
infoBox.innerHTML = names.join(', ');
|
||||||
|
} else {
|
||||||
|
infoBox.innerHTML = 'No countries selected';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,18 +17,30 @@ var replacer = function(key, value) {
|
|||||||
var geometry = value.geometry;
|
var geometry = value.geometry;
|
||||||
|
|
||||||
if (rawType === 1) {
|
if (rawType === 1) {
|
||||||
type = geometry.length === 1 ? 'Point' : 'MultiPoint';
|
type = 'MultiPoint';
|
||||||
|
if (geometry.length == 1) {
|
||||||
|
type = 'Point';
|
||||||
|
geometry = geometry[0];
|
||||||
|
}
|
||||||
} else if (rawType === 2) {
|
} else if (rawType === 2) {
|
||||||
type = geometry.length === 1 ? 'LineString' : 'MultiLineString';
|
type = 'MultiLineString';
|
||||||
|
if (geometry.length == 1) {
|
||||||
|
type = 'LineString';
|
||||||
|
geometry = geometry[0];
|
||||||
|
}
|
||||||
} else if (rawType === 3) {
|
} else if (rawType === 3) {
|
||||||
type = geometry.length === 1 ? 'Polygon' : 'MultiPolygon';
|
type = 'Polygon';
|
||||||
|
if (geometry.length > 1) {
|
||||||
|
type = 'MultiPolygon';
|
||||||
|
geometry = [geometry];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'type': 'Feature',
|
'type': 'Feature',
|
||||||
'geometry': {
|
'geometry': {
|
||||||
'type': type,
|
'type': type,
|
||||||
'coordinates': geometry.length == 1 ? geometry : [geometry]
|
'coordinates': geometry
|
||||||
},
|
},
|
||||||
'properties': value.tags
|
'properties': value.tags
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ layout: example.html
|
|||||||
title: Advanced Mapbox Vector Tiles
|
title: Advanced Mapbox Vector Tiles
|
||||||
shortdesc: Example of a Mapbox vector tiles map with custom tile grid.
|
shortdesc: Example of a Mapbox vector tiles map with custom tile grid.
|
||||||
docs: >
|
docs: >
|
||||||
A vector tiles map which reuses the same tiles for subsequent zoom levels to save bandwidth on mobile devices. **Note**: No map will be visible when the access token has expired.
|
A vector tiles map which reuses the same source tiles for subsequent zoom levels to save bandwidth on mobile devices. **Note**: No map will be visible when the access token has expired.
|
||||||
tags: "mapbox, vector, tiles, mobile"
|
tags: "mapbox, vector, tiles, mobile"
|
||||||
resources:
|
resources:
|
||||||
- resources/mapbox-streets-v6-style.js
|
- resources/mapbox-streets-v6-style.js
|
||||||
|
|||||||
@@ -15,25 +15,16 @@ goog.require('ol.tilegrid.TileGrid');
|
|||||||
|
|
||||||
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
|
||||||
|
|
||||||
// For how many zoom levels do we want to use the same vector tiles?
|
// Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
||||||
// 1 means "use tiles from all zoom levels". 2 means "use the same tiles for 2
|
|
||||||
// subsequent zoom levels".
|
|
||||||
var reuseZoomLevels = 2;
|
|
||||||
|
|
||||||
// Offset of loaded tiles from web mercator zoom level 0.
|
|
||||||
// 0 means "At map zoom level 0, use tiles from zoom level 0". 1 means "At map
|
|
||||||
// zoom level 0, use tiles from zoom level 1".
|
|
||||||
var zoomOffset = 1;
|
|
||||||
|
|
||||||
// Calculation of tile urls
|
|
||||||
var resolutions = [];
|
var resolutions = [];
|
||||||
for (var z = zoomOffset / reuseZoomLevels; z <= 22 / reuseZoomLevels; ++z) {
|
for (var i = 0; i <= 7; ++i) {
|
||||||
resolutions.push(156543.03392804097 / Math.pow(2, z * reuseZoomLevels));
|
resolutions.push(156543.03392804097 / Math.pow(2, i * 2));
|
||||||
}
|
}
|
||||||
|
// Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
||||||
function tileUrlFunction(tileCoord) {
|
function tileUrlFunction(tileCoord) {
|
||||||
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
||||||
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
|
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
|
||||||
.replace('{z}', String(tileCoord[0] * reuseZoomLevels + zoomOffset))
|
.replace('{z}', String(tileCoord[0] * 2 - 1))
|
||||||
.replace('{x}', String(tileCoord[1]))
|
.replace('{x}', String(tileCoord[1]))
|
||||||
.replace('{y}', String(-tileCoord[2] - 1))
|
.replace('{y}', String(-tileCoord[2] - 1))
|
||||||
.replace('{a-d}', 'abcd'.substr(
|
.replace('{a-d}', 'abcd'.substr(
|
||||||
@@ -43,8 +34,6 @@ function tileUrlFunction(tileCoord) {
|
|||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.VectorTile({
|
new ol.layer.VectorTile({
|
||||||
renderMode: 'vector',
|
|
||||||
preload: Infinity,
|
|
||||||
source: new ol.source.VectorTile({
|
source: new ol.source.VectorTile({
|
||||||
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
|
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
|
||||||
'© <a href="https://www.openstreetmap.org/copyright">' +
|
'© <a href="https://www.openstreetmap.org/copyright">' +
|
||||||
@@ -52,9 +41,10 @@ var map = new ol.Map({
|
|||||||
format: new ol.format.MVT(),
|
format: new ol.format.MVT(),
|
||||||
tileGrid: new ol.tilegrid.TileGrid({
|
tileGrid: new ol.tilegrid.TileGrid({
|
||||||
extent: ol.proj.get('EPSG:3857').getExtent(),
|
extent: ol.proj.get('EPSG:3857').getExtent(),
|
||||||
resolutions: resolutions
|
resolutions: resolutions,
|
||||||
|
tileSize: 512
|
||||||
}),
|
}),
|
||||||
tilePixelRatio: 16,
|
tilePixelRatio: 8,
|
||||||
tileUrlFunction: tileUrlFunction
|
tileUrlFunction: tileUrlFunction
|
||||||
}),
|
}),
|
||||||
style: createMapboxStreetsV6Style()
|
style: createMapboxStreetsV6Style()
|
||||||
|
|||||||
@@ -222,7 +222,13 @@ var select = new ol.interaction.Select({
|
|||||||
|
|
||||||
var modify = new ol.interaction.Modify({
|
var modify = new ol.interaction.Modify({
|
||||||
features: select.getFeatures(),
|
features: select.getFeatures(),
|
||||||
style: overlayStyle
|
style: overlayStyle,
|
||||||
|
insertVertexCondition: function() {
|
||||||
|
// prevent new vertices to be added to the polygons
|
||||||
|
return !this.features_.getArray().every(function(feature) {
|
||||||
|
return feature.getGeometry().getType().match(/Polygon/);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ goog.require('ol.control');
|
|||||||
goog.require('ol.control.MousePosition');
|
goog.require('ol.control.MousePosition');
|
||||||
goog.require('ol.coordinate');
|
goog.require('ol.coordinate');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
var mousePositionControl = new ol.control.MousePosition({
|
var mousePositionControl = new ol.control.MousePosition({
|
||||||
@@ -37,7 +36,7 @@ var map = new ol.Map({
|
|||||||
|
|
||||||
var projectionSelect = document.getElementById('projection');
|
var projectionSelect = document.getElementById('projection');
|
||||||
projectionSelect.addEventListener('change', function(event) {
|
projectionSelect.addEventListener('change', function(event) {
|
||||||
mousePositionControl.setProjection(ol.proj.get(event.target.value));
|
mousePositionControl.setProjection(event.target.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
var precisionInput = document.getElementById('precision');
|
var precisionInput = document.getElementById('precision');
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ layout: example.html
|
|||||||
title: OSM Vector Tiles
|
title: OSM Vector Tiles
|
||||||
shortdesc: Using OpenStreetMap vector tiles.
|
shortdesc: Using OpenStreetMap vector tiles.
|
||||||
docs: >
|
docs: >
|
||||||
A simple vector tiles map with Mapzen vector tiles. **Note**: TopoJSON vector tiles are not optimized for rendering - they might clip geometries exactly at the tile boundary instead of adding a buffer, and use geographic coordinates instead of tile relative pixel coordinates in view projection.
|
A simple vector tiles map with Mapzen vector tiles. This example uses the TopoJSON format's `layerName` option to determine the layer ("water", "roads", "buildings") for styling. **Note**: [`ol.format.MVT`](../apidoc/ol.format.MVT.html) is an even more efficient format for vector tiles.
|
||||||
tags: "vector, tiles, osm, mapzen"
|
tags: "vector, tiles, osm, mapzen"
|
||||||
cloak:
|
cloak:
|
||||||
vector-tiles-5eJz6JX: Your Mapzen API key from https://mapzen.com/developers
|
vector-tiles-5eJz6JX: Your Mapzen API key from https://mapzen.com/developers
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
goog.require('ol.Attribution');
|
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
goog.require('ol.format.TopoJSON');
|
goog.require('ol.format.TopoJSON');
|
||||||
@@ -13,11 +12,6 @@ goog.require('ol.tilegrid');
|
|||||||
|
|
||||||
var key = 'vector-tiles-5eJz6JX';
|
var key = 'vector-tiles-5eJz6JX';
|
||||||
|
|
||||||
var attribution = [new ol.Attribution({
|
|
||||||
html: '© OpenStreetMap contributors, Who’s On First, Natural Earth, and openstreetmapdata.com'
|
|
||||||
})];
|
|
||||||
var format = new ol.format.TopoJSON();
|
|
||||||
var tileGrid = ol.tilegrid.createXYZ({maxZoom: 19});
|
|
||||||
var roadStyleCache = {};
|
var roadStyleCache = {};
|
||||||
var roadColor = {
|
var roadColor = {
|
||||||
'major_road': '#776',
|
'major_road': '#776',
|
||||||
@@ -34,30 +28,12 @@ var buildingStyle = new ol.style.Style({
|
|||||||
width: 1
|
width: 1
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
var waterStyle = new ol.style.Style({
|
||||||
var map = new ol.Map({
|
|
||||||
layers: [
|
|
||||||
new ol.layer.VectorTile({
|
|
||||||
source: new ol.source.VectorTile({
|
|
||||||
attributions: attribution,
|
|
||||||
format: format,
|
|
||||||
tileGrid: tileGrid,
|
|
||||||
url: 'https://tile.mapzen.com/mapzen/vector/v1/water/{z}/{x}/{y}.topojson?api_key=' + key
|
|
||||||
}),
|
|
||||||
style: new ol.style.Style({
|
|
||||||
fill: new ol.style.Fill({
|
fill: new ol.style.Fill({
|
||||||
color: '#9db9e8'
|
color: '#9db9e8'
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
}),
|
var roadStyle = function(feature) {
|
||||||
new ol.layer.VectorTile({
|
|
||||||
source: new ol.source.VectorTile({
|
|
||||||
attributions: attribution,
|
|
||||||
format: format,
|
|
||||||
tileGrid: tileGrid,
|
|
||||||
url: 'https://tile.mapzen.com/mapzen/vector/v1/roads/{z}/{x}/{y}.topojson?api_key=' + key
|
|
||||||
}),
|
|
||||||
style: function(feature) {
|
|
||||||
var kind = feature.get('kind');
|
var kind = feature.get('kind');
|
||||||
var railway = feature.get('railway');
|
var railway = feature.get('railway');
|
||||||
var sort_key = feature.get('sort_key');
|
var sort_key = feature.get('sort_key');
|
||||||
@@ -82,17 +58,28 @@ var map = new ol.Map({
|
|||||||
roadStyleCache[styleKey] = style;
|
roadStyleCache[styleKey] = style;
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
}
|
};
|
||||||
}),
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: [
|
||||||
new ol.layer.VectorTile({
|
new ol.layer.VectorTile({
|
||||||
source: new ol.source.VectorTile({
|
source: new ol.source.VectorTile({
|
||||||
attributions: attribution,
|
attributions: '© OpenStreetMap contributors, Who’s On First, ' +
|
||||||
format: format,
|
'Natural Earth, and openstreetmapdata.com',
|
||||||
tileGrid: tileGrid,
|
format: new ol.format.TopoJSON({
|
||||||
url: 'https://tile.mapzen.com/mapzen/vector/v1/buildings/{z}/{x}/{y}.topojson?api_key=' + key
|
layerName: 'layer',
|
||||||
|
layers: ['water', 'roads', 'buildings']
|
||||||
}),
|
}),
|
||||||
style: function(f, resolution) {
|
tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
|
||||||
return (resolution < 10) ? buildingStyle : null;
|
url: 'https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key
|
||||||
|
}),
|
||||||
|
style: function(feature, resolution) {
|
||||||
|
switch (feature.get('layer')) {
|
||||||
|
case 'water': return waterStyle;
|
||||||
|
case 'roads': return roadStyle(feature);
|
||||||
|
case 'buildings': return (resolution < 10) ? buildingStyle : null;
|
||||||
|
default: return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ var map = new ol.Map({
|
|||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
view: new ol.View({
|
view: new ol.View({
|
||||||
center: [-25860000, 4130000],
|
center: [14200000, 4130000],
|
||||||
rotation: Math.PI / 6,
|
rotation: Math.PI / 6,
|
||||||
zoom: 10
|
zoom: 10
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ tags: "draw, edit, modify, vector, snap"
|
|||||||
<option value="Point">Point</option>
|
<option value="Point">Point</option>
|
||||||
<option value="LineString">LineString</option>
|
<option value="LineString">LineString</option>
|
||||||
<option value="Polygon">Polygon</option>
|
<option value="Polygon">Polygon</option>
|
||||||
|
<option value="Circle">Circle</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ var Draw = {
|
|||||||
this.LineString.setActive(false);
|
this.LineString.setActive(false);
|
||||||
map.addInteraction(this.Polygon);
|
map.addInteraction(this.Polygon);
|
||||||
this.Polygon.setActive(false);
|
this.Polygon.setActive(false);
|
||||||
|
map.addInteraction(this.Circle);
|
||||||
|
this.Circle.setActive(false);
|
||||||
},
|
},
|
||||||
Point: new ol.interaction.Draw({
|
Point: new ol.interaction.Draw({
|
||||||
source: vector.getSource(),
|
source: vector.getSource(),
|
||||||
@@ -94,6 +96,10 @@ var Draw = {
|
|||||||
source: vector.getSource(),
|
source: vector.getSource(),
|
||||||
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
|
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
|
||||||
}),
|
}),
|
||||||
|
Circle: new ol.interaction.Draw({
|
||||||
|
source: vector.getSource(),
|
||||||
|
type: /** @type {ol.geom.GeometryType} */ ('Circle')
|
||||||
|
}),
|
||||||
getActive: function() {
|
getActive: function() {
|
||||||
return this.activeType ? this[this.activeType].getActive() : false;
|
return this.activeType ? this[this.activeType].getActive() : false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,13 +29,14 @@ var style = new ol.style.Style({
|
|||||||
var vector = new ol.layer.Vector({
|
var vector = new ol.layer.Vector({
|
||||||
source: new ol.source.Vector({
|
source: new ol.source.Vector({
|
||||||
url: 'data/topojson/world-110m.json',
|
url: 'data/topojson/world-110m.json',
|
||||||
format: new ol.format.TopoJSON(),
|
format: new ol.format.TopoJSON({
|
||||||
|
// don't want to render the full world polygon (stored as 'land' layer),
|
||||||
|
// which repeats all countries
|
||||||
|
layers: ['countries']
|
||||||
|
}),
|
||||||
overlaps: false
|
overlaps: false
|
||||||
}),
|
}),
|
||||||
style: function(feature) {
|
style: style
|
||||||
// don't want to render the full world polygon, which repeats all countries
|
|
||||||
return feature.getId() !== undefined ? style : null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var map = new ol.Map({
|
var map = new ol.Map({
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ olx.interaction.InteractionOptions.prototype.handleEvent;
|
|||||||
* loadTilesWhileAnimating: (boolean|undefined),
|
* loadTilesWhileAnimating: (boolean|undefined),
|
||||||
* loadTilesWhileInteracting: (boolean|undefined),
|
* loadTilesWhileInteracting: (boolean|undefined),
|
||||||
* logo: (boolean|string|olx.LogoOptions|Element|undefined),
|
* logo: (boolean|string|olx.LogoOptions|Element|undefined),
|
||||||
|
* moveTolerance: (number|undefined),
|
||||||
* overlays: (ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined),
|
* overlays: (ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined),
|
||||||
* renderer: (ol.renderer.Type|Array.<ol.renderer.Type>|undefined),
|
* renderer: (ol.renderer.Type|Array.<ol.renderer.Type>|undefined),
|
||||||
* target: (Element|string|undefined),
|
* target: (Element|string|undefined),
|
||||||
@@ -385,6 +386,17 @@ olx.MapOptions.prototype.loadTilesWhileInteracting;
|
|||||||
olx.MapOptions.prototype.logo;
|
olx.MapOptions.prototype.logo;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum distance in pixels the cursor must move to be detected
|
||||||
|
* as a map move event instead of a click. Increasing this value can make it
|
||||||
|
* easier to click on the map.
|
||||||
|
* Default is `1`.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.MapOptions.prototype.moveTolerance;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overlays initially added to the map. By default, no overlays are added.
|
* Overlays initially added to the map. By default, no overlays are added.
|
||||||
* @type {ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined}
|
* @type {ol.Collection.<ol.Overlay>|Array.<ol.Overlay>|undefined}
|
||||||
@@ -668,7 +680,8 @@ olx.ProjectionOptions.prototype.worldExtent;
|
|||||||
/**
|
/**
|
||||||
* Function to determine resolution at a point. The function is called with a
|
* Function to determine resolution at a point. The function is called with a
|
||||||
* `{number}` view resolution and an `{ol.Coordinate}` as arguments, and returns
|
* `{number}` view resolution and an `{ol.Coordinate}` as arguments, and returns
|
||||||
* the `{number}` resolution at the passed coordinate.
|
* the `{number}` resolution at the passed coordinate. If this is `undefined`,
|
||||||
|
* the default {@link ol.proj#getPointResolution} function will be used.
|
||||||
* @type {(function(number, ol.Coordinate):number|undefined)}
|
* @type {(function(number, ol.Coordinate):number|undefined)}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -1983,7 +1996,7 @@ olx.format.MVTOptions;
|
|||||||
* which is optimized for rendering and hit detection.
|
* which is optimized for rendering and hit detection.
|
||||||
* @type {undefined|function((ol.geom.Geometry|Object.<string,*>)=)|
|
* @type {undefined|function((ol.geom.Geometry|Object.<string,*>)=)|
|
||||||
* function(ol.geom.GeometryType,Array.<number>,
|
* function(ol.geom.GeometryType,Array.<number>,
|
||||||
* (Array.<number>|Array.<Array.<number>>),Object.<string, *>)}
|
* (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.format.MVTOptions.prototype.featureClass;
|
olx.format.MVTOptions.prototype.featureClass;
|
||||||
@@ -2040,7 +2053,11 @@ olx.format.PolylineOptions.prototype.geometryLayout;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{defaultDataProjection: ol.ProjectionLike}}
|
* @typedef {{
|
||||||
|
* defaultDataProjection: ol.ProjectionLike,
|
||||||
|
* layerName: (string|undefined),
|
||||||
|
* layers: (Array.<string>|undefined)
|
||||||
|
* }}
|
||||||
*/
|
*/
|
||||||
olx.format.TopoJSONOptions;
|
olx.format.TopoJSONOptions;
|
||||||
|
|
||||||
@@ -2053,6 +2070,38 @@ olx.format.TopoJSONOptions;
|
|||||||
olx.format.TopoJSONOptions.prototype.defaultDataProjection;
|
olx.format.TopoJSONOptions.prototype.defaultDataProjection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the TopoJSON topology `objects`'s children as feature
|
||||||
|
* property with the specified name. This means that when set to `'layer'`, a
|
||||||
|
* topology like
|
||||||
|
* ```
|
||||||
|
* {
|
||||||
|
* "type": "Topology",
|
||||||
|
* "objects": {
|
||||||
|
* "example": {
|
||||||
|
* "type": "GeometryCollection",
|
||||||
|
* "geometries": []
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* will result in features that have a property `'layer'` set to `'example'`.
|
||||||
|
* When not set, no property will be added to features.
|
||||||
|
* @type {string|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.format.TopoJSONOptions.prototype.layerName;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Names of the TopoJSON topology's `objects`'s children to read features from.
|
||||||
|
* If not provided, features will be read from all children.
|
||||||
|
* @type {Array.<string>|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.format.TopoJSONOptions.prototype.layers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{altitudeMode: (ol.format.IGCZ|undefined)}}
|
* @typedef {{altitudeMode: (ol.format.IGCZ|undefined)}}
|
||||||
*/
|
*/
|
||||||
@@ -3164,12 +3213,15 @@ olx.interaction.KeyboardZoomOptions.prototype.delta;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{condition: (ol.EventsConditionType|undefined),
|
* @typedef {{
|
||||||
|
* condition: (ol.EventsConditionType|undefined),
|
||||||
* deleteCondition: (ol.EventsConditionType|undefined),
|
* deleteCondition: (ol.EventsConditionType|undefined),
|
||||||
|
* insertVertexCondition: (ol.EventsConditionType|undefined),
|
||||||
* pixelTolerance: (number|undefined),
|
* pixelTolerance: (number|undefined),
|
||||||
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
|
||||||
* features: ol.Collection.<ol.Feature>,
|
* features: ol.Collection.<ol.Feature>,
|
||||||
* wrapX: (boolean|undefined)}}
|
* wrapX: (boolean|undefined)
|
||||||
|
* }}
|
||||||
*/
|
*/
|
||||||
olx.interaction.ModifyOptions;
|
olx.interaction.ModifyOptions;
|
||||||
|
|
||||||
@@ -3196,6 +3248,16 @@ olx.interaction.ModifyOptions.prototype.condition;
|
|||||||
olx.interaction.ModifyOptions.prototype.deleteCondition;
|
olx.interaction.ModifyOptions.prototype.deleteCondition;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function that takes an {@link ol.MapBrowserEvent} and returns a boolean
|
||||||
|
* to indicate whether a new vertex can be added to the sketch features.
|
||||||
|
* Default is {@link ol.events.condition.always}
|
||||||
|
* @type {ol.EventsConditionType|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.interaction.ModifyOptions.prototype.insertVertexCondition;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pixel tolerance for considering the pointer close enough to a segment or
|
* Pixel tolerance for considering the pointer close enough to a segment or
|
||||||
* vertex for editing. Default is `10`.
|
* vertex for editing. Default is `10`.
|
||||||
@@ -4864,7 +4926,7 @@ olx.source.VectorTileOptions.prototype.state;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to instantiate image tiles. Default is {@link ol.VectorTile}.
|
* Class used to instantiate vector tiles. Default is {@link ol.VectorTile}.
|
||||||
* @type {function(new: ol.VectorTile, ol.TileCoord,
|
* @type {function(new: ol.VectorTile, ol.TileCoord,
|
||||||
* ol.TileState, string, ol.format.Feature,
|
* ol.TileState, string, ol.format.Feature,
|
||||||
* ol.TileLoadFunctionType)|undefined}
|
* ol.TileLoadFunctionType)|undefined}
|
||||||
@@ -5991,8 +6053,9 @@ olx.source.TileArcGISRestOptions.prototype.urls;
|
|||||||
* crossOrigin: (null|string|undefined),
|
* crossOrigin: (null|string|undefined),
|
||||||
* jsonp: (boolean|undefined),
|
* jsonp: (boolean|undefined),
|
||||||
* reprojectionErrorThreshold: (number|undefined),
|
* reprojectionErrorThreshold: (number|undefined),
|
||||||
|
* tileJSON: (TileJSON|undefined),
|
||||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||||
* url: string,
|
* url: (string|undefined),
|
||||||
* wrapX: (boolean|undefined)}}
|
* wrapX: (boolean|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.source.TileJSONOptions;
|
olx.source.TileJSONOptions;
|
||||||
@@ -6046,6 +6109,15 @@ olx.source.TileJSONOptions.prototype.jsonp;
|
|||||||
olx.source.TileJSONOptions.prototype.reprojectionErrorThreshold;
|
olx.source.TileJSONOptions.prototype.reprojectionErrorThreshold;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TileJSON configuration for this source. If not provided, `url` must be
|
||||||
|
* configured.
|
||||||
|
* @type {TileJSON|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.source.TileJSONOptions.prototype.tileJSON;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional function to load a tile given a URL. The default is
|
* Optional function to load a tile given a URL. The default is
|
||||||
* ```js
|
* ```js
|
||||||
@@ -6060,8 +6132,8 @@ olx.source.TileJSONOptions.prototype.tileLoadFunction;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL to the TileJSON file.
|
* URL to the TileJSON file. If not provided, `tileJSON` must be configured.
|
||||||
* @type {string}
|
* @type {string|undefined}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.source.TileJSONOptions.prototype.url;
|
olx.source.TileJSONOptions.prototype.url;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
|||||||
44
package.json
44
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openlayers",
|
"name": "openlayers",
|
||||||
"version": "4.1.2-beta.1",
|
"version": "4.3.0-beta.2",
|
||||||
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
"description": "Build tools and sources for developing OpenLayers based mapping applications",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"map",
|
"map",
|
||||||
@@ -31,13 +31,13 @@
|
|||||||
"css/ol.css"
|
"css/ol.css"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "2.4.0",
|
"async": "2.5.0",
|
||||||
"closure-util": "1.20.0",
|
"closure-util": "1.22.0",
|
||||||
"derequire": "2.0.6",
|
"derequire": "2.0.6",
|
||||||
"fs-extra": "3.0.1",
|
"fs-extra": "4.0.0",
|
||||||
"glob": "7.1.1",
|
"glob": "7.1.1",
|
||||||
"handlebars": "4.0.8",
|
"handlebars": "4.0.10",
|
||||||
"jsdoc": "3.4.3",
|
"jsdoc": "3.5.3",
|
||||||
"marked": "0.3.6",
|
"marked": "0.3.6",
|
||||||
"metalsmith": "2.3.0",
|
"metalsmith": "2.3.0",
|
||||||
"metalsmith-layouts": "1.8.1",
|
"metalsmith-layouts": "1.8.1",
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
"pbf": "3.0.5",
|
"pbf": "3.0.5",
|
||||||
"pixelworks": "1.1.0",
|
"pixelworks": "1.1.0",
|
||||||
"rbush": "2.0.1",
|
"rbush": "2.0.1",
|
||||||
"rollup": "^0.41.6",
|
"rollup": "^0.45.0",
|
||||||
"rollup-plugin-cleanup": "^1.0.0",
|
"rollup-plugin-cleanup": "^1.0.0",
|
||||||
"rollup-plugin-commonjs": "^8.0.2",
|
"rollup-plugin-commonjs": "^8.0.2",
|
||||||
"rollup-plugin-node-resolve": "^3.0.0",
|
"rollup-plugin-node-resolve": "^3.0.0",
|
||||||
@@ -54,10 +54,10 @@
|
|||||||
"walk": "2.3.9"
|
"walk": "2.3.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"clean-css-cli": "4.1.0",
|
"clean-css-cli": "4.1.6",
|
||||||
"coveralls": "2.13.1",
|
"coveralls": "2.13.1",
|
||||||
"debounce": "^1.0.0",
|
"debounce": "^1.0.0",
|
||||||
"eslint": "3.19.0",
|
"eslint": "4.2.0",
|
||||||
"eslint-config-openlayers": "7.0.0",
|
"eslint-config-openlayers": "7.0.0",
|
||||||
"eslint-plugin-openlayers-internal": "^3.1.0",
|
"eslint-plugin-openlayers-internal": "^3.1.0",
|
||||||
"expect.js": "0.3.1",
|
"expect.js": "0.3.1",
|
||||||
@@ -65,14 +65,14 @@
|
|||||||
"istanbul": "0.4.5",
|
"istanbul": "0.4.5",
|
||||||
"jquery": "3.2.1",
|
"jquery": "3.2.1",
|
||||||
"jscodeshift": "^0.3.30",
|
"jscodeshift": "^0.3.30",
|
||||||
"mocha": "3.3.0",
|
"mocha": "3.4.2",
|
||||||
"mocha-phantomjs-core": "^2.1.0",
|
"mocha-phantomjs-core": "^2.1.0",
|
||||||
"mustache": "2.3.0",
|
"mustache": "2.3.0",
|
||||||
"phantomjs-prebuilt": "2.1.14",
|
"phantomjs-prebuilt": "2.1.14",
|
||||||
"proj4": "2.4.3",
|
"proj4": "2.4.3",
|
||||||
"resemblejs": "2.2.4",
|
"resemblejs": "2.2.4",
|
||||||
"serve-files": "1.0.1",
|
"serve-files": "1.0.1",
|
||||||
"sinon": "2.2.0",
|
"sinon": "2.3.8",
|
||||||
"slimerjs": "0.10.3"
|
"slimerjs": "0.10.3"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
@@ -100,7 +100,27 @@
|
|||||||
"openlayers-internal/one-provide": 2,
|
"openlayers-internal/one-provide": 2,
|
||||||
"openlayers-internal/requires-first": 2,
|
"openlayers-internal/requires-first": 2,
|
||||||
"openlayers-internal/valid-provide": 2,
|
"openlayers-internal/valid-provide": 2,
|
||||||
"openlayers-internal/valid-requires": 2
|
"openlayers-internal/valid-requires": 2,
|
||||||
|
"indent": [
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"VariableDeclarator": 2,
|
||||||
|
"SwitchCase": 1,
|
||||||
|
"MemberExpression": 2,
|
||||||
|
"FunctionDeclaration": {
|
||||||
|
"parameters": 2,
|
||||||
|
"body": 1
|
||||||
|
},
|
||||||
|
"FunctionExpression": {
|
||||||
|
"parameters": 2,
|
||||||
|
"body": 1
|
||||||
|
},
|
||||||
|
"CallExpression": {
|
||||||
|
"arguments": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ext": [
|
"ext": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ol",
|
"name": "ol",
|
||||||
"version": "4.1.1",
|
"version": "4.3.0-beta.2",
|
||||||
"description": "OpenLayers as ES2015 modules",
|
"description": "OpenLayers as ES2015 modules",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "index.js",
|
"module": "index.js",
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
goog.provide('ol.Constraints');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {ol.CenterConstraintType} centerConstraint Center constraint.
|
|
||||||
* @param {ol.ResolutionConstraintType} resolutionConstraint
|
|
||||||
* Resolution constraint.
|
|
||||||
* @param {ol.RotationConstraintType} rotationConstraint
|
|
||||||
* Rotation constraint.
|
|
||||||
*/
|
|
||||||
ol.Constraints = function(centerConstraint, resolutionConstraint, rotationConstraint) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.CenterConstraintType}
|
|
||||||
*/
|
|
||||||
this.center = centerConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.ResolutionConstraintType}
|
|
||||||
*/
|
|
||||||
this.resolution = resolutionConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.RotationConstraintType}
|
|
||||||
*/
|
|
||||||
this.rotation = rotationConstraint;
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -47,7 +47,7 @@ ol.control.MousePosition = function(opt_options) {
|
|||||||
this.setCoordinateFormat(options.coordinateFormat);
|
this.setCoordinateFormat(options.coordinateFormat);
|
||||||
}
|
}
|
||||||
if (options.projection) {
|
if (options.projection) {
|
||||||
this.setProjection(ol.proj.get(options.projection));
|
this.setProjection(options.projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,13 +192,13 @@ ol.control.MousePosition.prototype.setCoordinateFormat = function(format) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the projection that is used to report the mouse position.
|
* Set the projection that is used to report the mouse position.
|
||||||
* @param {ol.proj.Projection} projection The projection to report mouse
|
* @param {ol.ProjectionLike} projection The projection to report mouse
|
||||||
* position in.
|
* position in.
|
||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.setProjection = function(projection) {
|
ol.control.MousePosition.prototype.setProjection = function(projection) {
|
||||||
this.set(ol.control.MousePosition.Property_.PROJECTION, projection);
|
this.set(ol.control.MousePosition.Property_.PROJECTION, ol.proj.get(projection));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,37 @@ ol.coordinate.add = function(coordinate, delta) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the point closest to the passed coordinate on the passed circle.
|
||||||
|
*
|
||||||
|
* @param {ol.Coordinate} coordinate The coordinate.
|
||||||
|
* @param {ol.geom.Circle} circle The circle.
|
||||||
|
* @return {ol.Coordinate} Closest point on the circumference
|
||||||
|
*/
|
||||||
|
ol.coordinate.closestOnCircle = function(coordinate, circle) {
|
||||||
|
var r = circle.getRadius();
|
||||||
|
var center = circle.getCenter();
|
||||||
|
var x0 = center[0];
|
||||||
|
var y0 = center[1];
|
||||||
|
var x1 = coordinate[0];
|
||||||
|
var y1 = coordinate[1];
|
||||||
|
|
||||||
|
var dx = x1 - x0;
|
||||||
|
var dy = y1 - y0;
|
||||||
|
if (dx === 0 && dy === 0) {
|
||||||
|
dx = 1;
|
||||||
|
}
|
||||||
|
var d = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
|
var x, y;
|
||||||
|
|
||||||
|
x = x0 + r * dx / d;
|
||||||
|
y = y0 + r * dy / d;
|
||||||
|
|
||||||
|
return [x, y];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the point closest to the passed coordinate on the passed segment.
|
* Calculates the point closest to the passed coordinate on the passed segment.
|
||||||
* This is the foot of the perpendicular of the coordinate to the segment when
|
* This is the foot of the perpendicular of the coordinate to the segment when
|
||||||
|
|||||||
@@ -426,8 +426,10 @@ ol.extent.forEachCorner = function(extent, callback, opt_this) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the size of an extent.
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @return {number} Area.
|
* @return {number} Area.
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.extent.getArea = function(extent) {
|
ol.extent.getArea = function(extent) {
|
||||||
var area = 0;
|
var area = 0;
|
||||||
|
|||||||
@@ -121,9 +121,11 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) {
|
|||||||
// loop over all outer rings and see if they contain our hole.
|
// loop over all outer rings and see if they contain our hole.
|
||||||
for (i = outerRings.length - 1; i >= 0; i--) {
|
for (i = outerRings.length - 1; i >= 0; i--) {
|
||||||
var outerRing = outerRings[i][0];
|
var outerRing = outerRings[i][0];
|
||||||
if (ol.extent.containsExtent(new ol.geom.LinearRing(
|
var containsHole = ol.extent.containsExtent(
|
||||||
outerRing).getExtent(),
|
new ol.geom.LinearRing(outerRing).getExtent(),
|
||||||
new ol.geom.LinearRing(hole).getExtent())) {
|
new ol.geom.LinearRing(hole).getExtent()
|
||||||
|
);
|
||||||
|
if (containsHole) {
|
||||||
// the hole is contained push it into our polygon
|
// the hole is contained push it into our polygon
|
||||||
outerRings[i].push(hole);
|
outerRings[i].push(hole);
|
||||||
matched = true;
|
matched = true;
|
||||||
|
|||||||
@@ -183,14 +183,14 @@ ol.format.Feature.transformWithOptions = function(
|
|||||||
// FIXME this is necessary because ol.format.GML treats extents
|
// FIXME this is necessary because ol.format.GML treats extents
|
||||||
// as geometries
|
// as geometries
|
||||||
transformed = ol.proj.transformExtent(
|
transformed = ol.proj.transformExtent(
|
||||||
write ? geometry.slice() : geometry,
|
geometry,
|
||||||
write ? featureProjection : dataProjection,
|
dataProjection,
|
||||||
write ? dataProjection : featureProjection);
|
featureProjection);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
transformed = geometry;
|
transformed = geometry;
|
||||||
}
|
}
|
||||||
if (write && opt_options && opt_options.decimals) {
|
if (write && opt_options && opt_options.decimals !== undefined) {
|
||||||
var power = Math.pow(10, opt_options.decimals);
|
var power = Math.pow(10, opt_options.decimals);
|
||||||
// if decimals option on write, round each coordinate appropriately
|
// if decimals option on write, round each coordinate appropriately
|
||||||
/**
|
/**
|
||||||
@@ -203,11 +203,10 @@ ol.format.Feature.transformWithOptions = function(
|
|||||||
}
|
}
|
||||||
return coordinates;
|
return coordinates;
|
||||||
};
|
};
|
||||||
if (Array.isArray(transformed)) {
|
if (transformed === geometry) {
|
||||||
transform(transformed);
|
transformed = transformed.clone();
|
||||||
} else {
|
|
||||||
transformed.applyTransform(transform);
|
|
||||||
}
|
}
|
||||||
|
transformed.applyTransform(transform);
|
||||||
}
|
}
|
||||||
return transformed;
|
return transformed;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ goog.provide('ol.format.filter');
|
|||||||
|
|
||||||
goog.require('ol.format.filter.And');
|
goog.require('ol.format.filter.And');
|
||||||
goog.require('ol.format.filter.Bbox');
|
goog.require('ol.format.filter.Bbox');
|
||||||
|
goog.require('ol.format.filter.During');
|
||||||
goog.require('ol.format.filter.EqualTo');
|
goog.require('ol.format.filter.EqualTo');
|
||||||
goog.require('ol.format.filter.GreaterThan');
|
goog.require('ol.format.filter.GreaterThan');
|
||||||
goog.require('ol.format.filter.GreaterThanOrEqualTo');
|
goog.require('ol.format.filter.GreaterThanOrEqualTo');
|
||||||
@@ -230,3 +231,17 @@ ol.format.filter.like = function(propertyName, pattern,
|
|||||||
return new ol.format.filter.IsLike(propertyName, pattern,
|
return new ol.format.filter.IsLike(propertyName, pattern,
|
||||||
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
|
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a `<During>` temporal operator.
|
||||||
|
*
|
||||||
|
* @param {!string} propertyName Name of the context property to compare.
|
||||||
|
* @param {!string} begin The begin date in ISO-8601 format.
|
||||||
|
* @param {!string} end The end date in ISO-8601 format.
|
||||||
|
* @returns {!ol.format.filter.During} `<During>` operator.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.format.filter.during = function(propertyName, begin, end) {
|
||||||
|
return new ol.format.filter.During(propertyName, begin, end);
|
||||||
|
};
|
||||||
|
|||||||
33
src/ol/format/filter/during.js
Normal file
33
src/ol/format/filter/during.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
goog.provide('ol.format.filter.During');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
|
goog.require('ol.format.filter.Comparison');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @classdesc
|
||||||
|
* Represents a `<During>` comparison operator.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @param {!string} propertyName Name of the context property to compare.
|
||||||
|
* @param {!string} begin The begin date in ISO-8601 format.
|
||||||
|
* @param {!string} end The end date in ISO-8601 format.
|
||||||
|
* @extends {ol.format.filter.Comparison}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.format.filter.During = function(propertyName, begin, end) {
|
||||||
|
ol.format.filter.Comparison.call(this, 'During', propertyName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @type {!string}
|
||||||
|
*/
|
||||||
|
this.begin = begin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @type {!string}
|
||||||
|
*/
|
||||||
|
this.end = end;
|
||||||
|
};
|
||||||
|
ol.inherits(ol.format.filter.During, ol.format.filter.Comparison);
|
||||||
@@ -329,7 +329,8 @@ ol.format.GeoJSON.GEOMETRY_WRITERS_ = {
|
|||||||
/**
|
/**
|
||||||
* Read a feature from a GeoJSON Feature source. Only works for Feature or
|
* Read a feature from a GeoJSON Feature source. Only works for Feature or
|
||||||
* geometry types. Use {@link ol.format.GeoJSON#readFeatures} to read
|
* geometry types. Use {@link ol.format.GeoJSON#readFeatures} to read
|
||||||
* FeatureCollection source.
|
* FeatureCollection source. If feature at source has an id, it will be used
|
||||||
|
* as Feature id by calling {@link ol.Feature#setId} internally.
|
||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
* @param {Document|Node|Object|string} source Source.
|
* @param {Document|Node|Object|string} source Source.
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ ol.format.KML.readFlatCoordinates_ = function(node) {
|
|||||||
*/
|
*/
|
||||||
ol.format.KML.readURI_ = function(node) {
|
ol.format.KML.readURI_ = function(node) {
|
||||||
var s = ol.xml.getAllTextContent(node, false).trim();
|
var s = ol.xml.getAllTextContent(node, false).trim();
|
||||||
if (node.baseURI) {
|
if (node.baseURI && node.baseURI !== 'about:blank') {
|
||||||
var url = new URL(s, node.baseURI);
|
var url = new URL(s, node.baseURI);
|
||||||
return url.href;
|
return url.href;
|
||||||
} else {
|
} else {
|
||||||
@@ -1092,13 +1092,13 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
|||||||
ol.format.KML.DataParser_ = function(node, objectStack) {
|
ol.format.KML.DataParser_ = function(node, objectStack) {
|
||||||
var name = node.getAttribute('name');
|
var name = node.getAttribute('name');
|
||||||
ol.xml.parseNode(ol.format.KML.DATA_PARSERS_, node, objectStack);
|
ol.xml.parseNode(ol.format.KML.DATA_PARSERS_, node, objectStack);
|
||||||
var featureObject =
|
var featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||||
/** @type {Object} */ (objectStack[objectStack.length - 1]);
|
|
||||||
if (name !== null) {
|
if (name !== null) {
|
||||||
featureObject[name] = featureObject.value;
|
featureObject[name] = featureObject.value;
|
||||||
} else if (featureObject.displayName !== null) {
|
} else if (featureObject.displayName !== null) {
|
||||||
featureObject[featureObject.displayName] = featureObject.value;
|
featureObject[featureObject.displayName] = featureObject.value;
|
||||||
}
|
}
|
||||||
|
delete featureObject['value'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1737,7 +1737,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
|||||||
var style = ol.format.KML.readStyle_(node, objectStack);
|
var style = ol.format.KML.readStyle_(node, objectStack);
|
||||||
if (style) {
|
if (style) {
|
||||||
var styleUri;
|
var styleUri;
|
||||||
if (node.baseURI) {
|
if (node.baseURI && node.baseURI !== 'about:blank') {
|
||||||
var url = new URL('#' + id, node.baseURI);
|
var url = new URL('#' + id, node.baseURI);
|
||||||
styleUri = url.href;
|
styleUri = url.href;
|
||||||
} else {
|
} else {
|
||||||
@@ -1764,7 +1764,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var styleUri;
|
var styleUri;
|
||||||
if (node.baseURI) {
|
if (node.baseURI && node.baseURI !== 'about:blank') {
|
||||||
var url = new URL('#' + id, node.baseURI);
|
var url = new URL('#' + id, node.baseURI);
|
||||||
styleUri = url.href;
|
styleUri = url.href;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ ol.format.MVT = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {function((ol.geom.Geometry|Object.<string,*>)=)|
|
* @type {function((ol.geom.Geometry|Object.<string,*>)=)|
|
||||||
* function(ol.geom.GeometryType,Array.<number>,
|
* function(ol.geom.GeometryType,Array.<number>,
|
||||||
* (Array.<number>|Array.<Array.<number>>),Object.<string, *>)}
|
* (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)}
|
||||||
*/
|
*/
|
||||||
this.featureClass_ = options.featureClass ?
|
this.featureClass_ = options.featureClass ?
|
||||||
options.featureClass : ol.render.Feature;
|
options.featureClass : ol.render.Feature;
|
||||||
@@ -137,8 +137,9 @@ ol.format.MVT.prototype.readRenderFeature_ = function(rawFeature, layer) {
|
|||||||
|
|
||||||
var values = rawFeature.properties;
|
var values = rawFeature.properties;
|
||||||
values[this.layerName_] = layer;
|
values[this.layerName_] = layer;
|
||||||
|
var id = rawFeature.id;
|
||||||
|
|
||||||
return new this.featureClass_(geometryType, flatCoordinates, ends, values);
|
return new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ goog.require('ol.geom.MultiPoint');
|
|||||||
goog.require('ol.geom.MultiPolygon');
|
goog.require('ol.geom.MultiPolygon');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.obj');
|
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +28,18 @@ ol.format.TopoJSON = function(opt_options) {
|
|||||||
|
|
||||||
ol.format.JSONFeature.call(this);
|
ol.format.JSONFeature.call(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {string|undefined}
|
||||||
|
*/
|
||||||
|
this.layerName_ = options.layerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Array.<string>}
|
||||||
|
*/
|
||||||
|
this.layers_ = options.layers ? options.layers : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -202,18 +213,21 @@ ol.format.TopoJSON.readMultiPolygonGeometry_ = function(object, arcs) {
|
|||||||
* @param {Array.<Array.<ol.Coordinate>>} arcs Array of arcs.
|
* @param {Array.<Array.<ol.Coordinate>>} arcs Array of arcs.
|
||||||
* @param {Array.<number>} scale Scale for each dimension.
|
* @param {Array.<number>} scale Scale for each dimension.
|
||||||
* @param {Array.<number>} translate Translation for each dimension.
|
* @param {Array.<number>} translate Translation for each dimension.
|
||||||
|
* @param {string|undefined} property Property to set the `GeometryCollection`'s parent
|
||||||
|
* object to.
|
||||||
|
* @param {string} name Name of the `Topology`'s child object.
|
||||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||||
* @return {Array.<ol.Feature>} Array of features.
|
* @return {Array.<ol.Feature>} Array of features.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function(
|
ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function(
|
||||||
collection, arcs, scale, translate, opt_options) {
|
collection, arcs, scale, translate, property, name, opt_options) {
|
||||||
var geometries = collection.geometries;
|
var geometries = collection.geometries;
|
||||||
var features = [];
|
var features = [];
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||||
features[i] = ol.format.TopoJSON.readFeatureFromGeometry_(
|
features[i] = ol.format.TopoJSON.readFeatureFromGeometry_(
|
||||||
geometries[i], arcs, scale, translate, opt_options);
|
geometries[i], arcs, scale, translate, property, name, opt_options);
|
||||||
}
|
}
|
||||||
return features;
|
return features;
|
||||||
};
|
};
|
||||||
@@ -226,12 +240,15 @@ ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function(
|
|||||||
* @param {Array.<Array.<ol.Coordinate>>} arcs Array of arcs.
|
* @param {Array.<Array.<ol.Coordinate>>} arcs Array of arcs.
|
||||||
* @param {Array.<number>} scale Scale for each dimension.
|
* @param {Array.<number>} scale Scale for each dimension.
|
||||||
* @param {Array.<number>} translate Translation for each dimension.
|
* @param {Array.<number>} translate Translation for each dimension.
|
||||||
|
* @param {string|undefined} property Property to set the `GeometryCollection`'s parent
|
||||||
|
* object to.
|
||||||
|
* @param {string} name Name of the `Topology`'s child object.
|
||||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||||
* @return {ol.Feature} Feature.
|
* @return {ol.Feature} Feature.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
||||||
scale, translate, opt_options) {
|
scale, translate, property, name, opt_options) {
|
||||||
var geometry;
|
var geometry;
|
||||||
var type = object.type;
|
var type = object.type;
|
||||||
var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type];
|
var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type];
|
||||||
@@ -246,8 +263,15 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
|||||||
if (object.id !== undefined) {
|
if (object.id !== undefined) {
|
||||||
feature.setId(object.id);
|
feature.setId(object.id);
|
||||||
}
|
}
|
||||||
if (object.properties) {
|
var properties = object.properties;
|
||||||
feature.setProperties(object.properties);
|
if (property) {
|
||||||
|
if (!properties) {
|
||||||
|
properties = {};
|
||||||
|
}
|
||||||
|
properties[property] = name;
|
||||||
|
}
|
||||||
|
if (properties) {
|
||||||
|
feature.setProperties(properties);
|
||||||
}
|
}
|
||||||
return feature;
|
return feature;
|
||||||
};
|
};
|
||||||
@@ -283,21 +307,24 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function(
|
|||||||
}
|
}
|
||||||
/** @type {Array.<ol.Feature>} */
|
/** @type {Array.<ol.Feature>} */
|
||||||
var features = [];
|
var features = [];
|
||||||
var topoJSONFeatures = ol.obj.getValues(topoJSONTopology.objects);
|
var topoJSONFeatures = topoJSONTopology.objects;
|
||||||
var i, ii;
|
var property = this.layerName_;
|
||||||
var feature;
|
var objectName, feature;
|
||||||
for (i = 0, ii = topoJSONFeatures.length; i < ii; ++i) {
|
for (objectName in topoJSONFeatures) {
|
||||||
if (topoJSONFeatures[i].type === 'GeometryCollection') {
|
if (this.layers_ && this.layers_.indexOf(objectName) == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (topoJSONFeatures[objectName].type === 'GeometryCollection') {
|
||||||
feature = /** @type {TopoJSONGeometryCollection} */
|
feature = /** @type {TopoJSONGeometryCollection} */
|
||||||
(topoJSONFeatures[i]);
|
(topoJSONFeatures[objectName]);
|
||||||
features.push.apply(features,
|
features.push.apply(features,
|
||||||
ol.format.TopoJSON.readFeaturesFromGeometryCollection_(
|
ol.format.TopoJSON.readFeaturesFromGeometryCollection_(
|
||||||
feature, arcs, scale, translate, opt_options));
|
feature, arcs, scale, translate, property, objectName, opt_options));
|
||||||
} else {
|
} else {
|
||||||
feature = /** @type {TopoJSONGeometry} */
|
feature = /** @type {TopoJSONGeometry} */
|
||||||
(topoJSONFeatures[i]);
|
(topoJSONFeatures[objectName]);
|
||||||
features.push(ol.format.TopoJSON.readFeatureFromGeometry_(
|
features.push(ol.format.TopoJSON.readFeatureFromGeometry_(
|
||||||
feature, arcs, scale, translate, opt_options));
|
feature, arcs, scale, translate, property, objectName, opt_options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return features;
|
return features;
|
||||||
|
|||||||
@@ -90,6 +90,13 @@ ol.format.WFS.OGCNS = 'http://www.opengis.net/ogc';
|
|||||||
ol.format.WFS.WFSNS = 'http://www.opengis.net/wfs';
|
ol.format.WFS.WFSNS = 'http://www.opengis.net/wfs';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.format.WFS.FESNS = 'http://www.opengis.net/fes';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Object.<string, string>}
|
* @type {Object.<string, string>}
|
||||||
@@ -646,6 +653,32 @@ ol.format.WFS.writeWithinFilter_ = function(node, filter, objectStack) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Node} node Node.
|
||||||
|
* @param {ol.format.filter.During} filter Filter.
|
||||||
|
* @param {Array.<*>} objectStack Node stack.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.format.WFS.writeDuringFilter_ = function(node, filter, objectStack) {
|
||||||
|
|
||||||
|
var valueReference = ol.xml.createElementNS(ol.format.WFS.FESNS, 'ValueReference');
|
||||||
|
ol.format.XSD.writeStringTextNode(valueReference, filter.propertyName);
|
||||||
|
node.appendChild(valueReference);
|
||||||
|
|
||||||
|
var timePeriod = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'TimePeriod');
|
||||||
|
|
||||||
|
node.appendChild(timePeriod);
|
||||||
|
|
||||||
|
var begin = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'begin');
|
||||||
|
timePeriod.appendChild(begin);
|
||||||
|
ol.format.WFS.writeTimeInstant_(begin, filter.begin);
|
||||||
|
|
||||||
|
var end = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'end');
|
||||||
|
timePeriod.appendChild(end);
|
||||||
|
ol.format.WFS.writeTimeInstant_(end, filter.end);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Node} node Node.
|
* @param {Node} node Node.
|
||||||
* @param {ol.format.filter.LogicalNary} filter Filter.
|
* @param {ol.format.filter.LogicalNary} filter Filter.
|
||||||
@@ -777,6 +810,21 @@ ol.format.WFS.writeOgcLiteral_ = function(node, value) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Node} node Node.
|
||||||
|
* @param {string} time PropertyName value.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.format.WFS.writeTimeInstant_ = function(node, time) {
|
||||||
|
var timeInstant = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'TimeInstant');
|
||||||
|
node.appendChild(timeInstant);
|
||||||
|
|
||||||
|
var timePosition = ol.xml.createElementNS(ol.format.GMLBase.GMLNS, 'timePosition');
|
||||||
|
timeInstant.appendChild(timePosition);
|
||||||
|
ol.format.XSD.writeStringTextNode(timePosition, time);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
|
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
|
||||||
* @private
|
* @private
|
||||||
@@ -786,6 +834,7 @@ ol.format.WFS.GETFEATURE_SERIALIZERS_ = {
|
|||||||
'Query': ol.xml.makeChildAppender(ol.format.WFS.writeQuery_)
|
'Query': ol.xml.makeChildAppender(ol.format.WFS.writeQuery_)
|
||||||
},
|
},
|
||||||
'http://www.opengis.net/ogc': {
|
'http://www.opengis.net/ogc': {
|
||||||
|
'During': ol.xml.makeChildAppender(ol.format.WFS.writeDuringFilter_),
|
||||||
'And': ol.xml.makeChildAppender(ol.format.WFS.writeLogicalFilter_),
|
'And': ol.xml.makeChildAppender(ol.format.WFS.writeLogicalFilter_),
|
||||||
'Or': ol.xml.makeChildAppender(ol.format.WFS.writeLogicalFilter_),
|
'Or': ol.xml.makeChildAppender(ol.format.WFS.writeLogicalFilter_),
|
||||||
'Not': ol.xml.makeChildAppender(ol.format.WFS.writeNotFilter_),
|
'Not': ol.xml.makeChildAppender(ol.format.WFS.writeNotFilter_),
|
||||||
@@ -931,9 +980,10 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version];
|
var schemaLocation = ol.format.WFS.SCHEMA_LOCATIONS[version];
|
||||||
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'xsi:schemaLocation', schemaLocation);
|
'xsi:schemaLocation', schemaLocation);
|
||||||
|
var featurePrefix = options.featurePrefix ? options.featurePrefix : ol.format.WFS.FEATURE_PREFIX;
|
||||||
if (inserts) {
|
if (inserts) {
|
||||||
obj = {node: node, 'featureNS': options.featureNS,
|
obj = {node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
||||||
ol.obj.assign(obj, baseObj);
|
ol.obj.assign(obj, baseObj);
|
||||||
ol.xml.pushSerializeAndPop(obj,
|
ol.xml.pushSerializeAndPop(obj,
|
||||||
@@ -943,7 +993,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
}
|
}
|
||||||
if (updates) {
|
if (updates) {
|
||||||
obj = {node: node, 'featureNS': options.featureNS,
|
obj = {node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
|
||||||
ol.obj.assign(obj, baseObj);
|
ol.obj.assign(obj, baseObj);
|
||||||
ol.xml.pushSerializeAndPop(obj,
|
ol.xml.pushSerializeAndPop(obj,
|
||||||
@@ -953,7 +1003,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
}
|
}
|
||||||
if (deletes) {
|
if (deletes) {
|
||||||
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
||||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||||
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
|
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
|
||||||
@@ -961,7 +1011,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
|
|||||||
}
|
}
|
||||||
if (options.nativeElements) {
|
if (options.nativeElements) {
|
||||||
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
ol.xml.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
|
||||||
'featureType': options.featureType, 'featurePrefix': options.featurePrefix,
|
'featureType': options.featureType, 'featurePrefix': featurePrefix,
|
||||||
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
'gmlVersion': gmlVersion, 'srsName': options.srsName},
|
||||||
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
ol.format.WFS.TRANSACTION_SERIALIZERS_,
|
||||||
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,
|
ol.xml.makeSimpleNodeFactory('Native'), options.nativeElements,
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
goog.provide('ol.Geolocation');
|
goog.provide('ol.Geolocation');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
|
||||||
goog.require('ol.GeolocationProperty');
|
goog.require('ol.GeolocationProperty');
|
||||||
|
goog.require('ol.Object');
|
||||||
|
goog.require('ol.Sphere');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.has');
|
goog.require('ol.has');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.sphere.WGS84');
|
goog.require('ol.proj.EPSG4326');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,6 +60,12 @@ ol.Geolocation = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.transform_ = ol.proj.identityTransform;
|
this.transform_ = ol.proj.identityTransform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.Sphere}
|
||||||
|
*/
|
||||||
|
this.sphere_ = new ol.Sphere(ol.proj.EPSG4326.RADIUS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
@@ -73,7 +80,7 @@ ol.Geolocation = function(opt_options) {
|
|||||||
this.handleTrackingChanged_, this);
|
this.handleTrackingChanged_, this);
|
||||||
|
|
||||||
if (options.projection !== undefined) {
|
if (options.projection !== undefined) {
|
||||||
this.setProjection(ol.proj.get(options.projection));
|
this.setProjection(options.projection);
|
||||||
}
|
}
|
||||||
if (options.trackingOptions !== undefined) {
|
if (options.trackingOptions !== undefined) {
|
||||||
this.setTrackingOptions(options.trackingOptions);
|
this.setTrackingOptions(options.trackingOptions);
|
||||||
@@ -154,7 +161,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
|
|||||||
this.set(ol.GeolocationProperty.SPEED,
|
this.set(ol.GeolocationProperty.SPEED,
|
||||||
coords.speed === null ? undefined : coords.speed);
|
coords.speed === null ? undefined : coords.speed);
|
||||||
var geometry = ol.geom.Polygon.circular(
|
var geometry = ol.geom.Polygon.circular(
|
||||||
ol.sphere.WGS84, this.position_, coords.accuracy);
|
this.sphere_, this.position_, coords.accuracy);
|
||||||
geometry.applyTransform(this.transform_);
|
geometry.applyTransform(this.transform_);
|
||||||
this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry);
|
this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry);
|
||||||
this.changed();
|
this.changed();
|
||||||
@@ -308,13 +315,13 @@ ol.Geolocation.prototype.getTrackingOptions = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the projection to use for transforming the coordinates.
|
* Set the projection to use for transforming the coordinates.
|
||||||
* @param {ol.proj.Projection} projection The projection the position is
|
* @param {ol.ProjectionLike} projection The projection the position is
|
||||||
* reported in.
|
* reported in.
|
||||||
* @observable
|
* @observable
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.Geolocation.prototype.setProjection = function(projection) {
|
ol.Geolocation.prototype.setProjection = function(projection) {
|
||||||
this.set(ol.GeolocationProperty.PROJECTION, projection);
|
this.set(ol.GeolocationProperty.PROJECTION, ol.proj.get(projection));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -528,7 +528,7 @@ ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of parallels. Pallels are lines of equal latitude.
|
* Get the list of parallels. Parallels are lines of equal latitude.
|
||||||
* @return {Array.<ol.geom.LineString>} The parallels.
|
* @return {Array.<ol.geom.LineString>} The parallels.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.provide('ol.ImageTile');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
|
goog.require('ol.dom');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Image}
|
* @type {Image|HTMLCanvasElement}
|
||||||
*/
|
*/
|
||||||
this.image_ = new Image();
|
this.image_ = new Image();
|
||||||
if (crossOrigin !== null) {
|
if (crossOrigin !== null) {
|
||||||
@@ -59,6 +60,7 @@ ol.inherits(ol.ImageTile, ol.Tile);
|
|||||||
ol.ImageTile.prototype.disposeInternal = function() {
|
ol.ImageTile.prototype.disposeInternal = function() {
|
||||||
if (this.state == ol.TileState.LOADING) {
|
if (this.state == ol.TileState.LOADING) {
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
|
this.image_.src = ol.ImageTile.blankImage.toDataURL('image/png');
|
||||||
}
|
}
|
||||||
if (this.interimTile) {
|
if (this.interimTile) {
|
||||||
this.interimTile.dispose();
|
this.interimTile.dispose();
|
||||||
@@ -70,8 +72,8 @@ ol.ImageTile.prototype.disposeInternal = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the image element for this tile.
|
* Get the HTML image element for this tile (may be a Canvas, Image, or Video).
|
||||||
* @inheritDoc
|
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.ImageTile.prototype.getImage = function() {
|
ol.ImageTile.prototype.getImage = function() {
|
||||||
@@ -95,6 +97,7 @@ ol.ImageTile.prototype.getKey = function() {
|
|||||||
ol.ImageTile.prototype.handleImageError_ = function() {
|
ol.ImageTile.prototype.handleImageError_ = function() {
|
||||||
this.state = ol.TileState.ERROR;
|
this.state = ol.TileState.ERROR;
|
||||||
this.unlistenImage_();
|
this.unlistenImage_();
|
||||||
|
this.image_ = ol.ImageTile.blankImage;
|
||||||
this.changed();
|
this.changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,3 +146,15 @@ ol.ImageTile.prototype.unlistenImage_ = function() {
|
|||||||
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
this.imageListenerKeys_ = null;
|
this.imageListenerKeys_ = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A blank image.
|
||||||
|
* @type {HTMLCanvasElement}
|
||||||
|
*/
|
||||||
|
ol.ImageTile.blankImage = (function() {
|
||||||
|
var ctx = ol.dom.createCanvasContext2D(1, 1);
|
||||||
|
ctx.fillStyle = 'rgba(0,0,0,0)';
|
||||||
|
ctx.fillRect(0, 0, 1, 1);
|
||||||
|
return ctx.canvas;
|
||||||
|
})();
|
||||||
|
|||||||
@@ -141,14 +141,10 @@ ol.interaction.DragAndDrop.handleEvent = ol.functions.TRUE;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.DragAndDrop.prototype.setMap = function(map) {
|
ol.interaction.DragAndDrop.prototype.registerListeners_ = function() {
|
||||||
if (this.dropListenKeys_) {
|
var map = this.getMap();
|
||||||
this.dropListenKeys_.forEach(ol.events.unlistenByKey);
|
|
||||||
this.dropListenKeys_ = null;
|
|
||||||
}
|
|
||||||
ol.interaction.Interaction.prototype.setMap.call(this, map);
|
|
||||||
if (map) {
|
if (map) {
|
||||||
var dropArea = this.target ? this.target : map.getViewport();
|
var dropArea = this.target ? this.target : map.getViewport();
|
||||||
this.dropListenKeys_ = [
|
this.dropListenKeys_ = [
|
||||||
@@ -165,6 +161,31 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.interaction.DragAndDrop.prototype.setActive = function(active) {
|
||||||
|
ol.interaction.Interaction.prototype.setActive.call(this, active);
|
||||||
|
if (active) {
|
||||||
|
this.registerListeners_();
|
||||||
|
} else {
|
||||||
|
this.unregisterListeners_();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.interaction.DragAndDrop.prototype.setMap = function(map) {
|
||||||
|
this.unregisterListeners_();
|
||||||
|
ol.interaction.Interaction.prototype.setMap.call(this, map);
|
||||||
|
if (this.getActive()) {
|
||||||
|
this.registerListeners_();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.format.Feature} format Format.
|
* @param {ol.format.Feature} format Format.
|
||||||
* @param {string} text Text.
|
* @param {string} text Text.
|
||||||
@@ -181,6 +202,17 @@ ol.interaction.DragAndDrop.prototype.tryReadFeatures_ = function(format, text, o
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.interaction.DragAndDrop.prototype.unregisterListeners_ = function() {
|
||||||
|
if (this.dropListenKeys_) {
|
||||||
|
this.dropListenKeys_.forEach(ol.events.unlistenByKey);
|
||||||
|
this.dropListenKeys_ = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.interaction.DragRotate');
|
goog.provide('ol.interaction.DragRotate');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.RotationConstraint');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
@@ -64,13 +65,16 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
|
var view = map.getView();
|
||||||
|
if (view.getConstraints().rotation === ol.RotationConstraint.disable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
var offset = mapBrowserEvent.pixel;
|
var offset = mapBrowserEvent.pixel;
|
||||||
var theta =
|
var theta =
|
||||||
Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2);
|
Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2);
|
||||||
if (this.lastAngle_ !== undefined) {
|
if (this.lastAngle_ !== undefined) {
|
||||||
var delta = theta - this.lastAngle_;
|
var delta = theta - this.lastAngle_;
|
||||||
var view = map.getView();
|
|
||||||
var rotation = view.getRotation();
|
var rotation = view.getRotation();
|
||||||
ol.interaction.Interaction.rotateWithoutConstraints(
|
ol.interaction.Interaction.rotateWithoutConstraints(
|
||||||
view, rotation - delta);
|
view, rotation - delta);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.interaction.DragRotateAndZoom');
|
goog.provide('ol.interaction.DragRotateAndZoom');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.RotationConstraint');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
@@ -85,7 +86,7 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
var theta = Math.atan2(deltaY, deltaX);
|
var theta = Math.atan2(deltaY, deltaX);
|
||||||
var magnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
var magnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
if (this.lastAngle_ !== undefined) {
|
if (view.getConstraints().rotation !== ol.RotationConstraint.disable && this.lastAngle_ !== undefined) {
|
||||||
var angleDelta = theta - this.lastAngle_;
|
var angleDelta = theta - this.lastAngle_;
|
||||||
ol.interaction.Interaction.rotateWithoutConstraints(
|
ol.interaction.Interaction.rotateWithoutConstraints(
|
||||||
view, view.getRotation() - angleDelta);
|
view, view.getRotation() - angleDelta);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ ol.interaction.Draw = function(options) {
|
|||||||
if (!geometryFunction) {
|
if (!geometryFunction) {
|
||||||
if (this.type_ === ol.geom.GeometryType.CIRCLE) {
|
if (this.type_ === ol.geom.GeometryType.CIRCLE) {
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
|
* @param {!Array.<ol.Coordinate>} coordinates
|
||||||
* The coordinates.
|
* The coordinates.
|
||||||
* @param {ol.geom.SimpleGeometry=} opt_geometry Optional geometry.
|
* @param {ol.geom.SimpleGeometry=} opt_geometry Optional geometry.
|
||||||
* @return {ol.geom.SimpleGeometry} A geometry.
|
* @return {ol.geom.SimpleGeometry} A geometry.
|
||||||
@@ -151,7 +151,7 @@ ol.interaction.Draw = function(options) {
|
|||||||
Constructor = ol.geom.Polygon;
|
Constructor = ol.geom.Polygon;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
|
* @param {!Array.<ol.Coordinate>} coordinates
|
||||||
* The coordinates.
|
* The coordinates.
|
||||||
* @param {ol.geom.SimpleGeometry=} opt_geometry Optional geometry.
|
* @param {ol.geom.SimpleGeometry=} opt_geometry Optional geometry.
|
||||||
* @return {ol.geom.SimpleGeometry} A geometry.
|
* @return {ol.geom.SimpleGeometry} A geometry.
|
||||||
@@ -529,9 +529,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
|
|||||||
}
|
}
|
||||||
last[0] = coordinate[0];
|
last[0] = coordinate[0];
|
||||||
last[1] = coordinate[1];
|
last[1] = coordinate[1];
|
||||||
this.geometryFunction_(
|
this.geometryFunction_(/** @type {!Array.<ol.Coordinate>} */ (this.sketchCoords_), geometry);
|
||||||
/** @type {!ol.Coordinate|!Array.<ol.Coordinate>|!Array.<Array.<ol.Coordinate>>} */ (this.sketchCoords_),
|
|
||||||
geometry);
|
|
||||||
if (this.sketchPoint_) {
|
if (this.sketchPoint_) {
|
||||||
var sketchPointGeom = /** @type {ol.geom.Point} */ (this.sketchPoint_.getGeometry());
|
var sketchPointGeom = /** @type {ol.geom.Point} */ (this.sketchPoint_.getGeometry());
|
||||||
sketchPointGeom.setCoordinates(coordinate);
|
sketchPointGeom.setCoordinates(coordinate);
|
||||||
@@ -800,7 +798,7 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
|
|||||||
ol.interaction.Draw.createBox = function() {
|
ol.interaction.Draw.createBox = function() {
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
|
* @param {Array.<ol.Coordinate>} coordinates
|
||||||
* @param {ol.geom.SimpleGeometry=} opt_geometry
|
* @param {ol.geom.SimpleGeometry=} opt_geometry
|
||||||
* @return {ol.geom.SimpleGeometry}
|
* @return {ol.geom.SimpleGeometry}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -67,6 +67,13 @@ ol.interaction.Modify = function(options) {
|
|||||||
this.deleteCondition_ = options.deleteCondition ?
|
this.deleteCondition_ = options.deleteCondition ?
|
||||||
options.deleteCondition : this.defaultDeleteCondition_;
|
options.deleteCondition : this.defaultDeleteCondition_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol.EventsConditionType}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.insertVertexCondition_ = options.insertVertexCondition ?
|
||||||
|
options.insertVertexCondition : ol.events.condition.always;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editing vertex.
|
* Editing vertex.
|
||||||
* @type {ol.Feature}
|
* @type {ol.Feature}
|
||||||
@@ -600,7 +607,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
|
|||||||
|
|
||||||
this.dragSegments_.push([segmentDataMatch, 1]);
|
this.dragSegments_.push([segmentDataMatch, 1]);
|
||||||
componentSegments[uid][1] = segmentDataMatch;
|
componentSegments[uid][1] = segmentDataMatch;
|
||||||
} else if (ol.getUid(segment) in this.vertexSegments_ &&
|
} else if (this.insertVertexCondition_(evt) && ol.getUid(segment) in this.vertexSegments_ &&
|
||||||
(!componentSegments[uid][0] && !componentSegments[uid][1])) {
|
(!componentSegments[uid][0] && !componentSegments[uid][1])) {
|
||||||
insertVertices.push([segmentDataMatch, vertex]);
|
insertVertices.push([segmentDataMatch, vertex]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ goog.require('ol.ViewHint');
|
|||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
goog.require('ol.interaction.Pointer');
|
goog.require('ol.interaction.Pointer');
|
||||||
|
goog.require('ol.RotationConstraint');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,6 +96,10 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
this.lastAngle_ = angle;
|
this.lastAngle_ = angle;
|
||||||
|
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
|
var view = map.getView();
|
||||||
|
if (view.getConstraints().rotation === ol.RotationConstraint.disable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// rotate anchor point.
|
// rotate anchor point.
|
||||||
// FIXME: should be the intersection point between the lines:
|
// FIXME: should be the intersection point between the lines:
|
||||||
@@ -107,7 +112,6 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
|||||||
|
|
||||||
// rotate
|
// rotate
|
||||||
if (this.rotating_) {
|
if (this.rotating_) {
|
||||||
var view = map.getView();
|
|
||||||
var rotation = view.getRotation();
|
var rotation = view.getRotation();
|
||||||
map.render();
|
map.render();
|
||||||
ol.interaction.Interaction.rotateWithoutConstraints(view,
|
ol.interaction.Interaction.rotateWithoutConstraints(view,
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
|
|||||||
// the pixel.
|
// the pixel.
|
||||||
ol.obj.clear(this.featureLayerAssociation_);
|
ol.obj.clear(this.featureLayerAssociation_);
|
||||||
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
|
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
|
||||||
(/**
|
(
|
||||||
|
/**
|
||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
* @return {boolean|undefined} Continue to iterate over the features.
|
* @return {boolean|undefined} Continue to iterate over the features.
|
||||||
@@ -250,7 +251,8 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
|
|||||||
} else {
|
} else {
|
||||||
// Modify the currently selected feature(s).
|
// Modify the currently selected feature(s).
|
||||||
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
|
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
|
||||||
(/**
|
(
|
||||||
|
/**
|
||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
* @return {boolean|undefined} Continue to iterate over the features.
|
* @return {boolean|undefined} Continue to iterate over the features.
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ goog.require('ol.events');
|
|||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
|
goog.require('ol.geom.GeometryType');
|
||||||
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.interaction.Pointer');
|
goog.require('ol.interaction.Pointer');
|
||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
goog.require('ol.source.Vector');
|
goog.require('ol.source.Vector');
|
||||||
@@ -142,7 +144,8 @@ ol.interaction.Snap = function(opt_options) {
|
|||||||
'MultiPoint': this.writeMultiPointGeometry_,
|
'MultiPoint': this.writeMultiPointGeometry_,
|
||||||
'MultiLineString': this.writeMultiLineStringGeometry_,
|
'MultiLineString': this.writeMultiLineStringGeometry_,
|
||||||
'MultiPolygon': this.writeMultiPolygonGeometry_,
|
'MultiPolygon': this.writeMultiPolygonGeometry_,
|
||||||
'GeometryCollection': this.writeGeometryCollectionGeometry_
|
'GeometryCollection': this.writeGeometryCollectionGeometry_,
|
||||||
|
'Circle': this.writeCircleGeometry_
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ol.inherits(ol.interaction.Snap, ol.interaction.Pointer);
|
ol.inherits(ol.interaction.Snap, ol.interaction.Pointer);
|
||||||
@@ -345,6 +348,15 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
|
|||||||
var box = ol.extent.boundingExtent([lowerLeft, upperRight]);
|
var box = ol.extent.boundingExtent([lowerLeft, upperRight]);
|
||||||
|
|
||||||
var segments = this.rBush_.getInExtent(box);
|
var segments = this.rBush_.getInExtent(box);
|
||||||
|
|
||||||
|
// If snapping on vertices only, don't consider circles
|
||||||
|
if (this.vertex_ && !this.edge_) {
|
||||||
|
segments = segments.filter(function(segment) {
|
||||||
|
return segment.feature.getGeometry().getType() !==
|
||||||
|
ol.geom.GeometryType.CIRCLE;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var snappedToVertex = false;
|
var snappedToVertex = false;
|
||||||
var snapped = false;
|
var snapped = false;
|
||||||
var vertex = null;
|
var vertex = null;
|
||||||
@@ -354,6 +366,8 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
|
|||||||
this.pixelCoordinate_ = pixelCoordinate;
|
this.pixelCoordinate_ = pixelCoordinate;
|
||||||
segments.sort(this.sortByDistance_);
|
segments.sort(this.sortByDistance_);
|
||||||
var closestSegment = segments[0].segment;
|
var closestSegment = segments[0].segment;
|
||||||
|
var isCircle = segments[0].feature.getGeometry().getType() ===
|
||||||
|
ol.geom.GeometryType.CIRCLE;
|
||||||
if (this.vertex_ && !this.edge_) {
|
if (this.vertex_ && !this.edge_) {
|
||||||
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
||||||
pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
||||||
@@ -368,12 +382,17 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) {
|
|||||||
vertexPixel = map.getPixelFromCoordinate(vertex);
|
vertexPixel = map.getPixelFromCoordinate(vertex);
|
||||||
}
|
}
|
||||||
} else if (this.edge_) {
|
} else if (this.edge_) {
|
||||||
|
if (isCircle) {
|
||||||
|
vertex = ol.coordinate.closestOnCircle(pixelCoordinate,
|
||||||
|
/** @type {ol.geom.Circle} */ (segments[0].feature.getGeometry()));
|
||||||
|
} else {
|
||||||
vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
|
vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
|
||||||
closestSegment));
|
closestSegment));
|
||||||
|
}
|
||||||
vertexPixel = map.getPixelFromCoordinate(vertex);
|
vertexPixel = map.getPixelFromCoordinate(vertex);
|
||||||
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
|
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
|
||||||
snapped = true;
|
snapped = true;
|
||||||
if (this.vertex_) {
|
if (this.vertex_ && !isCircle) {
|
||||||
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
|
||||||
pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
|
||||||
squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
|
squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
|
||||||
@@ -410,6 +429,26 @@ ol.interaction.Snap.prototype.updateFeature_ = function(feature) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Feature} feature Feature
|
||||||
|
* @param {ol.geom.Circle} geometry Geometry.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.interaction.Snap.prototype.writeCircleGeometry_ = function(feature, geometry) {
|
||||||
|
var polygon = ol.geom.Polygon.fromCircle(geometry);
|
||||||
|
var coordinates = polygon.getCoordinates()[0];
|
||||||
|
var i, ii, segment, segmentData;
|
||||||
|
for (i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||||
|
segment = coordinates.slice(i, i + 2);
|
||||||
|
segmentData = /** @type {ol.SnapSegmentDataType} */ ({
|
||||||
|
feature: feature,
|
||||||
|
segment: segment
|
||||||
|
});
|
||||||
|
this.rBush_.insert(ol.extent.boundingExtent(segment), segmentData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature} feature Feature
|
* @param {ol.Feature} feature Feature
|
||||||
* @param {ol.geom.GeometryCollection} geometry Geometry.
|
* @param {ol.geom.GeometryCollection} geometry Geometry.
|
||||||
|
|||||||
@@ -32,13 +32,6 @@ ol.interaction.Translate = function(opt_options) {
|
|||||||
|
|
||||||
var options = opt_options ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.previousCursor_ = undefined;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last position we translated to.
|
* The last position we translated to.
|
||||||
* @type {ol.Coordinate}
|
* @type {ol.Coordinate}
|
||||||
@@ -175,23 +168,15 @@ ol.interaction.Translate.handleDragEvent_ = function(event) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Translate.handleMoveEvent_ = function(event) {
|
ol.interaction.Translate.handleMoveEvent_ = function(event) {
|
||||||
var elem = event.map.getTargetElement();
|
var elem = event.map.getViewport();
|
||||||
|
|
||||||
// Change the cursor to grab/grabbing if hovering any of the features managed
|
// Change the cursor to grab/grabbing if hovering any of the features managed
|
||||||
// by the interaction
|
// by the interaction
|
||||||
if (this.featuresAtPixel_(event.pixel, event.map)) {
|
if (this.featuresAtPixel_(event.pixel, event.map)) {
|
||||||
this.previousCursor_ = this.previousCursor_ !== undefined ?
|
elem.classList.remove(this.lastCoordinate_ ? 'ol-grab' : 'ol-grabbing');
|
||||||
this.previousCursor_ : elem.style.cursor;
|
elem.classList.add(this.lastCoordinate_ ? 'ol-grabbing' : 'ol-grab');
|
||||||
// WebKit browsers don't support the grab icons without a prefix
|
} else {
|
||||||
elem.style.cursor = this.lastCoordinate_ ?
|
elem.classList.remove('ol-grab', 'ol-grabbing');
|
||||||
'-webkit-grabbing' : '-webkit-grab';
|
|
||||||
|
|
||||||
// Thankfully, attempting to set the standard ones will silently fail,
|
|
||||||
// keeping the prefixed icons
|
|
||||||
elem.style.cursor = this.lastCoordinate_ ? 'grabbing' : 'grab';
|
|
||||||
} else if (this.previousCursor_ !== undefined) {
|
|
||||||
elem.style.cursor = this.previousCursor_;
|
|
||||||
this.previousCursor_ = undefined;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -266,14 +251,12 @@ ol.interaction.Translate.prototype.handleActiveChanged_ = function() {
|
|||||||
ol.interaction.Translate.prototype.updateState_ = function(oldMap) {
|
ol.interaction.Translate.prototype.updateState_ = function(oldMap) {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var active = this.getActive();
|
var active = this.getActive();
|
||||||
if ((!map || !active) && this.previousCursor_ !== undefined) {
|
if (!map || !active) {
|
||||||
if (!map) {
|
map = map || oldMap;
|
||||||
map = oldMap;
|
if (map) {
|
||||||
|
var elem = map.getViewport();
|
||||||
|
elem.classList.remove('ol-grab', 'ol-grabbing');
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = map.getTargetElement();
|
|
||||||
elem.style.cursor = this.previousCursor_;
|
|
||||||
this.previousCursor_ = undefined;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,15 @@ ol.Kinetic.prototype.end = function() {
|
|||||||
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
||||||
firstIndex -= 3;
|
firstIndex -= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
||||||
|
// we don't want a duration of 0 (divide by zero)
|
||||||
|
// we also make sure the user panned for a duration of at least one frame
|
||||||
|
// (1/60s) to compute sane displacement values
|
||||||
|
if (duration < 1000 / 60) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var dx = this.points_[lastIndex] - this.points_[firstIndex];
|
var dx = this.points_[lastIndex] - this.points_[firstIndex];
|
||||||
var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
||||||
this.angle_ = Math.atan2(dy, dx);
|
this.angle_ = Math.atan2(dy, dx);
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ ol.Map = function(options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {ol.Extent}
|
* @type {ol.Extent}
|
||||||
*/
|
*/
|
||||||
this.previousExtent_ = ol.extent.createEmpty();
|
this.previousExtent_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -278,7 +278,7 @@ ol.Map = function(options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {ol.MapBrowserEventHandler}
|
* @type {ol.MapBrowserEventHandler}
|
||||||
*/
|
*/
|
||||||
this.mapBrowserEventHandler_ = new ol.MapBrowserEventHandler(this);
|
this.mapBrowserEventHandler_ = new ol.MapBrowserEventHandler(this, options.moveTolerance);
|
||||||
for (var key in ol.MapBrowserEventType) {
|
for (var key in ol.MapBrowserEventType) {
|
||||||
ol.events.listen(this.mapBrowserEventHandler_, ol.MapBrowserEventType[key],
|
ol.events.listen(this.mapBrowserEventHandler_, ol.MapBrowserEventType[key],
|
||||||
this.handleMapBrowserEvent, this);
|
this.handleMapBrowserEvent, this);
|
||||||
@@ -1200,6 +1200,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
|||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
var view = this.getView();
|
var view = this.getView();
|
||||||
var extent = ol.extent.createEmpty();
|
var extent = ol.extent.createEmpty();
|
||||||
|
var previousFrameState = this.frameState_;
|
||||||
/** @type {?olx.FrameState} */
|
/** @type {?olx.FrameState} */
|
||||||
var frameState = null;
|
var frameState = null;
|
||||||
if (size !== undefined && ol.size.hasArea(size) && view && view.isDef()) {
|
if (size !== undefined && ol.size.hasArea(size) && view && view.isDef()) {
|
||||||
@@ -1249,7 +1250,19 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
|||||||
Array.prototype.push.apply(
|
Array.prototype.push.apply(
|
||||||
this.postRenderFunctions_, frameState.postRenderFunctions);
|
this.postRenderFunctions_, frameState.postRenderFunctions);
|
||||||
|
|
||||||
var idle = !frameState.viewHints[ol.ViewHint.ANIMATING] &&
|
if (previousFrameState) {
|
||||||
|
var moveStart = !this.previousExtent_ ||
|
||||||
|
(!ol.extent.isEmpty(this.previousExtent_) &&
|
||||||
|
!ol.extent.equals(frameState.extent, this.previousExtent_));
|
||||||
|
if (moveStart) {
|
||||||
|
this.dispatchEvent(
|
||||||
|
new ol.MapEvent(ol.MapEventType.MOVESTART, this, previousFrameState));
|
||||||
|
this.previousExtent_ = ol.extent.createOrUpdateEmpty(this.previousExtent_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var idle = this.previousExtent_ &&
|
||||||
|
!frameState.viewHints[ol.ViewHint.ANIMATING] &&
|
||||||
!frameState.viewHints[ol.ViewHint.INTERACTING] &&
|
!frameState.viewHints[ol.ViewHint.INTERACTING] &&
|
||||||
!ol.extent.equals(frameState.extent, this.previousExtent_);
|
!ol.extent.equals(frameState.extent, this.previousExtent_);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.MapBrowserEventHandler');
|
goog.provide('ol.MapBrowserEventHandler');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.has');
|
||||||
goog.require('ol.MapBrowserEventType');
|
goog.require('ol.MapBrowserEventType');
|
||||||
goog.require('ol.MapBrowserPointerEvent');
|
goog.require('ol.MapBrowserPointerEvent');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -11,10 +12,11 @@ goog.require('ol.pointer.PointerEventHandler');
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map The map with the viewport to listen to events on.
|
* @param {ol.Map} map The map with the viewport to listen to events on.
|
||||||
|
* @param {number|undefined} moveTolerance The minimal distance the pointer must travel to trigger a move.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.events.EventTarget}
|
* @extends {ol.events.EventTarget}
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler = function(map) {
|
ol.MapBrowserEventHandler = function(map, moveTolerance) {
|
||||||
|
|
||||||
ol.events.EventTarget.call(this);
|
ol.events.EventTarget.call(this);
|
||||||
|
|
||||||
@@ -43,6 +45,13 @@ ol.MapBrowserEventHandler = function(map) {
|
|||||||
*/
|
*/
|
||||||
this.dragListenerKeys_ = [];
|
this.dragListenerKeys_ = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.moveTolerance_ = moveTolerance ?
|
||||||
|
moveTolerance * ol.has.DEVICE_PIXEL_RATIO : ol.has.DEVICE_PIXEL_RATIO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most recent "down" type event (or null if none have occurred).
|
* The most recent "down" type event (or null if none have occurred).
|
||||||
* Set on pointerdown.
|
* Set on pointerdown.
|
||||||
@@ -241,11 +250,9 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent)
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
|
ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
|
||||||
// Fix IE10 on windows Surface : When you tap the tablet, it triggers
|
// Between pointerdown and pointerup, pointermove events are triggered.
|
||||||
// multiple pointermove events between pointerdown and pointerup with
|
// To avoid a 'false' touchmove event to be dispatched, we test if the pointer
|
||||||
// the exact same coordinates of the pointerdown event. To avoid a
|
// moved a significant distance.
|
||||||
// 'false' touchmove event to be dispatched , we test if the pointer
|
|
||||||
// effectively moved.
|
|
||||||
if (this.isMoving_(pointerEvent)) {
|
if (this.isMoving_(pointerEvent)) {
|
||||||
this.dragging_ = true;
|
this.dragging_ = true;
|
||||||
var newEvent = new ol.MapBrowserPointerEvent(
|
var newEvent = new ol.MapBrowserPointerEvent(
|
||||||
@@ -281,8 +288,8 @@ ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
|
ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
|
||||||
return pointerEvent.clientX != this.down_.clientX ||
|
return Math.abs(pointerEvent.clientX - this.down_.clientX) > this.moveTolerance_ ||
|
||||||
pointerEvent.clientY != this.down_.clientY;
|
Math.abs(pointerEvent.clientY - this.down_.clientY) > this.moveTolerance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,13 @@ ol.MapEventType = {
|
|||||||
*/
|
*/
|
||||||
POSTRENDER: 'postrender',
|
POSTRENDER: 'postrender',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when the map starts moving.
|
||||||
|
* @event ol.MapEvent#movestart
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
MOVESTART: 'movestart',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered after the map is moved.
|
* Triggered after the map is moved.
|
||||||
* @event ol.MapEvent#moveend
|
* @event ol.MapEvent#moveend
|
||||||
|
|||||||
@@ -31,17 +31,6 @@ ol.pointer.EventSource.prototype.getEvents = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a mapping between the supported event types and
|
|
||||||
* the handlers that should handle an event.
|
|
||||||
* @return {Object.<string, function(Event)>}
|
|
||||||
* Event/Handler mapping
|
|
||||||
*/
|
|
||||||
ol.pointer.EventSource.prototype.getMapping = function() {
|
|
||||||
return this.mapping_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the handler that should handle a given event type.
|
* Returns the handler that should handle a given event type.
|
||||||
* @param {string} eventType The event type.
|
* @param {string} eventType The event type.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.proj');
|
goog.provide('ol.proj');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.Sphere');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.proj.EPSG3857');
|
goog.require('ol.proj.EPSG3857');
|
||||||
goog.require('ol.proj.EPSG4326');
|
goog.require('ol.proj.EPSG4326');
|
||||||
@@ -9,7 +10,6 @@ goog.require('ol.proj.Units');
|
|||||||
goog.require('ol.proj.proj4');
|
goog.require('ol.proj.proj4');
|
||||||
goog.require('ol.proj.projections');
|
goog.require('ol.proj.projections');
|
||||||
goog.require('ol.proj.transforms');
|
goog.require('ol.proj.transforms');
|
||||||
goog.require('ol.sphere.NORMAL');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,14 @@ goog.require('ol.sphere.NORMAL');
|
|||||||
ol.proj.METERS_PER_UNIT = ol.proj.Units.METERS_PER_UNIT;
|
ol.proj.METERS_PER_UNIT = ol.proj.Units.METERS_PER_UNIT;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A place to store the radius of the Clarke 1866 Authalic Sphere.
|
||||||
|
* @private
|
||||||
|
* @type {ol.Sphere}
|
||||||
|
*/
|
||||||
|
ol.proj.AUTHALIC_SPHERE_ = new ol.Sphere(6370997);
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_PROJ4JS) {
|
if (ol.ENABLE_PROJ4JS) {
|
||||||
/**
|
/**
|
||||||
* Register proj4. If not explicitly registered, it will be assumed that
|
* Register proj4. If not explicitly registered, it will be assumed that
|
||||||
@@ -44,16 +52,22 @@ if (ol.ENABLE_PROJ4JS) {
|
|||||||
* Get the resolution of the point in degrees or distance units.
|
* Get the resolution of the point in degrees or distance units.
|
||||||
* For projections with degrees as the unit this will simply return the
|
* For projections with degrees as the unit this will simply return the
|
||||||
* provided resolution. For other projections the point resolution is
|
* provided resolution. For other projections the point resolution is
|
||||||
* estimated by transforming the 'point' pixel to EPSG:4326,
|
* by default estimated by transforming the 'point' pixel to EPSG:4326,
|
||||||
* measuring its width and height on the normal sphere,
|
* measuring its width and height on the normal sphere,
|
||||||
* and taking the average of the width and height.
|
* and taking the average of the width and height.
|
||||||
* @param {ol.proj.Projection} projection The projection.
|
* A custom function can be provided for a specific projection, either
|
||||||
|
* by setting the `getPointResolution` option in the
|
||||||
|
* {@link ol.proj.Projection} constructor or by using
|
||||||
|
* {@link ol.proj.Projection#setGetPointResolution} to change an existing
|
||||||
|
* projection object.
|
||||||
|
* @param {ol.ProjectionLike} projection The projection.
|
||||||
* @param {number} resolution Nominal resolution in projection units.
|
* @param {number} resolution Nominal resolution in projection units.
|
||||||
* @param {ol.Coordinate} point Point to find adjusted resolution at.
|
* @param {ol.Coordinate} point Point to find adjusted resolution at.
|
||||||
* @return {number} Point resolution at point in projection units.
|
* @return {number} Point resolution at point in projection units.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.proj.getPointResolution = function(projection, resolution, point) {
|
ol.proj.getPointResolution = function(projection, resolution, point) {
|
||||||
|
projection = ol.proj.get(projection);
|
||||||
var pointResolution;
|
var pointResolution;
|
||||||
var getter = projection.getPointResolutionFunc();
|
var getter = projection.getPointResolutionFunc();
|
||||||
if (getter) {
|
if (getter) {
|
||||||
@@ -74,9 +88,9 @@ ol.proj.getPointResolution = function(projection, resolution, point) {
|
|||||||
point[0], point[1] + resolution / 2
|
point[0], point[1] + resolution / 2
|
||||||
];
|
];
|
||||||
vertices = toEPSG4326(vertices, vertices, 2);
|
vertices = toEPSG4326(vertices, vertices, 2);
|
||||||
var width = ol.sphere.NORMAL.haversineDistance(
|
var width = ol.proj.AUTHALIC_SPHERE_.haversineDistance(
|
||||||
vertices.slice(0, 2), vertices.slice(2, 4));
|
vertices.slice(0, 2), vertices.slice(2, 4));
|
||||||
var height = ol.sphere.NORMAL.haversineDistance(
|
var height = ol.proj.AUTHALIC_SPHERE_.haversineDistance(
|
||||||
vertices.slice(4, 6), vertices.slice(6, 8));
|
vertices.slice(4, 6), vertices.slice(6, 8));
|
||||||
pointResolution = (width + height) / 2;
|
pointResolution = (width + height) / 2;
|
||||||
var metersPerUnit = projection.getMetersPerUnit();
|
var metersPerUnit = projection.getMetersPerUnit();
|
||||||
@@ -148,10 +162,7 @@ ol.proj.addProjection = function(projection) {
|
|||||||
* @param {Array.<ol.proj.Projection>} projections Projections.
|
* @param {Array.<ol.proj.Projection>} projections Projections.
|
||||||
*/
|
*/
|
||||||
ol.proj.addProjections = function(projections) {
|
ol.proj.addProjections = function(projections) {
|
||||||
var addedProjections = [];
|
projections.forEach(ol.proj.addProjection);
|
||||||
projections.forEach(function(projection) {
|
|
||||||
addedProjections.push(ol.proj.addProjection(projection));
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -288,9 +299,9 @@ ol.proj.get = function(projectionLike) {
|
|||||||
} else if (typeof projectionLike === 'string') {
|
} else if (typeof projectionLike === 'string') {
|
||||||
var code = projectionLike;
|
var code = projectionLike;
|
||||||
projection = ol.proj.projections.get(code);
|
projection = ol.proj.projections.get(code);
|
||||||
if (ol.ENABLE_PROJ4JS) {
|
if (ol.ENABLE_PROJ4JS && !projection) {
|
||||||
var proj4js = ol.proj.proj4.get();
|
var proj4js = ol.proj.proj4.get();
|
||||||
if (!projection && typeof proj4js == 'function' &&
|
if (typeof proj4js == 'function' &&
|
||||||
proj4js.defs(code) !== undefined) {
|
proj4js.defs(code) !== undefined) {
|
||||||
projection = new ol.proj.Projection({code: code});
|
projection = new ol.proj.Projection({code: code});
|
||||||
ol.proj.addProjection(projection);
|
ol.proj.addProjection(projection);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ ol.inherits(ol.proj.EPSG3857.Projection_, ol.proj.Projection);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Radius of WGS84 sphere
|
||||||
|
*
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ goog.provide('ol.proj.EPSG4326');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.proj.Projection');
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.proj.Units');
|
goog.require('ol.proj.Units');
|
||||||
goog.require('ol.sphere.WGS84');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,6 +33,15 @@ ol.proj.EPSG4326.Projection_ = function(code, opt_axisOrientation) {
|
|||||||
ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection);
|
ol.inherits(ol.proj.EPSG4326.Projection_, ol.proj.Projection);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Radius of WGS84 sphere
|
||||||
|
*
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
ol.proj.EPSG4326.RADIUS = 6378137;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extent of the EPSG:4326 projection which is the whole world.
|
* Extent of the EPSG:4326 projection which is the whole world.
|
||||||
*
|
*
|
||||||
@@ -47,7 +55,7 @@ ol.proj.EPSG4326.EXTENT = [-180, -90, 180, 90];
|
|||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.sphere.WGS84.radius / 180;
|
ol.proj.EPSG4326.METERS_PER_UNIT = Math.PI * ol.proj.EPSG4326.RADIUS / 180;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ ol.proj.Projection.prototype.setWorldExtent = function(worldExtent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the getPointResolution function for this projection.
|
* Set the getPointResolution function (see {@link ol.proj#getPointResolution}
|
||||||
|
* for this projection.
|
||||||
* @param {function(number, ol.Coordinate):number} func Function
|
* @param {function(number, ol.Coordinate):number} func Function
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
goog.provide('ol.proj.Units');
|
goog.provide('ol.proj.Units');
|
||||||
|
|
||||||
goog.require('ol.sphere.NORMAL');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or
|
* Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or
|
||||||
@@ -25,8 +23,9 @@ ol.proj.Units = {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.proj.Units.METERS_PER_UNIT = {};
|
ol.proj.Units.METERS_PER_UNIT = {};
|
||||||
|
// use the radius of the Normal sphere
|
||||||
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.DEGREES] =
|
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.DEGREES] =
|
||||||
2 * Math.PI * ol.sphere.NORMAL.radius / 360;
|
2 * Math.PI * 6370997 / 360;
|
||||||
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048;
|
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.FEET] = 0.3048;
|
||||||
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.METERS] = 1;
|
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.METERS] = 1;
|
||||||
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.USFEET] = 1200 / 3937;
|
ol.proj.Units.METERS_PER_UNIT[ol.proj.Units.USFEET] = 1200 / 3937;
|
||||||
|
|||||||
@@ -16,14 +16,21 @@ goog.require('ol.geom.GeometryType');
|
|||||||
* to be right-handed for polygons.
|
* to be right-handed for polygons.
|
||||||
* @param {Array.<number>|Array.<Array.<number>>} ends Ends or Endss.
|
* @param {Array.<number>|Array.<Array.<number>>} ends Ends or Endss.
|
||||||
* @param {Object.<string, *>} properties Properties.
|
* @param {Object.<string, *>} properties Properties.
|
||||||
|
* @param {number|string|undefined} id Feature id.
|
||||||
*/
|
*/
|
||||||
ol.render.Feature = function(type, flatCoordinates, ends, properties) {
|
ol.render.Feature = function(type, flatCoordinates, ends, properties, id) {
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Extent|undefined}
|
* @type {ol.Extent|undefined}
|
||||||
*/
|
*/
|
||||||
this.extent_;
|
this.extent_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number|string|undefined}
|
||||||
|
*/
|
||||||
|
this.id_ = id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.geom.GeometryType}
|
* @type {ol.geom.GeometryType}
|
||||||
@@ -85,6 +92,16 @@ ol.render.Feature.prototype.getExtent = function() {
|
|||||||
return this.extent_;
|
return this.extent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the feature identifier. This is a stable identifier for the feature and
|
||||||
|
* is set when reading data from a remote source.
|
||||||
|
* @return {number|string|undefined} Id.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.render.Feature.prototype.getId = function() {
|
||||||
|
return this.id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Array.<number>} Flat coordinates.
|
* @return {Array.<number>} Flat coordinates.
|
||||||
@@ -102,7 +119,8 @@ ol.render.Feature.prototype.getFlatCoordinates =
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the feature for working with its geometry.
|
* For API compatibility with {@link ol.Feature}, this method is useful when
|
||||||
|
* determining the geometry type in style function (see {@link #getType}).
|
||||||
* @return {ol.render.Feature} Feature.
|
* @return {ol.render.Feature} Feature.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,12 +5,20 @@ goog.require('ol');
|
|||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
if (ol.ENABLE_WEBGL) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.defaultFont = '10px sans-serif';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Color}
|
* @type {ol.Color}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
ol.render.webgl.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -51,6 +59,21 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
ol.render.webgl.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.defaultTextAlign = 0.5;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.defaultTextBaseline = 0.5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
|||||||
@@ -1,123 +1,34 @@
|
|||||||
goog.provide('ol.render.webgl.ImageReplay');
|
goog.provide('ol.render.webgl.ImageReplay');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.render.webgl.TextureReplay');
|
||||||
goog.require('ol.obj');
|
|
||||||
goog.require('ol.render.webgl.imagereplay.defaultshader');
|
|
||||||
goog.require('ol.render.webgl.Replay');
|
|
||||||
goog.require('ol.webgl');
|
|
||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
goog.require('ol.webgl.Context');
|
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
if (ol.ENABLE_WEBGL) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.Replay}
|
* @extends {ol.render.webgl.TextureReplay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.anchorX_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.anchorY_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array.<number>}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.groupIndices_ = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array.<number>}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.hitDetectionGroupIndices_ = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.height_ = undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>}
|
* @type {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.images_ = [];
|
this.images_ = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>}
|
* @type {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.hitDetectionImages_ = [];
|
this.hitDetectionImages_ = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.imageHeight_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.imageWidth_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {ol.render.webgl.imagereplay.defaultshader.Locations}
|
|
||||||
*/
|
|
||||||
this.defaultLocations_ = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {number|undefined}
|
|
||||||
*/
|
|
||||||
this.opacity_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.originX_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.originY_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {boolean|undefined}
|
|
||||||
*/
|
|
||||||
this.rotateWithView_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {number|undefined}
|
|
||||||
*/
|
|
||||||
this.rotation_ = undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {number|undefined}
|
|
||||||
*/
|
|
||||||
this.scale_ = undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<WebGLTexture>}
|
* @type {Array.<WebGLTexture>}
|
||||||
* @private
|
* @private
|
||||||
@@ -130,141 +41,8 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.hitDetectionTextures_ = [];
|
this.hitDetectionTextures_ = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number|undefined}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.width_ = undefined;
|
|
||||||
};
|
|
||||||
ol.inherits(ol.render.webgl.ImageReplay, ol.render.webgl.Replay);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction = function(context) {
|
|
||||||
var verticesBuffer = this.verticesBuffer;
|
|
||||||
var indicesBuffer = this.indicesBuffer;
|
|
||||||
var textures = this.textures_;
|
|
||||||
var hitDetectionTextures = this.hitDetectionTextures_;
|
|
||||||
var gl = context.getGL();
|
|
||||||
return function() {
|
|
||||||
if (!gl.isContextLost()) {
|
|
||||||
var i, ii;
|
|
||||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
|
||||||
gl.deleteTexture(textures[i]);
|
|
||||||
}
|
|
||||||
for (i = 0, ii = hitDetectionTextures.length; i < ii; ++i) {
|
|
||||||
gl.deleteTexture(hitDetectionTextures[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.deleteBuffer(verticesBuffer);
|
|
||||||
context.deleteBuffer(indicesBuffer);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
|
||||||
* @param {number} offset Offset.
|
|
||||||
* @param {number} end End.
|
|
||||||
* @param {number} stride Stride.
|
|
||||||
* @return {number} My end.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
|
||||||
var anchorX = /** @type {number} */ (this.anchorX_);
|
|
||||||
var anchorY = /** @type {number} */ (this.anchorY_);
|
|
||||||
var height = /** @type {number} */ (this.height_);
|
|
||||||
var imageHeight = /** @type {number} */ (this.imageHeight_);
|
|
||||||
var imageWidth = /** @type {number} */ (this.imageWidth_);
|
|
||||||
var opacity = /** @type {number} */ (this.opacity_);
|
|
||||||
var originX = /** @type {number} */ (this.originX_);
|
|
||||||
var originY = /** @type {number} */ (this.originY_);
|
|
||||||
var rotateWithView = this.rotateWithView_ ? 1.0 : 0.0;
|
|
||||||
// this.rotation_ is anti-clockwise, but rotation is clockwise
|
|
||||||
var rotation = /** @type {number} */ (-this.rotation_);
|
|
||||||
var scale = /** @type {number} */ (this.scale_);
|
|
||||||
var width = /** @type {number} */ (this.width_);
|
|
||||||
var cos = Math.cos(rotation);
|
|
||||||
var sin = Math.sin(rotation);
|
|
||||||
var numIndices = this.indices.length;
|
|
||||||
var numVertices = this.vertices.length;
|
|
||||||
var i, n, offsetX, offsetY, x, y;
|
|
||||||
for (i = offset; i < end; i += stride) {
|
|
||||||
x = flatCoordinates[i] - this.origin[0];
|
|
||||||
y = flatCoordinates[i + 1] - this.origin[1];
|
|
||||||
|
|
||||||
// There are 4 vertices per [x, y] point, one for each corner of the
|
|
||||||
// rectangle we're going to draw. We'd use 1 vertex per [x, y] point if
|
|
||||||
// WebGL supported Geometry Shaders (which can emit new vertices), but that
|
|
||||||
// is not currently the case.
|
|
||||||
//
|
|
||||||
// And each vertex includes 8 values: the x and y coordinates, the x and
|
|
||||||
// y offsets used to calculate the position of the corner, the u and
|
|
||||||
// v texture coordinates for the corner, the opacity, and whether the
|
|
||||||
// the image should be rotated with the view (rotateWithView).
|
|
||||||
|
|
||||||
n = numVertices / 8;
|
|
||||||
|
|
||||||
// bottom-left corner
|
|
||||||
offsetX = -scale * anchorX;
|
|
||||||
offsetY = -scale * (height - anchorY);
|
|
||||||
this.vertices[numVertices++] = x;
|
|
||||||
this.vertices[numVertices++] = y;
|
|
||||||
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
|
||||||
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
|
||||||
this.vertices[numVertices++] = originX / imageWidth;
|
|
||||||
this.vertices[numVertices++] = (originY + height) / imageHeight;
|
|
||||||
this.vertices[numVertices++] = opacity;
|
|
||||||
this.vertices[numVertices++] = rotateWithView;
|
|
||||||
|
|
||||||
// bottom-right corner
|
|
||||||
offsetX = scale * (width - anchorX);
|
|
||||||
offsetY = -scale * (height - anchorY);
|
|
||||||
this.vertices[numVertices++] = x;
|
|
||||||
this.vertices[numVertices++] = y;
|
|
||||||
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
|
||||||
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
|
||||||
this.vertices[numVertices++] = (originX + width) / imageWidth;
|
|
||||||
this.vertices[numVertices++] = (originY + height) / imageHeight;
|
|
||||||
this.vertices[numVertices++] = opacity;
|
|
||||||
this.vertices[numVertices++] = rotateWithView;
|
|
||||||
|
|
||||||
// top-right corner
|
|
||||||
offsetX = scale * (width - anchorX);
|
|
||||||
offsetY = scale * anchorY;
|
|
||||||
this.vertices[numVertices++] = x;
|
|
||||||
this.vertices[numVertices++] = y;
|
|
||||||
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
|
||||||
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
|
||||||
this.vertices[numVertices++] = (originX + width) / imageWidth;
|
|
||||||
this.vertices[numVertices++] = originY / imageHeight;
|
|
||||||
this.vertices[numVertices++] = opacity;
|
|
||||||
this.vertices[numVertices++] = rotateWithView;
|
|
||||||
|
|
||||||
// top-left corner
|
|
||||||
offsetX = -scale * anchorX;
|
|
||||||
offsetY = scale * anchorY;
|
|
||||||
this.vertices[numVertices++] = x;
|
|
||||||
this.vertices[numVertices++] = y;
|
|
||||||
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
|
||||||
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
|
||||||
this.vertices[numVertices++] = originX / imageWidth;
|
|
||||||
this.vertices[numVertices++] = originY / imageHeight;
|
|
||||||
this.vertices[numVertices++] = opacity;
|
|
||||||
this.vertices[numVertices++] = rotateWithView;
|
|
||||||
|
|
||||||
this.indices[numIndices++] = n;
|
|
||||||
this.indices[numIndices++] = n + 1;
|
|
||||||
this.indices[numIndices++] = n + 2;
|
|
||||||
this.indices[numIndices++] = n;
|
|
||||||
this.indices[numIndices++] = n + 2;
|
|
||||||
this.indices[numIndices++] = n + 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
return numVertices;
|
|
||||||
};
|
};
|
||||||
|
ol.inherits(ol.render.webgl.ImageReplay, ol.render.webgl.TextureReplay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -275,7 +53,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.startIndicesFeature.push(feature);
|
this.startIndicesFeature.push(feature);
|
||||||
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
||||||
var stride = multiPointGeometry.getStride();
|
var stride = multiPointGeometry.getStride();
|
||||||
this.drawCoordinates_(
|
this.drawCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -288,7 +66,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.startIndicesFeature.push(feature);
|
this.startIndicesFeature.push(feature);
|
||||||
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
||||||
var stride = pointGeometry.getStride();
|
var stride = pointGeometry.getStride();
|
||||||
this.drawCoordinates_(
|
this.drawCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -299,8 +77,8 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
this.groupIndices_.push(this.indices.length);
|
this.groupIndices.push(this.indices.length);
|
||||||
this.hitDetectionGroupIndices_.push(this.indices.length);
|
this.hitDetectionGroupIndices.push(this.indices.length);
|
||||||
|
|
||||||
// create, bind, and populate the vertices buffer
|
// create, bind, and populate the vertices buffer
|
||||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||||
@@ -314,246 +92,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
/** @type {Object.<string, WebGLTexture>} */
|
/** @type {Object.<string, WebGLTexture>} */
|
||||||
var texturePerImage = {};
|
var texturePerImage = {};
|
||||||
|
|
||||||
this.createTextures_(this.textures_, this.images_, texturePerImage, gl);
|
this.createTextures(this.textures_, this.images_, texturePerImage, gl);
|
||||||
|
|
||||||
this.createTextures_(this.hitDetectionTextures_, this.hitDetectionImages_,
|
this.createTextures(this.hitDetectionTextures_, this.hitDetectionImages_,
|
||||||
texturePerImage, gl);
|
texturePerImage, gl);
|
||||||
|
|
||||||
this.anchorX_ = undefined;
|
|
||||||
this.anchorY_ = undefined;
|
|
||||||
this.height_ = undefined;
|
|
||||||
this.images_ = null;
|
this.images_ = null;
|
||||||
this.hitDetectionImages_ = null;
|
this.hitDetectionImages_ = null;
|
||||||
this.imageHeight_ = undefined;
|
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
||||||
this.imageWidth_ = undefined;
|
|
||||||
this.indices = null;
|
|
||||||
this.opacity_ = undefined;
|
|
||||||
this.originX_ = undefined;
|
|
||||||
this.originY_ = undefined;
|
|
||||||
this.rotateWithView_ = undefined;
|
|
||||||
this.rotation_ = undefined;
|
|
||||||
this.scale_ = undefined;
|
|
||||||
this.vertices = null;
|
|
||||||
this.width_ = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {Array.<WebGLTexture>} textures Textures.
|
|
||||||
* @param {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>} images
|
|
||||||
* Images.
|
|
||||||
* @param {Object.<string, WebGLTexture>} texturePerImage Texture cache.
|
|
||||||
* @param {WebGLRenderingContext} gl Gl.
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.createTextures_ = function(textures, images, texturePerImage, gl) {
|
|
||||||
var texture, image, uid, i;
|
|
||||||
var ii = images.length;
|
|
||||||
for (i = 0; i < ii; ++i) {
|
|
||||||
image = images[i];
|
|
||||||
|
|
||||||
uid = ol.getUid(image).toString();
|
|
||||||
if (uid in texturePerImage) {
|
|
||||||
texture = texturePerImage[uid];
|
|
||||||
} else {
|
|
||||||
texture = ol.webgl.Context.createTexture(
|
|
||||||
gl, image, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE);
|
|
||||||
texturePerImage[uid] = texture;
|
|
||||||
}
|
|
||||||
textures[i] = texture;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
|
||||||
// get the program
|
|
||||||
var fragmentShader = ol.render.webgl.imagereplay.defaultshader.fragment;
|
|
||||||
var vertexShader = ol.render.webgl.imagereplay.defaultshader.vertex;
|
|
||||||
var program = context.getProgram(fragmentShader, vertexShader);
|
|
||||||
|
|
||||||
// get the locations
|
|
||||||
var locations;
|
|
||||||
if (!this.defaultLocations_) {
|
|
||||||
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
|
||||||
locations = new ol.render.webgl.imagereplay.defaultshader.Locations(gl, program);
|
|
||||||
this.defaultLocations_ = locations;
|
|
||||||
} else {
|
|
||||||
locations = this.defaultLocations_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use the program (FIXME: use the return value)
|
|
||||||
context.useProgram(program);
|
|
||||||
|
|
||||||
// enable the vertex attrib arrays
|
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
|
||||||
gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT,
|
|
||||||
false, 32, 0);
|
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_offsets);
|
|
||||||
gl.vertexAttribPointer(locations.a_offsets, 2, ol.webgl.FLOAT,
|
|
||||||
false, 32, 8);
|
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
|
||||||
gl.vertexAttribPointer(locations.a_texCoord, 2, ol.webgl.FLOAT,
|
|
||||||
false, 32, 16);
|
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_opacity);
|
|
||||||
gl.vertexAttribPointer(locations.a_opacity, 1, ol.webgl.FLOAT,
|
|
||||||
false, 32, 24);
|
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_rotateWithView);
|
|
||||||
gl.vertexAttribPointer(locations.a_rotateWithView, 1, ol.webgl.FLOAT,
|
|
||||||
false, 32, 28);
|
|
||||||
|
|
||||||
return locations;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.shutDownProgram = function(gl, locations) {
|
|
||||||
gl.disableVertexAttribArray(locations.a_position);
|
|
||||||
gl.disableVertexAttribArray(locations.a_offsets);
|
|
||||||
gl.disableVertexAttribArray(locations.a_texCoord);
|
|
||||||
gl.disableVertexAttribArray(locations.a_opacity);
|
|
||||||
gl.disableVertexAttribArray(locations.a_rotateWithView);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
|
||||||
var textures = hitDetection ? this.hitDetectionTextures_ : this.textures_;
|
|
||||||
var groupIndices = hitDetection ? this.hitDetectionGroupIndices_ : this.groupIndices_;
|
|
||||||
|
|
||||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
|
||||||
this.drawReplaySkipping_(
|
|
||||||
gl, context, skippedFeaturesHash, textures, groupIndices);
|
|
||||||
} else {
|
|
||||||
var i, ii, start;
|
|
||||||
for (i = 0, ii = textures.length, start = 0; i < ii; ++i) {
|
|
||||||
gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]);
|
|
||||||
var end = groupIndices[i];
|
|
||||||
this.drawElements(gl, context, start, end);
|
|
||||||
start = end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw the replay while paying attention to skipped features.
|
|
||||||
*
|
|
||||||
* This functions creates groups of features that can be drawn to together,
|
|
||||||
* so that the number of `drawElements` calls is minimized.
|
|
||||||
*
|
|
||||||
* For example given the following texture groups:
|
|
||||||
*
|
|
||||||
* Group 1: A B C
|
|
||||||
* Group 2: D [E] F G
|
|
||||||
*
|
|
||||||
* If feature E should be skipped, the following `drawElements` calls will be
|
|
||||||
* made:
|
|
||||||
*
|
|
||||||
* drawElements with feature A, B and C
|
|
||||||
* drawElements with feature D
|
|
||||||
* drawElements with feature F and G
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
|
||||||
* @param {ol.webgl.Context} context Context.
|
|
||||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
|
||||||
* to skip.
|
|
||||||
* @param {Array.<WebGLTexture>} textures Textures.
|
|
||||||
* @param {Array.<number>} groupIndices Texture group indices.
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash, textures,
|
|
||||||
groupIndices) {
|
|
||||||
var featureIndex = 0;
|
|
||||||
|
|
||||||
var i, ii;
|
|
||||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
|
||||||
gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]);
|
|
||||||
var groupStart = (i > 0) ? groupIndices[i - 1] : 0;
|
|
||||||
var groupEnd = groupIndices[i];
|
|
||||||
|
|
||||||
var start = groupStart;
|
|
||||||
var end = groupStart;
|
|
||||||
while (featureIndex < this.startIndices.length &&
|
|
||||||
this.startIndices[featureIndex] <= groupEnd) {
|
|
||||||
var feature = this.startIndicesFeature[featureIndex];
|
|
||||||
|
|
||||||
var featureUid = ol.getUid(feature).toString();
|
|
||||||
if (skippedFeaturesHash[featureUid] !== undefined) {
|
|
||||||
// feature should be skipped
|
|
||||||
if (start !== end) {
|
|
||||||
// draw the features so far
|
|
||||||
this.drawElements(gl, context, start, end);
|
|
||||||
}
|
|
||||||
// continue with the next feature
|
|
||||||
start = (featureIndex === this.startIndices.length - 1) ?
|
|
||||||
groupEnd : this.startIndices[featureIndex + 1];
|
|
||||||
end = start;
|
|
||||||
} else {
|
|
||||||
// the feature is not skipped, augment the end index
|
|
||||||
end = (featureIndex === this.startIndices.length - 1) ?
|
|
||||||
groupEnd : this.startIndices[featureIndex + 1];
|
|
||||||
}
|
|
||||||
featureIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (start !== end) {
|
|
||||||
// draw the remaining features (in case there was no skipped feature
|
|
||||||
// in this texture group, all features of a group are drawn together)
|
|
||||||
this.drawElements(gl, context, start, end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
|
||||||
featureCallback, opt_hitExtent) {
|
|
||||||
var i, groupStart, start, end, feature, featureUid;
|
|
||||||
var featureIndex = this.startIndices.length - 1;
|
|
||||||
for (i = this.hitDetectionTextures_.length - 1; i >= 0; --i) {
|
|
||||||
gl.bindTexture(ol.webgl.TEXTURE_2D, this.hitDetectionTextures_[i]);
|
|
||||||
groupStart = (i > 0) ? this.hitDetectionGroupIndices_[i - 1] : 0;
|
|
||||||
end = this.hitDetectionGroupIndices_[i];
|
|
||||||
|
|
||||||
// draw all features for this texture group
|
|
||||||
while (featureIndex >= 0 &&
|
|
||||||
this.startIndices[featureIndex] >= groupStart) {
|
|
||||||
start = this.startIndices[featureIndex];
|
|
||||||
feature = this.startIndicesFeature[featureIndex];
|
|
||||||
featureUid = ol.getUid(feature).toString();
|
|
||||||
|
|
||||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
|
||||||
feature.getGeometry() &&
|
|
||||||
(opt_hitExtent === undefined || ol.extent.intersects(
|
|
||||||
/** @type {Array<number>} */ (opt_hitExtent),
|
|
||||||
feature.getGeometry().getExtent()))) {
|
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
||||||
this.drawElements(gl, context, start, end);
|
|
||||||
|
|
||||||
var result = featureCallback(feature);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end = start;
|
|
||||||
featureIndex--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -578,7 +124,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
} else {
|
} else {
|
||||||
currentImage = this.images_[this.images_.length - 1];
|
currentImage = this.images_[this.images_.length - 1];
|
||||||
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
||||||
this.groupIndices_.push(this.indices.length);
|
this.groupIndices.push(this.indices.length);
|
||||||
this.images_.push(image);
|
this.images_.push(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,23 +135,39 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
currentImage =
|
currentImage =
|
||||||
this.hitDetectionImages_[this.hitDetectionImages_.length - 1];
|
this.hitDetectionImages_[this.hitDetectionImages_.length - 1];
|
||||||
if (ol.getUid(currentImage) != ol.getUid(hitDetectionImage)) {
|
if (ol.getUid(currentImage) != ol.getUid(hitDetectionImage)) {
|
||||||
this.hitDetectionGroupIndices_.push(this.indices.length);
|
this.hitDetectionGroupIndices.push(this.indices.length);
|
||||||
this.hitDetectionImages_.push(hitDetectionImage);
|
this.hitDetectionImages_.push(hitDetectionImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.anchorX_ = anchor[0];
|
this.anchorX = anchor[0];
|
||||||
this.anchorY_ = anchor[1];
|
this.anchorY = anchor[1];
|
||||||
this.height_ = size[1];
|
this.height = size[1];
|
||||||
this.imageHeight_ = imageSize[1];
|
this.imageHeight = imageSize[1];
|
||||||
this.imageWidth_ = imageSize[0];
|
this.imageWidth = imageSize[0];
|
||||||
this.opacity_ = opacity;
|
this.opacity = opacity;
|
||||||
this.originX_ = origin[0];
|
this.originX = origin[0];
|
||||||
this.originY_ = origin[1];
|
this.originY = origin[1];
|
||||||
this.rotation_ = rotation;
|
this.rotation = rotation;
|
||||||
this.rotateWithView_ = rotateWithView;
|
this.rotateWithView = rotateWithView;
|
||||||
this.scale_ = scale;
|
this.scale = scale;
|
||||||
this.width_ = size[0];
|
this.width = size[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) {
|
||||||
|
return opt_all ? this.textures_.concat(this.hitDetectionTextures_) : this.textures_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.ImageReplay.prototype.getHitDetectionTextures = function() {
|
||||||
|
return this.hitDetectionTextures_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,154 +0,0 @@
|
|||||||
// This file is automatically generated, do not edit
|
|
||||||
/* eslint openlayers-internal/no-missing-requires: 0 */
|
|
||||||
goog.provide('ol.render.webgl.imagereplay.defaultshader');
|
|
||||||
|
|
||||||
goog.require('ol');
|
|
||||||
goog.require('ol.webgl.Fragment');
|
|
||||||
goog.require('ol.webgl.Vertex');
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.webgl.Fragment}
|
|
||||||
* @struct
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Fragment = function() {
|
|
||||||
ol.webgl.Fragment.call(this, ol.render.webgl.imagereplay.defaultshader.Fragment.SOURCE);
|
|
||||||
};
|
|
||||||
ol.inherits(ol.render.webgl.imagereplay.defaultshader.Fragment, ol.webgl.Fragment);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Fragment.DEBUG_SOURCE :
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.fragment = new ol.render.webgl.imagereplay.defaultshader.Fragment();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.webgl.Vertex}
|
|
||||||
* @struct
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Vertex = function() {
|
|
||||||
ol.webgl.Vertex.call(this, ol.render.webgl.imagereplay.defaultshader.Vertex.SOURCE);
|
|
||||||
};
|
|
||||||
ol.inherits(ol.render.webgl.imagereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Vertex.DEBUG_SOURCE :
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.vertex = new ol.render.webgl.imagereplay.defaultshader.Vertex();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
|
||||||
* @param {WebGLProgram} program Program.
|
|
||||||
* @struct
|
|
||||||
*/
|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Locations = function(gl, program) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {WebGLUniformLocation}
|
|
||||||
*/
|
|
||||||
this.u_image = gl.getUniformLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'u_image' : 'l');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {WebGLUniformLocation}
|
|
||||||
*/
|
|
||||||
this.u_offsetRotateMatrix = gl.getUniformLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {WebGLUniformLocation}
|
|
||||||
*/
|
|
||||||
this.u_offsetScaleMatrix = gl.getUniformLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {WebGLUniformLocation}
|
|
||||||
*/
|
|
||||||
this.u_opacity = gl.getUniformLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'u_opacity' : 'k');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {WebGLUniformLocation}
|
|
||||||
*/
|
|
||||||
this.u_projectionMatrix = gl.getUniformLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.a_offsets = gl.getAttribLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'a_offsets' : 'e');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.a_opacity = gl.getAttribLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'a_opacity' : 'f');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.a_position = gl.getAttribLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'a_position' : 'c');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.a_rotateWithView = gl.getAttribLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'a_rotateWithView' : 'g');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.a_texCoord = gl.getAttribLocation(
|
|
||||||
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'd');
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -324,16 +324,19 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||||
var indexCount = this.indices.length;
|
var indexCount = this.indices.length;
|
||||||
var lineStringGeometries = multiLineStringGeometry.getLineStrings();
|
var ends = multiLineStringGeometry.getEnds();
|
||||||
|
ends.unshift(0);
|
||||||
|
var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
|
||||||
|
var stride = multiLineStringGeometry.getStride();
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = lineStringGeometries.length; i < ii; ++i) {
|
if (ends.length > 1) {
|
||||||
var flatCoordinates = lineStringGeometries[i].getFlatCoordinates();
|
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||||
var stride = lineStringGeometries[i].getStride();
|
if (this.isValid_(flatCoordinates, ends[i - 1], ends[i], stride)) {
|
||||||
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
var lineString = ol.geom.flat.transform.translate(flatCoordinates, ends[i - 1], ends[i],
|
||||||
flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, flatCoordinates.length,
|
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
this.drawCoordinates_(
|
this.drawCoordinates_(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
lineString, 0, lineString.length, stride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.indices.length > indexCount) {
|
if (this.indices.length > indexCount) {
|
||||||
|
|||||||
@@ -88,20 +88,39 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
|
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
|
||||||
var holeList = {
|
var holeList = {
|
||||||
list: new ol.structs.LinkedList(),
|
list: new ol.structs.LinkedList(),
|
||||||
maxX: undefined
|
maxX: undefined,
|
||||||
|
rtree: new ol.structs.RBush()
|
||||||
};
|
};
|
||||||
holeLists.push(holeList);
|
holeLists.push(holeList);
|
||||||
holeList.maxX = this.processFlatCoordinates_(holeFlatCoordinates[i],
|
holeList.maxX = this.processFlatCoordinates_(holeFlatCoordinates[i],
|
||||||
stride, holeList.list, rtree, false);
|
stride, holeList.list, holeList.rtree, false);
|
||||||
}
|
}
|
||||||
holeLists.sort(function(a, b) {
|
holeLists.sort(function(a, b) {
|
||||||
return b.maxX - a.maxX;
|
return b.maxX[0] === a.maxX[0] ? a.maxX[1] - b.maxX[1] : b.maxX[0] - a.maxX[0];
|
||||||
});
|
});
|
||||||
for (i = 0; i < holeLists.length; ++i) {
|
for (i = 0; i < holeLists.length; ++i) {
|
||||||
this.bridgeHole_(holeLists[i].list, holeLists[i].maxX, outerRing, maxX, rtree);
|
var currList = holeLists[i].list;
|
||||||
}
|
var start = currList.firstItem();
|
||||||
|
var currItem = start;
|
||||||
|
var intersection;
|
||||||
|
do {
|
||||||
|
if (this.getIntersections_(currItem, rtree).length) {
|
||||||
|
intersection = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
currItem = currList.nextItem();
|
||||||
|
} while (start !== currItem);
|
||||||
|
if (!intersection) {
|
||||||
|
this.classifyPoints_(currList, holeLists[i].rtree, true);
|
||||||
|
if (this.bridgeHole_(currList, holeLists[i].maxX[0], outerRing, maxX[0], rtree)) {
|
||||||
|
rtree.concat(holeLists[i].rtree);
|
||||||
this.classifyPoints_(outerRing, rtree, false);
|
this.classifyPoints_(outerRing, rtree, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.classifyPoints_(outerRing, rtree, false);
|
||||||
|
}
|
||||||
this.triangulate_(outerRing, rtree);
|
this.triangulate_(outerRing, rtree);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,13 +133,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.structs.LinkedList} list Linked list.
|
* @param {ol.structs.LinkedList} list Linked list.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
* @param {boolean} clockwise Coordinate order should be clockwise.
|
* @param {boolean} clockwise Coordinate order should be clockwise.
|
||||||
* @return {number} Maximum X value.
|
* @return {Array.<number>} X and Y coords of maximum X value.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
||||||
flatCoordinates, stride, list, rtree, clockwise) {
|
flatCoordinates, stride, list, rtree, clockwise) {
|
||||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates,
|
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates,
|
||||||
0, flatCoordinates.length, stride);
|
0, flatCoordinates.length, stride);
|
||||||
var i, ii, maxX;
|
var i, ii, maxXX, maxXY;
|
||||||
var n = this.vertices.length / 2;
|
var n = this.vertices.length / 2;
|
||||||
/** @type {ol.WebglPolygonVertex} */
|
/** @type {ol.WebglPolygonVertex} */
|
||||||
var start;
|
var start;
|
||||||
@@ -133,13 +152,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
if (clockwise === isClockwise) {
|
if (clockwise === isClockwise) {
|
||||||
start = this.createPoint_(flatCoordinates[0], flatCoordinates[1], n++);
|
start = this.createPoint_(flatCoordinates[0], flatCoordinates[1], n++);
|
||||||
p0 = start;
|
p0 = start;
|
||||||
maxX = flatCoordinates[0];
|
maxXX = flatCoordinates[0];
|
||||||
|
maxXY = flatCoordinates[1];
|
||||||
for (i = stride, ii = flatCoordinates.length; i < ii; i += stride) {
|
for (i = stride, ii = flatCoordinates.length; i < ii; i += stride) {
|
||||||
p1 = this.createPoint_(flatCoordinates[i], flatCoordinates[i + 1], n++);
|
p1 = this.createPoint_(flatCoordinates[i], flatCoordinates[i + 1], n++);
|
||||||
segments.push(this.insertItem_(p0, p1, list));
|
segments.push(this.insertItem_(p0, p1, list));
|
||||||
extents.push([Math.min(p0.x, p1.x), Math.min(p0.y, p1.y), Math.max(p0.x, p1.x),
|
extents.push([Math.min(p0.x, p1.x), Math.min(p0.y, p1.y), Math.max(p0.x, p1.x),
|
||||||
Math.max(p0.y, p1.y)]);
|
Math.max(p0.y, p1.y)]);
|
||||||
maxX = flatCoordinates[i] > maxX ? flatCoordinates[i] : maxX;
|
if (flatCoordinates[i] > maxXX) {
|
||||||
|
maxXX = flatCoordinates[i];
|
||||||
|
maxXY = flatCoordinates[i + 1];
|
||||||
|
}
|
||||||
p0 = p1;
|
p0 = p1;
|
||||||
}
|
}
|
||||||
segments.push(this.insertItem_(p1, start, list));
|
segments.push(this.insertItem_(p1, start, list));
|
||||||
@@ -149,13 +172,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var end = flatCoordinates.length - stride;
|
var end = flatCoordinates.length - stride;
|
||||||
start = this.createPoint_(flatCoordinates[end], flatCoordinates[end + 1], n++);
|
start = this.createPoint_(flatCoordinates[end], flatCoordinates[end + 1], n++);
|
||||||
p0 = start;
|
p0 = start;
|
||||||
maxX = flatCoordinates[end];
|
maxXX = flatCoordinates[end];
|
||||||
|
maxXY = flatCoordinates[end + 1];
|
||||||
for (i = end - stride, ii = 0; i >= ii; i -= stride) {
|
for (i = end - stride, ii = 0; i >= ii; i -= stride) {
|
||||||
p1 = this.createPoint_(flatCoordinates[i], flatCoordinates[i + 1], n++);
|
p1 = this.createPoint_(flatCoordinates[i], flatCoordinates[i + 1], n++);
|
||||||
segments.push(this.insertItem_(p0, p1, list));
|
segments.push(this.insertItem_(p0, p1, list));
|
||||||
extents.push([Math.min(p0.x, p1.x), Math.min(p0.y, p1.y), Math.max(p0.x, p1.x),
|
extents.push([Math.min(p0.x, p1.x), Math.min(p0.y, p1.y), Math.max(p0.x, p1.x),
|
||||||
Math.max(p0.y, p1.y)]);
|
Math.max(p0.y, p1.y)]);
|
||||||
maxX = flatCoordinates[i] > maxX ? flatCoordinates[i] : maxX;
|
if (flatCoordinates[i] > maxXX) {
|
||||||
|
maxXX = flatCoordinates[i];
|
||||||
|
maxXY = flatCoordinates[i + 1];
|
||||||
|
}
|
||||||
p0 = p1;
|
p0 = p1;
|
||||||
}
|
}
|
||||||
segments.push(this.insertItem_(p1, start, list));
|
segments.push(this.insertItem_(p1, start, list));
|
||||||
@@ -164,7 +191,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
rtree.load(extents, segments);
|
rtree.load(extents, segments);
|
||||||
|
|
||||||
return maxX;
|
return [maxXX, maxXY];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -212,10 +239,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @param {number} listMaxX Maximum X value of the polygon.
|
* @param {number} listMaxX Maximum X value of the polygon.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
|
* @return {boolean} Bridging was successful.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||||
list, listMaxX, rtree) {
|
list, listMaxX, rtree) {
|
||||||
this.classifyPoints_(hole, rtree, true);
|
|
||||||
var seg = hole.firstItem();
|
var seg = hole.firstItem();
|
||||||
while (seg.p1.x !== holeMaxX) {
|
while (seg.p1.x !== holeMaxX) {
|
||||||
seg = hole.nextItem();
|
seg = hole.nextItem();
|
||||||
@@ -232,19 +259,18 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var intersectingSegments = this.getIntersections_({p0: p1, p1: p2}, rtree, true);
|
var intersectingSegments = this.getIntersections_({p0: p1, p1: p2}, rtree, true);
|
||||||
for (i = 0, ii = intersectingSegments.length; i < ii; ++i) {
|
for (i = 0, ii = intersectingSegments.length; i < ii; ++i) {
|
||||||
var currSeg = intersectingSegments[i];
|
var currSeg = intersectingSegments[i];
|
||||||
if (currSeg.p0.reflex === undefined) {
|
|
||||||
var intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
|
var intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
|
||||||
currSeg.p1, true);
|
currSeg.p1, true);
|
||||||
var dist = Math.abs(p1.x - intersection[0]);
|
var dist = Math.abs(p1.x - intersection[0]);
|
||||||
if (dist < minDist) {
|
if (dist < minDist && ol.render.webgl.triangleIsCounterClockwise(p1.x, p1.y,
|
||||||
|
currSeg.p0.x, currSeg.p0.y, currSeg.p1.x, currSeg.p1.y) !== undefined) {
|
||||||
minDist = dist;
|
minDist = dist;
|
||||||
p5 = {x: intersection[0], y: intersection[1], i: -1};
|
p5 = {x: intersection[0], y: intersection[1], i: -1};
|
||||||
seg = currSeg;
|
seg = currSeg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (minDist === Infinity) {
|
if (minDist === Infinity) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
bestPoint = seg.p1;
|
bestPoint = seg.p1;
|
||||||
|
|
||||||
@@ -264,7 +290,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
seg = list.firstItem();
|
seg = list.firstItem();
|
||||||
while (seg.p1 !== bestPoint) {
|
while (seg.p1.x !== bestPoint.x || seg.p1.y !== bestPoint.y) {
|
||||||
seg = list.nextItem();
|
seg = list.nextItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +304,8 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
seg.p1 = p1Bridge;
|
seg.p1 = p1Bridge;
|
||||||
hole.setFirstItem();
|
hole.setFirstItem();
|
||||||
list.concat(hole);
|
list.concat(hole);
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -712,28 +740,33 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||||
var polygons = multiPolygonGeometry.getPolygons();
|
var endss = multiPolygonGeometry.getEndss();
|
||||||
var stride = multiPolygonGeometry.getStride();
|
var stride = multiPolygonGeometry.getStride();
|
||||||
var currIndex = this.indices.length;
|
var currIndex = this.indices.length;
|
||||||
var currLineIndex = this.lineStringReplay.getCurrentIndex();
|
var currLineIndex = this.lineStringReplay.getCurrentIndex();
|
||||||
|
var flatCoordinates = multiPolygonGeometry.getFlatCoordinates();
|
||||||
var i, ii, j, jj;
|
var i, ii, j, jj;
|
||||||
for (i = 0, ii = polygons.length; i < ii; ++i) {
|
var start = 0;
|
||||||
var linearRings = polygons[i].getLinearRings();
|
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||||
if (linearRings.length > 0) {
|
var ends = endss[i];
|
||||||
var flatCoordinates = linearRings[0].getFlatCoordinates();
|
if (ends.length > 0) {
|
||||||
flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, flatCoordinates.length,
|
var outerRing = ol.geom.flat.transform.translate(flatCoordinates, start, ends[0],
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
|
if (outerRing.length) {
|
||||||
var holes = [];
|
var holes = [];
|
||||||
var holeFlatCoords;
|
var holeFlatCoords;
|
||||||
for (j = 1, jj = linearRings.length; j < jj; ++j) {
|
for (j = 1, jj = ends.length; j < jj; ++j) {
|
||||||
holeFlatCoords = linearRings[j].getFlatCoordinates();
|
if (ends[j] !== ends[j - 1]) {
|
||||||
holeFlatCoords = ol.geom.flat.transform.translate(holeFlatCoords, 0, holeFlatCoords.length,
|
holeFlatCoords = ol.geom.flat.transform.translate(flatCoordinates, ends[j - 1],
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
ends[j], stride, -this.origin[0], -this.origin[1]);
|
||||||
holes.push(holeFlatCoords);
|
holes.push(holeFlatCoords);
|
||||||
}
|
}
|
||||||
this.lineStringReplay.drawPolygonCoordinates(flatCoordinates, holes, stride);
|
|
||||||
this.drawCoordinates_(flatCoordinates, holes, stride);
|
|
||||||
}
|
}
|
||||||
|
this.lineStringReplay.drawPolygonCoordinates(outerRing, holes, stride);
|
||||||
|
this.drawCoordinates_(outerRing, holes, stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start = ends[ends.length - 1];
|
||||||
}
|
}
|
||||||
if (this.indices.length > currIndex) {
|
if (this.indices.length > currIndex) {
|
||||||
this.startIndices.push(currIndex);
|
this.startIndices.push(currIndex);
|
||||||
@@ -753,9 +786,23 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||||
var linearRings = polygonGeometry.getLinearRings();
|
var ends = polygonGeometry.getEnds();
|
||||||
var stride = polygonGeometry.getStride();
|
var stride = polygonGeometry.getStride();
|
||||||
if (linearRings.length > 0) {
|
if (ends.length > 0) {
|
||||||
|
var flatCoordinates = polygonGeometry.getFlatCoordinates().map(Number);
|
||||||
|
var outerRing = ol.geom.flat.transform.translate(flatCoordinates, 0, ends[0],
|
||||||
|
stride, -this.origin[0], -this.origin[1]);
|
||||||
|
if (outerRing.length) {
|
||||||
|
var holes = [];
|
||||||
|
var i, ii, holeFlatCoords;
|
||||||
|
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||||
|
if (ends[i] !== ends[i - 1]) {
|
||||||
|
holeFlatCoords = ol.geom.flat.transform.translate(flatCoordinates, ends[i - 1],
|
||||||
|
ends[i], stride, -this.origin[0], -this.origin[1]);
|
||||||
|
holes.push(holeFlatCoords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.startIndices.push(this.indices.length);
|
this.startIndices.push(this.indices.length);
|
||||||
this.startIndicesFeature.push(feature);
|
this.startIndicesFeature.push(feature);
|
||||||
if (this.state_.changed) {
|
if (this.state_.changed) {
|
||||||
@@ -764,19 +811,9 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
this.lineStringReplay.setPolygonStyle(feature);
|
this.lineStringReplay.setPolygonStyle(feature);
|
||||||
|
|
||||||
var flatCoordinates = linearRings[0].getFlatCoordinates();
|
this.lineStringReplay.drawPolygonCoordinates(outerRing, holes, stride);
|
||||||
flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, flatCoordinates.length,
|
this.drawCoordinates_(outerRing, holes, stride);
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
|
||||||
var holes = [];
|
|
||||||
var i, ii, holeFlatCoords;
|
|
||||||
for (i = 1, ii = linearRings.length; i < ii; ++i) {
|
|
||||||
holeFlatCoords = linearRings[i].getFlatCoordinates();
|
|
||||||
holeFlatCoords = ol.geom.flat.transform.translate(holeFlatCoords, 0, holeFlatCoords.length,
|
|
||||||
stride, -this.origin[0], -this.origin[1]);
|
|
||||||
holes.push(holeFlatCoords);
|
|
||||||
}
|
}
|
||||||
this.lineStringReplay.drawPolygonCoordinates(flatCoordinates, holes, stride);
|
|
||||||
this.drawCoordinates_(flatCoordinates, holes, stride);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -140,9 +140,9 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.Size} size Size.
|
* @param {ol.Size} size Size.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @return {ol.render.webgl.circlereplay.defaultshader.Locations|
|
* @return {ol.render.webgl.circlereplay.defaultshader.Locations|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Locations|
|
|
||||||
ol.render.webgl.linestringreplay.defaultshader.Locations|
|
ol.render.webgl.linestringreplay.defaultshader.Locations|
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Locations} Locations.
|
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Locations} Locations.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {};
|
ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {};
|
||||||
|
|
||||||
@@ -152,9 +152,9 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.render.webgl.circlereplay.defaultshader.Locations|
|
* @param {ol.render.webgl.circlereplay.defaultshader.Locations|
|
||||||
ol.render.webgl.imagereplay.defaultshader.Locations|
|
|
||||||
ol.render.webgl.linestringreplay.defaultshader.Locations|
|
ol.render.webgl.linestringreplay.defaultshader.Locations|
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Locations} locations Locations.
|
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Locations} locations Locations.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {};
|
ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {};
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +1,455 @@
|
|||||||
goog.provide('ol.render.webgl.TextReplay');
|
goog.provide('ol.render.webgl.TextReplay');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.colorlike');
|
||||||
|
goog.require('ol.dom');
|
||||||
|
goog.require('ol.has');
|
||||||
|
goog.require('ol.render.webgl');
|
||||||
|
goog.require('ol.render.webgl.TextureReplay');
|
||||||
|
goog.require('ol.style.AtlasManager');
|
||||||
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
if (ol.ENABLE_WEBGL) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @abstract
|
* @extends {ol.render.webgl.TextureReplay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay = function(tolerance, maxExtent) {};
|
ol.render.webgl.TextReplay = function(tolerance, maxExtent) {
|
||||||
|
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.style.Text} textStyle Text style.
|
* @private
|
||||||
|
* @type {Array.<HTMLCanvasElement>}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {};
|
this.images_ = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @private
|
||||||
* @param {ol.Coordinate} center Center.
|
* @type {Array.<WebGLTexture>}
|
||||||
* @param {number} resolution Resolution.
|
|
||||||
* @param {number} rotation Rotation.
|
|
||||||
* @param {ol.Size} size Size.
|
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
|
||||||
* @param {number} opacity Global opacity.
|
|
||||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
|
||||||
* to skip.
|
|
||||||
* @param {function((ol.Feature|ol.render.Feature)): T|undefined} featureCallback Feature callback.
|
|
||||||
* @param {boolean} oneByOne Draw features one-by-one for the hit-detecion.
|
|
||||||
* @param {ol.Extent=} opt_hitExtent Hit extent: Only features intersecting
|
|
||||||
* this extent are checked.
|
|
||||||
* @return {T|undefined} Callback result.
|
|
||||||
* @template T
|
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.replay = function(context,
|
this.textures_ = [];
|
||||||
center, resolution, rotation, size, pixelRatio,
|
|
||||||
opacity, skippedFeaturesHash,
|
/**
|
||||||
featureCallback, oneByOne, opt_hitExtent) {
|
* @private
|
||||||
return undefined;
|
* @type {HTMLCanvasElement}
|
||||||
|
*/
|
||||||
|
this.measureCanvas_ = ol.dom.createCanvasContext2D(0, 0).canvas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {{strokeColor: (ol.ColorLike|null),
|
||||||
|
* lineCap: (string|undefined),
|
||||||
|
* lineDash: Array.<number>,
|
||||||
|
* lineDashOffset: (number|undefined),
|
||||||
|
* lineJoin: (string|undefined),
|
||||||
|
* lineWidth: number,
|
||||||
|
* miterLimit: (number|undefined),
|
||||||
|
* fillColor: (ol.ColorLike|null),
|
||||||
|
* font: (string|undefined),
|
||||||
|
* scale: (number|undefined)}}
|
||||||
|
*/
|
||||||
|
this.state_ = {
|
||||||
|
strokeColor: null,
|
||||||
|
lineCap: undefined,
|
||||||
|
lineDash: null,
|
||||||
|
lineDashOffset: undefined,
|
||||||
|
lineJoin: undefined,
|
||||||
|
lineWidth: 0,
|
||||||
|
miterLimit: undefined,
|
||||||
|
fillColor: null,
|
||||||
|
font: undefined,
|
||||||
|
scale: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.text_ = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.textAlign_ = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.textBaseline_ = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.offsetX_ = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.offsetY_ = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, ol.WebglGlyphAtlas>}
|
||||||
|
*/
|
||||||
|
this.atlases_ = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.WebglGlyphAtlas|undefined}
|
||||||
|
*/
|
||||||
|
this.currAtlas_ = undefined;
|
||||||
|
|
||||||
|
this.scale = 1;
|
||||||
|
|
||||||
|
this.opacity = 1;
|
||||||
|
|
||||||
|
};
|
||||||
|
ol.inherits(ol.render.webgl.TextReplay, ol.render.webgl.TextureReplay);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.drawText = function(flatCoordinates, offset,
|
||||||
|
end, stride, geometry, feature) {
|
||||||
|
if (this.text_) {
|
||||||
|
this.startIndices.push(this.indices.length);
|
||||||
|
this.startIndicesFeature.push(feature);
|
||||||
|
|
||||||
|
var glyphAtlas = this.currAtlas_;
|
||||||
|
var lines = this.text_.split('\n');
|
||||||
|
var textSize = this.getTextSize_(lines);
|
||||||
|
var i, ii, j, jj, currX, currY, charArr, charInfo;
|
||||||
|
var anchorX = Math.round(textSize[0] * this.textAlign_ + this.offsetX_);
|
||||||
|
var anchorY = Math.round(textSize[1] * this.textBaseline_ + this.offsetY_);
|
||||||
|
var lineWidth = (this.state_.lineWidth / 2) * this.state_.scale;
|
||||||
|
|
||||||
|
for (i = 0, ii = lines.length; i < ii; ++i) {
|
||||||
|
currX = 0;
|
||||||
|
currY = glyphAtlas.height * i;
|
||||||
|
charArr = lines[i].split('');
|
||||||
|
|
||||||
|
for (j = 0, jj = charArr.length; j < jj; ++j) {
|
||||||
|
charInfo = glyphAtlas.atlas.getInfo(charArr[j]);
|
||||||
|
|
||||||
|
if (charInfo) {
|
||||||
|
var image = charInfo.image;
|
||||||
|
|
||||||
|
this.anchorX = anchorX - currX;
|
||||||
|
this.anchorY = anchorY - currY;
|
||||||
|
this.originX = j === 0 ? charInfo.offsetX - lineWidth : charInfo.offsetX;
|
||||||
|
this.originY = charInfo.offsetY;
|
||||||
|
this.height = glyphAtlas.height;
|
||||||
|
this.width = j === 0 || j === charArr.length - 1 ?
|
||||||
|
glyphAtlas.width[charArr[j]] + lineWidth : glyphAtlas.width[charArr[j]];
|
||||||
|
this.imageHeight = image.height;
|
||||||
|
this.imageWidth = image.width;
|
||||||
|
|
||||||
|
var currentImage;
|
||||||
|
if (this.images_.length === 0) {
|
||||||
|
this.images_.push(image);
|
||||||
|
} else {
|
||||||
|
currentImage = this.images_[this.images_.length - 1];
|
||||||
|
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
||||||
|
this.groupIndices.push(this.indices.length);
|
||||||
|
this.images_.push(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.drawText_(flatCoordinates, offset, end, stride);
|
||||||
|
}
|
||||||
|
currX += this.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {Array.<string>} lines Label to draw split to lines.
|
||||||
|
* @return {Array.<number>} Size of the label in pixels.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) {
|
||||||
|
var self = this;
|
||||||
|
var glyphAtlas = this.currAtlas_;
|
||||||
|
var textHeight = lines.length * glyphAtlas.height;
|
||||||
|
//Split every line to an array of chars, sum up their width, and select the longest.
|
||||||
|
var textWidth = lines.map(function(str) {
|
||||||
|
var sum = 0;
|
||||||
|
var i, ii;
|
||||||
|
for (i = 0, ii = str.length; i < ii; ++i) {
|
||||||
|
var curr = str[i];
|
||||||
|
if (!glyphAtlas.width[curr]) {
|
||||||
|
self.addCharToAtlas_(curr);
|
||||||
|
}
|
||||||
|
sum += glyphAtlas.width[curr] ? glyphAtlas.width[curr] : 0;
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}).reduce(function(max, curr) {
|
||||||
|
return Math.max(max, curr);
|
||||||
|
});
|
||||||
|
|
||||||
|
return [textWidth, textHeight];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
|
||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.drawText = function(flatCoordinates, offset,
|
ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offset,
|
||||||
end, stride, geometry, feature) {};
|
end, stride) {
|
||||||
|
var i, ii;
|
||||||
|
for (i = offset, ii = end; i < ii; i += stride) {
|
||||||
|
this.drawCoordinates(flatCoordinates, offset, end, stride);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @private
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {string} char Character.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.finish = function(context) {};
|
ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) {
|
||||||
|
if (char.length === 1) {
|
||||||
|
var glyphAtlas = this.currAtlas_;
|
||||||
|
var state = this.state_;
|
||||||
|
var mCtx = this.measureCanvas_.getContext('2d');
|
||||||
|
mCtx.font = state.font;
|
||||||
|
var width = Math.ceil(mCtx.measureText(char).width * state.scale);
|
||||||
|
|
||||||
|
var info = glyphAtlas.atlas.add(char, width, glyphAtlas.height,
|
||||||
|
function(ctx, x, y) {
|
||||||
|
//Parameterize the canvas
|
||||||
|
ctx.font = /** @type {string} */ (state.font);
|
||||||
|
ctx.fillStyle = state.fillColor;
|
||||||
|
ctx.strokeStyle = state.strokeColor;
|
||||||
|
ctx.lineWidth = state.lineWidth;
|
||||||
|
ctx.lineCap = /*** @type {string} */ (state.lineCap);
|
||||||
|
ctx.lineJoin = /** @type {string} */ (state.lineJoin);
|
||||||
|
ctx.miterLimit = /** @type {number} */ (state.miterLimit);
|
||||||
|
ctx.textAlign = 'left';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
if (ol.has.CANVAS_LINE_DASH && state.lineDash) {
|
||||||
|
//FIXME: use pixelRatio
|
||||||
|
ctx.setLineDash(state.lineDash);
|
||||||
|
ctx.lineDashOffset = /** @type {number} */ (state.lineDashOffset);
|
||||||
|
}
|
||||||
|
if (state.scale !== 1) {
|
||||||
|
//FIXME: use pixelRatio
|
||||||
|
ctx.setTransform(/** @type {number} */ (state.scale), 0, 0,
|
||||||
|
/** @type {number} */ (state.scale), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw the character on the canvas
|
||||||
|
if (state.strokeColor) {
|
||||||
|
ctx.strokeText(char, x, y);
|
||||||
|
}
|
||||||
|
if (state.fillColor) {
|
||||||
|
ctx.fillText(char, x, y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
glyphAtlas.width[char] = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Context} context WebGL context.
|
* @inheritDoc
|
||||||
* @return {function()} Delete resources function.
|
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.getDeleteResourcesFunction = function(context) {
|
ol.render.webgl.TextReplay.prototype.finish = function(context) {
|
||||||
return ol.nullFunction;
|
var gl = context.getGL();
|
||||||
|
|
||||||
|
this.groupIndices.push(this.indices.length);
|
||||||
|
this.hitDetectionGroupIndices = this.groupIndices;
|
||||||
|
|
||||||
|
// create, bind, and populate the vertices buffer
|
||||||
|
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||||
|
|
||||||
|
// create, bind, and populate the indices buffer
|
||||||
|
this.indicesBuffer = new ol.webgl.Buffer(this.indices);
|
||||||
|
|
||||||
|
// create textures
|
||||||
|
/** @type {Object.<string, WebGLTexture>} */
|
||||||
|
var texturePerImage = {};
|
||||||
|
|
||||||
|
this.createTextures(this.textures_, this.images_, texturePerImage, gl);
|
||||||
|
|
||||||
|
this.state_ = {
|
||||||
|
strokeColor: null,
|
||||||
|
lineCap: undefined,
|
||||||
|
lineDash: null,
|
||||||
|
lineDashOffset: undefined,
|
||||||
|
lineJoin: undefined,
|
||||||
|
lineWidth: 0,
|
||||||
|
miterLimit: undefined,
|
||||||
|
fillColor: null,
|
||||||
|
font: undefined,
|
||||||
|
scale: undefined
|
||||||
|
};
|
||||||
|
this.text_ = '';
|
||||||
|
this.textAlign_ = undefined;
|
||||||
|
this.textBaseline_ = undefined;
|
||||||
|
this.offsetX_ = undefined;
|
||||||
|
this.offsetY_ = undefined;
|
||||||
|
this.images_ = null;
|
||||||
|
this.atlases_ = {};
|
||||||
|
this.currAtlas_ = undefined;
|
||||||
|
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {
|
||||||
|
var state = this.state_;
|
||||||
|
var textFillStyle = textStyle.getFill();
|
||||||
|
var textStrokeStyle = textStyle.getStroke();
|
||||||
|
if (!textStyle || !textStyle.getText() || (!textFillStyle && !textStrokeStyle)) {
|
||||||
|
this.text_ = '';
|
||||||
|
} else {
|
||||||
|
if (!textFillStyle) {
|
||||||
|
state.fillColor = null;
|
||||||
|
} else {
|
||||||
|
var textFillStyleColor = textFillStyle.getColor();
|
||||||
|
state.fillColor = ol.colorlike.asColorLike(textFillStyleColor ?
|
||||||
|
textFillStyleColor : ol.render.webgl.defaultFillStyle);
|
||||||
|
}
|
||||||
|
if (!textStrokeStyle) {
|
||||||
|
state.strokeColor = null;
|
||||||
|
state.lineWidth = 0;
|
||||||
|
} else {
|
||||||
|
var textStrokeStyleColor = textStrokeStyle.getColor();
|
||||||
|
state.strokeColor = ol.colorlike.asColorLike(textStrokeStyleColor ?
|
||||||
|
textStrokeStyleColor : ol.render.webgl.defaultStrokeStyle);
|
||||||
|
state.lineWidth = textStrokeStyle.getWidth() || ol.render.webgl.defaultLineWidth;
|
||||||
|
state.lineCap = textStrokeStyle.getLineCap() || ol.render.webgl.defaultLineCap;
|
||||||
|
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || ol.render.webgl.defaultLineDashOffset;
|
||||||
|
state.lineJoin = textStrokeStyle.getLineJoin() || ol.render.webgl.defaultLineJoin;
|
||||||
|
state.miterLimit = textStrokeStyle.getMiterLimit() || ol.render.webgl.defaultMiterLimit;
|
||||||
|
var lineDash = textStrokeStyle.getLineDash();
|
||||||
|
state.lineDash = lineDash ? lineDash.slice() : ol.render.webgl.defaultLineDash;
|
||||||
|
}
|
||||||
|
state.font = textStyle.getFont() || ol.render.webgl.defaultFont;
|
||||||
|
state.scale = textStyle.getScale() || 1;
|
||||||
|
this.text_ = /** @type {string} */ (textStyle.getText());
|
||||||
|
var textAlign = ol.render.webgl.TextReplay.Align_[textStyle.getTextAlign()];
|
||||||
|
var textBaseline = ol.render.webgl.TextReplay.Align_[textStyle.getTextBaseline()];
|
||||||
|
this.textAlign_ = textAlign === undefined ?
|
||||||
|
ol.render.webgl.defaultTextAlign : textAlign;
|
||||||
|
this.textBaseline_ = textBaseline === undefined ?
|
||||||
|
ol.render.webgl.defaultTextBaseline : textBaseline;
|
||||||
|
this.offsetX_ = textStyle.getOffsetX() || 0;
|
||||||
|
this.offsetY_ = textStyle.getOffsetY() || 0;
|
||||||
|
this.rotateWithView = !!textStyle.getRotateWithView();
|
||||||
|
this.rotation = textStyle.getRotation() || 0;
|
||||||
|
|
||||||
|
this.currAtlas_ = this.getAtlas_(state);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {Object} state Font attributes.
|
||||||
|
* @return {ol.WebglGlyphAtlas} Glyph atlas.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) {
|
||||||
|
var params = [];
|
||||||
|
var i;
|
||||||
|
for (i in state) {
|
||||||
|
if (state[i] || state[i] === 0) {
|
||||||
|
if (Array.isArray(state[i])) {
|
||||||
|
params = params.concat(state[i]);
|
||||||
|
} else {
|
||||||
|
params.push(state[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var hash = this.calculateHash_(params);
|
||||||
|
if (!this.atlases_[hash]) {
|
||||||
|
var mCtx = this.measureCanvas_.getContext('2d');
|
||||||
|
mCtx.font = state.font;
|
||||||
|
var height = Math.ceil((mCtx.measureText('M').width * 1.5 +
|
||||||
|
state.lineWidth / 2) * state.scale);
|
||||||
|
|
||||||
|
this.atlases_[hash] = {
|
||||||
|
atlas: new ol.style.AtlasManager({
|
||||||
|
space: state.lineWidth + 1
|
||||||
|
}),
|
||||||
|
width: {},
|
||||||
|
height: height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return this.atlases_[hash];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {Array.<string|number>} params Array of parameters.
|
||||||
|
* @return {string} Hash string.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) {
|
||||||
|
//TODO: Create a more performant, reliable, general hash function.
|
||||||
|
var i, ii;
|
||||||
|
var hash = '';
|
||||||
|
for (i = 0, ii = params.length; i < ii; ++i) {
|
||||||
|
hash += params[i];
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) {
|
||||||
|
return this.textures_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.prototype.getHitDetectionTextures = function() {
|
||||||
|
return this.textures_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextReplay.Align_ = {
|
||||||
|
left: 0,
|
||||||
|
end: 0,
|
||||||
|
center: 0.5,
|
||||||
|
right: 1,
|
||||||
|
start: 1,
|
||||||
|
top: 0,
|
||||||
|
middle: 0.5,
|
||||||
|
hanging: 0.2,
|
||||||
|
alphabetic: 0.8,
|
||||||
|
ideographic: 0.8,
|
||||||
|
bottom: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
497
src/ol/render/webgl/texturereplay.js
Normal file
497
src/ol/render/webgl/texturereplay.js
Normal file
@@ -0,0 +1,497 @@
|
|||||||
|
goog.provide('ol.render.webgl.TextureReplay');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.obj');
|
||||||
|
goog.require('ol.render.webgl.texturereplay.defaultshader');
|
||||||
|
goog.require('ol.render.webgl.Replay');
|
||||||
|
goog.require('ol.webgl');
|
||||||
|
goog.require('ol.webgl.Context');
|
||||||
|
|
||||||
|
if (ol.ENABLE_WEBGL) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @abstract
|
||||||
|
* @extends {ol.render.webgl.Replay}
|
||||||
|
* @param {number} tolerance Tolerance.
|
||||||
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
|
* @struct
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay = function(tolerance, maxExtent) {
|
||||||
|
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.anchorX = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.anchorY = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<number>}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.groupIndices = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<number>}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.hitDetectionGroupIndices = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.height = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.imageHeight = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.imageWidth = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @type {ol.render.webgl.texturereplay.defaultshader.Locations}
|
||||||
|
*/
|
||||||
|
this.defaultLocations = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.opacity = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.originX = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.originY = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @type {boolean|undefined}
|
||||||
|
*/
|
||||||
|
this.rotateWithView = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.rotation = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.scale = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
this.width = undefined;
|
||||||
|
};
|
||||||
|
ol.inherits(ol.render.webgl.TextureReplay, ol.render.webgl.Replay);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||||
|
var verticesBuffer = this.verticesBuffer;
|
||||||
|
var indicesBuffer = this.indicesBuffer;
|
||||||
|
var textures = this.getTextures(true);
|
||||||
|
var gl = context.getGL();
|
||||||
|
return function() {
|
||||||
|
if (!gl.isContextLost()) {
|
||||||
|
var i, ii;
|
||||||
|
for (i = 0, ii = textures.length; i < ii; ++i) {
|
||||||
|
gl.deleteTexture(textures[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.deleteBuffer(verticesBuffer);
|
||||||
|
context.deleteBuffer(indicesBuffer);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
|
* @param {number} offset Offset.
|
||||||
|
* @param {number} end End.
|
||||||
|
* @param {number} stride Stride.
|
||||||
|
* @return {number} My end.
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) {
|
||||||
|
var anchorX = /** @type {number} */ (this.anchorX);
|
||||||
|
var anchorY = /** @type {number} */ (this.anchorY);
|
||||||
|
var height = /** @type {number} */ (this.height);
|
||||||
|
var imageHeight = /** @type {number} */ (this.imageHeight);
|
||||||
|
var imageWidth = /** @type {number} */ (this.imageWidth);
|
||||||
|
var opacity = /** @type {number} */ (this.opacity);
|
||||||
|
var originX = /** @type {number} */ (this.originX);
|
||||||
|
var originY = /** @type {number} */ (this.originY);
|
||||||
|
var rotateWithView = this.rotateWithView ? 1.0 : 0.0;
|
||||||
|
// this.rotation_ is anti-clockwise, but rotation is clockwise
|
||||||
|
var rotation = /** @type {number} */ (-this.rotation);
|
||||||
|
var scale = /** @type {number} */ (this.scale);
|
||||||
|
var width = /** @type {number} */ (this.width);
|
||||||
|
var cos = Math.cos(rotation);
|
||||||
|
var sin = Math.sin(rotation);
|
||||||
|
var numIndices = this.indices.length;
|
||||||
|
var numVertices = this.vertices.length;
|
||||||
|
var i, n, offsetX, offsetY, x, y;
|
||||||
|
for (i = offset; i < end; i += stride) {
|
||||||
|
x = flatCoordinates[i] - this.origin[0];
|
||||||
|
y = flatCoordinates[i + 1] - this.origin[1];
|
||||||
|
|
||||||
|
// There are 4 vertices per [x, y] point, one for each corner of the
|
||||||
|
// rectangle we're going to draw. We'd use 1 vertex per [x, y] point if
|
||||||
|
// WebGL supported Geometry Shaders (which can emit new vertices), but that
|
||||||
|
// is not currently the case.
|
||||||
|
//
|
||||||
|
// And each vertex includes 8 values: the x and y coordinates, the x and
|
||||||
|
// y offsets used to calculate the position of the corner, the u and
|
||||||
|
// v texture coordinates for the corner, the opacity, and whether the
|
||||||
|
// the image should be rotated with the view (rotateWithView).
|
||||||
|
|
||||||
|
n = numVertices / 8;
|
||||||
|
|
||||||
|
// bottom-left corner
|
||||||
|
offsetX = -scale * anchorX;
|
||||||
|
offsetY = -scale * (height - anchorY);
|
||||||
|
this.vertices[numVertices++] = x;
|
||||||
|
this.vertices[numVertices++] = y;
|
||||||
|
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
||||||
|
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
||||||
|
this.vertices[numVertices++] = originX / imageWidth;
|
||||||
|
this.vertices[numVertices++] = (originY + height) / imageHeight;
|
||||||
|
this.vertices[numVertices++] = opacity;
|
||||||
|
this.vertices[numVertices++] = rotateWithView;
|
||||||
|
|
||||||
|
// bottom-right corner
|
||||||
|
offsetX = scale * (width - anchorX);
|
||||||
|
offsetY = -scale * (height - anchorY);
|
||||||
|
this.vertices[numVertices++] = x;
|
||||||
|
this.vertices[numVertices++] = y;
|
||||||
|
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
||||||
|
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
||||||
|
this.vertices[numVertices++] = (originX + width) / imageWidth;
|
||||||
|
this.vertices[numVertices++] = (originY + height) / imageHeight;
|
||||||
|
this.vertices[numVertices++] = opacity;
|
||||||
|
this.vertices[numVertices++] = rotateWithView;
|
||||||
|
|
||||||
|
// top-right corner
|
||||||
|
offsetX = scale * (width - anchorX);
|
||||||
|
offsetY = scale * anchorY;
|
||||||
|
this.vertices[numVertices++] = x;
|
||||||
|
this.vertices[numVertices++] = y;
|
||||||
|
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
||||||
|
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
||||||
|
this.vertices[numVertices++] = (originX + width) / imageWidth;
|
||||||
|
this.vertices[numVertices++] = originY / imageHeight;
|
||||||
|
this.vertices[numVertices++] = opacity;
|
||||||
|
this.vertices[numVertices++] = rotateWithView;
|
||||||
|
|
||||||
|
// top-left corner
|
||||||
|
offsetX = -scale * anchorX;
|
||||||
|
offsetY = scale * anchorY;
|
||||||
|
this.vertices[numVertices++] = x;
|
||||||
|
this.vertices[numVertices++] = y;
|
||||||
|
this.vertices[numVertices++] = offsetX * cos - offsetY * sin;
|
||||||
|
this.vertices[numVertices++] = offsetX * sin + offsetY * cos;
|
||||||
|
this.vertices[numVertices++] = originX / imageWidth;
|
||||||
|
this.vertices[numVertices++] = originY / imageHeight;
|
||||||
|
this.vertices[numVertices++] = opacity;
|
||||||
|
this.vertices[numVertices++] = rotateWithView;
|
||||||
|
|
||||||
|
this.indices[numIndices++] = n;
|
||||||
|
this.indices[numIndices++] = n + 1;
|
||||||
|
this.indices[numIndices++] = n + 2;
|
||||||
|
this.indices[numIndices++] = n;
|
||||||
|
this.indices[numIndices++] = n + 2;
|
||||||
|
this.indices[numIndices++] = n + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numVertices;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @protected
|
||||||
|
* @param {Array.<WebGLTexture>} textures Textures.
|
||||||
|
* @param {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>} images
|
||||||
|
* Images.
|
||||||
|
* @param {Object.<string, WebGLTexture>} texturePerImage Texture cache.
|
||||||
|
* @param {WebGLRenderingContext} gl Gl.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) {
|
||||||
|
var texture, image, uid, i;
|
||||||
|
var ii = images.length;
|
||||||
|
for (i = 0; i < ii; ++i) {
|
||||||
|
image = images[i];
|
||||||
|
|
||||||
|
uid = ol.getUid(image).toString();
|
||||||
|
if (uid in texturePerImage) {
|
||||||
|
texture = texturePerImage[uid];
|
||||||
|
} else {
|
||||||
|
texture = ol.webgl.Context.createTexture(
|
||||||
|
gl, image, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE);
|
||||||
|
texturePerImage[uid] = texture;
|
||||||
|
}
|
||||||
|
textures[i] = texture;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||||
|
// get the program
|
||||||
|
var fragmentShader = ol.render.webgl.texturereplay.defaultshader.fragment;
|
||||||
|
var vertexShader = ol.render.webgl.texturereplay.defaultshader.vertex;
|
||||||
|
var program = context.getProgram(fragmentShader, vertexShader);
|
||||||
|
|
||||||
|
// get the locations
|
||||||
|
var locations;
|
||||||
|
if (!this.defaultLocations) {
|
||||||
|
// eslint-disable-next-line openlayers-internal/no-missing-requires
|
||||||
|
locations = new ol.render.webgl.texturereplay.defaultshader.Locations(gl, program);
|
||||||
|
this.defaultLocations = locations;
|
||||||
|
} else {
|
||||||
|
locations = this.defaultLocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the program (FIXME: use the return value)
|
||||||
|
context.useProgram(program);
|
||||||
|
|
||||||
|
// enable the vertex attrib arrays
|
||||||
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
|
gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT,
|
||||||
|
false, 32, 0);
|
||||||
|
|
||||||
|
gl.enableVertexAttribArray(locations.a_offsets);
|
||||||
|
gl.vertexAttribPointer(locations.a_offsets, 2, ol.webgl.FLOAT,
|
||||||
|
false, 32, 8);
|
||||||
|
|
||||||
|
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||||
|
gl.vertexAttribPointer(locations.a_texCoord, 2, ol.webgl.FLOAT,
|
||||||
|
false, 32, 16);
|
||||||
|
|
||||||
|
gl.enableVertexAttribArray(locations.a_opacity);
|
||||||
|
gl.vertexAttribPointer(locations.a_opacity, 1, ol.webgl.FLOAT,
|
||||||
|
false, 32, 24);
|
||||||
|
|
||||||
|
gl.enableVertexAttribArray(locations.a_rotateWithView);
|
||||||
|
gl.vertexAttribPointer(locations.a_rotateWithView, 1, ol.webgl.FLOAT,
|
||||||
|
false, 32, 28);
|
||||||
|
|
||||||
|
return locations;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||||
|
gl.disableVertexAttribArray(locations.a_position);
|
||||||
|
gl.disableVertexAttribArray(locations.a_offsets);
|
||||||
|
gl.disableVertexAttribArray(locations.a_texCoord);
|
||||||
|
gl.disableVertexAttribArray(locations.a_opacity);
|
||||||
|
gl.disableVertexAttribArray(locations.a_rotateWithView);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||||
|
var textures = hitDetection ? this.getHitDetectionTextures() : this.getTextures();
|
||||||
|
var groupIndices = hitDetection ? this.hitDetectionGroupIndices : this.groupIndices;
|
||||||
|
|
||||||
|
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||||
|
this.drawReplaySkipping(
|
||||||
|
gl, context, skippedFeaturesHash, textures, groupIndices);
|
||||||
|
} else {
|
||||||
|
var i, ii, start;
|
||||||
|
for (i = 0, ii = textures.length, start = 0; i < ii; ++i) {
|
||||||
|
gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]);
|
||||||
|
var end = groupIndices[i];
|
||||||
|
this.drawElements(gl, context, start, end);
|
||||||
|
start = end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw the replay while paying attention to skipped features.
|
||||||
|
*
|
||||||
|
* This functions creates groups of features that can be drawn to together,
|
||||||
|
* so that the number of `drawElements` calls is minimized.
|
||||||
|
*
|
||||||
|
* For example given the following texture groups:
|
||||||
|
*
|
||||||
|
* Group 1: A B C
|
||||||
|
* Group 2: D [E] F G
|
||||||
|
*
|
||||||
|
* If feature E should be skipped, the following `drawElements` calls will be
|
||||||
|
* made:
|
||||||
|
*
|
||||||
|
* drawElements with feature A, B and C
|
||||||
|
* drawElements with feature D
|
||||||
|
* drawElements with feature F and G
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
|
* @param {ol.webgl.Context} context Context.
|
||||||
|
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||||
|
* to skip.
|
||||||
|
* @param {Array.<WebGLTexture>} textures Textures.
|
||||||
|
* @param {Array.<number>} groupIndices Texture group indices.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures,
|
||||||
|
groupIndices) {
|
||||||
|
var featureIndex = 0;
|
||||||
|
|
||||||
|
var i, ii;
|
||||||
|
for (i = 0, ii = textures.length; i < ii; ++i) {
|
||||||
|
gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]);
|
||||||
|
var groupStart = (i > 0) ? groupIndices[i - 1] : 0;
|
||||||
|
var groupEnd = groupIndices[i];
|
||||||
|
|
||||||
|
var start = groupStart;
|
||||||
|
var end = groupStart;
|
||||||
|
while (featureIndex < this.startIndices.length &&
|
||||||
|
this.startIndices[featureIndex] <= groupEnd) {
|
||||||
|
var feature = this.startIndicesFeature[featureIndex];
|
||||||
|
|
||||||
|
var featureUid = ol.getUid(feature).toString();
|
||||||
|
if (skippedFeaturesHash[featureUid] !== undefined) {
|
||||||
|
// feature should be skipped
|
||||||
|
if (start !== end) {
|
||||||
|
// draw the features so far
|
||||||
|
this.drawElements(gl, context, start, end);
|
||||||
|
}
|
||||||
|
// continue with the next feature
|
||||||
|
start = (featureIndex === this.startIndices.length - 1) ?
|
||||||
|
groupEnd : this.startIndices[featureIndex + 1];
|
||||||
|
end = start;
|
||||||
|
} else {
|
||||||
|
// the feature is not skipped, augment the end index
|
||||||
|
end = (featureIndex === this.startIndices.length - 1) ?
|
||||||
|
groupEnd : this.startIndices[featureIndex + 1];
|
||||||
|
}
|
||||||
|
featureIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start !== end) {
|
||||||
|
// draw the remaining features (in case there was no skipped feature
|
||||||
|
// in this texture group, all features of a group are drawn together)
|
||||||
|
this.drawElements(gl, context, start, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||||
|
featureCallback, opt_hitExtent) {
|
||||||
|
var i, groupStart, start, end, feature, featureUid;
|
||||||
|
var featureIndex = this.startIndices.length - 1;
|
||||||
|
var hitDetectionTextures = this.getHitDetectionTextures();
|
||||||
|
for (i = hitDetectionTextures.length - 1; i >= 0; --i) {
|
||||||
|
gl.bindTexture(ol.webgl.TEXTURE_2D, hitDetectionTextures[i]);
|
||||||
|
groupStart = (i > 0) ? this.hitDetectionGroupIndices[i - 1] : 0;
|
||||||
|
end = this.hitDetectionGroupIndices[i];
|
||||||
|
|
||||||
|
// draw all features for this texture group
|
||||||
|
while (featureIndex >= 0 &&
|
||||||
|
this.startIndices[featureIndex] >= groupStart) {
|
||||||
|
start = this.startIndices[featureIndex];
|
||||||
|
feature = this.startIndicesFeature[featureIndex];
|
||||||
|
featureUid = ol.getUid(feature).toString();
|
||||||
|
|
||||||
|
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||||
|
feature.getGeometry() &&
|
||||||
|
(opt_hitExtent === undefined || ol.extent.intersects(
|
||||||
|
/** @type {Array<number>} */ (opt_hitExtent),
|
||||||
|
feature.getGeometry().getExtent()))) {
|
||||||
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||||
|
this.drawElements(gl, context, start, end);
|
||||||
|
|
||||||
|
var result = featureCallback(feature);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end = start;
|
||||||
|
featureIndex--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.finish = function(context) {
|
||||||
|
this.anchorX = undefined;
|
||||||
|
this.anchorY = undefined;
|
||||||
|
this.height = undefined;
|
||||||
|
this.imageHeight = undefined;
|
||||||
|
this.imageWidth = undefined;
|
||||||
|
this.indices = null;
|
||||||
|
this.opacity = undefined;
|
||||||
|
this.originX = undefined;
|
||||||
|
this.originY = undefined;
|
||||||
|
this.rotateWithView = undefined;
|
||||||
|
this.rotation = undefined;
|
||||||
|
this.scale = undefined;
|
||||||
|
this.vertices = null;
|
||||||
|
this.width = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @abstract
|
||||||
|
* @protected
|
||||||
|
* @param {boolean=} opt_all Return hit detection textures with regular ones.
|
||||||
|
* @returns {Array.<WebGLTexture>} Textures.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @abstract
|
||||||
|
* @protected
|
||||||
|
* @returns {Array.<WebGLTexture>} Textures.
|
||||||
|
*/
|
||||||
|
ol.render.webgl.TextureReplay.prototype.getHitDetectionTextures = function() {};
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//! NAMESPACE=ol.render.webgl.imagereplay.defaultshader
|
//! NAMESPACE=ol.render.webgl.texturereplay.defaultshader
|
||||||
//! CLASS=ol.render.webgl.imagereplay.defaultshader
|
//! CLASS=ol.render.webgl.texturereplay.defaultshader
|
||||||
|
|
||||||
|
|
||||||
//! COMMON
|
//! COMMON
|
||||||
154
src/ol/render/webgl/texturereplay/defaultshader.js
Normal file
154
src/ol/render/webgl/texturereplay/defaultshader.js
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
// This file is automatically generated, do not edit
|
||||||
|
/* eslint openlayers-internal/no-missing-requires: 0 */
|
||||||
|
goog.provide('ol.render.webgl.texturereplay.defaultshader');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
|
goog.require('ol.webgl.Fragment');
|
||||||
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
|
if (ol.ENABLE_WEBGL) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.webgl.Fragment}
|
||||||
|
* @struct
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Fragment = function() {
|
||||||
|
ol.webgl.Fragment.call(this, ol.render.webgl.texturereplay.defaultshader.Fragment.SOURCE);
|
||||||
|
};
|
||||||
|
ol.inherits(ol.render.webgl.texturereplay.defaultshader.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Fragment.DEBUG_SOURCE :
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.fragment = new ol.render.webgl.texturereplay.defaultshader.Fragment();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.webgl.Vertex}
|
||||||
|
* @struct
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Vertex = function() {
|
||||||
|
ol.webgl.Vertex.call(this, ol.render.webgl.texturereplay.defaultshader.Vertex.SOURCE);
|
||||||
|
};
|
||||||
|
ol.inherits(ol.render.webgl.texturereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Vertex.DEBUG_SOURCE :
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.vertex = new ol.render.webgl.texturereplay.defaultshader.Vertex();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
|
* @param {WebGLProgram} program Program.
|
||||||
|
* @struct
|
||||||
|
*/
|
||||||
|
ol.render.webgl.texturereplay.defaultshader.Locations = function(gl, program) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {WebGLUniformLocation}
|
||||||
|
*/
|
||||||
|
this.u_image = gl.getUniformLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'u_image' : 'l');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {WebGLUniformLocation}
|
||||||
|
*/
|
||||||
|
this.u_offsetRotateMatrix = gl.getUniformLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {WebGLUniformLocation}
|
||||||
|
*/
|
||||||
|
this.u_offsetScaleMatrix = gl.getUniformLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {WebGLUniformLocation}
|
||||||
|
*/
|
||||||
|
this.u_opacity = gl.getUniformLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'u_opacity' : 'k');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {WebGLUniformLocation}
|
||||||
|
*/
|
||||||
|
this.u_projectionMatrix = gl.getUniformLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.a_offsets = gl.getAttribLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'a_offsets' : 'e');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.a_opacity = gl.getAttribLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'a_opacity' : 'f');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.a_position = gl.getAttribLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'a_position' : 'c');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.a_rotateWithView = gl.getAttribLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'a_rotateWithView' : 'g');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.a_texCoord = gl.getAttribLocation(
|
||||||
|
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'd');
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -144,6 +144,15 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
|
|||||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||||
tile = tileSource.getTile(z, x, y, pixelRatio, projection);
|
tile = tileSource.getTile(z, x, y, pixelRatio, projection);
|
||||||
|
if (tile.getState() == ol.TileState.ERROR) {
|
||||||
|
if (!tileLayer.getUseInterimTilesOnError()) {
|
||||||
|
// When useInterimTilesOnError is false, we consider the error tile as loaded.
|
||||||
|
tile.setState(ol.TileState.LOADED);
|
||||||
|
} else if (tileLayer.getPreload() > 0) {
|
||||||
|
// Preloaded tiles for lower resolutions might have finished loading.
|
||||||
|
newTiles = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!this.isDrawableTile_(tile)) {
|
if (!this.isDrawableTile_(tile)) {
|
||||||
tile = tile.getInterimTile();
|
tile = tile.getInterimTile();
|
||||||
}
|
}
|
||||||
@@ -173,7 +182,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(frameState, layer
|
|||||||
var renderedResolution = tileResolution * pixelRatio / tilePixelRatio * oversampling;
|
var renderedResolution = tileResolution * pixelRatio / tilePixelRatio * oversampling;
|
||||||
var hints = frameState.viewHints;
|
var hints = frameState.viewHints;
|
||||||
var animatingOrInteracting = hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING];
|
var animatingOrInteracting = hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING];
|
||||||
if (!(Date.now() - frameState.time > 16 && animatingOrInteracting) && (
|
if (!(this.renderedResolution && Date.now() - frameState.time > 16 && animatingOrInteracting) && (
|
||||||
newTiles ||
|
newTiles ||
|
||||||
!(this.renderedExtent_ && ol.extent.containsExtent(this.renderedExtent_, extent)) ||
|
!(this.renderedExtent_ && ol.extent.containsExtent(this.renderedExtent_, extent)) ||
|
||||||
this.renderedRevision != sourceRevision ||
|
this.renderedRevision != sourceRevision ||
|
||||||
@@ -265,7 +274,7 @@ ol.renderer.canvas.TileLayer.prototype.drawTileImage = function(tile, frameState
|
|||||||
if (!this.getLayer().getSource().getOpaque(frameState.viewState.projection)) {
|
if (!this.getLayer().getSource().getOpaque(frameState.viewState.projection)) {
|
||||||
this.context.clearRect(x, y, w, h);
|
this.context.clearRect(x, y, w, h);
|
||||||
}
|
}
|
||||||
var image = tile.getImage();
|
var image = tile.getImage(this.getLayer());
|
||||||
if (image) {
|
if (image) {
|
||||||
this.context.drawImage(image, gutter, gutter,
|
this.context.drawImage(image, gutter, gutter,
|
||||||
image.width - 2 * gutter, image.height - 2 * gutter, x, y, w, h);
|
image.width - 2 * gutter, image.height - 2 * gutter, x, y, w, h);
|
||||||
|
|||||||
@@ -97,7 +97,9 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
|
|||||||
var drawOffsetX = 0;
|
var drawOffsetX = 0;
|
||||||
var drawOffsetY = 0;
|
var drawOffsetY = 0;
|
||||||
var replayContext;
|
var replayContext;
|
||||||
if (layer.hasListener(ol.render.EventType.RENDER)) {
|
var transparentLayer = layerState.opacity !== 1;
|
||||||
|
var hasRenderListeners = layer.hasListener(ol.render.EventType.RENDER);
|
||||||
|
if (transparentLayer || hasRenderListeners) {
|
||||||
var drawWidth = context.canvas.width;
|
var drawWidth = context.canvas.width;
|
||||||
var drawHeight = context.canvas.height;
|
var drawHeight = context.canvas.height;
|
||||||
if (rotation) {
|
if (rotation) {
|
||||||
@@ -113,11 +115,15 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
|
|||||||
} else {
|
} else {
|
||||||
replayContext = context;
|
replayContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var alpha = replayContext.globalAlpha;
|
||||||
|
if (!transparentLayer) {
|
||||||
// for performance reasons, context.save / context.restore is not used
|
// for performance reasons, context.save / context.restore is not used
|
||||||
// to save and restore the transformation matrix and the opacity.
|
// to save and restore the transformation matrix and the opacity.
|
||||||
// see http://jsperf.com/context-save-restore-versus-variable
|
// see http://jsperf.com/context-save-restore-versus-variable
|
||||||
var alpha = replayContext.globalAlpha;
|
|
||||||
replayContext.globalAlpha = layerState.opacity;
|
replayContext.globalAlpha = layerState.opacity;
|
||||||
|
}
|
||||||
|
|
||||||
if (replayContext != context) {
|
if (replayContext != context) {
|
||||||
replayContext.translate(drawOffsetX, drawOffsetY);
|
replayContext.translate(drawOffsetX, drawOffsetY);
|
||||||
}
|
}
|
||||||
@@ -159,12 +165,24 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
|
|||||||
width / 2, height / 2);
|
width / 2, height / 2);
|
||||||
|
|
||||||
if (replayContext != context) {
|
if (replayContext != context) {
|
||||||
|
if (hasRenderListeners) {
|
||||||
this.dispatchRenderEvent(replayContext, frameState, transform);
|
this.dispatchRenderEvent(replayContext, frameState, transform);
|
||||||
|
}
|
||||||
|
if (transparentLayer) {
|
||||||
|
var mainContextAlpha = context.globalAlpha;
|
||||||
|
context.globalAlpha = layerState.opacity;
|
||||||
context.drawImage(replayContext.canvas, -drawOffsetX, -drawOffsetY);
|
context.drawImage(replayContext.canvas, -drawOffsetX, -drawOffsetY);
|
||||||
|
context.globalAlpha = mainContextAlpha;
|
||||||
|
} else {
|
||||||
|
context.drawImage(replayContext.canvas, -drawOffsetX, -drawOffsetY);
|
||||||
|
}
|
||||||
replayContext.translate(-drawOffsetX, -drawOffsetY);
|
replayContext.translate(-drawOffsetX, -drawOffsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!transparentLayer) {
|
||||||
replayContext.globalAlpha = alpha;
|
replayContext.globalAlpha = alpha;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (clipped) {
|
if (clipped) {
|
||||||
context.restore();
|
context.restore();
|
||||||
@@ -277,8 +295,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
|
|||||||
|
|
||||||
this.dirty_ = false;
|
this.dirty_ = false;
|
||||||
|
|
||||||
var replayGroup =
|
var replayGroup = new ol.render.canvas.ReplayGroup(
|
||||||
new ol.render.canvas.ReplayGroup(
|
|
||||||
ol.renderer.vector.getTolerance(resolution, pixelRatio), extent,
|
ol.renderer.vector.getTolerance(resolution, pixelRatio), extent,
|
||||||
resolution, vectorSource.getOverlaps(), vectorLayer.getRenderBuffer());
|
resolution, vectorSource.getOverlaps(), vectorLayer.getRenderBuffer());
|
||||||
vectorSource.loadFeatures(extent, resolution, projection);
|
vectorSource.loadFeatures(extent, resolution, projection);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.renderer.canvas.VectorTileLayer');
|
goog.provide('ol.renderer.canvas.VectorTileLayer');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.dom');
|
goog.require('ol.dom');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -12,7 +13,6 @@ goog.require('ol.render.canvas.ReplayGroup');
|
|||||||
goog.require('ol.render.replay');
|
goog.require('ol.render.replay');
|
||||||
goog.require('ol.renderer.canvas.TileLayer');
|
goog.require('ol.renderer.canvas.TileLayer');
|
||||||
goog.require('ol.renderer.vector');
|
goog.require('ol.renderer.vector');
|
||||||
goog.require('ol.size');
|
|
||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
|
|
||||||
|
|
||||||
@@ -23,6 +23,9 @@ goog.require('ol.transform');
|
|||||||
*/
|
*/
|
||||||
ol.renderer.canvas.VectorTileLayer = function(layer) {
|
ol.renderer.canvas.VectorTileLayer = function(layer) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {CanvasRenderingContext2D}
|
||||||
|
*/
|
||||||
this.context = null;
|
this.context = null;
|
||||||
|
|
||||||
ol.renderer.canvas.TileLayer.call(this, layer);
|
ol.renderer.canvas.TileLayer.call(this, layer);
|
||||||
@@ -95,43 +98,55 @@ ol.renderer.canvas.VectorTileLayer.prototype.prepareFrame = function(frameState,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.VectorTile} tile Tile.
|
* @param {ol.VectorImageTile} tile Tile.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(tile,
|
ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(
|
||||||
frameState) {
|
tile, frameState) {
|
||||||
var layer = this.getLayer();
|
var layer = this.getLayer();
|
||||||
var pixelRatio = frameState.pixelRatio;
|
var pixelRatio = frameState.pixelRatio;
|
||||||
var projection = frameState.viewState.projection;
|
var projection = frameState.viewState.projection;
|
||||||
var revision = layer.getRevision();
|
var revision = layer.getRevision();
|
||||||
var renderOrder = layer.getRenderOrder() || null;
|
var renderOrder = /** @type {ol.RenderOrderFunction} */
|
||||||
|
(layer.getRenderOrder()) || null;
|
||||||
|
|
||||||
var replayState = tile.getReplayState();
|
var replayState = tile.getReplayState(layer);
|
||||||
if (!replayState.dirty && replayState.renderedRevision == revision &&
|
if (!replayState.dirty && replayState.renderedRevision == revision &&
|
||||||
replayState.renderedRenderOrder == renderOrder) {
|
replayState.renderedRenderOrder == renderOrder) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
replayState.replayGroup = null;
|
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
|
||||||
|
var sourceTile = tile.getTile(tile.tileKeys[t]);
|
||||||
replayState.dirty = false;
|
replayState.dirty = false;
|
||||||
|
|
||||||
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
|
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
|
||||||
var tileGrid = source.getTileGrid();
|
var sourceTileGrid = source.getTileGrid();
|
||||||
var tileCoord = tile.tileCoord;
|
var sourceTileCoord = sourceTile.tileCoord;
|
||||||
var tileProjection = tile.getProjection();
|
var tileProjection = sourceTile.getProjection();
|
||||||
var resolution = tileGrid.getResolution(tileCoord[0]);
|
var tileGrid = source.getTileGridForProjection(projection);
|
||||||
|
var resolution = tileGrid.getResolution(tile.tileCoord[0]);
|
||||||
|
var sourceTileResolution = sourceTileGrid.getResolution(sourceTile.tileCoord[0]);
|
||||||
|
var tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
|
||||||
|
var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
||||||
|
var sharedExtent = ol.extent.getIntersection(tileExtent, sourceTileExtent);
|
||||||
var extent, reproject, tileResolution;
|
var extent, reproject, tileResolution;
|
||||||
if (tileProjection.getUnits() == ol.proj.Units.TILE_PIXELS) {
|
if (tileProjection.getUnits() == ol.proj.Units.TILE_PIXELS) {
|
||||||
var tilePixelRatio = tileResolution = source.getTilePixelRatio();
|
var tilePixelRatio = tileResolution = source.getTilePixelRatio();
|
||||||
var tileSize = ol.size.toSize(tileGrid.getTileSize(tileCoord[0]));
|
var transform = ol.transform.compose(this.tmpTransform_,
|
||||||
extent = [0, 0, tileSize[0] * tilePixelRatio, tileSize[1] * tilePixelRatio];
|
0, 0,
|
||||||
|
1 / sourceTileResolution * tilePixelRatio, -1 / sourceTileResolution * tilePixelRatio,
|
||||||
|
0,
|
||||||
|
-sourceTileExtent[0], -sourceTileExtent[3]);
|
||||||
|
extent = (ol.transform.apply(transform, [sharedExtent[0], sharedExtent[3]])
|
||||||
|
.concat(ol.transform.apply(transform, [sharedExtent[2], sharedExtent[1]])));
|
||||||
} else {
|
} else {
|
||||||
tileResolution = resolution;
|
tileResolution = resolution;
|
||||||
extent = tileGrid.getTileCoordExtent(tileCoord);
|
extent = sharedExtent;
|
||||||
if (!ol.proj.equivalent(projection, tileProjection)) {
|
if (!ol.proj.equivalent(projection, tileProjection)) {
|
||||||
reproject = true;
|
reproject = true;
|
||||||
tile.setProjection(projection);
|
sourceTile.setProjection(projection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
replayState.dirty = false;
|
replayState.dirty = false;
|
||||||
@@ -144,7 +159,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(tile,
|
|||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
* @this {ol.renderer.canvas.VectorTileLayer}
|
* @this {ol.renderer.canvas.VectorTileLayer}
|
||||||
*/
|
*/
|
||||||
function renderFeature(feature) {
|
var renderFeature = function(feature) {
|
||||||
var styles;
|
var styles;
|
||||||
var styleFunction = feature.getStyleFunction();
|
var styleFunction = feature.getStyleFunction();
|
||||||
if (styleFunction) {
|
if (styleFunction) {
|
||||||
@@ -164,9 +179,9 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(tile,
|
|||||||
this.dirty_ = this.dirty_ || dirty;
|
this.dirty_ = this.dirty_ || dirty;
|
||||||
replayState.dirty = replayState.dirty || dirty;
|
replayState.dirty = replayState.dirty || dirty;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var features = tile.getFeatures();
|
var features = sourceTile.getFeatures();
|
||||||
if (renderOrder && renderOrder !== replayState.renderedRenderOrder) {
|
if (renderOrder && renderOrder !== replayState.renderedRenderOrder) {
|
||||||
features.sort(renderOrder);
|
features.sort(renderOrder);
|
||||||
}
|
}
|
||||||
@@ -178,13 +193,11 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(tile,
|
|||||||
}
|
}
|
||||||
renderFeature.call(this, feature);
|
renderFeature.call(this, feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
replayGroup.finish();
|
replayGroup.finish();
|
||||||
|
sourceTile.setReplayGroup(layer, tile.tileCoord.toString(), replayGroup);
|
||||||
|
}
|
||||||
replayState.renderedRevision = revision;
|
replayState.renderedRevision = revision;
|
||||||
replayState.renderedRenderOrder = renderOrder;
|
replayState.renderedRenderOrder = renderOrder;
|
||||||
replayState.replayGroup = replayGroup;
|
|
||||||
replayState.resolution = NaN;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -193,10 +206,10 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(tile,
|
|||||||
*/
|
*/
|
||||||
ol.renderer.canvas.VectorTileLayer.prototype.drawTileImage = function(
|
ol.renderer.canvas.VectorTileLayer.prototype.drawTileImage = function(
|
||||||
tile, frameState, layerState, x, y, w, h, gutter) {
|
tile, frameState, layerState, x, y, w, h, gutter) {
|
||||||
var vectorTile = /** @type {ol.VectorTile} */ (tile);
|
var vectorImageTile = /** @type {ol.VectorImageTile} */ (tile);
|
||||||
this.createReplayGroup_(vectorTile, frameState);
|
this.createReplayGroup_(vectorImageTile, frameState);
|
||||||
if (this.context) {
|
if (this.context) {
|
||||||
this.renderTileImage_(vectorTile, frameState, layerState);
|
this.renderTileImage_(vectorImageTile, frameState, layerState);
|
||||||
ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments);
|
ol.renderer.canvas.TileLayer.prototype.drawTileImage.apply(this, arguments);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -213,25 +226,31 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi
|
|||||||
/** @type {Object.<string, boolean>} */
|
/** @type {Object.<string, boolean>} */
|
||||||
var features = {};
|
var features = {};
|
||||||
|
|
||||||
/** @type {Array.<ol.VectorTile>} */
|
/** @type {Array.<ol.VectorImageTile>} */
|
||||||
var replayables = this.renderedTiles;
|
var renderedTiles = this.renderedTiles;
|
||||||
|
|
||||||
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
|
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
|
||||||
var tileGrid = source.getTileGrid();
|
var tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
|
||||||
var found, tileSpaceCoordinate;
|
var sourceTileGrid = source.getTileGrid();
|
||||||
|
var bufferedExtent, found, tileSpaceCoordinate;
|
||||||
var i, ii, origin, replayGroup;
|
var i, ii, origin, replayGroup;
|
||||||
var tile, tileCoord, tileExtent, tilePixelRatio, tileResolution;
|
var tile, tileCoord, tileExtent, tilePixelRatio, tileResolution;
|
||||||
for (i = 0, ii = replayables.length; i < ii; ++i) {
|
for (i = 0, ii = renderedTiles.length; i < ii; ++i) {
|
||||||
tile = replayables[i];
|
tile = renderedTiles[i];
|
||||||
tileCoord = tile.tileCoord;
|
tileCoord = tile.tileCoord;
|
||||||
tileExtent = source.getTileGrid().getTileCoordExtent(tileCoord, this.tmpExtent);
|
tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent);
|
||||||
if (!ol.extent.containsCoordinate(ol.extent.buffer(tileExtent, hitTolerance * resolution), coordinate)) {
|
bufferedExtent = ol.extent.buffer(tileExtent, hitTolerance * resolution, bufferedExtent);
|
||||||
|
if (!ol.extent.containsCoordinate(bufferedExtent, coordinate)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tile.getProjection().getUnits() === ol.proj.Units.TILE_PIXELS) {
|
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
|
||||||
origin = ol.extent.getTopLeft(tileExtent);
|
var sourceTile = tile.getTile(tile.tileKeys[t]);
|
||||||
|
if (sourceTile.getProjection().getUnits() === ol.proj.Units.TILE_PIXELS) {
|
||||||
|
var sourceTileCoord = sourceTile.tileCoord;
|
||||||
|
var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord, this.tmpExtent);
|
||||||
|
origin = ol.extent.getTopLeft(sourceTileExtent);
|
||||||
tilePixelRatio = source.getTilePixelRatio();
|
tilePixelRatio = source.getTilePixelRatio();
|
||||||
tileResolution = tileGrid.getResolution(tileCoord[0]) / tilePixelRatio;
|
tileResolution = sourceTileGrid.getResolution(sourceTileCoord[0]) / tilePixelRatio;
|
||||||
tileSpaceCoordinate = [
|
tileSpaceCoordinate = [
|
||||||
(coordinate[0] - origin[0]) / tileResolution,
|
(coordinate[0] - origin[0]) / tileResolution,
|
||||||
(origin[1] - coordinate[1]) / tileResolution
|
(origin[1] - coordinate[1]) / tileResolution
|
||||||
@@ -240,7 +259,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi
|
|||||||
} else {
|
} else {
|
||||||
tileSpaceCoordinate = coordinate;
|
tileSpaceCoordinate = coordinate;
|
||||||
}
|
}
|
||||||
replayGroup = tile.getReplayState().replayGroup;
|
replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString());
|
||||||
found = found || replayGroup.forEachFeatureAtCoordinate(
|
found = found || replayGroup.forEachFeatureAtCoordinate(
|
||||||
tileSpaceCoordinate, resolution, rotation, hitTolerance, {},
|
tileSpaceCoordinate, resolution, rotation, hitTolerance, {},
|
||||||
/**
|
/**
|
||||||
@@ -255,12 +274,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return found;
|
return found;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Tile} tile Tile.
|
* @param {ol.VectorTile} tile Tile.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @return {ol.Transform} transform Transform.
|
* @return {ol.Transform} transform Transform.
|
||||||
* @private
|
* @private
|
||||||
@@ -308,7 +328,9 @@ ol.renderer.canvas.VectorTileLayer.prototype.handleStyleImageChange_ = function(
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, frameState, layerState) {
|
ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, frameState, layerState) {
|
||||||
var renderMode = this.getLayer().getRenderMode();
|
var layer = this.getLayer();
|
||||||
|
var source = layer.getSource();
|
||||||
|
var renderMode = layer.getRenderMode();
|
||||||
var replays = ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS[renderMode];
|
var replays = ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS[renderMode];
|
||||||
if (replays) {
|
if (replays) {
|
||||||
var pixelRatio = frameState.pixelRatio;
|
var pixelRatio = frameState.pixelRatio;
|
||||||
@@ -317,18 +339,32 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra
|
|||||||
var offsetX = Math.round(pixelRatio * size[0] / 2);
|
var offsetX = Math.round(pixelRatio * size[0] / 2);
|
||||||
var offsetY = Math.round(pixelRatio * size[1] / 2);
|
var offsetY = Math.round(pixelRatio * size[1] / 2);
|
||||||
var tiles = this.renderedTiles;
|
var tiles = this.renderedTiles;
|
||||||
|
var tilePixelRatio = layer.getSource().getTilePixelRatio();
|
||||||
|
var sourceTileGrid = source.getTileGrid();
|
||||||
|
var tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
|
||||||
var clips = [];
|
var clips = [];
|
||||||
var zs = [];
|
var zs = [];
|
||||||
for (var i = tiles.length - 1; i >= 0; --i) {
|
for (var i = tiles.length - 1; i >= 0; --i) {
|
||||||
var tile = /** @type {ol.VectorTile} */ (tiles[i]);
|
var tile = /** @type {ol.VectorImageTile} */ (tiles[i]);
|
||||||
// Create a clip mask for regions in this low resolution tile that are
|
if (tile.getState() == ol.TileState.ABORT) {
|
||||||
// already filled by a higher resolution tile
|
continue;
|
||||||
var transform = this.getReplayTransform_(tile, frameState);
|
}
|
||||||
var currentClip = tile.getReplayState().replayGroup.getClipCoords(transform);
|
var tileCoord = tile.tileCoord;
|
||||||
var currentZ = tile.tileCoord[0];
|
var worldOffset = tileGrid.getTileCoordExtent(tileCoord)[0] -
|
||||||
|
tileGrid.getTileCoordExtent(tile.wrappedTileCoord)[0];
|
||||||
|
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
|
||||||
|
var sourceTile = tile.getTile(tile.tileKeys[t]);
|
||||||
|
var currentZ = sourceTile.tileCoord[0];
|
||||||
|
var sourceResolution = sourceTileGrid.getResolution(currentZ);
|
||||||
|
var transform = this.getReplayTransform_(sourceTile, frameState);
|
||||||
|
ol.transform.translate(transform, worldOffset * tilePixelRatio / sourceResolution, 0);
|
||||||
|
var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString());
|
||||||
|
var currentClip = replayGroup.getClipCoords(transform);
|
||||||
context.save();
|
context.save();
|
||||||
context.globalAlpha = layerState.opacity;
|
context.globalAlpha = layerState.opacity;
|
||||||
ol.render.canvas.rotateAtOffset(context, -rotation, offsetX, offsetY);
|
ol.render.canvas.rotateAtOffset(context, -rotation, offsetX, offsetY);
|
||||||
|
// Create a clip mask for regions in this low resolution tile that are
|
||||||
|
// already filled by a higher resolution tile
|
||||||
for (var j = 0, jj = clips.length; j < jj; ++j) {
|
for (var j = 0, jj = clips.length; j < jj; ++j) {
|
||||||
var clip = clips[j];
|
var clip = clips[j];
|
||||||
if (currentZ < zs[j]) {
|
if (currentZ < zs[j]) {
|
||||||
@@ -346,13 +382,13 @@ ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, fra
|
|||||||
context.clip();
|
context.clip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var replayGroup = tile.getReplayState().replayGroup;
|
|
||||||
replayGroup.replay(context, pixelRatio, transform, rotation, {}, replays);
|
replayGroup.replay(context, pixelRatio, transform, rotation, {}, replays);
|
||||||
context.restore();
|
context.restore();
|
||||||
clips.push(currentClip);
|
clips.push(currentClip);
|
||||||
zs.push(currentZ);
|
zs.push(currentZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ol.renderer.canvas.TileLayer.prototype.postCompose.apply(this, arguments);
|
ol.renderer.canvas.TileLayer.prototype.postCompose.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -386,7 +422,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderFeature = function(feature, s
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.VectorTile} tile Tile.
|
* @param {ol.VectorImageTile} tile Tile.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @param {ol.LayerState} layerState Layer state.
|
* @param {ol.LayerState} layerState Layer state.
|
||||||
* @private
|
* @private
|
||||||
@@ -394,33 +430,43 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderFeature = function(feature, s
|
|||||||
ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function(
|
ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function(
|
||||||
tile, frameState, layerState) {
|
tile, frameState, layerState) {
|
||||||
var layer = this.getLayer();
|
var layer = this.getLayer();
|
||||||
var replayState = tile.getReplayState();
|
var replayState = tile.getReplayState(layer);
|
||||||
var revision = layer.getRevision();
|
var revision = layer.getRevision();
|
||||||
var replays = ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS[layer.getRenderMode()];
|
var replays = ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS[layer.getRenderMode()];
|
||||||
if (replays && replayState.renderedTileRevision !== revision) {
|
if (replays && replayState.renderedTileRevision !== revision) {
|
||||||
replayState.renderedTileRevision = revision;
|
replayState.renderedTileRevision = revision;
|
||||||
var tileCoord = tile.tileCoord;
|
var tileCoord = tile.wrappedTileCoord;
|
||||||
var z = tile.tileCoord[0];
|
var z = tileCoord[0];
|
||||||
var pixelRatio = frameState.pixelRatio;
|
var pixelRatio = frameState.pixelRatio;
|
||||||
var source = layer.getSource();
|
var source = layer.getSource();
|
||||||
var tileGrid = source.getTileGrid();
|
var sourceTileGrid = source.getTileGrid();
|
||||||
var tilePixelRatio = source.getTilePixelRatio();
|
var tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
|
||||||
var transform = ol.transform.reset(this.tmpTransform_);
|
|
||||||
if (tile.getProjection().getUnits() == ol.proj.Units.TILE_PIXELS) {
|
|
||||||
var renderPixelRatio = pixelRatio / tilePixelRatio;
|
|
||||||
ol.transform.scale(transform, renderPixelRatio, renderPixelRatio);
|
|
||||||
} else {
|
|
||||||
var resolution = tileGrid.getResolution(z);
|
var resolution = tileGrid.getResolution(z);
|
||||||
var pixelScale = pixelRatio / resolution;
|
var tilePixelRatio = source.getTilePixelRatio();
|
||||||
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent);
|
var context = tile.getContext(layer);
|
||||||
ol.transform.scale(transform, pixelScale, -pixelScale);
|
|
||||||
ol.transform.translate(transform, -tileExtent[0], -tileExtent[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var context = tile.getContext();
|
|
||||||
var size = source.getTilePixelSize(z, pixelRatio, frameState.viewState.projection);
|
var size = source.getTilePixelSize(z, pixelRatio, frameState.viewState.projection);
|
||||||
context.canvas.width = size[0];
|
context.canvas.width = size[0];
|
||||||
context.canvas.height = size[1];
|
context.canvas.height = size[1];
|
||||||
replayState.replayGroup.replay(context, pixelRatio, transform, 0, {}, replays);
|
var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
|
||||||
|
for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) {
|
||||||
|
var sourceTile = tile.getTile(tile.tileKeys[i]);
|
||||||
|
var sourceTileCoord = sourceTile.tileCoord;
|
||||||
|
var pixelScale = pixelRatio / resolution;
|
||||||
|
var transform = ol.transform.reset(this.tmpTransform_);
|
||||||
|
if (sourceTile.getProjection().getUnits() == ol.proj.Units.TILE_PIXELS) {
|
||||||
|
var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord, this.tmpExtent);
|
||||||
|
var sourceResolution = sourceTileGrid.getResolution(sourceTileCoord[0]);
|
||||||
|
var renderPixelRatio = pixelRatio / tilePixelRatio * sourceResolution / resolution;
|
||||||
|
ol.transform.scale(transform, renderPixelRatio, renderPixelRatio);
|
||||||
|
var offsetX = (sourceTileExtent[0] - tileExtent[0]) / sourceResolution * tilePixelRatio;
|
||||||
|
var offsetY = (tileExtent[3] - sourceTileExtent[3]) / sourceResolution * tilePixelRatio;
|
||||||
|
ol.transform.translate(transform, Math.round(offsetX), Math.round(offsetY));
|
||||||
|
} else {
|
||||||
|
ol.transform.scale(transform, pixelScale, -pixelScale);
|
||||||
|
ol.transform.translate(transform, -tileExtent[0], -tileExtent[3]);
|
||||||
|
}
|
||||||
|
var replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString());
|
||||||
|
replayGroup.replay(context, pixelRatio, transform, 0, {}, replays);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -152,8 +152,10 @@ ol.renderer.Layer.prototype.scheduleExpireCache = function(frameState, tileSourc
|
|||||||
*/
|
*/
|
||||||
var postRenderFunction = function(tileSource, map, frameState) {
|
var postRenderFunction = function(tileSource, map, frameState) {
|
||||||
var tileSourceKey = ol.getUid(tileSource).toString();
|
var tileSourceKey = ol.getUid(tileSource).toString();
|
||||||
|
if (tileSourceKey in frameState.usedTiles) {
|
||||||
tileSource.expireCache(frameState.viewState.projection,
|
tileSource.expireCache(frameState.viewState.projection,
|
||||||
frameState.usedTiles[tileSourceKey]);
|
frameState.usedTiles[tileSourceKey]);
|
||||||
|
}
|
||||||
}.bind(null, tileSource);
|
}.bind(null, tileSource);
|
||||||
|
|
||||||
frameState.postRenderFunctions.push(
|
frameState.postRenderFunctions.push(
|
||||||
|
|||||||
@@ -40,13 +40,15 @@ ol.reproj.calculateSourceResolution = function(sourceProj, targetProj,
|
|||||||
// coordinates may be slightly different. We need to reverse-compensate this
|
// coordinates may be slightly different. We need to reverse-compensate this
|
||||||
// in order to achieve optimal results.
|
// in order to achieve optimal results.
|
||||||
|
|
||||||
|
var sourceExtent = sourceProj.getExtent();
|
||||||
|
if (!sourceExtent || ol.extent.containsCoordinate(sourceExtent, sourceCenter)) {
|
||||||
var compensationFactor =
|
var compensationFactor =
|
||||||
ol.proj.getPointResolution(sourceProj, sourceResolution, sourceCenter) /
|
ol.proj.getPointResolution(sourceProj, sourceResolution, sourceCenter) /
|
||||||
sourceResolution;
|
sourceResolution;
|
||||||
|
|
||||||
if (isFinite(compensationFactor) && compensationFactor > 0) {
|
if (isFinite(compensationFactor) && compensationFactor > 0) {
|
||||||
sourceResolution /= compensationFactor;
|
sourceResolution /= compensationFactor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return sourceResolution;
|
return sourceResolution;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -202,7 +202,8 @@ ol.reproj.Tile.prototype.disposeInternal = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* Get the HTML Canvas element for this tile.
|
||||||
|
* @return {HTMLCanvasElement} Canvas.
|
||||||
*/
|
*/
|
||||||
ol.reproj.Tile.prototype.getImage = function() {
|
ol.reproj.Tile.prototype.getImage = function() {
|
||||||
return this.canvas_;
|
return this.canvas_;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ ol.inherits(ol.source.BingMaps, ol.source.TileImage);
|
|||||||
*/
|
*/
|
||||||
ol.source.BingMaps.TOS_ATTRIBUTION = new ol.Attribution({
|
ol.source.BingMaps.TOS_ATTRIBUTION = new ol.Attribution({
|
||||||
html: '<a class="ol-attribution-bing-tos" ' +
|
html: '<a class="ol-attribution-bing-tos" ' +
|
||||||
'href="http://www.microsoft.com/maps/product/terms.html">' +
|
'href="https://www.microsoft.com/maps/product/terms.html">' +
|
||||||
'Terms of Use</a>'
|
'Terms of Use</a>'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,27 +35,28 @@ ol.source.Cluster = function(options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.resolution_ = undefined;
|
this.resolution = undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.distance_ = options.distance !== undefined ? options.distance : 20;
|
this.distance = options.distance !== undefined ? options.distance : 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array.<ol.Feature>}
|
* @type {Array.<ol.Feature>}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.features_ = [];
|
this.features = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature} feature Feature.
|
* @param {ol.Feature} feature Feature.
|
||||||
* @return {ol.geom.Point} Cluster calculation point.
|
* @return {ol.geom.Point} Cluster calculation point.
|
||||||
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.geometryFunction_ = options.geometryFunction || function(feature) {
|
this.geometryFunction = options.geometryFunction || function(feature) {
|
||||||
var geometry = /** @type {ol.geom.Point} */ (feature.getGeometry());
|
var geometry = /** @type {ol.geom.Point} */ (feature.getGeometry());
|
||||||
ol.asserts.assert(geometry instanceof ol.geom.Point,
|
ol.asserts.assert(geometry instanceof ol.geom.Point,
|
||||||
10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries
|
10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries
|
||||||
@@ -64,12 +65,12 @@ ol.source.Cluster = function(options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.source.Vector}
|
* @type {ol.source.Vector}
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.source_ = options.source;
|
this.source = options.source;
|
||||||
|
|
||||||
this.source_.on(ol.events.EventType.CHANGE,
|
this.source.on(ol.events.EventType.CHANGE,
|
||||||
ol.source.Cluster.prototype.refresh_, this);
|
ol.source.Cluster.prototype.refresh, this);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.source.Cluster, ol.source.Vector);
|
ol.inherits(ol.source.Cluster, ol.source.Vector);
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ ol.inherits(ol.source.Cluster, ol.source.Vector);
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.getDistance = function() {
|
ol.source.Cluster.prototype.getDistance = function() {
|
||||||
return this.distance_;
|
return this.distance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ ol.source.Cluster.prototype.getDistance = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.getSource = function() {
|
ol.source.Cluster.prototype.getSource = function() {
|
||||||
return this.source_;
|
return this.source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -99,12 +100,12 @@ ol.source.Cluster.prototype.getSource = function() {
|
|||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.loadFeatures = function(extent, resolution,
|
ol.source.Cluster.prototype.loadFeatures = function(extent, resolution,
|
||||||
projection) {
|
projection) {
|
||||||
this.source_.loadFeatures(extent, resolution, projection);
|
this.source.loadFeatures(extent, resolution, projection);
|
||||||
if (resolution !== this.resolution_) {
|
if (resolution !== this.resolution) {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.resolution_ = resolution;
|
this.resolution = resolution;
|
||||||
this.cluster_();
|
this.cluster();
|
||||||
this.addFeatures(this.features_);
|
this.addFeatures(this.features);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,34 +116,34 @@ ol.source.Cluster.prototype.loadFeatures = function(extent, resolution,
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.setDistance = function(distance) {
|
ol.source.Cluster.prototype.setDistance = function(distance) {
|
||||||
this.distance_ = distance;
|
this.distance = distance;
|
||||||
this.refresh_();
|
this.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle the source changing
|
* handle the source changing
|
||||||
* @private
|
* @override
|
||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.refresh_ = function() {
|
ol.source.Cluster.prototype.refresh = function() {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.cluster_();
|
this.cluster();
|
||||||
this.addFeatures(this.features_);
|
this.addFeatures(this.features);
|
||||||
this.changed();
|
ol.source.Vector.prototype.refresh.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.cluster_ = function() {
|
ol.source.Cluster.prototype.cluster = function() {
|
||||||
if (this.resolution_ === undefined) {
|
if (this.resolution === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.features_.length = 0;
|
this.features.length = 0;
|
||||||
var extent = ol.extent.createEmpty();
|
var extent = ol.extent.createEmpty();
|
||||||
var mapDistance = this.distance_ * this.resolution_;
|
var mapDistance = this.distance * this.resolution;
|
||||||
var features = this.source_.getFeatures();
|
var features = this.source.getFeatures();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {!Object.<string, boolean>}
|
* @type {!Object.<string, boolean>}
|
||||||
@@ -152,13 +153,13 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
|||||||
for (var i = 0, ii = features.length; i < ii; i++) {
|
for (var i = 0, ii = features.length; i < ii; i++) {
|
||||||
var feature = features[i];
|
var feature = features[i];
|
||||||
if (!(ol.getUid(feature).toString() in clustered)) {
|
if (!(ol.getUid(feature).toString() in clustered)) {
|
||||||
var geometry = this.geometryFunction_(feature);
|
var geometry = this.geometryFunction(feature);
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
var coordinates = geometry.getCoordinates();
|
var coordinates = geometry.getCoordinates();
|
||||||
ol.extent.createOrUpdateFromCoordinate(coordinates, extent);
|
ol.extent.createOrUpdateFromCoordinate(coordinates, extent);
|
||||||
ol.extent.buffer(extent, mapDistance, extent);
|
ol.extent.buffer(extent, mapDistance, extent);
|
||||||
|
|
||||||
var neighbors = this.source_.getFeaturesInExtent(extent);
|
var neighbors = this.source.getFeaturesInExtent(extent);
|
||||||
neighbors = neighbors.filter(function(neighbor) {
|
neighbors = neighbors.filter(function(neighbor) {
|
||||||
var uid = ol.getUid(neighbor).toString();
|
var uid = ol.getUid(neighbor).toString();
|
||||||
if (!(uid in clustered)) {
|
if (!(uid in clustered)) {
|
||||||
@@ -168,7 +169,7 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.features_.push(this.createCluster_(neighbors));
|
this.features.push(this.createCluster(neighbors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,12 +179,12 @@ ol.source.Cluster.prototype.cluster_ = function() {
|
|||||||
/**
|
/**
|
||||||
* @param {Array.<ol.Feature>} features Features
|
* @param {Array.<ol.Feature>} features Features
|
||||||
* @return {ol.Feature} The cluster feature.
|
* @return {ol.Feature} The cluster feature.
|
||||||
* @private
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.source.Cluster.prototype.createCluster_ = function(features) {
|
ol.source.Cluster.prototype.createCluster = function(features) {
|
||||||
var centroid = [0, 0];
|
var centroid = [0, 0];
|
||||||
for (var i = features.length - 1; i >= 0; --i) {
|
for (var i = features.length - 1; i >= 0; --i) {
|
||||||
var geometry = this.geometryFunction_(features[i]);
|
var geometry = this.geometryFunction(features[i]);
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
ol.coordinate.add(centroid, geometry.getCoordinates());
|
ol.coordinate.add(centroid, geometry.getCoordinates());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, pr
|
|||||||
ol.proj.equivalent(
|
ol.proj.equivalent(
|
||||||
this.reprojectedImage_.getProjection(), projection) &&
|
this.reprojectedImage_.getProjection(), projection) &&
|
||||||
this.reprojectedImage_.getResolution() == resolution &&
|
this.reprojectedImage_.getResolution() == resolution &&
|
||||||
this.reprojectedImage_.getPixelRatio() == pixelRatio &&
|
|
||||||
ol.extent.equals(this.reprojectedImage_.getExtent(), extent)) {
|
ol.extent.equals(this.reprojectedImage_.getExtent(), extent)) {
|
||||||
return this.reprojectedImage_;
|
return this.reprojectedImage_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,8 +220,6 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p
|
|||||||
var frameState = this.updateFrameState_(extent, resolution, projection);
|
var frameState = this.updateFrameState_(extent, resolution, projection);
|
||||||
this.requestedFrameState_ = frameState;
|
this.requestedFrameState_ = frameState;
|
||||||
|
|
||||||
frameState.tileQueue.loadMoreTiles(16, 16);
|
|
||||||
|
|
||||||
// check if we can't reuse the existing ol.ImageCanvas
|
// check if we can't reuse the existing ol.ImageCanvas
|
||||||
if (this.renderedImageCanvas_) {
|
if (this.renderedImageCanvas_) {
|
||||||
var renderedResolution = this.renderedImageCanvas_.getResolution();
|
var renderedResolution = this.renderedImageCanvas_.getResolution();
|
||||||
@@ -235,6 +233,7 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p
|
|||||||
this.processSources_();
|
this.processSources_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frameState.tileQueue.loadMoreTiles(16, 16);
|
||||||
return this.renderedImageCanvas_;
|
return this.renderedImageCanvas_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ ol.inherits(ol.source.Stamen, ol.source.XYZ);
|
|||||||
*/
|
*/
|
||||||
ol.source.Stamen.ATTRIBUTIONS = [
|
ol.source.Stamen.ATTRIBUTIONS = [
|
||||||
new ol.Attribution({
|
new ol.Attribution({
|
||||||
html: 'Map tiles by <a href="http://stamen.com/">Stamen Design</a>, ' +
|
html: 'Map tiles by <a href="https://stamen.com/">Stamen Design</a>, ' +
|
||||||
'under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY' +
|
'under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY' +
|
||||||
' 3.0</a>.'
|
' 3.0</a>.'
|
||||||
}),
|
}),
|
||||||
ol.source.OSM.ATTRIBUTION
|
ol.source.OSM.ATTRIBUTION
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ ol.inherits(ol.source.TileDebug.Tile_, ol.Tile);
|
|||||||
/**
|
/**
|
||||||
* Get the image element for this tile.
|
* Get the image element for this tile.
|
||||||
* @return {HTMLCanvasElement} Image.
|
* @return {HTMLCanvasElement} Image.
|
||||||
* @override
|
|
||||||
*/
|
*/
|
||||||
ol.source.TileDebug.Tile_.prototype.getImage = function() {
|
ol.source.TileDebug.Tile_.prototype.getImage = function() {
|
||||||
if (this.canvas_) {
|
if (this.canvas_) {
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
|||||||
|
|
||||||
if (tile) {
|
if (tile) {
|
||||||
newTile.interimTile = tile;
|
newTile.interimTile = tile;
|
||||||
|
newTile.refreshInterimChain();
|
||||||
cache.replace(tileCoordKey, newTile);
|
cache.replace(tileCoordKey, newTile);
|
||||||
} else {
|
} else {
|
||||||
cache.set(tileCoordKey, newTile);
|
cache.set(tileCoordKey, newTile);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ goog.provide('ol.source.TileJSON');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol.TileUrlFunction');
|
||||||
|
goog.require('ol.asserts');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.net');
|
goog.require('ol.net');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
@@ -45,6 +46,7 @@ ol.source.TileJSON = function(options) {
|
|||||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (options.url) {
|
||||||
if (options.jsonp) {
|
if (options.jsonp) {
|
||||||
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
||||||
this.handleTileJSONError.bind(this));
|
this.handleTileJSONError.bind(this));
|
||||||
@@ -55,6 +57,11 @@ ol.source.TileJSON = function(options) {
|
|||||||
client.open('GET', options.url);
|
client.open('GET', options.url);
|
||||||
client.send();
|
client.send();
|
||||||
}
|
}
|
||||||
|
} else if (options.tileJSON) {
|
||||||
|
this.handleTileJSONResponse(options.tileJSON);
|
||||||
|
} else {
|
||||||
|
ol.asserts.assert(false, 51); // Either `url` or `tileJSON` options must be provided
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.source.TileJSON, ol.source.TileImage);
|
ol.inherits(ol.source.TileJSON, ol.source.TileImage);
|
||||||
|
|||||||
@@ -320,7 +320,6 @@ ol.inherits(ol.source.TileUTFGrid.Tile_, ol.Tile);
|
|||||||
/**
|
/**
|
||||||
* Get the image element for this tile.
|
* Get the image element for this tile.
|
||||||
* @return {Image} Image.
|
* @return {Image} Image.
|
||||||
* @override
|
|
||||||
*/
|
*/
|
||||||
ol.source.TileUTFGrid.Tile_.prototype.getImage = function() {
|
ol.source.TileUTFGrid.Tile_.prototype.getImage = function() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -157,7 +157,9 @@ ol.inherits(ol.source.Vector, ol.source.Source);
|
|||||||
/**
|
/**
|
||||||
* Add a single feature to the source. If you want to add a batch of features
|
* Add a single feature to the source. If you want to add a batch of features
|
||||||
* at once, call {@link ol.source.Vector#addFeatures source.addFeatures()}
|
* at once, call {@link ol.source.Vector#addFeatures source.addFeatures()}
|
||||||
* instead.
|
* instead. A feature will not be added to the source if feature with
|
||||||
|
* the same id is already there. The reason for this behavior is to avoid
|
||||||
|
* feature duplication when using bbox or tile loading strategies.
|
||||||
* @param {ol.Feature} feature Feature to add.
|
* @param {ol.Feature} feature Feature to add.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -612,7 +614,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
|
|||||||
* `useSpatialIndex` set to `false`.
|
* `useSpatialIndex` set to `false`.
|
||||||
* @param {ol.Extent=} opt_extent Destination extent. If provided, no new extent
|
* @param {ol.Extent=} opt_extent Destination extent. If provided, no new extent
|
||||||
* will be created. Instead, that extent's coordinates will be overwritten.
|
* will be created. Instead, that extent's coordinates will be overwritten.
|
||||||
* @return {!ol.Extent} Extent.
|
* @return {ol.Extent} Extent.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.Vector.prototype.getExtent = function(opt_extent) {
|
ol.source.Vector.prototype.getExtent = function(opt_extent) {
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ goog.provide('ol.source.VectorTile');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
|
goog.require('ol.VectorImageTile');
|
||||||
goog.require('ol.VectorTile');
|
goog.require('ol.VectorTile');
|
||||||
goog.require('ol.events');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.events.EventType');
|
|
||||||
goog.require('ol.size');
|
goog.require('ol.size');
|
||||||
|
goog.require('ol.tilegrid');
|
||||||
goog.require('ol.source.UrlTile');
|
goog.require('ol.source.UrlTile');
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ ol.source.VectorTile = function(options) {
|
|||||||
state: options.state,
|
state: options.state,
|
||||||
tileGrid: options.tileGrid,
|
tileGrid: options.tileGrid,
|
||||||
tileLoadFunction: options.tileLoadFunction ?
|
tileLoadFunction: options.tileLoadFunction ?
|
||||||
options.tileLoadFunction : ol.VectorTile.defaultLoadFunction,
|
options.tileLoadFunction : ol.VectorImageTile.defaultLoadFunction,
|
||||||
tileUrlFunction: options.tileUrlFunction,
|
tileUrlFunction: options.tileUrlFunction,
|
||||||
tilePixelRatio: options.tilePixelRatio,
|
tilePixelRatio: options.tilePixelRatio,
|
||||||
url: options.url,
|
url: options.url,
|
||||||
@@ -51,6 +52,12 @@ ol.source.VectorTile = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.format_ = options.format ? options.format : null;
|
this.format_ = options.format ? options.format : null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string,ol.VectorTile>}
|
||||||
|
*/
|
||||||
|
this.sourceTiles_ = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -64,6 +71,16 @@ ol.source.VectorTile = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile;
|
this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string,ol.tilegrid.TileGrid>}
|
||||||
|
*/
|
||||||
|
this.tileGrids_ = {};
|
||||||
|
|
||||||
|
if (!this.tileGrid) {
|
||||||
|
this.tileGrid = this.getTileGridForProjection(ol.proj.get(options.projection || 'EPSG:3857'));
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.source.VectorTile, ol.source.UrlTile);
|
ol.inherits(ol.source.VectorTile, ol.source.UrlTile);
|
||||||
|
|
||||||
@@ -89,13 +106,14 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio
|
|||||||
tileCoord, projection);
|
tileCoord, projection);
|
||||||
var tileUrl = urlTileCoord ?
|
var tileUrl = urlTileCoord ?
|
||||||
this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined;
|
this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined;
|
||||||
var tile = new this.tileClass(
|
var tile = new ol.VectorImageTile(
|
||||||
tileCoord,
|
tileCoord,
|
||||||
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
|
||||||
tileUrl !== undefined ? tileUrl : '',
|
tileUrl !== undefined ? tileUrl : '',
|
||||||
this.format_, this.tileLoadFunction);
|
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
|
||||||
ol.events.listen(tile, ol.events.EventType.CHANGE,
|
this.tileGrid, this.getTileGridForProjection(projection),
|
||||||
this.handleTileChange, this);
|
this.sourceTiles_, pixelRatio, projection, this.tileClass,
|
||||||
|
this.handleTileChange.bind(this));
|
||||||
|
|
||||||
this.tileCache.set(tileCoordKey, tile);
|
this.tileCache.set(tileCoordKey, tile);
|
||||||
return tile;
|
return tile;
|
||||||
@@ -103,6 +121,23 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) {
|
||||||
|
var code = projection.getCode();
|
||||||
|
var tileGrid = this.tileGrids_[code];
|
||||||
|
if (!tileGrid) {
|
||||||
|
// A tile grid that matches the tile size of the source tile grid is more
|
||||||
|
// likely to have 1:1 relationships between source tiles and rendered tiles.
|
||||||
|
var sourceTileGrid = this.tileGrid;
|
||||||
|
tileGrid = this.tileGrids_[code] = ol.tilegrid.createForProjection(projection, undefined,
|
||||||
|
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
|
||||||
|
}
|
||||||
|
return tileGrid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -117,6 +152,6 @@ ol.source.VectorTile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.source.VectorTile.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
|
ol.source.VectorTile.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
|
||||||
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z));
|
var tileSize = ol.size.toSize(this.getTileGridForProjection(projection).getTileSize(z));
|
||||||
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
|
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
goog.provide('ol.sphere.NORMAL');
|
|
||||||
|
|
||||||
goog.require('ol.Sphere');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The normal sphere.
|
|
||||||
* @const
|
|
||||||
* @type {ol.Sphere}
|
|
||||||
*/
|
|
||||||
ol.sphere.NORMAL = new ol.Sphere(6370997);
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
goog.provide('ol.sphere.WGS84');
|
|
||||||
|
|
||||||
goog.require('ol.Sphere');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A sphere with radius equal to the semi-major axis of the WGS84 ellipsoid.
|
|
||||||
* @const
|
|
||||||
* @type {ol.Sphere}
|
|
||||||
*/
|
|
||||||
ol.sphere.WGS84 = new ol.Sphere(6378137);
|
|
||||||
@@ -208,10 +208,21 @@ ol.structs.RBush.prototype.clear = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Extent=} opt_extent Extent.
|
* @param {ol.Extent=} opt_extent Extent.
|
||||||
* @return {!ol.Extent} Extent.
|
* @return {ol.Extent} Extent.
|
||||||
*/
|
*/
|
||||||
ol.structs.RBush.prototype.getExtent = function(opt_extent) {
|
ol.structs.RBush.prototype.getExtent = function(opt_extent) {
|
||||||
// FIXME add getExtent() to rbush
|
// FIXME add getExtent() to rbush
|
||||||
var data = this.rbush_.data;
|
var data = this.rbush_.data;
|
||||||
return ol.extent.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
|
return ol.extent.createOrUpdate(data.minX, data.minY, data.maxX, data.maxY, opt_extent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.structs.RBush} rbush R-Tree.
|
||||||
|
*/
|
||||||
|
ol.structs.RBush.prototype.concat = function(rbush) {
|
||||||
|
this.rbush_.load(rbush.rbush_.all());
|
||||||
|
for (var i in rbush.items_) {
|
||||||
|
this.items_[i | 0] = rbush.items_[i | 0];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -66,10 +66,9 @@ ol.style.RegularShape = function(options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number|undefined}
|
||||||
*/
|
*/
|
||||||
this.radius2_ =
|
this.radius2_ = options.radius2;
|
||||||
options.radius2 !== undefined ? options.radius2 : this.radius_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -146,7 +145,7 @@ ol.inherits(ol.style.RegularShape, ol.style.Image);
|
|||||||
ol.style.RegularShape.prototype.clone = function() {
|
ol.style.RegularShape.prototype.clone = function() {
|
||||||
var style = new ol.style.RegularShape({
|
var style = new ol.style.RegularShape({
|
||||||
fill: this.getFill() ? this.getFill().clone() : undefined,
|
fill: this.getFill() ? this.getFill().clone() : undefined,
|
||||||
points: this.getRadius2() !== this.getRadius() ? this.getPoints() / 2 : this.getPoints(),
|
points: this.getPoints(),
|
||||||
radius: this.getRadius(),
|
radius: this.getRadius(),
|
||||||
radius2: this.getRadius2(),
|
radius2: this.getRadius2(),
|
||||||
angle: this.getAngle(),
|
angle: this.getAngle(),
|
||||||
@@ -263,7 +262,7 @@ ol.style.RegularShape.prototype.getRadius = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the secondary radius for the shape.
|
* Get the secondary radius for the shape.
|
||||||
* @return {number} Radius2.
|
* @return {number|undefined} Radius2.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.style.RegularShape.prototype.getRadius2 = function() {
|
ol.style.RegularShape.prototype.getRadius2 = function() {
|
||||||
@@ -428,17 +427,20 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
|
|||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
|
|
||||||
if (this.points_ === Infinity) {
|
var points = this.points_;
|
||||||
|
if (points === Infinity) {
|
||||||
context.arc(
|
context.arc(
|
||||||
renderOptions.size / 2, renderOptions.size / 2,
|
renderOptions.size / 2, renderOptions.size / 2,
|
||||||
this.radius_, 0, 2 * Math.PI, true);
|
this.radius_, 0, 2 * Math.PI, true);
|
||||||
} else {
|
} else {
|
||||||
if (this.radius2_ !== this.radius_) {
|
var radius2 = (this.radius2_ !== undefined) ? this.radius2_
|
||||||
this.points_ = 2 * this.points_;
|
: this.radius_;
|
||||||
|
if (radius2 !== this.radius_) {
|
||||||
|
points = 2 * points;
|
||||||
}
|
}
|
||||||
for (i = 0; i <= this.points_; i++) {
|
for (i = 0; i <= points; i++) {
|
||||||
angle0 = i * 2 * Math.PI / this.points_ - Math.PI / 2 + this.angle_;
|
angle0 = i * 2 * Math.PI / points - Math.PI / 2 + this.angle_;
|
||||||
radiusC = i % 2 === 0 ? this.radius_ : this.radius2_;
|
radiusC = i % 2 === 0 ? this.radius_ : radius2;
|
||||||
context.lineTo(renderOptions.size / 2 + radiusC * Math.cos(angle0),
|
context.lineTo(renderOptions.size / 2 + radiusC * Math.cos(angle0),
|
||||||
renderOptions.size / 2 + radiusC * Math.sin(angle0));
|
renderOptions.size / 2 + radiusC * Math.sin(angle0));
|
||||||
}
|
}
|
||||||
@@ -504,18 +506,21 @@ ol.style.RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions
|
|||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
|
|
||||||
if (this.points_ === Infinity) {
|
var points = this.points_;
|
||||||
|
if (points === Infinity) {
|
||||||
context.arc(
|
context.arc(
|
||||||
renderOptions.size / 2, renderOptions.size / 2,
|
renderOptions.size / 2, renderOptions.size / 2,
|
||||||
this.radius_, 0, 2 * Math.PI, true);
|
this.radius_, 0, 2 * Math.PI, true);
|
||||||
} else {
|
} else {
|
||||||
if (this.radius2_ !== this.radius_) {
|
var radius2 = (this.radius2_ !== undefined) ? this.radius2_
|
||||||
this.points_ = 2 * this.points_;
|
: this.radius_;
|
||||||
|
if (radius2 !== this.radius_) {
|
||||||
|
points = 2 * points;
|
||||||
}
|
}
|
||||||
var i, radiusC, angle0;
|
var i, radiusC, angle0;
|
||||||
for (i = 0; i <= this.points_; i++) {
|
for (i = 0; i <= points; i++) {
|
||||||
angle0 = i * 2 * Math.PI / this.points_ - Math.PI / 2 + this.angle_;
|
angle0 = i * 2 * Math.PI / points - Math.PI / 2 + this.angle_;
|
||||||
radiusC = i % 2 === 0 ? this.radius_ : this.radius2_;
|
radiusC = i % 2 === 0 ? this.radius_ : radius2;
|
||||||
context.lineTo(renderOptions.size / 2 + radiusC * Math.cos(angle0),
|
context.lineTo(renderOptions.size / 2 + radiusC * Math.cos(angle0),
|
||||||
renderOptions.size / 2 + radiusC * Math.sin(angle0));
|
renderOptions.size / 2 + radiusC * Math.sin(angle0));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,14 +59,6 @@ ol.Tile.prototype.changed = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the HTML image element for this tile (may be a Canvas, Image, or Video).
|
|
||||||
* @abstract
|
|
||||||
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
|
|
||||||
*/
|
|
||||||
ol.Tile.prototype.getImage = function() {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string} Key.
|
* @return {string} Key.
|
||||||
*/
|
*/
|
||||||
@@ -153,6 +145,13 @@ ol.Tile.prototype.getState = function() {
|
|||||||
return this.state;
|
return this.state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.TileState} state State.
|
||||||
|
*/
|
||||||
|
ol.Tile.prototype.setState = function(state) {
|
||||||
|
this.state = state;
|
||||||
|
this.changed();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the image or retry if loading previously failed.
|
* Load the image or retry if loading previously failed.
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ ol.tilegrid.createForExtent = function(extent, opt_maxZoom, opt_tileSize, opt_co
|
|||||||
/**
|
/**
|
||||||
* Creates a tile grid with a standard XYZ tiling scheme.
|
* Creates a tile grid with a standard XYZ tiling scheme.
|
||||||
* @param {olx.tilegrid.XYZOptions=} opt_options Tile grid options.
|
* @param {olx.tilegrid.XYZOptions=} opt_options Tile grid options.
|
||||||
* @return {ol.tilegrid.TileGrid} Tile grid instance.
|
* @return {!ol.tilegrid.TileGrid} Tile grid instance.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.tilegrid.createXYZ = function(opt_options) {
|
ol.tilegrid.createXYZ = function(opt_options) {
|
||||||
@@ -126,7 +126,8 @@ ol.tilegrid.resolutionsFromExtent = function(extent, opt_maxZoom, opt_tileSize)
|
|||||||
* @param {ol.ProjectionLike} projection Projection.
|
* @param {ol.ProjectionLike} projection Projection.
|
||||||
* @param {number=} opt_maxZoom Maximum zoom level (default is
|
* @param {number=} opt_maxZoom Maximum zoom level (default is
|
||||||
* ol.DEFAULT_MAX_ZOOM).
|
* ol.DEFAULT_MAX_ZOOM).
|
||||||
* @param {ol.Size=} opt_tileSize Tile size (default uses ol.DEFAULT_TILE_SIZE).
|
* @param {number|ol.Size=} opt_tileSize Tile size (default uses
|
||||||
|
* ol.DEFAULT_TILE_SIZE).
|
||||||
* @param {ol.extent.Corner=} opt_corner Extent corner (default is
|
* @param {ol.extent.Corner=} opt_corner Extent corner (default is
|
||||||
* ol.extent.Corner.BOTTOM_LEFT).
|
* ol.extent.Corner.BOTTOM_LEFT).
|
||||||
* @return {!ol.tilegrid.TileGrid} TileGrid instance.
|
* @return {!ol.tilegrid.TileGrid} TileGrid instance.
|
||||||
|
|||||||
@@ -106,16 +106,25 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
||||||
var newLoads = 0;
|
var newLoads = 0;
|
||||||
var tile, tileKey;
|
var abortedTiles = false;
|
||||||
|
var state, tile, tileKey;
|
||||||
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
|
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
|
||||||
this.getCount() > 0) {
|
this.getCount() > 0) {
|
||||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
||||||
tileKey = tile.getKey();
|
tileKey = tile.getKey();
|
||||||
if (tile.getState() === ol.TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) {
|
state = tile.getState();
|
||||||
|
if (state === ol.TileState.ABORT) {
|
||||||
|
abortedTiles = true;
|
||||||
|
} else if (state === ol.TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) {
|
||||||
this.tilesLoadingKeys_[tileKey] = true;
|
this.tilesLoadingKeys_[tileKey] = true;
|
||||||
++this.tilesLoading_;
|
++this.tilesLoading_;
|
||||||
++newLoads;
|
++newLoads;
|
||||||
tile.load();
|
tile.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (newLoads === 0 && abortedTiles) {
|
||||||
|
// Do not stop the render loop when all wanted tiles were aborted due to
|
||||||
|
// a small, saturated tile cache.
|
||||||
|
this.tileChangeCallback_();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -130,6 +130,16 @@ ol.Color;
|
|||||||
ol.ColorLike;
|
ol.ColorLike;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* center: ol.CenterConstraintType,
|
||||||
|
* resolution: ol.ResolutionConstraintType,
|
||||||
|
* rotation: ol.RotationConstraintType
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
|
ol.Constraints;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of numbers representing an xy coordinate. Example: `[16, 48]`.
|
* An array of numbers representing an xy coordinate. Example: `[16, 48]`.
|
||||||
* @typedef {Array.<number>}
|
* @typedef {Array.<number>}
|
||||||
@@ -156,12 +166,11 @@ ol.DragBoxEndConditionType;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that takes coordinates and an optional existing geometry as
|
* Function that takes an array of coordinates and an optional existing geometry as
|
||||||
* arguments, and returns a geometry. The optional existing geometry is the
|
* arguments, and returns a geometry. The optional existing geometry is the
|
||||||
* geometry that is returned when the function is called without a second
|
* geometry that is returned when the function is called without a second
|
||||||
* argument.
|
* argument.
|
||||||
* @typedef {function(!(ol.Coordinate|Array.<ol.Coordinate>|
|
* @typedef {function(!Array.<ol.Coordinate>, ol.geom.SimpleGeometry=):
|
||||||
* Array.<Array.<ol.Coordinate>>), ol.geom.SimpleGeometry=):
|
|
||||||
* ol.geom.SimpleGeometry}
|
* ol.geom.SimpleGeometry}
|
||||||
*/
|
*/
|
||||||
ol.DrawGeometryFunctionType;
|
ol.DrawGeometryFunctionType;
|
||||||
@@ -454,9 +463,11 @@ ol.RegularShapeRenderOptions;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A function to be used when sorting features before rendering.
|
* A function to be used when sorting features before rendering.
|
||||||
* It takes two instances of {@link ol.Feature} and returns a `{number}`.
|
* It takes two instances of {@link ol.Feature} or {@link ol.render.Feature} and
|
||||||
|
* returns a `{number}`.
|
||||||
*
|
*
|
||||||
* @typedef {function(ol.Feature, ol.Feature):number}
|
* @typedef {function((ol.Feature|ol.render.Feature), (ol.Feature|ol.render.Feature)):
|
||||||
|
* number}
|
||||||
*/
|
*/
|
||||||
ol.RenderOrderFunction;
|
ol.RenderOrderFunction;
|
||||||
|
|
||||||
@@ -652,8 +663,7 @@ ol.TilePriorityFunction;
|
|||||||
* dirty: boolean,
|
* dirty: boolean,
|
||||||
* renderedRenderOrder: (null|ol.RenderOrderFunction),
|
* renderedRenderOrder: (null|ol.RenderOrderFunction),
|
||||||
* renderedTileRevision: number,
|
* renderedTileRevision: number,
|
||||||
* renderedRevision: number,
|
* renderedRevision: number}}
|
||||||
* replayGroup: ol.render.ReplayGroup}}
|
|
||||||
*/
|
*/
|
||||||
ol.TileReplayState;
|
ol.TileReplayState;
|
||||||
|
|
||||||
@@ -713,6 +723,14 @@ ol.ViewAnimation;
|
|||||||
ol.WebglBufferCacheEntry;
|
ol.WebglBufferCacheEntry;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{atlas: ol.style.AtlasManager,
|
||||||
|
* width: Object.<string, number>,
|
||||||
|
* height: number}}
|
||||||
|
*/
|
||||||
|
ol.WebglGlyphAtlas;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{p0: ol.WebglPolygonVertex,
|
* @typedef {{p0: ol.WebglPolygonVertex,
|
||||||
* p1: ol.WebglPolygonVertex}}
|
* p1: ol.WebglPolygonVertex}}
|
||||||
|
|||||||
282
src/ol/vectorimagetile.js
Normal file
282
src/ol/vectorimagetile.js
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
goog.provide('ol.VectorImageTile');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
|
goog.require('ol.Tile');
|
||||||
|
goog.require('ol.TileState');
|
||||||
|
goog.require('ol.array');
|
||||||
|
goog.require('ol.dom');
|
||||||
|
goog.require('ol.events');
|
||||||
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.events.EventType');
|
||||||
|
goog.require('ol.featureloader');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.Tile}
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
|
* @param {ol.TileState} state State.
|
||||||
|
* @param {string} src Data source url.
|
||||||
|
* @param {ol.format.Feature} format Feature format.
|
||||||
|
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||||
|
* @param {ol.TileCoord} urlTileCoord Wrapped tile coordinate for source urls.
|
||||||
|
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile url function.
|
||||||
|
* @param {ol.tilegrid.TileGrid} sourceTileGrid Tile grid of the source.
|
||||||
|
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid of the renderer.
|
||||||
|
* @param {Object.<string,ol.VectorTile>} sourceTiles Source tiles.
|
||||||
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
|
* @param {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string,
|
||||||
|
* ol.format.Feature, ol.TileLoadFunctionType)} tileClass Class to
|
||||||
|
* instantiate for source tiles.
|
||||||
|
* @param {function(this: ol.source.VectorTile, ol.events.Event)} handleTileChange
|
||||||
|
* Function to call when a source tile's state changes.
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile = function(tileCoord, state, src, format, tileLoadFunction,
|
||||||
|
urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid, sourceTiles,
|
||||||
|
pixelRatio, projection, tileClass, handleTileChange) {
|
||||||
|
|
||||||
|
ol.Tile.call(this, tileCoord, state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, CanvasRenderingContext2D>}
|
||||||
|
*/
|
||||||
|
this.context_ = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.FeatureLoader}
|
||||||
|
*/
|
||||||
|
this.loader_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, ol.TileReplayState>}
|
||||||
|
*/
|
||||||
|
this.replayState_ = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string,ol.VectorTile>}
|
||||||
|
*/
|
||||||
|
this.sourceTiles_ = sourceTiles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys of source tiles used by this tile. Use with {@link #getTile}.
|
||||||
|
* @type {Array.<string>}
|
||||||
|
*/
|
||||||
|
this.tileKeys = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.src_ = src;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol.TileCoord}
|
||||||
|
*/
|
||||||
|
this.wrappedTileCoord = urlTileCoord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<ol.EventsKey>}
|
||||||
|
*/
|
||||||
|
this.loadListenerKeys_ = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<ol.EventsKey>}
|
||||||
|
*/
|
||||||
|
this.sourceTileListenerKeys_ = [];
|
||||||
|
|
||||||
|
if (urlTileCoord) {
|
||||||
|
var extent = tileGrid.getTileCoordExtent(urlTileCoord);
|
||||||
|
var resolution = tileGrid.getResolution(tileCoord[0]);
|
||||||
|
var sourceZ = sourceTileGrid.getZForResolution(resolution);
|
||||||
|
sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) {
|
||||||
|
var sharedExtent = ol.extent.getIntersection(extent,
|
||||||
|
sourceTileGrid.getTileCoordExtent(sourceTileCoord));
|
||||||
|
if (ol.extent.getWidth(sharedExtent) / resolution >= 0.5 &&
|
||||||
|
ol.extent.getHeight(sharedExtent) / resolution >= 0.5) {
|
||||||
|
// only include source tile if overlap is at least 1 pixel
|
||||||
|
var sourceTileKey = sourceTileCoord.toString();
|
||||||
|
var sourceTile = sourceTiles[sourceTileKey];
|
||||||
|
if (!sourceTile) {
|
||||||
|
var tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection);
|
||||||
|
sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord,
|
||||||
|
tileUrl == undefined ? ol.TileState.EMPTY : ol.TileState.IDLE,
|
||||||
|
tileUrl == undefined ? '' : tileUrl,
|
||||||
|
format, tileLoadFunction);
|
||||||
|
this.sourceTileListenerKeys_.push(
|
||||||
|
ol.events.listen(sourceTile, ol.events.EventType.CHANGE, handleTileChange));
|
||||||
|
}
|
||||||
|
sourceTile.consumers++;
|
||||||
|
this.tileKeys.push(sourceTileKey);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
ol.inherits(ol.VectorImageTile, ol.Tile);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.disposeInternal = function() {
|
||||||
|
for (var i = 0, ii = this.tileKeys.length; i < ii; ++i) {
|
||||||
|
var sourceTileKey = this.tileKeys[i];
|
||||||
|
var sourceTile = this.getTile(sourceTileKey);
|
||||||
|
sourceTile.consumers--;
|
||||||
|
if (sourceTile.consumers == 0) {
|
||||||
|
delete this.sourceTiles_[sourceTileKey];
|
||||||
|
sourceTile.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tileKeys.length = 0;
|
||||||
|
this.sourceTiles_ = null;
|
||||||
|
if (this.state == ol.TileState.LOADING) {
|
||||||
|
this.loadListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
|
this.loadListenerKeys_.length = 0;
|
||||||
|
}
|
||||||
|
if (this.interimTile) {
|
||||||
|
this.interimTile.dispose();
|
||||||
|
}
|
||||||
|
this.state = ol.TileState.ABORT;
|
||||||
|
this.changed();
|
||||||
|
this.sourceTileListenerKeys_.forEach(ol.events.unlistenByKey);
|
||||||
|
this.sourceTileListenerKeys_.length = 0;
|
||||||
|
ol.Tile.prototype.disposeInternal.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
|
* @return {CanvasRenderingContext2D} The rendering context.
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.getContext = function(layer) {
|
||||||
|
var key = ol.getUid(layer).toString();
|
||||||
|
if (!(key in this.context_)) {
|
||||||
|
this.context_[key] = ol.dom.createCanvasContext2D();
|
||||||
|
}
|
||||||
|
return this.context_[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Canvas for this tile.
|
||||||
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
|
* @return {HTMLCanvasElement} Canvas.
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.getImage = function(layer) {
|
||||||
|
return this.getReplayState(layer).renderedTileRevision == -1 ?
|
||||||
|
null : this.getContext(layer).canvas;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
|
* @return {ol.TileReplayState} The replay state.
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.getReplayState = function(layer) {
|
||||||
|
var key = ol.getUid(layer).toString();
|
||||||
|
if (!(key in this.replayState_)) {
|
||||||
|
this.replayState_[key] = {
|
||||||
|
dirty: false,
|
||||||
|
renderedRenderOrder: null,
|
||||||
|
renderedRevision: -1,
|
||||||
|
renderedTileRevision: -1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return this.replayState_[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.getKey = function() {
|
||||||
|
return this.tileKeys.join('/') + '/' + this.src_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} tileKey Key (tileCoord) of the source tile.
|
||||||
|
* @return {ol.VectorTile} Source tile.
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.getTile = function(tileKey) {
|
||||||
|
return this.sourceTiles_[tileKey];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.load = function() {
|
||||||
|
var leftToLoad = 0;
|
||||||
|
if (this.state == ol.TileState.IDLE) {
|
||||||
|
this.setState(ol.TileState.LOADING);
|
||||||
|
}
|
||||||
|
if (this.state == ol.TileState.LOADING) {
|
||||||
|
this.tileKeys.forEach(function(sourceTileKey) {
|
||||||
|
var sourceTile = this.getTile(sourceTileKey);
|
||||||
|
if (sourceTile.state == ol.TileState.IDLE) {
|
||||||
|
sourceTile.setLoader(this.loader_);
|
||||||
|
sourceTile.load();
|
||||||
|
}
|
||||||
|
if (sourceTile.state == ol.TileState.LOADING) {
|
||||||
|
var key = ol.events.listen(sourceTile, ol.events.EventType.CHANGE, function(e) {
|
||||||
|
var state = sourceTile.getState();
|
||||||
|
if (state == ol.TileState.LOADED ||
|
||||||
|
state == ol.TileState.ERROR) {
|
||||||
|
--leftToLoad;
|
||||||
|
ol.events.unlistenByKey(key);
|
||||||
|
ol.array.remove(this.loadListenerKeys_, key);
|
||||||
|
if (leftToLoad == 0) {
|
||||||
|
this.finishLoading_();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
this.loadListenerKeys_.push(key);
|
||||||
|
++leftToLoad;
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
if (leftToLoad == 0) {
|
||||||
|
setTimeout(this.finishLoading_.bind(this), 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.prototype.finishLoading_ = function() {
|
||||||
|
var errors = false;
|
||||||
|
var loaded = this.tileKeys.length;
|
||||||
|
var state;
|
||||||
|
for (var i = loaded - 1; i >= 0; --i) {
|
||||||
|
state = this.getTile(this.tileKeys[i]).getState();
|
||||||
|
if (state != ol.TileState.LOADED) {
|
||||||
|
if (state == ol.TileState.ERROR) {
|
||||||
|
errors = true;
|
||||||
|
}
|
||||||
|
--loaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setState(loaded > 0 ?
|
||||||
|
ol.TileState.LOADED :
|
||||||
|
(errors ? ol.TileState.ERROR : ol.TileState.EMPTY));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the loader for a tile.
|
||||||
|
* @param {ol.VectorTile} tile Vector tile.
|
||||||
|
* @param {string} url URL.
|
||||||
|
*/
|
||||||
|
ol.VectorImageTile.defaultLoadFunction = function(tile, url) {
|
||||||
|
var loader = ol.featureloader.loadFeaturesXhr(
|
||||||
|
url, tile.getFormat(), tile.onLoad_.bind(tile), tile.onError_.bind(tile));
|
||||||
|
|
||||||
|
tile.setLoader(loader);
|
||||||
|
};
|
||||||
@@ -3,8 +3,6 @@ goog.provide('ol.VectorTile');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.dom');
|
|
||||||
goog.require('ol.featureloader');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,10 +19,9 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
|
|||||||
ol.Tile.call(this, tileCoord, state);
|
ol.Tile.call(this, tileCoord, state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @type {number}
|
||||||
* @type {CanvasRenderingContext2D}
|
|
||||||
*/
|
*/
|
||||||
this.context_ = null;
|
this.consumers = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -53,15 +50,9 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.TileReplayState}
|
* @type {Object.<string, ol.render.ReplayGroup>}
|
||||||
*/
|
*/
|
||||||
this.replayState_ = {
|
this.replayGroups_ = {};
|
||||||
dirty: false,
|
|
||||||
renderedRenderOrder: null,
|
|
||||||
renderedRevision: -1,
|
|
||||||
renderedTileRevision: -1,
|
|
||||||
replayGroup: null
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -80,22 +71,14 @@ ol.inherits(ol.VectorTile, ol.Tile);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {CanvasRenderingContext2D} The rendering context.
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.VectorTile.prototype.getContext = function() {
|
ol.VectorTile.prototype.disposeInternal = function() {
|
||||||
if (!this.context_) {
|
this.features_ = null;
|
||||||
this.context_ = ol.dom.createCanvasContext2D();
|
this.replayGroups_ = {};
|
||||||
}
|
this.state = ol.TileState.ABORT;
|
||||||
return this.context_;
|
this.changed();
|
||||||
};
|
ol.Tile.prototype.disposeInternal.call(this);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @override
|
|
||||||
*/
|
|
||||||
ol.VectorTile.prototype.getImage = function() {
|
|
||||||
return this.replayState_.renderedTileRevision == -1 ?
|
|
||||||
null : this.context_.canvas;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -110,21 +93,16 @@ ol.VectorTile.prototype.getFormat = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Array.<ol.Feature>} Features.
|
* Get the features for this tile. Geometries will be in the projection returned
|
||||||
|
* by {@link #getProjection}.
|
||||||
|
* @return {Array.<ol.Feature|ol.render.Feature>} Features.
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.VectorTile.prototype.getFeatures = function() {
|
ol.VectorTile.prototype.getFeatures = function() {
|
||||||
return this.features_;
|
return this.features_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.TileReplayState} The replay state.
|
|
||||||
*/
|
|
||||||
ol.VectorTile.prototype.getReplayState = function() {
|
|
||||||
return this.replayState_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -134,13 +112,25 @@ ol.VectorTile.prototype.getKey = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the feature projection of features returned by {@link #getFeatures}.
|
||||||
* @return {ol.proj.Projection} Feature projection.
|
* @return {ol.proj.Projection} Feature projection.
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.VectorTile.prototype.getProjection = function() {
|
ol.VectorTile.prototype.getProjection = function() {
|
||||||
return this.projection_;
|
return this.projection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
|
* @param {string} key Key.
|
||||||
|
* @return {ol.render.ReplayGroup} Replay group.
|
||||||
|
*/
|
||||||
|
ol.VectorTile.prototype.getReplayGroup = function(layer, key) {
|
||||||
|
return this.replayGroups_[ol.getUid(layer) + ',' + key];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -193,11 +183,12 @@ ol.VectorTile.prototype.setProjection = function(projection) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileState} tileState Tile state.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
|
* @param {string} key Key.
|
||||||
|
* @param {ol.render.ReplayGroup} replayGroup Replay group.
|
||||||
*/
|
*/
|
||||||
ol.VectorTile.prototype.setState = function(tileState) {
|
ol.VectorTile.prototype.setReplayGroup = function(layer, key, replayGroup) {
|
||||||
this.state = tileState;
|
this.replayGroups_[ol.getUid(layer) + ',' + key] = replayGroup;
|
||||||
this.changed();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -209,16 +200,3 @@ ol.VectorTile.prototype.setState = function(tileState) {
|
|||||||
ol.VectorTile.prototype.setLoader = function(loader) {
|
ol.VectorTile.prototype.setLoader = function(loader) {
|
||||||
this.loader_ = loader;
|
this.loader_ = loader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the loader for a tile.
|
|
||||||
* @param {ol.VectorTile} tile Vector tile.
|
|
||||||
* @param {string} url URL.
|
|
||||||
*/
|
|
||||||
ol.VectorTile.defaultLoadFunction = function(tile, url) {
|
|
||||||
var loader = ol.featureloader.loadFeaturesXhr(
|
|
||||||
url, tile.getFormat(), tile.onLoad_.bind(tile), tile.onError_.bind(tile));
|
|
||||||
|
|
||||||
tile.setLoader(loader);
|
|
||||||
};
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user