Compare commits

..

34 Commits

Author SHA1 Message Date
Andreas Hocevar
ca3e11a10b Merge pull request #7539 from openlayers/release-v4.6.0
Release v4.6.0
2017-12-06 15:55:14 +01:00
Andreas Hocevar
7245805c90 Update package version to 4.6.0 2017-12-06 14:40:04 +01:00
Andreas Hocevar
5234a4dd21 Changelog for v4.6.0 2017-12-06 14:36:55 +01:00
Andreas Hocevar
b262b8535e Merge pull request #7538 from ahocevar/rem_from_loaded_ext
removeFromLoadedExtents to remove extents that failed to load
2017-12-06 14:22:11 +01:00
Andreas Hocevar
45ae731aa6 Add test 2017-12-06 13:39:35 +01:00
Andreas Hocevar
8bc61504c8 Give method a better name and add docs 2017-12-06 13:30:49 +01:00
geonux
5641430590 RemoveFromLoadedExtent to remove extent to the list of loaded extent in case of server error/restriction. 2017-12-06 12:53:14 +01:00
Frédéric Junod
2e2d8ea3d7 Merge pull request #7537 from walkermatt/removeLastPoint
Fix Draw.removeLastPoint exception when no points to remove
2017-12-06 11:51:14 +01:00
Frédéric Junod
d4f23e0ea9 Merge pull request #7536 from openlayers/greenkeeper/fs-extra-4.0.3
Update fs-extra to the latest version 🚀
2017-12-05 16:51:16 +01:00
greenkeeper[bot]
607e836df4 fix(package): update fs-extra to version 4.0.3 2017-12-05 15:03:48 +00:00
Bart van den Eijnden
8afcd1c2ff Merge pull request #7461 from oterral/teo_wmts
Use the matrixSet projection by default
2017-12-05 10:51:11 +01:00
Frédéric Junod
ebfdddbb8e Merge pull request #5883 from bylexus/master
Fixes setUrl() for WMTS sources (ol.source.WMTS)
2017-12-04 10:49:55 +01:00
Frederic Junod
14e3fd9214 Fix eslint errors 2017-12-04 10:06:00 +01:00
Frederic Junod
9c8c9c1a17 Store createFromWMTSTemplate into a private variable 2017-12-04 09:30:12 +01:00
Alexander Schenkel
c7cb26a066 Fixes setUrl() for WMTS sources (ol.source.WMTS)
See Issue #5881: setUrl was inherited from ol.source UrlTile, which creates a wrong tileUrlFunction: The official WMTS URL Template variables were no longer replaced.
2017-12-04 09:11:28 +01:00
Andreas Hocevar
b4a5142aaa Merge pull request #7531 from ahocevar/package-readme
Update the ol package readme
2017-12-02 17:42:20 +01:00
Tim Schaub
e96d190e1e Merge pull request #7533 from openlayers/greenkeeper/marked-0.3.7
Update marked to the latest version 🚀
2017-12-02 09:24:46 -07:00
greenkeeper[bot]
41efec1e74 chore(package): update marked to version 0.3.7 2017-12-01 18:30:04 +00:00
Andreas Hocevar
7941a33069 Merge pull request #7372 from notnotse/iconimagecache-setmaxcachesize
Add method to set max cache size in ol.style.IconImageCache
2017-12-01 18:00:36 +01:00
Andreas Hocevar
8a9f32fa09 Rename method and make it appear in the API docs 2017-12-01 17:03:28 +01:00
Matt Walker
90d8224a08 Fix Draw.removeLastPoint exception when no points to remove 2017-12-01 15:50:21 +00:00
Andreas Hocevar
55f7468c68 Update the ol package readme 2017-12-01 13:41:45 +01:00
Andreas Hocevar
fca0b0771d Merge pull request #7530 from raiyni/crossing-dateline
Check forward/back 1 world if wrapping
2017-12-01 09:20:39 +01:00
Ron Young
19bceff077 Check forward/back 1 world if wrapping 2017-11-30 14:23:42 -06:00
Tim Schaub
c3db3e2f6f Merge pull request #7526 from tschaub/stop-click
Allow clicks to be stopped while drawing
2017-11-30 09:21:06 -07:00
Andreas Hocevar
73f64a9e89 Merge pull request #7524 from ahocevar/view-pixel
Snap view center to pixel
2017-11-30 15:13:45 +01:00
Andreas Hocevar
74bf846ffe Add pixel ratio to label cache key 2017-11-30 01:20:49 +01:00
Andreas Hocevar
4e8714d619 Fix tests 2017-11-30 01:03:15 +01:00
Andreas Hocevar
9307c35c17 Improve vertical font placement in Firefox 2017-11-30 01:03:15 +01:00
Andreas Hocevar
3bb62a2c41 Snap view center to pixel 2017-11-30 01:03:15 +01:00
Tim Schaub
b58073dd06 Allow clicks to be stopped while drawing 2017-11-29 16:58:26 -07:00
oterral
9cc7cca447 Fix #6835: doesn't break if Constraint does not exist 2017-11-17 09:00:44 +01:00
oterral
5a252e628b Fix #7460: use the matrixSet projection by default 2017-11-13 11:06:31 +01:00
Bobo Häggström
343a4085a0 Add method to set max cache size in ol.style.IconImageCache 2017-10-24 16:04:55 +02:00
19 changed files with 426 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
## Upgrade notes
### Next release
### v4.6.0
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow`

91
changelog/v4.6.0.md Normal file
View File

@@ -0,0 +1,91 @@
# v4.6.0
### Summary
The 4.6 release includes enhancements and fixes from 30 or so pull requests. Headlining this release, vector layers got new `textBackgroundFill`, `textBackgroundStroke` and `padding` options that can be used to render background boxes for text. `ol.source.ImageVector` is now deprecated and replaced by a more convenient way to render vectors as images: by simply setting `renderMode: 'image'` on the vector layer.
Please note that if you are using `closure-util` to build your OpenLayers based application, it is time to migrate to using the [`ol` package](https://www.npmjs.com/package/ol) and a module bundler like webpack. OpenLayers has not had a dependency on the Closure Library since the [3.19 release](https://github.com/openlayers/openlayers/releases/tag/v3.19.0); and with the 5.0 release we will be moving completely away from `goog.require` and `goog.provide`, dropping support for `closure-util`, and going with ES modules for our sources.
See the [wiki](https://github.com/openlayers/openlayers/wiki/OpenLayers-v5.x) about upcoming changes in 5.0 and tips on how to upgrade. We likely won't have another 4.x release before the 5.0 release. If you're interested in continuing to get feature enhancements in future releases, migrating to the `ol` package now will make the transition easier.
### Upgrade notes
#### Renamed `exceedLength` option of `ol.style.Text` to `overflow`
To update your applications, simply replace `exceedLength` with `overflow`.
#### Deprecation of `ol.source.ImageVector`
Rendering vector sources as image is now directly supported by `ol.layer.Vector` with the new `renderMode: 'image'` configuration option. Change code like this:
```js
new ol.layer.Image({
source: new ol.source.ImageVector({
style: myStyle,
source: new ol.source.Vector({
url: 'my/data.json',
format: new ol.format.GeoJSON()
})
})
});
```
to:
```js
new ol.layer.Vector({
renderMode: 'image',
style: myStyle,
source: new ol.source.Vector({
url: 'my/data.json',
format: new ol.format.GeoJSON()
})
});
```
## Detailed changes
See below for the full list of changes.
* [#7538](https://github.com/openlayers/openlayers/pull/7538) - removeFromLoadedExtents to remove extents that failed to load ([@ahocevar](https://github.com/ahocevar))
* [#7537](https://github.com/openlayers/openlayers/pull/7537) - Fix Draw.removeLastPoint exception when no points to remove ([@walkermatt](https://github.com/walkermatt))
* [#7461](https://github.com/openlayers/openlayers/pull/7461) - Use the matrixSet projection by default ([@oterral](https://github.com/oterral))
* [#5883](https://github.com/openlayers/openlayers/pull/5883) - Fixes setUrl() for WMTS sources (ol.source.WMTS) ([@bylexus](https://github.com/bylexus))
* [#7531](https://github.com/openlayers/openlayers/pull/7531) - Update the ol package readme ([@ahocevar](https://github.com/ahocevar))
* [#7372](https://github.com/openlayers/openlayers/pull/7372) - Add method to set max cache size in ol.style.IconImageCache ([@notnotse](https://github.com/notnotse))
* [#7530](https://github.com/openlayers/openlayers/pull/7530) - Check forward/back 1 world if wrapping ([@raiyni](https://github.com/raiyni))
* [#7526](https://github.com/openlayers/openlayers/pull/7526) - Allow clicks to be stopped while drawing ([@tschaub](https://github.com/tschaub))
* [#7524](https://github.com/openlayers/openlayers/pull/7524) - Snap view center to pixel ([@ahocevar](https://github.com/ahocevar))
* [#7521](https://github.com/openlayers/openlayers/pull/7521) - fix setMinZoom/setMaxZoom ([@cs09g](https://github.com/cs09g))
* [#7519](https://github.com/openlayers/openlayers/pull/7519) - Reuse declutter tree for hit detection ([@ahocevar](https://github.com/ahocevar))
* [#7499](https://github.com/openlayers/openlayers/pull/7499) - Remove attributions from olx.FrameState instances ([@openlayers](https://github.com/openlayers))
* [#7501](https://github.com/openlayers/openlayers/pull/7501) - Option to render vector layers as images ([@ahocevar](https://github.com/ahocevar))
* [#7516](https://github.com/openlayers/openlayers/pull/7516) - Deprecate exceedLength and replace with overflow ([@ahocevar](https://github.com/ahocevar))
* [#7510](https://github.com/openlayers/openlayers/pull/7510) - Do not fade the states layer ([@ahocevar](https://github.com/ahocevar))
* [#7513](https://github.com/openlayers/openlayers/pull/7513) - Make strokeKey safer ([@ahocevar](https://github.com/ahocevar))
* [#7514](https://github.com/openlayers/openlayers/pull/7514) - Prune the label cache less aggressively ([@ahocevar](https://github.com/ahocevar))
* [#7505](https://github.com/openlayers/openlayers/pull/7505) - Remove ol.DeviceOrientation link from API index ([@fredj](https://github.com/fredj))
* [#7497](https://github.com/openlayers/openlayers/pull/7497) - Use getGeometry ([@nicholas-l](https://github.com/nicholas-l))
* [#7495](https://github.com/openlayers/openlayers/pull/7495) - Remove layer renderers when viewport is removed ([@ahocevar](https://github.com/ahocevar))
* [#7492](https://github.com/openlayers/openlayers/pull/7492) - Remove unneeded type cast from examples ([@fredj](https://github.com/fredj))
* [#7489](https://github.com/openlayers/openlayers/pull/7489) - Allow string to be passed as ol.interaction.Draw type ([@fredj](https://github.com/fredj))
* [#7445](https://github.com/openlayers/openlayers/pull/7445) - Load css rules from full-screen.css in examples ([@fredj](https://github.com/fredj))
* [#7481](https://github.com/openlayers/openlayers/pull/7481) - Make zoom to extent control extensible ([@gberaudo](https://github.com/gberaudo))
* [#7477](https://github.com/openlayers/openlayers/pull/7477) - Make text states available for replay time ([@ahocevar](https://github.com/ahocevar))
* [#7482](https://github.com/openlayers/openlayers/pull/7482) - Reset rotation after rendering ([@ahocevar](https://github.com/ahocevar))
* [#7480](https://github.com/openlayers/openlayers/pull/7480) - Create a new image when loading tile after an error ([@ahocevar](https://github.com/ahocevar))
* [#7476](https://github.com/openlayers/openlayers/pull/7476) - Reset text measurements when available fonts change ([@ahocevar](https://github.com/ahocevar))
* [#7454](https://github.com/openlayers/openlayers/pull/7454) - Add text background rendering and text padding ([@ahocevar](https://github.com/ahocevar))
* [#7468](https://github.com/openlayers/openlayers/pull/7468) - Add new API-key for HERE example ([@chrismayer](https://github.com/chrismayer))
* [#7465](https://github.com/openlayers/openlayers/pull/7465) - Export ol.proj.Projection#getAxisOrientation function ([@fredj](https://github.com/fredj))
* [#7462](https://github.com/openlayers/openlayers/pull/7462) - Respect metersPerUnit in ScaleLine control ([@ahocevar](https://github.com/ahocevar))
Additionally a number of updates where made to our dependencies:
* [#7536](https://github.com/openlayers/openlayers/pull/7536) - Update fs-extra to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#7533](https://github.com/openlayers/openlayers/pull/7533) - Update marked to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#7527](https://github.com/openlayers/openlayers/pull/7527) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#7511](https://github.com/openlayers/openlayers/pull/7511) - Update rollup to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#7512](https://github.com/openlayers/openlayers/pull/7512) - Update eslint to the latest version 🚀 ([@openlayers](https://github.com/openlayers))
* [#7484](https://github.com/openlayers/openlayers/pull/7484) - Update closure-util to the latest version 🚀 ([@openlayers](https://github.com/openlayers))

View File

@@ -3005,6 +3005,7 @@ olx.interaction.DragZoomOptions.prototype.out;
* source: (ol.source.Vector|undefined),
* snapTolerance: (number|undefined),
* type: (ol.geom.GeometryType|string),
* stopClick: (boolean|undefined),
* maxPoints: (number|undefined),
* minPoints: (number|undefined),
* finishCondition: (ol.EventsConditionType|undefined),
@@ -3064,6 +3065,15 @@ olx.interaction.DrawOptions.prototype.snapTolerance;
olx.interaction.DrawOptions.prototype.type;
/**
* Stop click, singleclick, and doubleclick events from firing during drawing.
* Default is `false`.
* @type {boolean|undefined}
* @api
*/
olx.interaction.DrawOptions.prototype.stopClick;
/**
* The number of points that can be drawn before a polygon ring or line string
* is finished. The default is no restriction.
@@ -6674,6 +6684,37 @@ olx.source.VectorOptions.prototype.format;
* The loader function used to load features, from a remote source for example.
* If this is not set and `url` is set, the source will create and use an XHR
* feature loader.
*
* Example:
*
* ```js
* var vectorSource = new ol.source.Vector({
* format: new ol.format.GeoJSON(),
* loader: function(extent, resolution, projection) {
* var proj = projection.getCode();
* var url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
* 'outputFormat=application/json&srsname=' + proj + '&' +
* 'bbox=' + extent.join(',') + ',' + proj;
* var xhr = new XMLHttpRequest();
* xhr.open('GET', url);
* var onError = function() {
* vectorSource.removeLoadedExtent(extent);
* }
* xhr.onerror = onError;
* xhr.onload = function() {
* if (xhr.status == 200) {
* vectorSource.addFeatures(
* vectorSource.getFormat().readFeatures(xhr.responseText));
* } else {
* onError();
* }
* }
* xhr.send();
* },
* strategy: ol.loadingstrategy.bbox
* });
* ```
* @type {ol.FeatureLoader|undefined}
* @api
*/

View File

@@ -1,6 +1,6 @@
{
"name": "openlayers",
"version": "4.6.0-beta.1",
"version": "4.6.0",
"description": "Build tools and sources for developing OpenLayers based mapping applications",
"keywords": [
"map",
@@ -40,7 +40,7 @@
"dependencies": {
"async": "2.6.0",
"closure-util": "1.26.0",
"fs-extra": "4.0.2",
"fs-extra": "4.0.3",
"jsdoc": "3.5.5",
"nomnom": "1.8.1",
"pbf": "3.1.0",
@@ -73,7 +73,7 @@
"karma-firefox-launcher": "^1.0.1",
"karma-mocha": "^1.3.0",
"karma-sauce-launcher": "^1.1.0",
"marked": "0.3.6",
"marked": "0.3.7",
"metalsmith": "2.3.0",
"metalsmith-layouts": "1.8.1",
"mocha": "4.0.1",

View File

@@ -1,6 +1,6 @@
{
"name": "ol",
"version": "4.5.0",
"version": "4.6.0",
"description": "OpenLayers as ES2015 modules",
"main": "index.js",
"module": "index.js",

View File

@@ -37,6 +37,7 @@ See the following examples for more detail on bundling OpenLayers with your appl
* Using [Rollup & Uglify](https://gist.github.com/tschaub/8beb328ea72b36446fc2198d008287de)
* Using [Rollup & Closure Compiler](https://gist.github.com/tschaub/32a5692bedac5254da24fa3b12072f35)
* Using [Webpack & Uglify](https://gist.github.com/tschaub/79025aef325cd2837364400a105405b8)
* Using [Webpack & Closure Compiler](https://gist.github.com/ahocevar/8ceafc6293455ba491dd9be12c15761f)
* Using [Browserify & Uglify](https://gist.github.com/tschaub/4bfb209a8f809823f1495b2e4436018e)
## Module Identifiers
@@ -46,7 +47,3 @@ The module identifiers above (e.g. `ol/map`) are like the `ol.Map` names in the
Constructors are exported from dedicated modules. For example, the `ol/layer/tile` module exports the `Tile` layer constructor.
Utility functions are available as properties of the default export from utility modules. For example, the `getCenter` function is a property of the default export from the `ol/extent` utility module.
## Caveats
* The WebGL renderer is not available in this package.

View File

@@ -97,6 +97,14 @@ ol.interaction.Draw = function(options) {
*/
this.mode_ = ol.interaction.Draw.getMode_(this.type_);
/**
* Stop click, singleclick, and doubleclick events from firing during drawing.
* Default is `false`.
* @type {boolean}
* @private
*/
this.stopClick_ = !!options.stopClick;
/**
* The number of points that must be drawn before a polygon ring or line
* string can be finished. The default is 3 for polygon rings and 2 for
@@ -160,7 +168,12 @@ ol.interaction.Draw = function(options) {
var geometry = opt_geometry;
if (geometry) {
if (mode === ol.interaction.Draw.Mode_.POLYGON) {
if (coordinates[0].length) {
// Add a closing coordinate to match the first
geometry.setCoordinates([coordinates[0].concat([coordinates[0][0]])]);
} else {
geometry.setCoordinates([]);
}
} else {
geometry.setCoordinates(coordinates);
}
@@ -384,6 +397,9 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
this.finishCoordinate_ = null;
this.abortDrawing_();
}
if (!pass && this.stopClick_) {
event.stopPropagation();
}
return pass;
};

View File

@@ -172,7 +172,9 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
// contact. isMouseActionButton returns true in these cases (evt.button is set
// to 0).
// See http://www.w3.org/TR/pointerevents/#button-states
if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
// We only fire click, singleclick, and doubleclick if nobody has called
// event.stopPropagation() or event.preventDefault().
if (!newEvent.propagationStopped && !this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
this.emulateClick_(this.down_);
}

View File

@@ -181,11 +181,11 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
ol.render.canvas.rotateAtOffset(replayContext, -rotation,
width / 2, height / 2);
replayGroup.replay(replayContext, transform, rotation, skippedFeatureUids);
if (vectorSource.getWrapX() && projection.canWrapX() &&
!ol.extent.containsExtent(projectionExtent, extent)) {
if (vectorSource.getWrapX() && projection.canWrapX()) {
var startX = extent[0];
var worldWidth = ol.extent.getWidth(projectionExtent);
var world = 0;
startX -= worldWidth;
var offsetX;
while (startX < projectionExtent[0]) {
--world;
@@ -196,6 +196,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay
}
world = 0;
startX = extent[2];
startX += worldWidth;
while (startX > projectionExtent[2]) {
++world;
offsetX = worldWidth * world;
@@ -325,8 +326,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
vectorLayerRenderBuffer * resolution);
var projectionExtent = viewState.projection.getExtent();
if (vectorSource.getWrapX() && viewState.projection.canWrapX() &&
!ol.extent.containsExtent(projectionExtent, frameState.extent)) {
if (vectorSource.getWrapX() && viewState.projection.canWrapX()) {
// For the replay group, we need an extent that intersects the real world
// (-180° to +180°). To support geometries in a coordinate range from -540°
// to +540°, we add at least 1 world width on each side of the projection

View File

@@ -762,6 +762,26 @@ ol.source.Vector.prototype.loadFeatures = function(
};
/**
* Remove an extent from the list of loaded extents.
* @param {ol.Extent} extent Extent.
* @api
*/
ol.source.Vector.prototype.removeLoadedExtent = function(extent) {
var loadedExtentsRtree = this.loadedExtentsRtree_;
var obj;
loadedExtentsRtree.forEachInExtent(extent, function(object) {
if (ol.extent.equals(object.extent, extent)) {
obj = object;
return true;
}
});
if (obj) {
loadedExtentsRtree.remove(obj);
}
};
/**
* Remove a single feature from the source. If you want to remove all features
* at once, use the {@link ol.source.Vector#clear source.clear()} method

View File

@@ -105,8 +105,9 @@ ol.source.WMTS = function(options) {
/**
* @param {string} template Template.
* @return {ol.TileUrlFunctionType} Tile URL function.
* @private
*/
function createFromWMTSTemplate(template) {
this.createFromWMTSTemplate_ = function(template) {
// TODO: we may want to create our own appendParams function so that params
// order conforms to wmts spec guidance, and so that we can avoid to escape
@@ -146,11 +147,11 @@ ol.source.WMTS = function(options) {
return url;
}
});
}
};
var tileUrlFunction = (urls && urls.length > 0) ?
ol.TileUrlFunction.createFromTileUrlFunctions(
urls.map(createFromWMTSTemplate)) :
urls.map(this.createFromWMTSTemplate_)) :
ol.TileUrlFunction.nullTileUrlFunction;
ol.source.TileImage.call(this, {
@@ -175,6 +176,18 @@ ol.source.WMTS = function(options) {
};
ol.inherits(ol.source.WMTS, ol.source.TileImage);
/**
* Set the URLs to use for requests.
* URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}.
* @override
*/
ol.source.WMTS.prototype.setUrls = function(urls) {
this.urls = urls;
var key = urls.join('\n');
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key);
};
/**
* Get the dimensions, i.e. those passed to the constructor through the
@@ -314,8 +327,9 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var tileMatrixSet = ol.array.find(tileMatrixSets, function(el) {
return el['Identifier'] == elt['TileMatrixSet'];
});
var supportedCRS = tileMatrixSet['SupportedCRS'].replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3');
var proj1 = ol.proj.get(supportedCRS);
var supportedCRS = tileMatrixSet['SupportedCRS'];
var proj1 = ol.proj.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
ol.proj.get(supportedCRS);
var proj2 = ol.proj.get(config['projection']);
if (proj1 && proj2) {
return ol.proj.equivalent(proj1, proj2);
@@ -374,11 +388,18 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
});
var projection;
var code = matrixSetObj['SupportedCRS'];
if (code) {
projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
ol.proj.get(code);
}
if ('projection' in config) {
projection = ol.proj.get(config['projection']);
} else {
projection = ol.proj.get(matrixSetObj['SupportedCRS'].replace(
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'));
var projConfig = ol.proj.get(config['projection']);
if (projConfig) {
if (!projection || ol.proj.equivalent(projConfig, projection)) {
projection = projConfig;
}
}
}
var wgs84BoundingBox = l['WGS84BoundingBox'];
@@ -411,6 +432,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'];
for (var i = 0, ii = gets.length; i < ii; ++i) {
if (gets[i]['Constraint']) {
var constraint = ol.array.find(gets[i]['Constraint'], function(element) {
return element['name'] == 'GetEncoding';
});
@@ -427,6 +449,10 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
} else {
break;
}
} else if (gets[i]['href']) {
requestEncoding = ol.source.WMTSRequestEncoding.KVP;
urls.push(/** @type {string} */ (gets[i]['href']));
}
}
}
if (urls.length === 0) {

View File

@@ -2,4 +2,8 @@ goog.provide('ol.style');
goog.require('ol.style.IconImageCache');
/**
* The {@link ol.style.IconImageCache} for {@link ol.style.Icon} images.
* @api
*/
ol.style.iconImageCache = new ol.style.IconImageCache();

View File

@@ -4,6 +4,7 @@ goog.require('ol.color');
/**
* Singleton class. Available through {@link ol.style.iconImageCache}.
* @constructor
*/
ol.style.IconImageCache = function() {
@@ -21,7 +22,6 @@ ol.style.IconImageCache = function() {
this.cacheSize_ = 0;
/**
* @const
* @type {number}
* @private
*/
@@ -91,3 +91,16 @@ ol.style.IconImageCache.prototype.set = function(src, crossOrigin, color, iconIm
this.cache_[key] = iconImage;
++this.cacheSize_;
};
/**
* Set the cache size of the icon cache. Default is `32`. Change this value when
* your map uses more than 32 different icon images and you are not caching icon
* styles on the application level.
* @param {number} maxCacheSize Cache max size.
* @api
*/
ol.style.IconImageCache.prototype.setSize = function(maxCacheSize) {
this.maxCacheSize_ = maxCacheSize;
this.expire();
};

View File

@@ -92,9 +92,9 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = function(matrixSet, opt_exten
var tileWidthPropName = 'TileWidth';
var tileHeightPropName = 'TileHeight';
var projection;
projection = ol.proj.get(matrixSet[supportedCRSPropName].replace(
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3'));
var code = matrixSet[supportedCRSPropName];
var projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
ol.proj.get(code);
var metersPerUnit = projection.getMetersPerUnit();
// swap origin x and y coordinates if axis orientation is lat/long
var switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';

View File

@@ -21,7 +21,7 @@ BUILDS=dist
#
# URL for canonical repo.
#
REMOTE=https://github.com/ahocevar/openlayers.git
REMOTE=https://github.com/openlayers/openlayers.git
#
# Display usage and exit.
@@ -98,7 +98,7 @@ main() {
npm install
build_js ${PROFILES}
build_css
npm publish --tag beta
npm publish
}
if test ${#} -ne 1; then

View File

@@ -585,6 +585,29 @@ describe('ol.interaction.Draw', function() {
expect(source.getFeatures()).to.have.length(0);
});
it('will tolerate removeLastPoint being called when no coordinates', function() {
// first point
simulateEvent('pointermove', 10, 20);
simulateEvent('pointerdown', 10, 20);
simulateEvent('pointerup', 10, 20);
// second point
simulateEvent('pointermove', 40, 30);
simulateEvent('pointerdown', 40, 30);
simulateEvent('pointerup', 40, 30);
simulateEvent('pointermove', 100, 100);
expect(function() {
draw.removeLastPoint();
draw.removeLastPoint();
draw.removeLastPoint();
}).to.not.throwException();
});
it('draws polygon with clicks, finishing on last point', function() {
// first point
simulateEvent('pointermove', 10, 20);

View File

@@ -451,6 +451,19 @@ describe('ol.source.Vector', function() {
expect(count1).to.eql(1);
expect(count2).to.eql(1);
});
it('removes extents with #removeLoadedExtent()', function(done) {
var source = new ol.source.Vector();
source.setLoader(function(bbox, resolution, projection) {
setTimeout(function() {
expect(source.loadedExtentsRtree_.getAll()).to.have.length(1);
source.removeLoadedExtent(bbox);
expect(source.loadedExtentsRtree_.getAll()).to.have.length(0);
done();
}, 0);
});
source.loadFeatures([-10000, -10000, 10000, 10000], 1, ol.proj.get('EPSG:3857'));
});
});
});

View File

@@ -11,10 +11,11 @@ describe('ol.source.WMTS', function() {
describe('when creating options from capabilities', function() {
var parser = new ol.format.WMTSCapabilities();
var capabilities;
var capabilities, content;
before(function(done) {
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
try {
content = xml;
capabilities = parser.read(xml);
} catch (e) {
done(e);
@@ -113,6 +114,7 @@ describe('ol.source.WMTS', function() {
});
expect(options.matrixSet).to.be.eql('google3857');
expect(options.projection.getCode()).to.be.eql('EPSG:3857');
});
it('can find a MatrixSet by equivalent SRS identifier', function() {
@@ -123,8 +125,57 @@ describe('ol.source.WMTS', function() {
});
expect(options.matrixSet).to.be.eql('google3857');
expect(options.projection.getCode()).to.be.eql('EPSG:900913');
});
it('can find the default MatrixSet', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
requestEncoding: 'REST'
});
expect(options.matrixSet).to.be.eql('BigWorldPixel');
expect(options.projection.getCode()).to.be.eql('urn:ogc:def:crs:OGC:1.3:CRS84');
});
it('uses the projection of the default MatrixSet if the config\'s projection is not supported', function() {
var options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
layer: 'BlueMarbleNextGeneration',
projection: new ol.proj.Projection({
code: 'EPSG:2056',
units: 'm'
})
});
expect(options.matrixSet).to.be.eql('BigWorldPixel');
expect(options.projection.getCode()).to.be.eql('urn:ogc:def:crs:OGC:1.3:CRS84');
});
it('doesn\'t fail if the GetCap doesn\'t contains Constraint tags', function() {
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
var tmpCapabilities = parser.read(tmpXml);
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities,
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
expect(options.matrixSet).to.be.eql('google3857');
});
it('set KVP as default request encoding if the GetCap doesn\'t contains Constraint and ResourceUrl tags', function() {
var tmpXml = content.replace(/<ows:Constraint[\s\S]*?<\/ows:Constraint>/g, '');
tmpXml = tmpXml.replace(/<ResourceURL[\s\S]*?"\/>/g, '');
var tmpCapabilities = parser.read(tmpXml);
expect(tmpCapabilities['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'][0]['Constraint']).to.be(undefined);
expect(tmpCapabilities['Contents']['Layer'][0]['ResourceURL']).to.be(undefined);
var options = ol.source.WMTS.optionsFromCapabilities(tmpCapabilities,
{layer: 'BlueMarbleNextGeneration', matrixSet: 'google3857'});
expect(options.layer).to.be.eql('BlueMarbleNextGeneration');
expect(options.matrixSet).to.be.eql('google3857');
expect(options.urls).to.be.an('array');
expect(options.urls).to.have.length(1);
expect(options.urls[0]).to.be.eql('http://www.maps.bob/cgi-bin/MiraMon5_0.cgi?');
});
});
describe('when creating tileUrlFunction', function() {
@@ -230,6 +281,70 @@ describe('ol.source.WMTS', function() {
});
});
describe('#setUrls()', function() {
it('sets the URL for the source', function() {
var source = new ol.source.WMTS({});
var urls = [
'https://a.example.com/',
'https://b.example.com/',
'https://c.example.com/'
];
source.setUrls(urls);
expect(source.getUrls()).to.eql(urls);
});
it('updates the key for the source', function() {
var source = new ol.source.WMTS({});
var urls = [
'https://a.example.com/',
'https://b.example.com/',
'https://c.example.com/'
];
source.setUrls(urls);
expect(source.getKey()).to.eql(urls.join('\n'));
});
it('generates the correct tileUrlFunction during application of setUrl()', function() {
var projection = ol.proj.get('EPSG:3857');
var source = new ol.source.WMTS({
projection: projection,
requestEncoding: 'REST',
urls: [
'http://1.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg',
'http://2.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpeg'
],
tileGrid: new ol.tilegrid.WMTS({
matrixIds: [0, 1, 2, 3, 4, 5, 6, 7],
origin: [2690000, 1285000],
resolutions: [4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250]
})
});
var urls = [
'https://a.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg',
'https://b.example.com/{TileMatrix}/{TileRow}/{TileCol}.jpg'
];
source.setUrls(urls);
var tileUrl1 = source.tileUrlFunction([2, 9, 4], 1, projection);
expect(tileUrl1).to.match(/https\:\/\/[ab]\.example\.com\/2\/-5\/9\.jpg/);
});
});
describe('url option', function() {
it('expands url template', function() {
var tileSource = new ol.source.WMTS({
url: '{1-3}'
});
var urls = tileSource.getUrls();
expect(urls).to.eql(['1', '2', '3']);
});
});
describe('#getUrls', function() {
var sourceOptions;

View File

@@ -66,4 +66,25 @@ describe('ol.style.IconImageCache', function() {
expect(cache.get('4', null, null)).to.not.be(null);
});
});
describe('#setSize', function() {
it('sets max cache size and expires cache', function() {
var cache = ol.style.iconImageCache;
var i, src, iconImage;
for (i = 0; i < 3; ++i) {
src = i + '';
iconImage = new ol.style.IconImage(null, src);
cache.set(src, null, null, iconImage);
}
expect(cache.cacheSize_).to.eql(3);
cache.setSize(2);
expect(cache.maxCacheSize_).to.eql(2);
expect(cache.cacheSize_).to.eql(2);
});
});
});