Compare commits

..

1 Commits

Author SHA1 Message Date
Andreas Hocevar 1cf01037aa Set version and tag for v4.3.0-beta.2 2017-07-15 11:33:05 +02:00
76 changed files with 408 additions and 1519 deletions
-7
View File
@@ -1,7 +0,0 @@
This issue tracker is for reporting bugs or feature requests, not for asking questions. For usage questions, refer to the (documentation)[http://openlayers.org/en/latest/doc/].
Ready to submit your bug or feature request? Make sure these boxes are checked before submitting your issue. Thank you!
- [ ] I have searched GitHub to see if a similar bug or feature request has already been reported.
- [ ] If reporting a bug, I have tried with the latest version of OpenLayers (see 'LATEST' on https://openlayers.org/)
- [ ] If reporting a bug, I have created a [CodePen](https://codepen.io) or prepared a stack trace (using the latest version and unminified code, so e.g. `ol-debug.js`, not `ol.js`) that shows the issue.
-5
View File
@@ -1,5 +0,0 @@
Make sure these boxes are checked before submitting your pull request. Thank you!
- [ ] This pull request addresses an issue that has been marked with the 'Pull request accepted' label.
- [ ] It contains one or more small, incremental, logically separate commits, with no merge commits.
- [ ] I have used clear commit messages.
+2 -5
View File
@@ -9,13 +9,9 @@
## Getting Started ## Getting Started
Use one of the following methods to use OpenLayers in your project:
- For use with mainstream bundlers and minifiers, install the [ol](https://www.npmjs.com/package/ol) npm package: `npm install ol`
- Use `ol.js` and `ol.css` from (cdnjs)[https://cdnjs.com/libraries/openlayers]
- Download the [latest release](https://openlayers.org/download/) - Download the [latest release](https://openlayers.org/download/)
- Install with npm: `npm install openlayers`
- Clone the repo: `git clone git@github.com:openlayers/openlayers.git` - Clone the repo: `git clone git@github.com:openlayers/openlayers.git`
- For use with Closure Library, install the [openlayers](https://npmjs.com/package/openlayers) npm package and read the [tutorial](http://openlayers.org/en/latest/doc/tutorials/closure.html).
## Supported Browsers ## Supported Browsers
@@ -37,3 +33,4 @@ Please see our guide on [contributing](CONTRIBUTING.md) if you're interested in
- Need help? Find it on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers) - Need help? Find it on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers)
- Follow [@openlayers](https://twitter.com/openlayers) on Twitter - Follow [@openlayers](https://twitter.com/openlayers) on Twitter
- Discuss with openlayers users on IRC in `#openlayers` at `chat.freenode`
-24
View File
@@ -2,30 +2,6 @@
### Next release ### Next release
#### `ol.interaction.Modify` deletes with `alt` key only
To delete features with the modify interaction, press the `alt` key while clicking on an existing vertex. If you want to configure the modify interaction with a different delete condition, use the `deleteCondition` option. For example, to allow deletion on a single click with no modifier keys, configure the interaction like this:
```js
var interaction = new ol.interaction.Modify({
source: source,
deleteCondition: function(event) {
return ol.events.condition.noModifierKeys(event) && ol.events.condition.singleClick(event);
}
});
```
The motivation for this change is to make the modify, draw, and snap interactions all work well together. Previously, the use of these interactions with the default configuration would make it so you couldn't reliably add new vertices (click with no modifier) and delete existing vertices (click with no modifier).
#### `ol.source.VectorTile` no longer has a `tilePixelRatio` option
The `tilePixelRatio` option was only used for tiles in projections with `tile-pixels` as units. For tiles read with `ol.format.MVT` and the default tile loader, or tiles with the default pixel size of 4096 pixels, no changes are necessary. For the very rare cases that do not fall under these categories, a custom `tileLoadFunction` now needs to be configured on the `ol.source.VectorTile`. In addition to calling `tile.setFeatures()` and `tile.setProjection()`, it also needs to contain code like the following:
```js
var extent = tile.getFormat() instanceof ol.format.MVT ?
tile.getLastExtent() :
[0, 0, tilePixelRatio * tileSize, tilePixelRatio * tileSize];
tile.setExtent(extent);
```
#### `ol.animate` now takes the shortest arc for rotation animation #### `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 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
+2 -2
View File
@@ -11,7 +11,7 @@ For a more in-depth overview of OpenLayers core concepts, check out the [tutoria
Make sure to also check out the [OpenLayers workshop](/workshop/). Make sure to also check out the [OpenLayers workshop](/workshop/).
Find additional reference material in the [API docs](../apidoc) and [examples](../examples). Find additional reference material in the [API docs](../apidoc).
# Frequently Asked Questions (FAQ) # Frequently Asked Questions (FAQ)
@@ -19,4 +19,4 @@ We have put together a document that lists [Frequently Asked Questions (FAQ)](fa
# More questions? # More questions?
If you cannot find an answer in the documentation or the FAQ, you can search [Stack Overflow](http://stackoverflow.com/questions/tagged/openlayers). If you cannot find an answer there, ask a new question there, using the tag 'openlayers'. If you cannot find an answer in the documentation or the FAQ, you can ask your question on [Stack Overflow using the tag 'openlayers'](http://stackoverflow.com/questions/tagged/openlayers).
+32 -30
View File
@@ -5,56 +5,57 @@ layout: doc.hbs
# Introduction # Introduction
When going beyond modifying existing examples you might be looking for a way to setup your own code with dependency management together with external dependencies like OpenLayers. When going beyond modifying existing examples you might be looking for a
way to setup your own code with dependency management together with external
dependencies like OpenLayers.
This tutorial serves as a suggested project setup using NPM and Browserify for the most basic needs. There are several other options, and in particular you might be interested in a more modern one (ES2015) [using Webpack with OpenLayers](https://gist.github.com/tschaub/79025aef325cd2837364400a105405b8). This tutorial serves as a suggested project setup using NPM and Browserify
for the most basic needs. There are several other options and in particular
you might be interested in
[compiling your own code together with OpenLayers](closure.html).
## Initial steps ## Initial steps
Create a new empty directory for your project and navigate to it by running `mkdir new-project && cd new-project`. Initialize your project using `npm init` and answer the questions asked. Create a new empty directory for your project and navigate to it by running
`mkdir new-project && cd new-project`. Initialize your project using `npm init`
and answer the questions asked.
Add OpenLayers as dependency to your application with `npm install --save ol`. At this point you can ask NPM to add required dependencies by running
`npm install --save-dev openlayers browserify watchify uglify-js`. Watchify and
At this point you can ask NPM to add required development dependencies by running Uglify will be used to monitor for changes and to build into a minified
``` bundle.
npm install --save-dev cssify browserify cssify http-server uglify-js watchify
npm install --save-dev babelify babel-plugin-transform-es2015-modules-commonjs
```
We will be using `cssify` to include the css definitions required by OpenLayers in our bundle. `watchify`, `http-server` and `uglify-js` are used to monitor for changes and to build into a minified bundle. `babelify` and `babel-plugin-transform-es2015-modules-commonjs` are used to make the `ol` package, which was created using ES2015 modules, work with CommonJS.
## Application code and index.html ## Application code and index.html
Place your application code in `index.js`. Here is a simple starting point: Place your application code in `index.js`. Here is a simple starting point:
```js ```js
require('ol/ol.css'); var ol = require('openlayers');
var ol_Map = require('ol/map').default;
var ol_layer_Tile = require('ol/layer/tile').default;
var ol_source_OSM = require('ol/source/osm').default;
var ol_View = require('ol/view').default;
var map = new ol_Map({ var map = new ol.Map({
target: 'map', target: 'map',
layers: [ layers: [
new ol_layer_Tile({ new ol.layer.Tile({
source: new ol_source_OSM() source: new ol.source.OSM()
}) })
], ],
view: new ol_View({ view: new ol.View({
center: [0, 0], center: [0, 0],
zoom: 0 zoom: 0
}) })
}); });
``` ```
You will also need an `ìndex.html` file that will use your bundle. Here is a simple example: You will also need an `ìndex.html` file that will use your bundle. Here is a simple
example:
```html ```html
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Using Browserify with OpenLayers</title> <title>Using Browserify with OpenLayers</title>
<link rel="stylesheet" href="node_modules/openlayers/dist/ol.css" type="text/css">
<style> <style>
#map { #map {
width: 400px; width: 400px;
@@ -71,17 +72,18 @@ You will also need an `ìndex.html` file that will use your bundle. Here is a si
## Creating a bundle ## Creating a bundle
With simple scripts you can introduce the commands `npm run build` and `npm start` to manually build your bundle and watch for changes, respectively. Add the following to the script section in `package.json`: With simple scripts you can introduce the commands `npm run build` and `npm start` to
manually build your bundle and watch for changes, respectively. Add the following
to the script section in `package.json`:
```json ```json
"scripts": { "scripts": {
"start": "watchify index.js -g cssify --outfile bundle.js & http-server", "start": "watchify index.js --outfile bundle.js",
"build": "browserify -g cssify index.js | uglifyjs --compress --output bundle.js" "build": "browserify index.js | uglifyjs --compress --output bundle.js"
} }
``` ```
Now to test your application open http://localhost:8080/ in your browser. `watchify` will update `bundle.js` whenever you change something. You simply need to reload the page in your browser to see the changes.
```
$ npm start
```
Note that `bundle.js` will contain your application code and all dependencies used in your application. From OpenLayers, it only contains the required components. Note that `bundle.js` will contain your application code and all dependencies
used in your application, in this case the official full build of OpenLayers.
If you only need parts of OpenLayers you can create
[custom builds](../../builder).
-4
View File
@@ -5,15 +5,11 @@ layout: doc.hbs
# Compiling Application with Closure Compiler # Compiling Application with Closure Compiler
**Note**: When building an application with dependencies that are available as [npm](https://npmjs.com/) packages, it will probably be easier to use the [ol](https://npmjs.com/package/ol) package and follow the instructions there.
The OpenLayers code uses the Closure Library, and it is compiled with the The OpenLayers code uses the Closure Library, and it is compiled with the
Closure Compiler. Using OpenLayers in an application does not require using Closure Compiler. Using OpenLayers in an application does not require using
Closure. But using Closure in an OpenLayers application is possible. And this Closure. But using Closure in an OpenLayers application is possible. And this
is what this tutorial is about. is what this tutorial is about.
When you want to include OpenLayers as separate script without bundling with your application, follow the [Creating custom builds](./custom-builds.html) tutorial instead.
This tutorial will teach you how to set up an OpenLayers application based on This tutorial will teach you how to set up an OpenLayers application based on
the [`closure-util`](https://github.com/openlayers/closure-util) node package, the [`closure-util`](https://github.com/openlayers/closure-util) node package,
which provides utilities for working with Closure. Using `closure-util` is one which provides utilities for working with Closure. Using `closure-util` is one
+30 -22
View File
@@ -1,8 +1,9 @@
goog.require('ol.Collection');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.View'); goog.require('ol.View');
goog.require('ol.events.condition');
goog.require('ol.interaction.Draw'); goog.require('ol.interaction.Draw');
goog.require('ol.interaction.Modify'); goog.require('ol.interaction.Modify');
goog.require('ol.interaction.Snap');
goog.require('ol.layer.Tile'); goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.source.OSM'); goog.require('ol.source.OSM');
@@ -16,9 +17,18 @@ var raster = new ol.layer.Tile({
source: new ol.source.OSM() source: new ol.source.OSM()
}); });
var source = new ol.source.Vector(); var map = new ol.Map({
var vector = new ol.layer.Vector({ layers: [raster],
source: source, target: 'map',
view: new ol.View({
center: [-11000000, 4600000],
zoom: 4
})
});
var features = new ol.Collection();
var featureOverlay = new ol.layer.Vector({
source: new ol.source.Vector({features: features}),
style: new ol.style.Style({ style: new ol.style.Style({
fill: new ol.style.Fill({ fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)' color: 'rgba(255, 255, 255, 0.2)'
@@ -35,40 +45,38 @@ var vector = new ol.layer.Vector({
}) })
}) })
}); });
featureOverlay.setMap(map);
var map = new ol.Map({ var modify = new ol.interaction.Modify({
layers: [raster, vector], features: features,
target: 'map', // the SHIFT key must be pressed to delete vertices, so
view: new ol.View({ // that new vertices can be drawn at the same position
center: [-11000000, 4600000], // of existing vertices
zoom: 4 deleteCondition: function(event) {
}) return ol.events.condition.shiftKeyOnly(event) &&
ol.events.condition.singleClick(event);
}
}); });
var modify = new ol.interaction.Modify({source: source});
map.addInteraction(modify); map.addInteraction(modify);
var draw, snap; // global so we can remove them later var draw; // global so we can remove it later
var typeSelect = document.getElementById('type'); var typeSelect = document.getElementById('type');
function addInteractions() { function addInteraction() {
draw = new ol.interaction.Draw({ draw = new ol.interaction.Draw({
source: source, features: features,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value) type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
}); });
map.addInteraction(draw); map.addInteraction(draw);
snap = new ol.interaction.Snap({source: source});
map.addInteraction(snap);
} }
/** /**
* Handle change event. * Handle change event.
*/ */
typeSelect.onchange = function() { typeSelect.onchange = function() {
map.removeInteraction(draw); map.removeInteraction(draw);
map.removeInteraction(snap); addInteraction();
addInteractions();
}; };
addInteractions(); addInteraction();
+1 -1
View File
@@ -144,7 +144,7 @@ var map = new ol.Map({
layers: [raster, vector], layers: [raster, vector],
interactions: ol.interaction.defaults().extend([new ol.interaction.Select({ interactions: ol.interaction.defaults().extend([new ol.interaction.Select({
condition: function(evt) { condition: function(evt) {
return evt.type == 'pointermove' || return evt.originalEvent.type == 'mousemove' ||
evt.type == 'singleclick'; evt.type == 'singleclick';
}, },
style: selectStyleFunction style: selectStyleFunction
+1
View File
@@ -78,6 +78,7 @@ fetch(url).then(function(response) {
var vectorSource = new ol.source.VectorTile({ var vectorSource = new ol.source.VectorTile({
format: new ol.format.GeoJSON(), format: new ol.format.GeoJSON(),
tileGrid: ol.tilegrid.createXYZ(), tileGrid: ol.tilegrid.createXYZ(),
tilePixelRatio: 16,
tileLoadFunction: function(tile) { tileLoadFunction: function(tile) {
var format = tile.getFormat(); var format = tile.getFormat();
var tileCoord = tile.getTileCoord(); var tileCoord = tile.getTileCoord();
+2 -1
View File
@@ -17,7 +17,7 @@ var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
// Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15. // Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
var resolutions = []; var resolutions = [];
for (var i = 0; i <= 8; ++i) { for (var i = 0; i <= 7; ++i) {
resolutions.push(156543.03392804097 / Math.pow(2, i * 2)); resolutions.push(156543.03392804097 / Math.pow(2, i * 2));
} }
// Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15. // Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
@@ -44,6 +44,7 @@ var map = new ol.Map({
resolutions: resolutions, resolutions: resolutions,
tileSize: 512 tileSize: 512
}), }),
tilePixelRatio: 8,
tileUrlFunction: tileUrlFunction tileUrlFunction: tileUrlFunction
}), }),
style: createMapboxStreetsV6Style() style: createMapboxStreetsV6Style()
+2 -1
View File
@@ -23,7 +23,8 @@ var map = new ol.Map({
'© <a href="https://www.openstreetmap.org/copyright">' + '© <a href="https://www.openstreetmap.org/copyright">' +
'OpenStreetMap contributors</a>', 'OpenStreetMap contributors</a>',
format: new ol.format.MVT(), format: new ol.format.MVT(),
tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22}), tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
tilePixelRatio: 16,
url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' + url: '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
}), }),
+1 -1
View File
@@ -70,7 +70,7 @@ var map = new ol.Map({
layerName: 'layer', layerName: 'layer',
layers: ['water', 'roads', 'buildings'] layers: ['water', 'roads', 'buildings']
}), }),
tileGrid: ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 19}), tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
url: 'https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key url: 'https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.topojson?api_key=' + key
}), }),
style: function(feature, resolution) { style: function(feature, resolution) {
-17
View File
@@ -1,17 +0,0 @@
---
layout: example.html
title: Street Labels
shortdesc: Render street names with a custom render.
docs: >
Example showing the use of a custom renderer to render text along a path. [Labelgun](https://github.com/Geovation/labelgun) is used to avoid label collisions. [label-segment](https://github.com/ahocevar/label-segment) makes sure that labels are placed on suitable street segments. [textpath](https://github.com/ahocevar/textpath) arranges the letters of a label along the geometry. The data is fetched from OSM using the [Overpass API](https://overpass-api.de).
tags: "vector, label, collision detection, labelgun, linelabel, overpass"
resources:
- https://cdn.polyfill.io/v2/polyfill.min.js?features=Set"
- https://unpkg.com/rbush@2.0.1/rbush.min.js
- https://unpkg.com/labelgun@0.1.1/lib/labelgun.min.js
- https://unpkg.com/textpath@1.0.1/dist/textpath.js
- https://unpkg.com/label-segment@1.0.0/dist/label-segment.js
cloak:
As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5: Your Bing Maps Key from http://www.bingmapsportal.com/ here
---
<div id="map" class="map"></div>
-115
View File
@@ -1,115 +0,0 @@
// NOCOMPILE
/* global labelgun, labelSegment, textPath */
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.extent');
goog.require('ol.format.OSMXML');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.BingMaps');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
var emptyFn = function() {};
var labelEngine = new labelgun['default'](emptyFn, emptyFn);
var context, pixelRatio; // Will be set in the map's postcompose listener
function measureText(text) {
return context.measureText(text).width * pixelRatio;
}
var extent, letters; // Will be set in the style's renderer function
function collectDrawData(letter, x, y, angle) {
ol.extent.extend(extent, [x, y, x, y]);
letters.push([x, y, angle, letter]);
}
var style = new ol.style.Style({
renderer: function(coords, context) {
var feature = context.feature;
var text = feature.get('name');
// Only create label when geometry has a long and straight segment
var path = labelSegment(coords, Math.PI / 8, measureText(text));
if (path) {
extent = ol.extent.createEmpty();
letters = [];
textPath(text, path, measureText, collectDrawData);
ol.extent.buffer(extent, 5 * pixelRatio, extent);
var bounds = {
bottomLeft: ol.extent.getBottomLeft(extent),
topRight: ol.extent.getTopRight(extent)
};
labelEngine.ingestLabel(bounds, feature.getId(), 1, letters, text, false);
}
}
});
var rasterLayer = new ol.layer.Tile({
source: new ol.source.BingMaps({
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5',
imagerySet: 'Aerial'
})
});
var source = new ol.source.Vector();
// Request streets from OSM, using the Overpass API
fetch('https://overpass-api.de/api/interpreter', {
method: 'POST',
body: '(way["highway"](48.19642,16.32580,48.22050,16.41986));(._;>;);out meta;'
}).then(function(response) {
return response.text();
}).then(function(responseText) {
var features = new ol.format.OSMXML().readFeatures(responseText, {
featureProjection: 'EPSG:3857'
});
source.addFeatures(features);
});
var vectorLayer = new ol.layer.Vector({
source: source,
style: function(feature) {
if (feature.getGeometry().getType() == 'LineString' && feature.get('name')) {
return style;
}
}
});
var viewExtent = [1817379, 6139595, 1827851, 6143616];
var map = new ol.Map({
layers: [rasterLayer, vectorLayer],
target: 'map',
view: new ol.View({
extent: viewExtent,
center: ol.extent.getCenter(viewExtent),
zoom: 17,
minZoom: 14
})
});
vectorLayer.on('precompose', function() {
labelEngine.destroy();
});
vectorLayer.on('postcompose', function(e) {
context = e.context;
pixelRatio = e.frameState.pixelRatio;
context.save();
context.font = 'normal 11px "Open Sans", "Arial Unicode MS"';
context.fillStyle = 'white';
context.textBaseline = 'middle';
context.textAlign = 'center';
var labels = labelEngine.getShown();
for (var i = 0, ii = labels.length; i < ii; ++i) {
// Render label letter by letter
var letters = labels[i].labelObject;
for (var j = 0, jj = letters.length; j < jj; ++j) {
var labelData = letters[j];
context.save();
context.translate(labelData[0], labelData[1]);
context.rotate(labelData[2]);
context.scale(pixelRatio, pixelRatio);
context.fillText(labelData[3], 0, 0);
context.restore();
}
}
context.restore();
});
-13
View File
@@ -1,13 +0,0 @@
---
layout: example.html
title: Vector Label Decluttering
shortdesc: Label decluttering with a custom renderer.
resources:
- https://cdn.polyfill.io/v2/polyfill.min.js?features=Set"
- https://unpkg.com/rbush@2.0.1/rbush.min.js
- https://unpkg.com/labelgun@0.1.1/lib/labelgun.min.js
docs: >
A custom `renderer` function is used instead of an `ol.style.Text` to label the countries of the world. Only texts that are not wider than their country's bounding box are considered and handed over to [Labelgun](https://github.com/Geovation/labelgun) for decluttering.
tags: "vector, renderer, labelgun, label"
---
<div id="map" class="map"></div>
-125
View File
@@ -1,125 +0,0 @@
// NOCOMPILE
/* global labelgun */
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.extent');
goog.require('ol.format.GeoJSON');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
// Style for labels
function setStyle(context) {
context.font = '12px Calibri,sans-serif';
context.fillStyle = '#000';
context.strokeStyle = '#fff';
context.lineWidth = 3;
context.textBaseline = 'hanging';
context.textAlign = 'start';
}
// A separate canvas context for measuring label width and height.
var textMeasureContext = document.createElement('CANVAS').getContext('2d');
setStyle(textMeasureContext);
// The label height is approximated by the width of the text 'WI'.
var height = textMeasureContext.measureText('WI').width;
// A cache for reusing label images once they have been created.
var textCache = {};
var map = new ol.Map({
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 1
})
});
var emptyFn = function() {};
var labelEngine = new labelgun['default'](emptyFn, emptyFn);
function createLabel(canvas, text, coord) {
var halfWidth = canvas.width / 2;
var halfHeight = canvas.height / 2;
var bounds = {
bottomLeft: [Math.round(coord[0] - halfWidth), Math.round(coord[1] - halfHeight)],
topRight: [Math.round(coord[0] + halfWidth), Math.round(coord[1] + halfHeight)]
};
labelEngine.ingestLabel(bounds, coord.toString(), 1, canvas, text, false);
}
// For multi-polygons, we only label the widest polygon. This is done by sorting
// by extent width in descending order, and take the first from the array.
function sortByWidth(a, b) {
return ol.extent.getWidth(b.getExtent()) - ol.extent.getWidth(a.getExtent());
}
var labelStyle = new ol.style.Style({
renderer: function(coords, state) {
var text = state.feature.get('name');
createLabel(textCache[text], text, coords);
}
});
var countryStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.6)'
}),
stroke: new ol.style.Stroke({
color: '#319FD3',
width: 1
})
});
var styleWithLabel = [countryStyle, labelStyle];
var styleWithoutLabel = [countryStyle];
var pixelRatio; // This is set by the map's precompose listener
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'data/geojson/countries.geojson',
format: new ol.format.GeoJSON()
}),
style: function(feature, resolution) {
var text = feature.get('name');
var width = textMeasureContext.measureText(text).width;
var geometry = feature.getGeometry();
if (geometry.getType() == 'MultiPolygon') {
geometry = geometry.getPolygons().sort(sortByWidth)[0];
}
var extentWidth = ol.extent.getWidth(geometry.getExtent());
if (extentWidth / resolution > width) {
// Only consider label when it fits its geometry's extent
if (!(text in textCache)) {
// Draw the label to its own canvas and cache it.
var canvas = textCache[text] = document.createElement('CANVAS');
canvas.width = width * pixelRatio;
canvas.height = height * pixelRatio;
var context = canvas.getContext('2d');
context.scale(pixelRatio, pixelRatio);
setStyle(context);
context.strokeText(text, 0, 0);
context.fillText(text, 0, 0);
}
labelStyle.setGeometry(geometry.getInteriorPoint());
return styleWithLabel;
} else {
return styleWithoutLabel;
}
}
});
vectorLayer.on('precompose', function(e) {
pixelRatio = e.frameState.pixelRatio;
labelEngine.destroy();
});
vectorLayer.on('postcompose', function(e) {
var labels = labelEngine.getShown();
for (var i = 0, ii = labels.length; i < ii; ++i) {
var label = labels[i];
// Draw label to the map canvas
e.context.drawImage(label.labelObject, label.minX, label.minY);
}
});
map.addLayer(vectorLayer);
-11
View File
@@ -91,17 +91,6 @@ oli.DrawEvent = function() {};
oli.DrawEvent.prototype.feature; oli.DrawEvent.prototype.feature;
/**
* @interface
*/
oli.ExtentEvent = function() {};
/**
* @type {ol.Extent}
*/
oli.ExtentEvent.prototype.extent;
/** /**
* @interface * @interface
*/ */
+20 -139
View File
@@ -3219,8 +3219,7 @@ olx.interaction.KeyboardZoomOptions.prototype.delta;
* insertVertexCondition: (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),
* source: (ol.source.Vector|undefined), * features: ol.Collection.<ol.Feature>,
* features: (ol.Collection.<ol.Feature>|undefined),
* wrapX: (boolean|undefined) * wrapX: (boolean|undefined)
* }} * }}
*/ */
@@ -3278,18 +3277,8 @@ olx.interaction.ModifyOptions.prototype.style;
/** /**
* The vector source with features to modify. If a vector source is not * The features the interaction works on.
* provided, a feature collection must be provided with the features option. * @type {ol.Collection.<ol.Feature>}
* @type {ol.source.Vector|undefined}
* @api
*/
olx.interaction.ModifyOptions.prototype.source;
/**
* The features the interaction works on. If a feature collection is not
* provided, a vector source must be provided with the source option.
* @type {ol.Collection.<ol.Feature>|undefined}
* @api * @api
*/ */
olx.interaction.ModifyOptions.prototype.features; olx.interaction.ModifyOptions.prototype.features;
@@ -3862,8 +3851,7 @@ olx.layer.GroupOptions.prototype.layers;
* maxResolution: (number|undefined), * maxResolution: (number|undefined),
* opacity: (number|undefined), * opacity: (number|undefined),
* source: (ol.source.Vector|undefined), * source: (ol.source.Vector|undefined),
* visible: (boolean|undefined), * visible: (boolean|undefined)}}
* zIndex: (number|undefined)}}
*/ */
olx.layer.HeatmapOptions; olx.layer.HeatmapOptions;
@@ -3960,15 +3948,6 @@ olx.layer.HeatmapOptions.prototype.source;
olx.layer.HeatmapOptions.prototype.visible; olx.layer.HeatmapOptions.prototype.visible;
/**
* The z-index for layer rendering. At rendering time, the layers will be
* ordered, first by Z-index and then by position. The default Z-index is 0.
* @type {number|undefined}
* @api
*/
olx.layer.HeatmapOptions.prototype.zIndex;
/** /**
* @typedef {{opacity: (number|undefined), * @typedef {{opacity: (number|undefined),
* map: (ol.Map|undefined), * map: (ol.Map|undefined),
@@ -3976,8 +3955,7 @@ olx.layer.HeatmapOptions.prototype.zIndex;
* visible: (boolean|undefined), * visible: (boolean|undefined),
* extent: (ol.Extent|undefined), * extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined), * maxResolution: (number|undefined)}}
* zIndex: (number|undefined)}}
*/ */
olx.layer.ImageOptions; olx.layer.ImageOptions;
@@ -4042,15 +4020,6 @@ olx.layer.ImageOptions.prototype.minResolution;
olx.layer.ImageOptions.prototype.maxResolution; olx.layer.ImageOptions.prototype.maxResolution;
/**
* The z-index for layer rendering. At rendering time, the layers will be
* ordered, first by Z-index and then by position. The default Z-index is 0.
* @type {number|undefined}
* @api
*/
olx.layer.ImageOptions.prototype.zIndex;
/** /**
* @typedef {{opacity: (number|undefined), * @typedef {{opacity: (number|undefined),
* preload: (number|undefined), * preload: (number|undefined),
@@ -4060,8 +4029,7 @@ olx.layer.ImageOptions.prototype.zIndex;
* extent: (ol.Extent|undefined), * extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined), * maxResolution: (number|undefined),
* useInterimTilesOnError: (boolean|undefined), * useInterimTilesOnError: (boolean|undefined)}}
* zIndex: (number|undefined)}}
*/ */
olx.layer.TileOptions; olx.layer.TileOptions;
@@ -4143,15 +4111,6 @@ olx.layer.TileOptions.prototype.maxResolution;
olx.layer.TileOptions.prototype.useInterimTilesOnError; olx.layer.TileOptions.prototype.useInterimTilesOnError;
/**
* The z-index for layer rendering. At rendering time, the layers will be
* ordered, first by Z-index and then by position. The default Z-index is 0.
* @type {number|undefined}
* @api
*/
olx.layer.TileOptions.prototype.zIndex;
/** /**
* @typedef {{renderOrder: (ol.RenderOrderFunction|null|undefined), * @typedef {{renderOrder: (ol.RenderOrderFunction|null|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
@@ -4163,8 +4122,7 @@ olx.layer.TileOptions.prototype.zIndex;
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined), * style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
* updateWhileAnimating: (boolean|undefined), * updateWhileAnimating: (boolean|undefined),
* updateWhileInteracting: (boolean|undefined), * updateWhileInteracting: (boolean|undefined),
* visible: (boolean|undefined), * visible: (boolean|undefined)}}
* zIndex: (number|undefined)}}
*/ */
olx.layer.VectorOptions; olx.layer.VectorOptions;
@@ -4279,15 +4237,6 @@ olx.layer.VectorOptions.prototype.updateWhileInteracting;
olx.layer.VectorOptions.prototype.visible; olx.layer.VectorOptions.prototype.visible;
/**
* The z-index for layer rendering. At rendering time, the layers will be
* ordered, first by Z-index and then by position. The default Z-index is 0.
* @type {number|undefined}
* @api
*/
olx.layer.VectorOptions.prototype.zIndex;
/** /**
* @typedef {{extent: (ol.Extent|undefined), * @typedef {{extent: (ol.Extent|undefined),
* map: (ol.Map|undefined), * map: (ol.Map|undefined),
@@ -4302,8 +4251,7 @@ olx.layer.VectorOptions.prototype.zIndex;
* style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined), * style: (ol.style.Style|Array.<ol.style.Style>|ol.StyleFunction|undefined),
* updateWhileAnimating: (boolean|undefined), * updateWhileAnimating: (boolean|undefined),
* updateWhileInteracting: (boolean|undefined), * updateWhileInteracting: (boolean|undefined),
* visible: (boolean|undefined), * visible: (boolean|undefined)}}
* zIndex: (number|undefined)}}
*/ */
olx.layer.VectorTileOptions; olx.layer.VectorTileOptions;
@@ -4445,15 +4393,6 @@ olx.layer.VectorTileOptions.prototype.updateWhileInteracting;
olx.layer.VectorTileOptions.prototype.visible; olx.layer.VectorTileOptions.prototype.visible;
/**
* The z-index for layer rendering. At rendering time, the layers will be
* ordered, first by Z-index and then by position. The default Z-index is 0.
* @type {number|undefined}
* @api
*/
olx.layer.VectorOptions.prototype.zIndex;
/** /**
* Namespace. * Namespace.
* @type {Object} * @type {Object}
@@ -4461,50 +4400,6 @@ olx.layer.VectorOptions.prototype.zIndex;
olx.render; olx.render;
/**
* @typedef {{context: CanvasRenderingContext2D,
* feature: (ol.Feature|ol.render.Feature),
* geometry: ol.geom.SimpleGeometry,
* pixelRatio: number,
* resolution: number,
* rotation: number}}
*/
olx.render.State;
/**
* Canvas context that the layer is being rendered to.
* @type {CanvasRenderingContext2D}
* @api
*/
olx.render.State.prototype.context;
/**
* Pixel ratio used by the layer renderer.
* @type {number}
* @api
*/
olx.render.State.prototype.pixelRatio;
/**
* Resolution that the render batch was created and optimized for. This is
* not the view's resolution that is being rendered.
* @type {number}
* @api
*/
olx.render.State.prototype.resolution;
/**
* Rotation of the rendered layer in radians.
* @type {number}
* @api
*/
olx.render.State.prototype.rotation;
/** /**
* @typedef {{size: (ol.Size|undefined), * @typedef {{size: (ol.Size|undefined),
* pixelRatio: (number|undefined)}} * pixelRatio: (number|undefined)}}
@@ -4961,6 +4856,7 @@ olx.source.TileImageOptions.prototype.wrapX;
* ol.TileLoadFunctionType)|undefined), * ol.TileLoadFunctionType)|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined), * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* tilePixelRatio: (number|undefined),
* tileUrlFunction: (ol.TileUrlFunctionType|undefined), * tileUrlFunction: (ol.TileUrlFunctionType|undefined),
* url: (string|undefined), * url: (string|undefined),
* urls: (Array.<string>|undefined), * urls: (Array.<string>|undefined),
@@ -5056,8 +4952,6 @@ olx.source.VectorTileOptions.prototype.tileGrid;
* var format = tile.getFormat(); * var format = tile.getFormat();
* tile.setFeatures(format.readFeatures(data)); * tile.setFeatures(format.readFeatures(data));
* tile.setProjection(format.readProjection(data)); * tile.setProjection(format.readProjection(data));
* // uncomment the line below for ol.format.MVT only
* //tile.setExtent(format.getLastExtent());
* }; * };
* }); * });
* ``` * ```
@@ -5067,6 +4961,17 @@ olx.source.VectorTileOptions.prototype.tileGrid;
olx.source.VectorTileOptions.prototype.tileLoadFunction; olx.source.VectorTileOptions.prototype.tileLoadFunction;
/**
* The pixel ratio used by the tile service. For example, if the tile
* service advertizes 256px by 256px tiles but actually sends 512px
* by 512px tiles (for retina/hidpi devices) then `tilePixelRatio`
* should be set to `2`. Default is `1`.
* @type {number|undefined}
* @api
*/
olx.source.VectorTileOptions.prototype.tilePixelRatio;
/** /**
* Optional function to get tile URL given a tile coordinate and the projection. * Optional function to get tile URL given a tile coordinate and the projection.
* @type {ol.TileUrlFunctionType|undefined} * @type {ol.TileUrlFunctionType|undefined}
@@ -6250,9 +6155,6 @@ olx.source.TileJSONOptions.prototype.wrapX;
* gutter: (number|undefined), * gutter: (number|undefined),
* hidpi: (boolean|undefined), * hidpi: (boolean|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
* ol.TileState, string, ?string,
* ol.TileLoadFunctionType)|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined), * tileGrid: (ol.tilegrid.TileGrid|undefined),
* projection: ol.ProjectionLike, * projection: ol.ProjectionLike,
* reprojectionErrorThreshold: (number|undefined), * reprojectionErrorThreshold: (number|undefined),
@@ -6335,16 +6237,6 @@ olx.source.TileWMSOptions.prototype.hidpi;
olx.source.TileWMSOptions.prototype.logo; olx.source.TileWMSOptions.prototype.logo;
/**
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
* @type {function(new: ol.ImageTile, ol.TileCoord,
* ol.TileState, string, ?string,
* ol.TileLoadFunctionType)|undefined}
* @api
*/
olx.source.TileWMSOptions.prototype.tileClass;
/** /**
* Tile grid. Base this on the resolutions, tilesize and extent supported by the * Tile grid. Base this on the resolutions, tilesize and extent supported by the
* server. * server.
@@ -7716,7 +7608,6 @@ olx.style.TextOptions.prototype.stroke;
* @typedef {{geometry: (undefined|string|ol.geom.Geometry|ol.StyleGeometryFunction), * @typedef {{geometry: (undefined|string|ol.geom.Geometry|ol.StyleGeometryFunction),
* fill: (ol.style.Fill|undefined), * fill: (ol.style.Fill|undefined),
* image: (ol.style.Image|undefined), * image: (ol.style.Image|undefined),
* renderer: (ol.StyleRenderFunction|undefined),
* stroke: (ol.style.Stroke|undefined), * stroke: (ol.style.Stroke|undefined),
* text: (ol.style.Text|undefined), * text: (ol.style.Text|undefined),
* zIndex: (number|undefined)}} * zIndex: (number|undefined)}}
@@ -7749,16 +7640,6 @@ olx.style.StyleOptions.prototype.fill;
olx.style.StyleOptions.prototype.image; olx.style.StyleOptions.prototype.image;
/**
* Custom renderer. When configured, `fill`, `stroke` and `image` will be
* ignored, and the provided function will be called with each render frame for
* each geometry.
*
* @type {ol.StyleRenderFunction|undefined}
*/
olx.style.StyleOptions.prototype.renderer;
/** /**
* Stroke style. * Stroke style.
* @type {ol.style.Stroke|undefined} * @type {ol.style.Stroke|undefined}
+12 -11
View File
@@ -1,6 +1,6 @@
{ {
"name": "openlayers", "name": "openlayers",
"version": "4.3.0-beta.3", "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",
@@ -33,8 +33,14 @@
"dependencies": { "dependencies": {
"async": "2.5.0", "async": "2.5.0",
"closure-util": "1.22.0", "closure-util": "1.22.0",
"fs-extra": "4.0.1", "derequire": "2.0.6",
"jsdoc": "3.5.4", "fs-extra": "4.0.0",
"glob": "7.1.1",
"handlebars": "4.0.10",
"jsdoc": "3.5.3",
"marked": "0.3.6",
"metalsmith": "2.3.0",
"metalsmith-layouts": "1.8.1",
"nomnom": "1.8.1", "nomnom": "1.8.1",
"pbf": "3.0.5", "pbf": "3.0.5",
"pixelworks": "1.1.0", "pixelworks": "1.1.0",
@@ -51,27 +57,22 @@
"clean-css-cli": "4.1.6", "clean-css-cli": "4.1.6",
"coveralls": "2.13.1", "coveralls": "2.13.1",
"debounce": "^1.0.0", "debounce": "^1.0.0",
"eslint": "4.4.1", "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",
"gaze": "^1.0.0", "gaze": "^1.0.0",
"glob": "7.1.1",
"handlebars": "4.0.10",
"istanbul": "0.4.5", "istanbul": "0.4.5",
"jquery": "3.2.1", "jquery": "3.2.1",
"jscodeshift": "^0.3.30", "jscodeshift": "^0.3.30",
"marked": "0.3.6", "mocha": "3.4.2",
"metalsmith": "2.3.0",
"metalsmith-layouts": "1.8.1",
"mocha": "3.5.0",
"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": "3.1.0", "sinon": "2.3.8",
"slimerjs": "0.10.3" "slimerjs": "0.10.3"
}, },
"eslintConfig": { "eslintConfig": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "ol", "name": "ol",
"version": "4.2.0", "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",
+2 -6
View File
@@ -23,7 +23,7 @@ goog.require('ol.events.Event');
* @constructor * @constructor
* @extends {ol.Object} * @extends {ol.Object}
* @fires ol.Collection.Event * @fires ol.Collection.Event
* @param {Array.<T>=} opt_array Array. * @param {!Array.<T>=} opt_array Array.
* @param {olx.CollectionOptions=} opt_options Collection options. * @param {olx.CollectionOptions=} opt_options Collection options.
* @template T * @template T
* @api * @api
@@ -95,11 +95,7 @@ ol.Collection.prototype.extend = function(arr) {
* @api * @api
*/ */
ol.Collection.prototype.forEach = function(f, opt_this) { ol.Collection.prototype.forEach = function(f, opt_this) {
var fn = (opt_this) ? f.bind(opt_this) : f; this.array_.forEach(f, opt_this);
var array = this.array_;
for (var i = 0, ii = array.length; i < ii; ++i) {
fn(array[i], i, array);
}
}; };
+5 -10
View File
@@ -168,22 +168,17 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
var center = viewState.center; var center = viewState.center;
var projection = viewState.projection; var projection = viewState.projection;
var units = this.getUnits(); var metersPerUnit = projection.getMetersPerUnit();
var pointResolutionUnits = units == ol.control.ScaleLineUnits.DEGREES ?
ol.proj.Units.DEGREES :
ol.proj.Units.METERS;
var pointResolution = var pointResolution =
ol.proj.getPointResolution(projection, viewState.resolution, center, pointResolutionUnits); ol.proj.getPointResolution(projection, viewState.resolution, center) *
metersPerUnit;
var nominalCount = this.minWidth_ * pointResolution; var nominalCount = this.minWidth_ * pointResolution;
var suffix = ''; var suffix = '';
var units = this.getUnits();
if (units == ol.control.ScaleLineUnits.DEGREES) { if (units == ol.control.ScaleLineUnits.DEGREES) {
var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES]; var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES];
if (projection.getUnits() == ol.proj.Units.DEGREES) { pointResolution /= metersPerDegree;
nominalCount *= metersPerDegree;
} else {
pointResolution /= metersPerDegree;
}
if (nominalCount < metersPerDegree / 60) { if (nominalCount < metersPerDegree / 60) {
suffix = '\u2033'; // seconds suffix = '\u2033'; // seconds
pointResolution *= 3600; pointResolution *= 3600;
+2 -2
View File
@@ -8,7 +8,7 @@ goog.require('ol.xml');
/** /**
* @param {string|ol.FeatureUrlFunction} url Feature URL service. * @param {string|ol.FeatureUrlFunction} url Feature URL service.
* @param {ol.format.Feature} format Feature format. * @param {ol.format.Feature} format Feature format.
* @param {function(this:ol.VectorTile, Array.<ol.Feature>, ol.proj.Projection, ol.Extent)|function(this:ol.source.Vector, Array.<ol.Feature>)} success * @param {function(this:ol.VectorTile, Array.<ol.Feature>, ol.proj.Projection)|function(this:ol.source.Vector, Array.<ol.Feature>)} success
* Function called with the loaded features and optionally with the data * Function called with the loaded features and optionally with the data
* projection. Called with the vector tile or source as `this`. * projection. Called with the vector tile or source as `this`.
* @param {function(this:ol.VectorTile)|function(this:ol.source.Vector)} failure * @param {function(this:ol.VectorTile)|function(this:ol.source.Vector)} failure
@@ -56,7 +56,7 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
if (source) { if (source) {
success.call(this, format.readFeatures(source, success.call(this, format.readFeatures(source,
{featureProjection: projection}), {featureProjection: projection}),
format.readProjection(source), format.getLastExtent()); format.readProjection(source));
} else { } else {
failure.call(this); failure.call(this);
} }
+30 -30
View File
@@ -290,9 +290,9 @@ ol.format.EsriJSON.getHasZM_ = function(geometry) {
var layout = geometry.getLayout(); var layout = geometry.getLayout();
return { return {
hasZ: (layout === ol.geom.GeometryLayout.XYZ || hasZ: (layout === ol.geom.GeometryLayout.XYZ ||
layout === ol.geom.GeometryLayout.XYZM), layout === ol.geom.GeometryLayout.XYZM),
hasM: (layout === ol.geom.GeometryLayout.XYM || hasM: (layout === ol.geom.GeometryLayout.XYM ||
layout === ol.geom.GeometryLayout.XYZM) layout === ol.geom.GeometryLayout.XYZM)
}; };
}; };
@@ -304,7 +304,7 @@ ol.format.EsriJSON.getHasZM_ = function(geometry) {
* @return {EsriJSONPolyline} EsriJSON geometry. * @return {EsriJSONPolyline} EsriJSON geometry.
*/ */
ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) { ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */(geometry)); var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */ (geometry));
return /** @type {EsriJSONPolyline} */ ({ return /** @type {EsriJSONPolyline} */ ({
hasZ: hasZM.hasZ, hasZ: hasZM.hasZ,
hasM: hasZM.hasM, hasM: hasZM.hasM,
@@ -323,7 +323,7 @@ ol.format.EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
*/ */
ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) { ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
// Esri geometries use the left-hand rule // Esri geometries use the left-hand rule
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */(geometry)); var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */ (geometry));
return /** @type {EsriJSONPolygon} */ ({ return /** @type {EsriJSONPolygon} */ ({
hasZ: hasZM.hasZ, hasZ: hasZM.hasZ,
hasM: hasZM.hasM, hasM: hasZM.hasM,
@@ -339,7 +339,7 @@ ol.format.EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
* @return {EsriJSONPolyline} EsriJSON geometry. * @return {EsriJSONPolyline} EsriJSON geometry.
*/ */
ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) { ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */(geometry)); var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */ (geometry));
return /** @type {EsriJSONPolyline} */ ({ return /** @type {EsriJSONPolyline} */ ({
hasZ: hasZM.hasZ, hasZ: hasZM.hasZ,
hasM: hasZM.hasM, hasM: hasZM.hasM,
@@ -355,7 +355,7 @@ ol.format.EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_option
* @return {EsriJSONMultipoint} EsriJSON geometry. * @return {EsriJSONMultipoint} EsriJSON geometry.
*/ */
ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) { ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */(geometry)); var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */ (geometry));
return /** @type {EsriJSONMultipoint} */ ({ return /** @type {EsriJSONMultipoint} */ ({
hasZ: hasZM.hasZ, hasZ: hasZM.hasZ,
hasM: hasZM.hasM, hasM: hasZM.hasM,
@@ -372,7 +372,7 @@ ol.format.EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
*/ */
ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry, ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
opt_options) { opt_options) {
var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */(geometry)); var hasZM = ol.format.EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */ (geometry));
var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false); var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
var output = []; var output = [];
for (var i = 0; i < coordinates.length; i++) { for (var i = 0; i < coordinates.length; i++) {
@@ -395,17 +395,17 @@ ol.format.EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
*/ */
ol.format.EsriJSON.GEOMETRY_READERS_ = {}; ol.format.EsriJSON.GEOMETRY_READERS_ = {};
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POINT] = ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POINT] =
ol.format.EsriJSON.readPointGeometry_; ol.format.EsriJSON.readPointGeometry_;
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.LINE_STRING] = ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.LINE_STRING] =
ol.format.EsriJSON.readLineStringGeometry_; ol.format.EsriJSON.readLineStringGeometry_;
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POLYGON] = ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.POLYGON] =
ol.format.EsriJSON.readPolygonGeometry_; ol.format.EsriJSON.readPolygonGeometry_;
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POINT] = ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POINT] =
ol.format.EsriJSON.readMultiPointGeometry_; ol.format.EsriJSON.readMultiPointGeometry_;
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_LINE_STRING] = ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_LINE_STRING] =
ol.format.EsriJSON.readMultiLineStringGeometry_; ol.format.EsriJSON.readMultiLineStringGeometry_;
ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] = ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] =
ol.format.EsriJSON.readMultiPolygonGeometry_; ol.format.EsriJSON.readMultiPolygonGeometry_;
/** /**
@@ -415,17 +415,17 @@ ol.format.EsriJSON.GEOMETRY_READERS_[ol.geom.GeometryType.MULTI_POLYGON] =
*/ */
ol.format.EsriJSON.GEOMETRY_WRITERS_ = {}; ol.format.EsriJSON.GEOMETRY_WRITERS_ = {};
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POINT] = ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POINT] =
ol.format.EsriJSON.writePointGeometry_; ol.format.EsriJSON.writePointGeometry_;
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.LINE_STRING] = ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.LINE_STRING] =
ol.format.EsriJSON.writeLineStringGeometry_; ol.format.EsriJSON.writeLineStringGeometry_;
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POLYGON] = ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.POLYGON] =
ol.format.EsriJSON.writePolygonGeometry_; ol.format.EsriJSON.writePolygonGeometry_;
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POINT] = ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POINT] =
ol.format.EsriJSON.writeMultiPointGeometry_; ol.format.EsriJSON.writeMultiPointGeometry_;
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_LINE_STRING] = ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_LINE_STRING] =
ol.format.EsriJSON.writeMultiLineStringGeometry_; ol.format.EsriJSON.writeMultiLineStringGeometry_;
ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POLYGON] = ol.format.EsriJSON.GEOMETRY_WRITERS_[ol.geom.GeometryType.MULTI_POLYGON] =
ol.format.EsriJSON.writeMultiPolygonGeometry_; ol.format.EsriJSON.writeMultiPolygonGeometry_;
/** /**
@@ -468,7 +468,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
} }
feature.setGeometry(geometry); feature.setGeometry(geometry);
if (opt_options && opt_options.idField && if (opt_options && opt_options.idField &&
esriJSONFeature.attributes[opt_options.idField]) { esriJSONFeature.attributes[opt_options.idField]) {
feature.setId(/** @type {number} */( feature.setId(/** @type {number} */(
esriJSONFeature.attributes[opt_options.idField])); esriJSONFeature.attributes[opt_options.idField]));
} }
@@ -488,7 +488,7 @@ ol.format.EsriJSON.prototype.readFeaturesFromObject = function(
var options = opt_options ? opt_options : {}; var options = opt_options ? opt_options : {};
if (esriJSONObject.features) { if (esriJSONObject.features) {
var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */ var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
(object); (object);
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
var esriJSONFeatures = esriJSONFeatureCollection.features; var esriJSONFeatures = esriJSONFeatureCollection.features;
@@ -523,7 +523,7 @@ ol.format.EsriJSON.prototype.readGeometry;
ol.format.EsriJSON.prototype.readGeometryFromObject = function( ol.format.EsriJSON.prototype.readGeometryFromObject = function(
object, opt_options) { object, opt_options) {
return ol.format.EsriJSON.readGeometry_( return ol.format.EsriJSON.readGeometry_(
/** @type {EsriJSONGeometry} */(object), opt_options); /** @type {EsriJSONGeometry} */ (object), opt_options);
}; };
@@ -560,7 +560,7 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) {
*/ */
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) { ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()]; var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
return geometryWriter(/** @type {ol.geom.Geometry} */( return geometryWriter(/** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions(geometry, true, opt_options)), ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
opt_options); opt_options);
}; };
@@ -622,13 +622,7 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (geometry) { if (geometry) {
object['geometry'] = object['geometry'] =
ol.format.EsriJSON.writeGeometry_(geometry, opt_options); ol.format.EsriJSON.writeGeometry_(geometry, opt_options);
if (opt_options && opt_options.featureProjection) {
object['geometry']['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: ol.proj.get(
opt_options.featureProjection).getCode().split(':').pop()
});
}
} }
var properties = feature.getProperties(); var properties = feature.getProperties();
delete properties[feature.getGeometryName()]; delete properties[feature.getGeometryName()];
@@ -637,6 +631,12 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
} else { } else {
object['attributes'] = {}; object['attributes'] = {};
} }
if (opt_options && opt_options.featureProjection) {
object['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: ol.proj.get(
opt_options.featureProjection).getCode().split(':').pop()
});
}
return object; return object;
}; };
-9
View File
@@ -72,15 +72,6 @@ ol.format.Feature.prototype.adaptOptions = function(options) {
}; };
/**
* Get the extent from the source of the last {@link readFeatures} call.
* @return {ol.Extent} Tile extent.
*/
ol.format.Feature.prototype.getLastExtent = function() {
return null;
};
/** /**
* @abstract * @abstract
* @return {ol.format.FormatType} Format. * @return {ol.format.FormatType} Format.
+1 -1
View File
@@ -2260,7 +2260,7 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) {
iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]); iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]);
} }
if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) { if (anchor && anchor[0] !== 0 && anchor[1] !== size[1]) {
var /** @type {ol.KMLVec2_} */ hotSpot = { var /** @type {ol.KMLVec2_} */ hotSpot = {
x: anchor[0], x: anchor[0],
xunits: ol.style.IconAnchorUnits.PIXELS, xunits: ol.style.IconAnchorUnits.PIXELS,
+2 -20
View File
@@ -69,25 +69,10 @@ ol.format.MVT = function(opt_options) {
*/ */
this.layers_ = options.layers ? options.layers : null; this.layers_ = options.layers ? options.layers : null;
/**
* @private
* @type {ol.Extent}
*/
this.extent_ = null;
}; };
ol.inherits(ol.format.MVT, ol.format.Feature); ol.inherits(ol.format.MVT, ol.format.Feature);
/**
* @inheritDoc
* @api
*/
ol.format.MVT.prototype.getLastExtent = function() {
return this.extent_;
};
/** /**
* @inheritDoc * @inheritDoc
*/ */
@@ -176,17 +161,14 @@ ol.format.MVT.prototype.readFeatures = function(source, opt_options) {
} }
layer = tile.layers[name]; layer = tile.layers[name];
var rawFeature;
for (var i = 0, ii = layer.length; i < ii; ++i) { for (var i = 0, ii = layer.length; i < ii; ++i) {
rawFeature = layer.feature(i);
if (featureClass === ol.render.Feature) { if (featureClass === ol.render.Feature) {
feature = this.readRenderFeature_(rawFeature, name); feature = this.readRenderFeature_(layer.feature(i), name);
} else { } else {
feature = this.readFeature_(rawFeature, name, opt_options); feature = this.readFeature_(layer.feature(i), name, opt_options);
} }
features.push(feature); features.push(feature);
} }
this.extent_ = layer ? [0, 0, layer.extent, layer.extent] : null;
} }
return features; return features;
+2 -4
View File
@@ -688,14 +688,12 @@ ol.format.WFS.writeDuringFilter_ = function(node, filter, objectStack) {
ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) { ol.format.WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
/** @type {ol.XmlNodeStackItem} */ /** @type {ol.XmlNodeStackItem} */
var item = {node: node}; var item = {node: node};
var conditions = filter.conditions; filter.conditions.forEach(function(condition) {
for (var i = 0, ii = conditions.length; i < ii; ++i) {
var condition = conditions[i];
ol.xml.pushSerializeAndPop(item, ol.xml.pushSerializeAndPop(item,
ol.format.WFS.GETFEATURE_SERIALIZERS_, ol.format.WFS.GETFEATURE_SERIALIZERS_,
ol.xml.makeSimpleNodeFactory(condition.getTagName()), ol.xml.makeSimpleNodeFactory(condition.getTagName()),
[condition], objectStack); [condition], objectStack);
} });
}; };
+1 -1
View File
@@ -519,7 +519,7 @@ ol.Graticule.prototype.getMeridians = function() {
ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
squaredTolerance, index) { squaredTolerance, index) {
var flatCoordinates = ol.geom.flat.geodesic.parallel(lat, var flatCoordinates = ol.geom.flat.geodesic.parallel(lat,
minLon, maxLon, this.projection_, squaredTolerance); this.minLon_, this.maxLon_, this.projection_, squaredTolerance);
var lineString = this.parallels_[index] !== undefined ? var lineString = this.parallels_[index] !== undefined ?
this.parallels_[index] : new ol.geom.LineString(null); this.parallels_[index] : new ol.geom.LineString(null);
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
+20 -9
View File
@@ -10,7 +10,6 @@ goog.require('ol.extent');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Point'); goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon'); goog.require('ol.geom.Polygon');
goog.require('ol.interaction.ExtentEventType');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
@@ -77,6 +76,10 @@ ol.interaction.Extent = function(opt_options) {
opt_options = {}; opt_options = {};
} }
if (opt_options.extent) {
this.setExtent(opt_options.extent);
}
/* Inherit ol.interaction.Pointer */ /* Inherit ol.interaction.Pointer */
ol.interaction.Pointer.call(this, { ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Extent.handleDownEvent_, handleDownEvent: ol.interaction.Extent.handleDownEvent_,
@@ -114,10 +117,6 @@ ol.interaction.Extent = function(opt_options) {
updateWhileAnimating: true, updateWhileAnimating: true,
updateWhileInteracting: true updateWhileInteracting: true
}); });
if (opt_options.extent) {
this.setExtent(opt_options.extent);
}
}; };
ol.inherits(ol.interaction.Extent, ol.interaction.Pointer); ol.inherits(ol.interaction.Extent, ol.interaction.Pointer);
@@ -446,19 +445,31 @@ ol.interaction.Extent.prototype.setExtent = function(extent) {
* this type. * this type.
* *
* @constructor * @constructor
* @implements {oli.ExtentEvent}
* @param {ol.Extent} extent the new extent * @param {ol.Extent} extent the new extent
* @extends {ol.events.Event} * @extends {ol.events.Event}
*/ */
ol.interaction.Extent.Event = function(extent) { ol.interaction.Extent.Event = function(extent) {
ol.events.Event.call(this, ol.interaction.ExtentEventType.EXTENTCHANGED); ol.events.Event.call(this, ol.interaction.Extent.EventType_.EXTENTCHANGED);
/** /**
* The current extent. * The current extent.
* @type {ol.Extent} * @type {ol.Extent}
* @api * @api
*/ */
this.extent = extent; this.extent_ = extent;
}; };
ol.inherits(ol.interaction.Extent.Event, ol.events.Event); ol.inherits(ol.interaction.Extent.Event, ol.events.Event);
/**
* @enum {string}
* @private
*/
ol.interaction.Extent.EventType_ = {
/**
* Triggered after the extent is changed
* @event ol.interaction.Extent.Event
* @api
*/
EXTENTCHANGED: 'extentchanged'
};
-14
View File
@@ -1,14 +0,0 @@
goog.provide('ol.interaction.ExtentEventType');
/**
* @enum {string}
*/
ol.interaction.ExtentEventType = {
/**
* Triggered after the extent is changed
* @event ol.interaction.Extent.Event#extentchanged
* @api
*/
EXTENTCHANGED: 'extentchanged'
};
+4 -58
View File
@@ -1,7 +1,6 @@
goog.provide('ol.interaction.Modify'); goog.provide('ol.interaction.Modify');
goog.require('ol'); goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType'); goog.require('ol.CollectionEventType');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.MapBrowserEventType'); goog.require('ol.MapBrowserEventType');
@@ -20,22 +19,13 @@ goog.require('ol.interaction.ModifyEventType');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
goog.require('ol.source.Vector'); goog.require('ol.source.Vector');
goog.require('ol.source.VectorEventType');
goog.require('ol.structs.RBush'); goog.require('ol.structs.RBush');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
/** /**
* @classdesc * @classdesc
* Interaction for modifying feature geometries. To modify features that have * Interaction for modifying feature geometries.
* been added to an existing source, construct the modify interaction with the
* `source` option. If you want to modify features in a collection (for example,
* the collection used by a select interaction), construct the interaction with
* the `features` option. The interaction must be constructed with either a
* `source` or `features` option.
*
* By default, the interaction will allow deletion of vertices when the `alt`
* key is pressed. To configure the interaction with a different condition
* for deletion, use the `deleteCondition` option.
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {ol.interaction.Pointer}
@@ -66,7 +56,7 @@ ol.interaction.Modify = function(options) {
* @return {boolean} Combined condition result. * @return {boolean} Combined condition result.
*/ */
this.defaultDeleteCondition_ = function(mapBrowserEvent) { this.defaultDeleteCondition_ = function(mapBrowserEvent) {
return ol.events.condition.altKeyOnly(mapBrowserEvent) && return ol.events.condition.noModifierKeys(mapBrowserEvent) &&
ol.events.condition.singleClick(mapBrowserEvent); ol.events.condition.singleClick(mapBrowserEvent);
}; };
@@ -185,33 +175,11 @@ ol.interaction.Modify = function(options) {
'GeometryCollection': this.writeGeometryCollectionGeometry_ 'GeometryCollection': this.writeGeometryCollectionGeometry_
}; };
/**
* @type {ol.source.Vector}
* @private
*/
this.source_ = null;
var features;
if (options.source) {
this.source_ = options.source;
features = new ol.Collection(this.source_.getFeatures());
ol.events.listen(this.source_, ol.source.VectorEventType.ADDFEATURE,
this.handleSourceAdd_, this);
ol.events.listen(this.source_, ol.source.VectorEventType.REMOVEFEATURE,
this.handleSourceRemove_, this);
} else {
features = options.features;
}
if (!features) {
throw new Error('The modify interaction requires features or a source');
}
/** /**
* @type {ol.Collection.<ol.Feature>} * @type {ol.Collection.<ol.Feature>}
* @private * @private
*/ */
this.features_ = features; this.features_ = options.features;
this.features_.forEach(this.addFeature_, this); this.features_.forEach(this.addFeature_, this);
ol.events.listen(this.features_, ol.CollectionEventType.ADD, ol.events.listen(this.features_, ol.CollectionEventType.ADD,
@@ -333,28 +301,6 @@ ol.interaction.Modify.prototype.setMap = function(map) {
}; };
/**
* @param {ol.source.Vector.Event} event Event.
* @private
*/
ol.interaction.Modify.prototype.handleSourceAdd_ = function(event) {
if (event.feature) {
this.features_.push(event.feature);
}
};
/**
* @param {ol.source.Vector.Event} event Event.
* @private
*/
ol.interaction.Modify.prototype.handleSourceRemove_ = function(event) {
if (event.feature) {
this.features_.remove(event.feature);
}
};
/** /**
* @param {ol.Collection.Event} evt Event. * @param {ol.Collection.Event} evt Event.
* @private * @private
+3 -1
View File
@@ -80,7 +80,9 @@ ol.layer.Group.prototype.createRenderer = function(mapRenderer) {};
* @private * @private
*/ */
ol.layer.Group.prototype.handleLayerChange_ = function() { ol.layer.Group.prototype.handleLayerChange_ = function() {
this.changed(); if (this.getVisible()) {
this.changed();
}
}; };
-9
View File
@@ -116,12 +116,3 @@ ol.layer.VectorTile.prototype.setUseInterimTilesOnError = function(useInterimTil
this.set( this.set(
ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError); ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
}; };
/**
* Return the associated {@link ol.source.VectorTile vectortilesource} of the layer.
* @function
* @return {ol.source.VectorTile} Source.
* @api
*/
ol.layer.VectorTile.prototype.getSource;
+1 -20
View File
@@ -541,7 +541,7 @@ ol.Map.prototype.disposeInternal = function() {
/** /**
* Detect features that intersect a pixel on the viewport, and execute a * Detect features that intersect a pixel on the viewport, and execute a
* callback with each intersecting feature. Layers included in the detection can * callback with each intersecting feature. Layers included in the detection can
* be configured through the `layerFilter` option in `opt_options`. * be configured through `opt_layerFilter`.
* @param {ol.Pixel} pixel Pixel. * @param {ol.Pixel} pixel Pixel.
* @param {function(this: S, (ol.Feature|ol.render.Feature), * @param {function(this: S, (ol.Feature|ol.render.Feature),
* ol.layer.Layer): T} callback Feature callback. The callback will be * ol.layer.Layer): T} callback Feature callback. The callback will be
@@ -573,25 +573,6 @@ ol.Map.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_options)
}; };
/**
* Get all features that intersect a pixel on the viewport.
* @param {ol.Pixel} pixel Pixel.
* @param {olx.AtPixelOptions=} opt_options Optional options.
* @return {Array.<ol.Feature|ol.render.Feature>} The detected features or
* `null` if none were found.
* @api
*/
ol.Map.prototype.getFeaturesAtPixel = function(pixel, opt_options) {
var features = null;
this.forEachFeatureAtPixel(pixel, function(feature) {
if (!features) {
features = [];
}
features.push(feature);
}, opt_options);
return features;
};
/** /**
* Detect layers that have a color value at a pixel on the viewport, and * Detect layers that have a color value at a pixel on the viewport, and
* execute a callback with each matching layer. Layers included in the * execute a callback with each matching layer. Layers included in the
+4 -4
View File
@@ -475,7 +475,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
if (this.rendered_.left_ !== '') { if (this.rendered_.left_ !== '') {
this.rendered_.left_ = style.left = ''; this.rendered_.left_ = style.left = '';
} }
var right = (mapSize[0] - pixel[0] - offsetX) + 'px'; var right = Math.round(mapSize[0] - pixel[0] - offsetX) + 'px';
if (this.rendered_.right_ != right) { if (this.rendered_.right_ != right) {
this.rendered_.right_ = style.right = right; this.rendered_.right_ = style.right = right;
} }
@@ -488,7 +488,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
positioning == ol.OverlayPositioning.TOP_CENTER) { positioning == ol.OverlayPositioning.TOP_CENTER) {
offsetX -= this.element_.offsetWidth / 2; offsetX -= this.element_.offsetWidth / 2;
} }
var left = (pixel[0] + offsetX) + 'px'; var left = Math.round(pixel[0] + offsetX) + 'px';
if (this.rendered_.left_ != left) { if (this.rendered_.left_ != left) {
this.rendered_.left_ = style.left = left; this.rendered_.left_ = style.left = left;
} }
@@ -499,7 +499,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
if (this.rendered_.top_ !== '') { if (this.rendered_.top_ !== '') {
this.rendered_.top_ = style.top = ''; this.rendered_.top_ = style.top = '';
} }
var bottom = (mapSize[1] - pixel[1] - offsetY) + 'px'; var bottom = Math.round(mapSize[1] - pixel[1] - offsetY) + 'px';
if (this.rendered_.bottom_ != bottom) { if (this.rendered_.bottom_ != bottom) {
this.rendered_.bottom_ = style.bottom = bottom; this.rendered_.bottom_ = style.bottom = bottom;
} }
@@ -512,7 +512,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
positioning == ol.OverlayPositioning.CENTER_RIGHT) { positioning == ol.OverlayPositioning.CENTER_RIGHT) {
offsetY -= this.element_.offsetHeight / 2; offsetY -= this.element_.offsetHeight / 2;
} }
var top = (pixel[1] + offsetY) + 'px'; var top = Math.round(pixel[1] + offsetY) + 'px';
if (this.rendered_.top_ != top) { if (this.rendered_.top_ != top) {
this.rendered_.top_ = style.top = top; this.rendered_.top_ = style.top = top;
} }
+4 -8
View File
@@ -63,12 +63,10 @@ if (ol.ENABLE_PROJ4JS) {
* @param {ol.ProjectionLike} projection The projection. * @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.
* @param {ol.proj.Units=} opt_units Units to get the point resolution in. * @return {number} Point resolution at point in projection units.
* Default is the projection's units.
* @return {number} Point resolution.
* @api * @api
*/ */
ol.proj.getPointResolution = function(projection, resolution, point, opt_units) { ol.proj.getPointResolution = function(projection, resolution, point) {
projection = ol.proj.get(projection); projection = ol.proj.get(projection);
var pointResolution; var pointResolution;
var getter = projection.getPointResolutionFunc(); var getter = projection.getPointResolutionFunc();
@@ -76,7 +74,7 @@ ol.proj.getPointResolution = function(projection, resolution, point, opt_units)
pointResolution = getter(resolution, point); pointResolution = getter(resolution, point);
} else { } else {
var units = projection.getUnits(); var units = projection.getUnits();
if (units == ol.proj.Units.DEGREES && !opt_units || opt_units == ol.proj.Units.DEGREES) { if (units == ol.proj.Units.DEGREES) {
pointResolution = resolution; pointResolution = resolution;
} else { } else {
// Estimate point resolution by transforming the center pixel to EPSG:4326, // Estimate point resolution by transforming the center pixel to EPSG:4326,
@@ -95,9 +93,7 @@ ol.proj.getPointResolution = function(projection, resolution, point, opt_units)
var height = ol.proj.AUTHALIC_SPHERE_.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 = opt_units ? var metersPerUnit = projection.getMetersPerUnit();
ol.proj.Units.METERS_PER_UNIT[opt_units] :
projection.getMetersPerUnit();
if (metersPerUnit !== undefined) { if (metersPerUnit !== undefined) {
pointResolution /= metersPerUnit; pointResolution /= metersPerUnit;
} }
+19 -9
View File
@@ -63,21 +63,31 @@ ol.proj.EPSG3857.EXTENT = [
ol.proj.EPSG3857.WORLD_EXTENT = [-180, -85, 180, 85]; ol.proj.EPSG3857.WORLD_EXTENT = [-180, -85, 180, 85];
/**
* Lists several projection codes with the same meaning as EPSG:3857.
*
* @type {Array.<string>}
*/
ol.proj.EPSG3857.CODES = [
'EPSG:3857',
'EPSG:102100',
'EPSG:102113',
'EPSG:900913',
'urn:ogc:def:crs:EPSG:6.18:3:3857',
'urn:ogc:def:crs:EPSG::3857',
'http://www.opengis.net/gml/srs/epsg.xml#3857'
];
/** /**
* Projections equal to EPSG:3857. * Projections equal to EPSG:3857.
* *
* @const * @const
* @type {Array.<ol.proj.Projection>} * @type {Array.<ol.proj.Projection>}
*/ */
ol.proj.EPSG3857.PROJECTIONS = [ ol.proj.EPSG3857.PROJECTIONS = ol.proj.EPSG3857.CODES.map(function(code) {
new ol.proj.EPSG3857.Projection_('EPSG:3857'), return new ol.proj.EPSG3857.Projection_(code);
new ol.proj.EPSG3857.Projection_('EPSG:102100'), });
new ol.proj.EPSG3857.Projection_('EPSG:102113'),
new ol.proj.EPSG3857.Projection_('EPSG:900913'),
new ol.proj.EPSG3857.Projection_('urn:ogc:def:crs:EPSG:6.18:3:3857'),
new ol.proj.EPSG3857.Projection_('urn:ogc:def:crs:EPSG::3857'),
new ol.proj.EPSG3857.Projection_('http://www.opengis.net/gml/srs/epsg.xml#3857')
];
/** /**
+1 -7
View File
@@ -735,7 +735,6 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
context.lineCap = strokeState.lineCap; context.lineCap = strokeState.lineCap;
if (ol.has.CANVAS_LINE_DASH) { if (ol.has.CANVAS_LINE_DASH) {
context.setLineDash(strokeState.lineDash); context.setLineDash(strokeState.lineDash);
context.lineDashOffset = strokeState.lineDashOffset;
} }
context.lineJoin = strokeState.lineJoin; context.lineJoin = strokeState.lineJoin;
context.lineWidth = strokeState.lineWidth; context.lineWidth = strokeState.lineWidth;
@@ -744,7 +743,6 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
this.contextStrokeState_ = { this.contextStrokeState_ = {
lineCap: strokeState.lineCap, lineCap: strokeState.lineCap,
lineDash: strokeState.lineDash, lineDash: strokeState.lineDash,
lineDashOffset: strokeState.lineDashOffset,
lineJoin: strokeState.lineJoin, lineJoin: strokeState.lineJoin,
lineWidth: strokeState.lineWidth, lineWidth: strokeState.lineWidth,
miterLimit: strokeState.miterLimit, miterLimit: strokeState.miterLimit,
@@ -759,10 +757,6 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
contextStrokeState.lineDash, strokeState.lineDash)) { contextStrokeState.lineDash, strokeState.lineDash)) {
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash); context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
} }
if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) {
contextStrokeState.lineDashOffset = context.lineDashOffset =
strokeState.lineDashOffset;
}
} }
if (contextStrokeState.lineJoin != strokeState.lineJoin) { if (contextStrokeState.lineJoin != strokeState.lineJoin) {
contextStrokeState.lineJoin = context.lineJoin = strokeState.lineJoin; contextStrokeState.lineJoin = context.lineJoin = strokeState.lineJoin;
@@ -886,7 +880,7 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
this.imageOriginY_ = imageOrigin[1]; this.imageOriginY_ = imageOrigin[1];
this.imageRotateWithView_ = imageStyle.getRotateWithView(); this.imageRotateWithView_ = imageStyle.getRotateWithView();
this.imageRotation_ = imageStyle.getRotation(); this.imageRotation_ = imageStyle.getRotation();
this.imageScale_ = imageStyle.getScale() * this.pixelRatio_; this.imageScale_ = imageStyle.getScale();
this.imageSnapToPixel_ = imageStyle.getSnapToPixel(); this.imageSnapToPixel_ = imageStyle.getSnapToPixel();
this.imageWidth_ = imageSize[0]; this.imageWidth_ = imageSize[0];
} }
+9 -10
View File
@@ -8,14 +8,13 @@ ol.render.canvas.Instruction = {
BEGIN_PATH: 1, BEGIN_PATH: 1,
CIRCLE: 2, CIRCLE: 2,
CLOSE_PATH: 3, CLOSE_PATH: 3,
CUSTOM: 4, DRAW_IMAGE: 4,
DRAW_IMAGE: 5, DRAW_TEXT: 5,
DRAW_TEXT: 6, END_GEOMETRY: 6,
END_GEOMETRY: 7, FILL: 7,
FILL: 8, MOVE_TO_LINE_TO: 8,
MOVE_TO_LINE_TO: 9, SET_FILL_STYLE: 9,
SET_FILL_STYLE: 10, SET_STROKE_STYLE: 10,
SET_STROKE_STYLE: 11, SET_TEXT_STYLE: 11,
SET_TEXT_STYLE: 12, STROKE: 12
STROKE: 13
}; };
+4 -5
View File
@@ -37,7 +37,7 @@ ol.render.canvas.LineStringReplay = function(tolerance, maxExtent, resolution, o
* currentLineJoin: (string|undefined), * currentLineJoin: (string|undefined),
* currentLineWidth: (number|undefined), * currentLineWidth: (number|undefined),
* currentMiterLimit: (number|undefined), * currentMiterLimit: (number|undefined),
* lastStroke: (number|undefined), * lastStroke: number,
* strokeStyle: (ol.ColorLike|undefined), * strokeStyle: (ol.ColorLike|undefined),
* lineCap: (string|undefined), * lineCap: (string|undefined),
* lineDash: Array.<number>, * lineDash: Array.<number>,
@@ -54,7 +54,7 @@ ol.render.canvas.LineStringReplay = function(tolerance, maxExtent, resolution, o
currentLineJoin: undefined, currentLineJoin: undefined,
currentLineWidth: undefined, currentLineWidth: undefined,
currentMiterLimit: undefined, currentMiterLimit: undefined,
lastStroke: undefined, lastStroke: 0,
strokeStyle: undefined, strokeStyle: undefined,
lineCap: undefined, lineCap: undefined,
lineDash: null, lineDash: null,
@@ -122,11 +122,10 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
state.currentLineJoin != lineJoin || state.currentLineJoin != lineJoin ||
state.currentLineWidth != lineWidth || state.currentLineWidth != lineWidth ||
state.currentMiterLimit != miterLimit) { state.currentMiterLimit != miterLimit) {
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) { if (state.lastStroke != this.coordinates.length) {
this.instructions.push([ol.render.canvas.Instruction.STROKE]); this.instructions.push([ol.render.canvas.Instruction.STROKE]);
state.lastStroke = this.coordinates.length; state.lastStroke = this.coordinates.length;
} }
state.lastStroke = 0;
this.instructions.push([ this.instructions.push([
ol.render.canvas.Instruction.SET_STROKE_STYLE, ol.render.canvas.Instruction.SET_STROKE_STYLE,
strokeStyle, lineWidth, lineCap, lineJoin, miterLimit, lineDash, lineDashOffset, true, 1 strokeStyle, lineWidth, lineCap, lineJoin, miterLimit, lineDash, lineDashOffset, true, 1
@@ -209,7 +208,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi
*/ */
ol.render.canvas.LineStringReplay.prototype.finish = function() { ol.render.canvas.LineStringReplay.prototype.finish = function() {
var state = this.state_; var state = this.state_;
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) { if (state.lastStroke != this.coordinates.length) {
this.instructions.push([ol.render.canvas.Instruction.STROKE]); this.instructions.push([ol.render.canvas.Instruction.STROKE]);
} }
this.reverseHitDetectionInstructions(); this.reverseHitDetectionInstructions();
+3 -110
View File
@@ -4,8 +4,6 @@ goog.require('ol');
goog.require('ol.array'); goog.require('ol.array');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.extent.Relationship'); goog.require('ol.extent.Relationship');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.flat.inflate');
goog.require('ol.geom.flat.transform'); goog.require('ol.geom.flat.transform');
goog.require('ol.has'); goog.require('ol.has');
goog.require('ol.obj'); goog.require('ol.obj');
@@ -88,12 +86,6 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, overlaps) {
*/ */
this.coordinates = []; this.coordinates = [];
/**
* @private
* @type {Object.<number,ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>>}
*/
this.coordinateCache_ = {};
/** /**
* @private * @private
* @type {!ol.Transform} * @type {!ol.Transform}
@@ -182,75 +174,6 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat
}; };
/**
* @param {Array.<number>} flatCoordinates Flat coordinates.
* @param {number} offset Offset.
* @param {Array.<number>} ends Ends.
* @param {number} stride Stride.
* @param {Array.<number>} replayEnds Replay ends.
* @return {number} Offset.
*/
ol.render.canvas.Replay.prototype.drawCustomCoordinates_ = function(flatCoordinates, offset, ends, stride, replayEnds) {
for (var i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i];
var replayEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
replayEnds.push(replayEnd);
offset = end;
}
return offset;
};
/**
* @inheritDoc.
*/
ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, renderer) {
this.beginGeometry(geometry, feature);
var type = geometry.getType();
var stride = geometry.getStride();
var replayBegin = this.coordinates.length;
var flatCoordinates, replayEnd, replayEnds, replayEndss;
var offset;
if (type == ol.geom.GeometryType.MULTI_POLYGON) {
geometry = /** @type {ol.geom.MultiPolygon} */ (geometry);
flatCoordinates = geometry.getOrientedFlatCoordinates();
replayEndss = [];
var endss = geometry.getEndss();
offset = 0;
for (var i = 0, ii = endss.length; i < ii; ++i) {
var myEnds = [];
offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
replayEndss.push(myEnds);
}
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
replayBegin, replayEndss, geometry, renderer, ol.geom.flat.inflate.coordinatesss]);
} else if (type == ol.geom.GeometryType.POLYGON || type == ol.geom.GeometryType.MULTI_LINE_STRING) {
replayEnds = [];
flatCoordinates = (type == ol.geom.GeometryType.POLYGON) ?
/** @type {ol.geom.Polygon} */ (geometry).getOrientedFlatCoordinates() :
geometry.getFlatCoordinates();
offset = this.drawCustomCoordinates_(flatCoordinates, 0,
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
stride, replayEnds);
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
replayBegin, replayEnds, geometry, renderer, ol.geom.flat.inflate.coordinatess]);
} else if (type == ol.geom.GeometryType.LINE_STRING || type == ol.geom.GeometryType.MULTI_POINT) {
flatCoordinates = geometry.getFlatCoordinates();
replayEnd = this.appendFlatCoordinates(
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
replayBegin, replayEnd, geometry, renderer, ol.geom.flat.inflate.coordinates]);
} else if (type == ol.geom.GeometryType.POINT) {
flatCoordinates = geometry.getFlatCoordinates();
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
replayEnd = this.coordinates.length;
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
replayBegin, replayEnd, geometry, renderer]);
}
this.endGeometry(geometry, feature);
};
/** /**
* @protected * @protected
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry. * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
@@ -326,15 +249,6 @@ ol.render.canvas.Replay.prototype.replay_ = function(
var prevX, prevY, roundX, roundY; var prevX, prevY, roundX, roundY;
var pendingFill = 0; var pendingFill = 0;
var pendingStroke = 0; var pendingStroke = 0;
var coordinateCache = this.coordinateCache_;
var state = /** @type {olx.render.State} */ ({
context: context,
pixelRatio: pixelRatio,
resolution: this.resolution,
rotation: viewRotation
});
// When the batch size gets too big, performance decreases. 200 is a good // When the batch size gets too big, performance decreases. 200 is a good
// balance between batch size and number of fill/stroke instructions. // balance between batch size and number of fill/stroke instructions.
var batchSize = var batchSize =
@@ -342,7 +256,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
while (i < ii) { while (i < ii) {
var instruction = instructions[i]; var instruction = instructions[i];
var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]); var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
var /** @type {ol.Feature|ol.render.Feature} */ feature, fill, stroke, text, x, y; var feature, fill, stroke, text, x, y;
switch (type) { switch (type) {
case ol.render.canvas.Instruction.BEGIN_GEOMETRY: case ol.render.canvas.Instruction.BEGIN_GEOMETRY:
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]); feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
@@ -389,28 +303,6 @@ ol.render.canvas.Replay.prototype.replay_ = function(
context.closePath(); context.closePath();
++i; ++i;
break; break;
case ol.render.canvas.Instruction.CUSTOM:
d = /** @type {number} */ (instruction[1]);
dd = instruction[2];
var geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]);
var renderer = instruction[4];
var fn = instruction.length == 6 ? instruction[5] : undefined;
state.geometry = geometry;
state.feature = feature;
if (!(i in coordinateCache)) {
coordinateCache[i] = [];
}
var coords = coordinateCache[i];
if (fn) {
fn(pixelCoordinates, d, dd, 2, coords);
} else {
coords[0] = pixelCoordinates[d];
coords[1] = pixelCoordinates[d + 1];
coords.length = 2;
}
renderer(coords, state);
++i;
break;
case ol.render.canvas.Instruction.DRAW_IMAGE: case ol.render.canvas.Instruction.DRAW_IMAGE:
d = /** @type {number} */ (instruction[1]); d = /** @type {number} */ (instruction[1]);
dd = /** @type {number} */ (instruction[2]); dd = /** @type {number} */ (instruction[2]);
@@ -522,7 +414,8 @@ ol.render.canvas.Replay.prototype.replay_ = function(
break; break;
case ol.render.canvas.Instruction.END_GEOMETRY: case ol.render.canvas.Instruction.END_GEOMETRY:
if (featureCallback !== undefined) { if (featureCallback !== undefined) {
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]); feature =
/** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
var result = featureCallback(feature); var result = featureCallback(feature);
if (result) { if (result) {
return result; return result;
-20
View File
@@ -7,7 +7,6 @@ goog.require('ol.extent');
goog.require('ol.geom.flat.transform'); goog.require('ol.geom.flat.transform');
goog.require('ol.obj'); goog.require('ol.obj');
goog.require('ol.render.ReplayGroup'); goog.require('ol.render.ReplayGroup');
goog.require('ol.render.canvas.Replay');
goog.require('ol.render.canvas.ImageReplay'); goog.require('ol.render.canvas.ImageReplay');
goog.require('ol.render.canvas.LineStringReplay'); goog.require('ol.render.canvas.LineStringReplay');
goog.require('ol.render.canvas.PolygonReplay'); goog.require('ol.render.canvas.PolygonReplay');
@@ -162,24 +161,6 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) {
return arr; return arr;
}; };
/**
* @param {Array.<ol.render.ReplayType>} replays Replays.
* @return {boolean} Has replays of the provided types.
*/
ol.render.canvas.ReplayGroup.prototype.hasReplays = function(replays) {
for (var zIndex in this.replaysByZIndex_) {
var candidates = this.replaysByZIndex_[zIndex];
for (var i = 0, ii = replays.length; i < ii; ++i) {
if (replays[i] in candidates) {
return true;
}
}
}
return false;
};
/** /**
* FIXME empty description for jsdoc * FIXME empty description for jsdoc
*/ */
@@ -406,7 +387,6 @@ ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
*/ */
ol.render.canvas.ReplayGroup.BATCH_CONSTRUCTORS_ = { ol.render.canvas.ReplayGroup.BATCH_CONSTRUCTORS_ = {
'Circle': ol.render.canvas.PolygonReplay, 'Circle': ol.render.canvas.PolygonReplay,
'Default': ol.render.canvas.Replay,
'Image': ol.render.canvas.ImageReplay, 'Image': ol.render.canvas.ImageReplay,
'LineString': ol.render.canvas.LineStringReplay, 'LineString': ol.render.canvas.LineStringReplay,
'Polygon': ol.render.canvas.PolygonReplay, 'Polygon': ol.render.canvas.PolygonReplay,
+1 -2
View File
@@ -12,6 +12,5 @@ ol.render.replay.ORDER = [
ol.render.ReplayType.CIRCLE, ol.render.ReplayType.CIRCLE,
ol.render.ReplayType.LINE_STRING, ol.render.ReplayType.LINE_STRING,
ol.render.ReplayType.IMAGE, ol.render.ReplayType.IMAGE,
ol.render.ReplayType.TEXT, ol.render.ReplayType.TEXT
ol.render.ReplayType.DEFAULT
]; ];
-1
View File
@@ -6,7 +6,6 @@ goog.provide('ol.render.ReplayType');
*/ */
ol.render.ReplayType = { ol.render.ReplayType = {
CIRCLE: 'Circle', CIRCLE: 'Circle',
DEFAULT: 'Default',
IMAGE: 'Image', IMAGE: 'Image',
LINE_STRING: 'LineString', LINE_STRING: 'LineString',
POLYGON: 'Polygon', POLYGON: 'Polygon',
-10
View File
@@ -13,16 +13,6 @@ ol.render.VectorContext = function() {
}; };
/**
* Render a geometry with a custom renderer.
*
* @param {ol.geom.SimpleGeometry} geometry Geometry.
* @param {ol.Feature|ol.render.Feature} feature Feature.
* @param {Function} renderer Renderer.
*/
ol.render.VectorContext.prototype.drawCustom = function(geometry, feature, renderer) {};
/** /**
* Render a geometry. * Render a geometry.
* *
+2 -4
View File
@@ -319,7 +319,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
feature, resolution, pixelRatio, styles, replayGroup); feature, resolution, pixelRatio, styles, replayGroup);
this.dirty_ = this.dirty_ || dirty; this.dirty_ = this.dirty_ || dirty;
} }
}.bind(this); };
if (vectorLayerRenderOrder) { if (vectorLayerRenderOrder) {
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
@@ -331,9 +331,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
features.push(feature); features.push(feature);
}, this); }, this);
features.sort(vectorLayerRenderOrder); features.sort(vectorLayerRenderOrder);
for (var i = 0, ii = features.length; i < ii; ++i) { features.forEach(renderFeature, this);
renderFeature(features[i]);
}
} else { } else {
vectorSource.forEachFeatureInExtent(extent, renderFeature, this); vectorSource.forEachFeatureInExtent(extent, renderFeature, this);
} }
+66 -83
View File
@@ -13,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');
@@ -62,8 +61,7 @@ ol.inherits(ol.renderer.canvas.VectorTileLayer, ol.renderer.canvas.TileLayer);
* @type {!Object.<string, Array.<ol.render.ReplayType>>} * @type {!Object.<string, Array.<ol.render.ReplayType>>}
*/ */
ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS = { ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS = {
'image': [ol.render.ReplayType.POLYGON, ol.render.ReplayType.CIRCLE, 'image': ol.render.replay.ORDER,
ol.render.ReplayType.LINE_STRING, ol.render.ReplayType.IMAGE, ol.render.ReplayType.TEXT],
'hybrid': [ol.render.ReplayType.POLYGON, ol.render.ReplayType.LINE_STRING] 'hybrid': [ol.render.ReplayType.POLYGON, ol.render.ReplayType.LINE_STRING]
}; };
@@ -73,8 +71,7 @@ ol.renderer.canvas.VectorTileLayer.IMAGE_REPLAYS = {
* @type {!Object.<string, Array.<ol.render.ReplayType>>} * @type {!Object.<string, Array.<ol.render.ReplayType>>}
*/ */
ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS = { ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS = {
'image': [ol.render.ReplayType.DEFAULT], 'hybrid': [ol.render.ReplayType.IMAGE, ol.render.ReplayType.TEXT],
'hybrid': [ol.render.ReplayType.IMAGE, ol.render.ReplayType.TEXT, ol.render.ReplayType.DEFAULT],
'vector': ol.render.replay.ORDER 'vector': ol.render.replay.ORDER
}; };
@@ -120,31 +117,30 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup_ = function(
return; return;
} }
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
var sourceTileGrid = source.getTileGrid();
var tileGrid = source.getTileGridForProjection(projection);
var resolution = tileGrid.getResolution(tile.tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) { for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
var sourceTile = tile.getTile(tile.tileKeys[t]); var sourceTile = tile.getTile(tile.tileKeys[t]);
replayState.dirty = false; replayState.dirty = false;
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
var sourceTileGrid = source.getTileGrid();
var sourceTileCoord = sourceTile.tileCoord; var sourceTileCoord = sourceTile.tileCoord;
var tileProjection = sourceTile.getProjection(); var tileProjection = sourceTile.getProjection();
var tileGrid = source.getTileGridForProjection(projection);
var resolution = tileGrid.getResolution(tile.tileCoord[0]);
var sourceTileResolution = sourceTileGrid.getResolution(sourceTile.tileCoord[0]); var sourceTileResolution = sourceTileGrid.getResolution(sourceTile.tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord); var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
var sharedExtent = ol.extent.getIntersection(tileExtent, sourceTileExtent); 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 = this.getTilePixelRatio_(source, sourceTile); var tilePixelRatio = tileResolution = source.getTilePixelRatio();
var transform = ol.transform.compose(this.tmpTransform_, var transform = ol.transform.compose(this.tmpTransform_,
0, 0, 0, 0,
1 / sourceTileResolution * tilePixelRatio, -1 / sourceTileResolution * tilePixelRatio, 1 / sourceTileResolution * tilePixelRatio, -1 / sourceTileResolution * tilePixelRatio,
0, 0,
-sourceTileExtent[0], -sourceTileExtent[3]); -sourceTileExtent[0], -sourceTileExtent[3]);
extent = (ol.transform.apply(transform, [sharedExtent[0], sharedExtent[3]]) extent = (ol.transform.apply(transform, [sharedExtent[0], sharedExtent[3]])
.concat(ol.transform.apply(transform, [sharedExtent[2], sharedExtent[1]]))); .concat(ol.transform.apply(transform, [sharedExtent[2], sharedExtent[1]])));
} else { } else {
tileResolution = resolution; tileResolution = resolution;
extent = sharedExtent; extent = sharedExtent;
@@ -253,7 +249,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi
var sourceTileCoord = sourceTile.tileCoord; var sourceTileCoord = sourceTile.tileCoord;
var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord, this.tmpExtent); var sourceTileExtent = sourceTileGrid.getTileCoordExtent(sourceTileCoord, this.tmpExtent);
origin = ol.extent.getTopLeft(sourceTileExtent); origin = ol.extent.getTopLeft(sourceTileExtent);
tilePixelRatio = this.getTilePixelRatio_(source, sourceTile); tilePixelRatio = source.getTilePixelRatio();
tileResolution = sourceTileGrid.getResolution(sourceTileCoord[0]) / tilePixelRatio; tileResolution = sourceTileGrid.getResolution(sourceTileCoord[0]) / tilePixelRatio;
tileSpaceCoordinate = [ tileSpaceCoordinate = [
(coordinate[0] - origin[0]) / tileResolution, (coordinate[0] - origin[0]) / tileResolution,
@@ -296,7 +292,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.getReplayTransform_ = function(tile
var tileGrid = source.getTileGrid(); var tileGrid = source.getTileGrid();
var tileCoord = tile.tileCoord; var tileCoord = tile.tileCoord;
var tileResolution = var tileResolution =
tileGrid.getResolution(tileCoord[0]) / this.getTilePixelRatio_(source, tile); tileGrid.getResolution(tileCoord[0]) / source.getTilePixelRatio();
var viewState = frameState.viewState; var viewState = frameState.viewState;
var pixelRatio = frameState.pixelRatio; var pixelRatio = frameState.pixelRatio;
var renderResolution = viewState.resolution / pixelRatio; var renderResolution = viewState.resolution / pixelRatio;
@@ -318,18 +314,6 @@ ol.renderer.canvas.VectorTileLayer.prototype.getReplayTransform_ = function(tile
}; };
/**
* @private
* @param {ol.source.VectorTile} source Source.
* @param {ol.VectorTile} tile Tile.
* @return {number} The tile's pixel ratio.
*/
ol.renderer.canvas.VectorTileLayer.prototype.getTilePixelRatio_ = function(source, tile) {
return ol.extent.getWidth(tile.getExtent()) /
ol.size.toSize(source.getTileGrid().getTileSize(tile.tileCoord[0]))[0];
};
/** /**
* Handle changes in image style state. * Handle changes in image style state.
* @param {ol.events.Event} event Image style change event. * @param {ol.events.Event} event Image style change event.
@@ -345,65 +329,64 @@ ol.renderer.canvas.VectorTileLayer.prototype.handleStyleImageChange_ = function(
*/ */
ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, frameState, layerState) { ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, frameState, layerState) {
var layer = this.getLayer(); var layer = this.getLayer();
var source = /** @type {ol.source.VectorTile} */ (layer.getSource()); var source = layer.getSource();
var renderMode = layer.getRenderMode(); var renderMode = layer.getRenderMode();
var replays = ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS[renderMode]; var replays = ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS[renderMode];
var pixelRatio = frameState.pixelRatio; if (replays) {
var rotation = frameState.viewState.rotation; var pixelRatio = frameState.pixelRatio;
var size = frameState.size; var rotation = frameState.viewState.rotation;
var offsetX = Math.round(pixelRatio * size[0] / 2); var size = frameState.size;
var offsetY = Math.round(pixelRatio * size[1] / 2); var offsetX = Math.round(pixelRatio * size[0] / 2);
var tiles = this.renderedTiles; var offsetY = Math.round(pixelRatio * size[1] / 2);
var sourceTileGrid = source.getTileGrid(); var tiles = this.renderedTiles;
var tileGrid = source.getTileGridForProjection(frameState.viewState.projection); var tilePixelRatio = layer.getSource().getTilePixelRatio();
var clips = []; var sourceTileGrid = source.getTileGrid();
var zs = []; var tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
for (var i = tiles.length - 1; i >= 0; --i) { var clips = [];
var tile = /** @type {ol.VectorImageTile} */ (tiles[i]); var zs = [];
if (tile.getState() == ol.TileState.ABORT) { for (var i = tiles.length - 1; i >= 0; --i) {
continue; var tile = /** @type {ol.VectorImageTile} */ (tiles[i]);
} if (tile.getState() == ol.TileState.ABORT) {
var tileCoord = tile.tileCoord;
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 tilePixelRatio = this.getTilePixelRatio_(source, sourceTile);
var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString());
if (renderMode != ol.layer.VectorTileRenderType.VECTOR && !replayGroup.hasReplays(replays)) {
continue; continue;
} }
var currentZ = sourceTile.tileCoord[0]; var tileCoord = tile.tileCoord;
var sourceResolution = sourceTileGrid.getResolution(currentZ); var worldOffset = tileGrid.getTileCoordExtent(tileCoord)[0] -
var transform = this.getReplayTransform_(sourceTile, frameState); tileGrid.getTileCoordExtent(tile.wrappedTileCoord)[0];
ol.transform.translate(transform, worldOffset * tilePixelRatio / sourceResolution, 0); for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
var currentClip = replayGroup.getClipCoords(transform); var sourceTile = tile.getTile(tile.tileKeys[t]);
context.save(); var currentZ = sourceTile.tileCoord[0];
context.globalAlpha = layerState.opacity; var sourceResolution = sourceTileGrid.getResolution(currentZ);
ol.render.canvas.rotateAtOffset(context, -rotation, offsetX, offsetY); var transform = this.getReplayTransform_(sourceTile, frameState);
// Create a clip mask for regions in this low resolution tile that are ol.transform.translate(transform, worldOffset * tilePixelRatio / sourceResolution, 0);
// already filled by a higher resolution tile var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString());
for (var j = 0, jj = clips.length; j < jj; ++j) { var currentClip = replayGroup.getClipCoords(transform);
var clip = clips[j]; context.save();
if (currentZ < zs[j]) { context.globalAlpha = layerState.opacity;
context.beginPath(); ol.render.canvas.rotateAtOffset(context, -rotation, offsetX, offsetY);
// counter-clockwise (outer ring) for current tile // Create a clip mask for regions in this low resolution tile that are
context.moveTo(currentClip[0], currentClip[1]); // already filled by a higher resolution tile
context.lineTo(currentClip[2], currentClip[3]); for (var j = 0, jj = clips.length; j < jj; ++j) {
context.lineTo(currentClip[4], currentClip[5]); var clip = clips[j];
context.lineTo(currentClip[6], currentClip[7]); if (currentZ < zs[j]) {
// clockwise (inner ring) for higher resolution tile context.beginPath();
context.moveTo(clip[6], clip[7]); // counter-clockwise (outer ring) for current tile
context.lineTo(clip[4], clip[5]); context.moveTo(currentClip[0], currentClip[1]);
context.lineTo(clip[2], clip[3]); context.lineTo(currentClip[2], currentClip[3]);
context.lineTo(clip[0], clip[1]); context.lineTo(currentClip[4], currentClip[5]);
context.clip(); context.lineTo(currentClip[6], currentClip[7]);
// clockwise (inner ring) for higher resolution tile
context.moveTo(clip[6], clip[7]);
context.lineTo(clip[4], clip[5]);
context.lineTo(clip[2], clip[3]);
context.lineTo(clip[0], clip[1]);
context.clip();
}
} }
replayGroup.replay(context, pixelRatio, transform, rotation, {}, replays);
context.restore();
clips.push(currentClip);
zs.push(currentZ);
} }
replayGroup.replay(context, pixelRatio, transform, rotation, {}, replays);
context.restore();
clips.push(currentClip);
zs.push(currentZ);
} }
} }
ol.renderer.canvas.TileLayer.prototype.postCompose.apply(this, arguments); ol.renderer.canvas.TileLayer.prototype.postCompose.apply(this, arguments);
@@ -455,10 +438,11 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function(
var tileCoord = tile.wrappedTileCoord; var tileCoord = tile.wrappedTileCoord;
var z = tileCoord[0]; var z = tileCoord[0];
var pixelRatio = frameState.pixelRatio; var pixelRatio = frameState.pixelRatio;
var source = /** @type {ol.source.VectorTile} */ (layer.getSource()); var source = layer.getSource();
var sourceTileGrid = source.getTileGrid(); var sourceTileGrid = source.getTileGrid();
var tileGrid = source.getTileGridForProjection(frameState.viewState.projection); var tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
var resolution = tileGrid.getResolution(z); var resolution = tileGrid.getResolution(z);
var tilePixelRatio = source.getTilePixelRatio();
var context = tile.getContext(layer); var context = tile.getContext(layer);
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];
@@ -466,7 +450,6 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function(
var tileExtent = tileGrid.getTileCoordExtent(tileCoord); var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) { for (var i = 0, ii = tile.tileKeys.length; i < ii; ++i) {
var sourceTile = tile.getTile(tile.tileKeys[i]); var sourceTile = tile.getTile(tile.tileKeys[i]);
var tilePixelRatio = this.getTilePixelRatio_(source, sourceTile);
var sourceTileCoord = sourceTile.tileCoord; var sourceTileCoord = sourceTile.tileCoord;
var pixelScale = pixelRatio / resolution; var pixelScale = pixelRatio / resolution;
var transform = ol.transform.reset(this.tmpTransform_); var transform = ol.transform.reset(this.tmpTransform_);
@@ -483,7 +466,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderTileImage_ = function(
ol.transform.translate(transform, -tileExtent[0], -tileExtent[3]); ol.transform.translate(transform, -tileExtent[0], -tileExtent[3]);
} }
var replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString()); var replayGroup = sourceTile.getReplayGroup(layer, tile.tileCoord.toString());
replayGroup.replay(context, pixelRatio, transform, 0, {}, replays, true); replayGroup.replay(context, pixelRatio, transform, 0, {}, replays);
} }
} }
}; };
+3 -29
View File
@@ -2,7 +2,6 @@ goog.provide('ol.renderer.vector');
goog.require('ol'); goog.require('ol');
goog.require('ol.ImageState'); goog.require('ol.ImageState');
goog.require('ol.geom.GeometryType');
goog.require('ol.render.ReplayType'); goog.require('ol.render.ReplayType');
@@ -112,34 +111,9 @@ ol.renderer.vector.renderFeature_ = function(
return; return;
} }
var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance); var simplifiedGeometry = geometry.getSimplifiedGeometry(squaredTolerance);
var renderer = style.getRenderer(); var geometryRenderer =
if (renderer) { ol.renderer.vector.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()];
ol.renderer.vector.renderGeometry_(replayGroup, simplifiedGeometry, style, feature); geometryRenderer(replayGroup, simplifiedGeometry, style, feature);
} else {
var geometryRenderer =
ol.renderer.vector.GEOMETRY_RENDERERS_[simplifiedGeometry.getType()];
geometryRenderer(replayGroup, simplifiedGeometry, style, feature);
}
};
/**
* @param {ol.render.ReplayGroup} replayGroup Replay group.
* @param {ol.geom.Geometry} geometry Geometry.
* @param {ol.style.Style} style Style.
* @param {ol.Feature|ol.render.Feature} feature Feature.
* @private
*/
ol.renderer.vector.renderGeometry_ = function(replayGroup, geometry, style, feature) {
if (geometry.getType() == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
var geometries = /** @type {ol.geom.GeometryCollection} */ (geometry).getGeometries();
for (var i = 0, ii = geometries.length; i < ii; ++i) {
ol.renderer.vector.renderGeometry_(replayGroup, geometries[i], style, feature);
}
return;
}
var replay = replayGroup.getReplay(style.getZIndex(), ol.render.ReplayType.DEFAULT);
replay.drawCustom(/** @type {ol.geom.SimpleGeometry} */ (geometry), feature, style.getRenderer());
}; };
+1 -1
View File
@@ -141,7 +141,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
extent: extent, extent: extent,
minZoom: resource.zoomMin, minZoom: resource.zoomMin,
maxZoom: maxZoom, maxZoom: maxZoom,
tileSize: tileSize / (this.hidpi_ ? 2 : 1) tileSize: tileSize / this.getTilePixelRatio()
}); });
this.tileGrid = tileGrid; this.tileGrid = tileGrid;
+2 -1
View File
@@ -74,7 +74,8 @@ ol.source.ImageWMS = function(opt_options) {
* @private * @private
* @type {ol.source.WMSServerType|undefined} * @type {ol.source.WMSServerType|undefined}
*/ */
this.serverType_ = /** @type {ol.source.WMSServerType|undefined} */ (options.serverType); this.serverType_ =
/** @type {ol.source.WMSServerType|undefined} */ (options.serverType);
/** /**
* @private * @private
+4 -3
View File
@@ -244,11 +244,12 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
/** /**
* Get the tile pixel ratio for this source. Subclasses may override this * Get the tile pixel ratio for this source. Subclasses may override this
* method, which is meant to return a supported pixel ratio that matches the * method, which is meant to return a supported pixel ratio that matches the
* provided `pixelRatio` as close as possible. * provided `opt_pixelRatio` as close as possible. When no `opt_pixelRatio` is
* @param {number} pixelRatio Pixel ratio. * provided, it is meant to return `this.tilePixelRatio_`.
* @param {number=} opt_pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio. * @return {number} Tile pixel ratio.
*/ */
ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) { ol.source.Tile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
return this.tilePixelRatio_; return this.tilePixelRatio_;
}; };
+2 -2
View File
@@ -42,7 +42,6 @@ ol.source.TileWMS = function(opt_options) {
opaque: !transparent, opaque: !transparent,
projection: options.projection, projection: options.projection,
reprojectionErrorThreshold: options.reprojectionErrorThreshold, reprojectionErrorThreshold: options.reprojectionErrorThreshold,
tileClass: options.tileClass,
tileGrid: options.tileGrid, tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction, tileLoadFunction: options.tileLoadFunction,
url: options.url, url: options.url,
@@ -72,7 +71,8 @@ ol.source.TileWMS = function(opt_options) {
* @private * @private
* @type {ol.source.WMSServerType|undefined} * @type {ol.source.WMSServerType|undefined}
*/ */
this.serverType_ = /** @type {ol.source.WMSServerType|undefined} */ (options.serverType); this.serverType_ =
/** @type {ol.source.WMSServerType|undefined} */ (options.serverType);
/** /**
* @private * @private
+5 -2
View File
@@ -40,6 +40,7 @@ ol.source.VectorTile = function(options) {
tileLoadFunction: options.tileLoadFunction ? tileLoadFunction: options.tileLoadFunction ?
options.tileLoadFunction : ol.VectorImageTile.defaultLoadFunction, options.tileLoadFunction : ol.VectorImageTile.defaultLoadFunction,
tileUrlFunction: options.tileUrlFunction, tileUrlFunction: options.tileUrlFunction,
tilePixelRatio: options.tilePixelRatio,
url: options.url, url: options.url,
urls: options.urls, urls: options.urls,
wrapX: options.wrapX === undefined ? true : options.wrapX wrapX: options.wrapX === undefined ? true : options.wrapX
@@ -140,8 +141,10 @@ ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.source.VectorTile.prototype.getTilePixelRatio = function(pixelRatio) { ol.source.VectorTile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
return pixelRatio; return opt_pixelRatio == undefined ?
ol.source.UrlTile.prototype.getTilePixelRatio.call(this, opt_pixelRatio) :
opt_pixelRatio;
}; };
-6
View File
@@ -317,7 +317,6 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
var lineJoin = ''; var lineJoin = '';
var miterLimit = 0; var miterLimit = 0;
var lineDash = null; var lineDash = null;
var lineDashOffset = 0;
var strokeStyle; var strokeStyle;
var strokeWidth = 0; var strokeWidth = 0;
@@ -332,10 +331,8 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
strokeWidth = ol.render.canvas.defaultLineWidth; strokeWidth = ol.render.canvas.defaultLineWidth;
} }
lineDash = this.stroke_.getLineDash(); lineDash = this.stroke_.getLineDash();
lineDashOffset = this.stroke_.getLineDashOffset();
if (!ol.has.CANVAS_LINE_DASH) { if (!ol.has.CANVAS_LINE_DASH) {
lineDash = null; lineDash = null;
lineDashOffset = 0;
} }
lineJoin = this.stroke_.getLineJoin(); lineJoin = this.stroke_.getLineJoin();
if (lineJoin === undefined) { if (lineJoin === undefined) {
@@ -360,7 +357,6 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
size: size, size: size,
lineCap: lineCap, lineCap: lineCap,
lineDash: lineDash, lineDash: lineDash,
lineDashOffset: lineDashOffset,
lineJoin: lineJoin, lineJoin: lineJoin,
miterLimit: miterLimit miterLimit: miterLimit
}; };
@@ -464,7 +460,6 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
context.lineWidth = renderOptions.strokeWidth; context.lineWidth = renderOptions.strokeWidth;
if (renderOptions.lineDash) { if (renderOptions.lineDash) {
context.setLineDash(renderOptions.lineDash); context.setLineDash(renderOptions.lineDash);
context.lineDashOffset = renderOptions.lineDashOffset;
} }
context.lineCap = renderOptions.lineCap; context.lineCap = renderOptions.lineCap;
context.lineJoin = renderOptions.lineJoin; context.lineJoin = renderOptions.lineJoin;
@@ -538,7 +533,6 @@ ol.style.RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions
context.lineWidth = renderOptions.strokeWidth; context.lineWidth = renderOptions.strokeWidth;
if (renderOptions.lineDash) { if (renderOptions.lineDash) {
context.setLineDash(renderOptions.lineDash); context.setLineDash(renderOptions.lineDash);
context.lineDashOffset = renderOptions.lineDashOffset;
} }
context.stroke(); context.stroke();
} }
-28
View File
@@ -50,12 +50,6 @@ ol.style.Style = function(opt_options) {
*/ */
this.image_ = options.image !== undefined ? options.image : null; this.image_ = options.image !== undefined ? options.image : null;
/**
* @private
* @type {ol.StyleRenderFunction|null}
*/
this.renderer_ = options.renderer !== undefined ? options.renderer : null;
/** /**
* @private * @private
* @type {ol.style.Stroke} * @type {ol.style.Stroke}
@@ -98,28 +92,6 @@ ol.style.Style.prototype.clone = function() {
}; };
/**
* Get the custom renderer function that was configured with
* {@link #setRenderer} or the `renderer` constructor option.
* @return {ol.StyleRenderFunction|null} Custom renderer function.
* @api
*/
ol.style.Style.prototype.getRenderer = function() {
return this.renderer_;
};
/**
* Sets a custom renderer function for this style. When set, `fill`, `stroke`
* and `image` options of the style will be ignored.
* @param {ol.StyleRenderFunction|null} renderer Custom renderer function.
* @api
*/
ol.style.Style.prototype.setRenderer = function(renderer) {
this.renderer_ = renderer;
};
/** /**
* Get the geometry to be rendered. * Get the geometry to be rendered.
* @return {string|ol.geom.Geometry|ol.StyleGeometryFunction} * @return {string|ol.geom.Geometry|ol.StyleGeometryFunction}
-12
View File
@@ -79,7 +79,6 @@ ol.CanvasFunctionType;
/** /**
* @typedef {{lineCap: string, * @typedef {{lineCap: string,
* lineDash: Array.<number>, * lineDash: Array.<number>,
* lineDashOffset: number,
* lineJoin: string, * lineJoin: string,
* lineWidth: number, * lineWidth: number,
* miterLimit: number, * miterLimit: number,
@@ -626,17 +625,6 @@ ol.StyleFunction;
ol.StyleGeometryFunction; ol.StyleGeometryFunction;
/**
* Custom renderer function. Takes two arguments:
*
* 1. The pixel coordinates of the geometry in GeoJSON notation.
* 2. The {@link olx.render.State} of the layer renderer.
*
* @typedef {function((ol.Coordinate|Array<ol.Coordinate>|Array.<Array.<ol.Coordinate>>),olx.render.State)}
*/
ol.StyleRenderFunction;
/** /**
* @typedef {{opacity: number, * @typedef {{opacity: number,
* rotateWithView: boolean, * rotateWithView: boolean,
+1 -1
View File
@@ -276,7 +276,7 @@ ol.VectorImageTile.prototype.finishLoading_ = function() {
*/ */
ol.VectorImageTile.defaultLoadFunction = function(tile, url) { ol.VectorImageTile.defaultLoadFunction = function(tile, url) {
var loader = ol.featureloader.loadFeaturesXhr( var loader = ol.featureloader.loadFeaturesXhr(
url, tile.getFormat(), tile.onLoad.bind(tile), tile.onError.bind(tile)); url, tile.getFormat(), tile.onLoad_.bind(tile), tile.onError_.bind(tile));
tile.setLoader(loader); tile.setLoader(loader);
}; };
+5 -51
View File
@@ -23,12 +23,6 @@ ol.VectorTile = function(tileCoord, state, src, format, tileLoadFunction) {
*/ */
this.consumers = 0; this.consumers = 0;
/**
* @private
* @type {ol.Extent}
*/
this.extent_ = null;
/** /**
* @private * @private
* @type {ol.format.Feature} * @type {ol.format.Feature}
@@ -88,15 +82,6 @@ ol.VectorTile.prototype.disposeInternal = function() {
}; };
/**
* Gets the extent of the vector tile.
* @return {ol.Extent} The extent.
*/
ol.VectorTile.prototype.getExtent = function() {
return this.extent_ || ol.VectorTile.DEFAULT_EXTENT;
};
/** /**
* Get the feature format assigned for reading this tile's features. * Get the feature format assigned for reading this tile's features.
* @return {ol.format.Feature} Feature format. * @return {ol.format.Feature} Feature format.
@@ -109,7 +94,7 @@ ol.VectorTile.prototype.getFormat = function() {
/** /**
* Get the features for this tile. Geometries will be in the projection returned * Get the features for this tile. Geometries will be in the projection returned
* by {@link ol.VectorTile#getProjection}. * by {@link #getProjection}.
* @return {Array.<ol.Feature|ol.render.Feature>} Features. * @return {Array.<ol.Feature|ol.render.Feature>} Features.
* @api * @api
*/ */
@@ -127,8 +112,7 @@ ol.VectorTile.prototype.getKey = function() {
/** /**
* Get the feature projection of features returned by * Get the feature projection of features returned by {@link #getFeatures}.
* {@link ol.VectorTile#getFeatures}.
* @return {ol.proj.Projection} Feature projection. * @return {ol.proj.Projection} Feature projection.
* @api * @api
*/ */
@@ -163,43 +147,22 @@ ol.VectorTile.prototype.load = function() {
* Handler for successful tile load. * Handler for successful tile load.
* @param {Array.<ol.Feature>} features The loaded features. * @param {Array.<ol.Feature>} features The loaded features.
* @param {ol.proj.Projection} dataProjection Data projection. * @param {ol.proj.Projection} dataProjection Data projection.
* @param {ol.Extent} extent Extent.
*/ */
ol.VectorTile.prototype.onLoad = function(features, dataProjection, extent) { ol.VectorTile.prototype.onLoad_ = function(features, dataProjection) {
this.setProjection(dataProjection); this.setProjection(dataProjection);
this.setFeatures(features); this.setFeatures(features);
this.setExtent(extent);
}; };
/** /**
* Handler for tile load errors. * Handler for tile load errors.
*/ */
ol.VectorTile.prototype.onError = function() { ol.VectorTile.prototype.onError_ = function() {
this.setState(ol.TileState.ERROR); this.setState(ol.TileState.ERROR);
}; };
/** /**
* Function for use in an {@link ol.source.VectorTile}'s `tileLoadFunction`.
* Sets the extent of the vector tile. This is only required for tiles in
* projections with `tile-pixels` as units. The extent should be set to
* `[0, 0, tilePixelSize, tilePixelSize]`, where `tilePixelSize` is calculated
* by multiplying the tile size with the tile pixel ratio. For sources using
* {@link ol.format.MVT} as feature format, the
* {@link ol.format.MVT#getLastExtent} method will return the correct extent.
* The default is `[0, 0, 4096, 4096]`.
* @param {ol.Extent} extent The extent.
* @api
*/
ol.VectorTile.prototype.setExtent = function(extent) {
this.extent_ = extent;
};
/**
* Function for use in an {@link ol.source.VectorTile}'s `tileLoadFunction`.
* Sets the features for the tile.
* @param {Array.<ol.Feature>} features Features. * @param {Array.<ol.Feature>} features Features.
* @api * @api
*/ */
@@ -210,9 +173,7 @@ ol.VectorTile.prototype.setFeatures = function(features) {
/** /**
* Function for use in an {@link ol.source.VectorTile}'s `tileLoadFunction`. * Set the projection of the features that were added with {@link #setFeatures}.
* Sets the projection of the features that were added with
* {@link ol.VectorTile#setFeatures}.
* @param {ol.proj.Projection} projection Feature projection. * @param {ol.proj.Projection} projection Feature projection.
* @api * @api
*/ */
@@ -239,10 +200,3 @@ ol.VectorTile.prototype.setReplayGroup = function(layer, key, replayGroup) {
ol.VectorTile.prototype.setLoader = function(loader) { ol.VectorTile.prototype.setLoader = function(loader) {
this.loader_ = loader; this.loader_ = loader;
}; };
/**
* @const
* @type {ol.Extent}
*/
ol.VectorTile.DEFAULT_EXTENT = [0, 0, 4096, 4096];
+1 -1
View File
@@ -10,7 +10,7 @@ var markupRegEx = /([^\/^\.]*)\.html$/;
var cleanupJSRegEx = /.*(\/\/ NOCOMPILE|goog\.require\(.*\);)[\r\n]*/g; var cleanupJSRegEx = /.*(\/\/ NOCOMPILE|goog\.require\(.*\);)[\r\n]*/g;
var requiresRegEx = /.*goog\.require\('(ol\.\S*)'\);/g; var requiresRegEx = /.*goog\.require\('(ol\.\S*)'\);/g;
var isCssRegEx = /\.css$/; var isCssRegEx = /\.css$/;
var isJsRegEx = /\.js(\?.*)?$/; var isJsRegEx = /\.js$/;
var srcDir = path.join(__dirname, '..', 'examples'); var srcDir = path.join(__dirname, '..', 'examples');
var destDir = path.join(__dirname, '..', 'build', 'examples'); var destDir = path.join(__dirname, '..', 'build', 'examples');
+1 -1
View File
@@ -98,7 +98,7 @@ main() {
npm install npm install
build_js ${PROFILES} build_js ${PROFILES}
build_css build_css
npm publish npm publish --tag beta
} }
if test ${#} -ne 1; then if test ${#} -ne 1; then
-38
View File
@@ -262,44 +262,6 @@ describe('ol.control.ScaleLine', function() {
}); });
}); });
describe('latitude may affect scale line in EPSG:4326', function() {
it('is rendered differently at different latitudes for metric', function() {
var ctrl = new ol.control.ScaleLine();
ctrl.setMap(map);
map.setView(new ol.View({
center: ol.proj.fromLonLat([7, 0]),
zoom: 2,
projection: 'EPSG:4326'
}));
map.renderSync();
var innerHtml0 = ctrl.element_.innerHTML;
map.getView().setCenter([7, 52]);
map.renderSync();
var innerHtml52 = ctrl.element_.innerHTML;
expect(innerHtml0).to.not.be(innerHtml52);
});
it('is rendered the same at different latitudes for degrees', function() {
var ctrl = new ol.control.ScaleLine({
units: 'degrees'
});
ctrl.setMap(map);
map.setView(new ol.View({
center: ol.proj.fromLonLat([7, 0]),
zoom: 2,
projection: 'EPSG:4326'
}));
map.renderSync();
var innerHtml0 = ctrl.element_.innerHTML;
map.getView().setCenter([7, 52]);
map.renderSync();
var innerHtml52 = ctrl.element_.innerHTML;
expect(innerHtml0).to.be(innerHtml52);
});
});
describe('zoom affects the scaleline', function() { describe('zoom affects the scaleline', function() {
var currentZoom; var currentZoom;
var ctrl; var ctrl;
-7
View File
@@ -88,13 +88,6 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
expect(features[0].getId()).to.be(2); expect(features[0].getId()).to.be(2);
}); });
it('sets the extent of the last readFeatures call', function() {
var format = new ol.format.MVT();
format.readFeatures(data);
var extent = format.getLastExtent();
expect(extent.getWidth()).to.be(4096);
});
}); });
}); });
-13
View File
@@ -72,19 +72,6 @@ describe('ol.interaction.Extent', function() {
event.pointerEvent.pointerId = 1; event.pointerEvent.pointerId = 1;
map.handleMapBrowserEvent(event); map.handleMapBrowserEvent(event);
} }
describe('Constructor', function() {
it('can be configured with an extent', function() {
expect(function() {
new ol.interaction.Extent({
extent: [-10, -10, 10, 10]
});
}).to.not.throwException();
});
});
describe('snap to vertex', function() { describe('snap to vertex', function() {
it('snap to vertex works', function() { it('snap to vertex works', function() {
interaction.setExtent([-50, -50, 50, 50]); interaction.setExtent([-50, -50, 50, 50]);
+90 -101
View File
@@ -74,20 +74,19 @@ describe('ol.interaction.Modify', function() {
* @param {string} type Event type. * @param {string} type Event type.
* @param {number} x Horizontal offset from map center. * @param {number} x Horizontal offset from map center.
* @param {number} y Vertical offset from map center. * @param {number} y Vertical offset from map center.
* @param {Object} modifiers Lookup of modifier keys. * @param {boolean=} opt_shiftKey Shift key is pressed.
* @param {number} button The mouse button. * @param {number} button The mouse button.
*/ */
function simulateEvent(type, x, y, modifiers, button) { function simulateEvent(type, x, y, opt_shiftKey, button) {
modifiers = modifiers || {};
var viewport = map.getViewport(); var viewport = map.getViewport();
// calculated in case body has top < 0 (test runner with small window) // calculated in case body has top < 0 (test runner with small window)
var position = viewport.getBoundingClientRect(); var position = viewport.getBoundingClientRect();
var shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
var pointerEvent = new ol.pointer.PointerEvent(type, { var pointerEvent = new ol.pointer.PointerEvent(type, {
type: type, type: type,
clientX: position.left + x + width / 2, clientX: position.left + x + width / 2,
clientY: position.top + y + height / 2, clientY: position.top + y + height / 2,
shiftKey: modifiers.shift || false, shiftKey: shiftKey
altKey: modifiers.alt || false
}, { }, {
button: button, button: button,
isPrimary: true isPrimary: true
@@ -178,16 +177,6 @@ describe('ol.interaction.Modify', function() {
expect(rbushEntries[0].feature).to.be(feature); expect(rbushEntries[0].feature).to.be(feature);
}); });
it('accepts a source', function() {
var feature = new ol.Feature(
new ol.geom.Point([0, 0]));
var source = new ol.source.Vector({features: [feature]});
var modify = new ol.interaction.Modify({source: source});
var rbushEntries = modify.rBush_.getAll();
expect(rbushEntries.length).to.be(1);
expect(rbushEntries[0].feature).to.be(feature);
});
}); });
describe('vertex deletion', function() { describe('vertex deletion', function() {
@@ -212,10 +201,10 @@ describe('ol.interaction.Modify', function() {
expect(second.getGeometry().getRevision()).to.equal(secondRevision); expect(second.getGeometry().getRevision()).to.equal(secondRevision);
expect(second.getGeometry().getCoordinates()[0]).to.have.length(5); expect(second.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointerdown', 10, -20, {alt: true}, 0); simulateEvent('pointerdown', 10, -20, false, 0);
simulateEvent('pointerup', 10, -20, {alt: true}, 0); simulateEvent('pointerup', 10, -20, false, 0);
simulateEvent('click', 10, -20, {alt: true}, 0); simulateEvent('click', 10, -20, false, 0);
simulateEvent('singleclick', 10, -20, {alt: true}, 0); simulateEvent('singleclick', 10, -20, false, 0);
expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1); expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1);
expect(first.getGeometry().getCoordinates()[0]).to.have.length(4); expect(first.getGeometry().getCoordinates()[0]).to.have.length(4);
@@ -248,10 +237,10 @@ describe('ol.interaction.Modify', function() {
expect(first.getGeometry().getRevision()).to.equal(firstRevision); expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()).to.have.length(5); expect(first.getGeometry().getCoordinates()).to.have.length(5);
simulateEvent('pointerdown', 0, 0, {alt: true}, 0); simulateEvent('pointerdown', 0, 0, false, 0);
simulateEvent('pointerup', 0, 0, {alt: true}, 0); simulateEvent('pointerup', 0, 0, false, 0);
simulateEvent('click', 0, 0, {alt: true}, 0); simulateEvent('click', 0, 0, false, 0);
simulateEvent('singleclick', 0, 0, {alt: true}, 0); simulateEvent('singleclick', 0, 0, false, 0);
expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1); expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1);
expect(first.getGeometry().getCoordinates()).to.have.length(4); expect(first.getGeometry().getCoordinates()).to.have.length(4);
@@ -284,10 +273,10 @@ describe('ol.interaction.Modify', function() {
expect(first.getGeometry().getRevision()).to.equal(firstRevision); expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()).to.have.length(5); expect(first.getGeometry().getCoordinates()).to.have.length(5);
simulateEvent('pointerdown', 40, 0, {alt: true}, 0); simulateEvent('pointerdown', 40, 0, false, 0);
simulateEvent('pointerup', 40, 0, {alt: true}, 0); simulateEvent('pointerup', 40, 0, false, 0);
simulateEvent('click', 40, 0, {alt: true}, 0); simulateEvent('click', 40, 0, false, 0);
simulateEvent('singleclick', 40, 0, {alt: true}, 0); simulateEvent('singleclick', 40, 0, false, 0);
expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1); expect(first.getGeometry().getRevision()).to.equal(firstRevision + 1);
expect(first.getGeometry().getCoordinates()).to.have.length(4); expect(first.getGeometry().getCoordinates()).to.have.length(4);
@@ -320,8 +309,8 @@ describe('ol.interaction.Modify', function() {
expect(first.getGeometry().getRevision()).to.equal(firstRevision); expect(first.getGeometry().getRevision()).to.equal(firstRevision);
expect(first.getGeometry().getCoordinates()).to.have.length(5); expect(first.getGeometry().getCoordinates()).to.have.length(5);
simulateEvent('pointerdown', 40, 0, null, 0); simulateEvent('pointerdown', 40, 0, false, 0);
simulateEvent('pointerup', 40, 0, null, 0); simulateEvent('pointerup', 40, 0, false, 0);
var removed = modify.removePoint(); var removed = modify.removePoint();
@@ -354,25 +343,25 @@ describe('ol.interaction.Modify', function() {
map.addInteraction(modify); map.addInteraction(modify);
// Move first vertex // Move first vertex
simulateEvent('pointermove', 0, 0, null, 0); simulateEvent('pointermove', 0, 0, false, 0);
simulateEvent('pointerdown', 0, 0, null, 0); simulateEvent('pointerdown', 0, 0, false, 0);
simulateEvent('pointermove', -10, -10, null, 0); simulateEvent('pointermove', -10, -10, false, 0);
simulateEvent('pointerdrag', -10, -10, null, 0); simulateEvent('pointerdrag', -10, -10, false, 0);
simulateEvent('pointerup', -10, -10, null, 0); simulateEvent('pointerup', -10, -10, false, 0);
// Move middle vertex // Move middle vertex
simulateEvent('pointermove', 0, -40, null, 0); simulateEvent('pointermove', 0, -40, false, 0);
simulateEvent('pointerdown', 0, -40, null, 0); simulateEvent('pointerdown', 0, -40, false, 0);
simulateEvent('pointermove', 10, -30, null, 0); simulateEvent('pointermove', 10, -30, false, 0);
simulateEvent('pointerdrag', 10, -30, null, 0); simulateEvent('pointerdrag', 10, -30, false, 0);
simulateEvent('pointerup', 10, -30, null, 0); simulateEvent('pointerup', 10, -30, false, 0);
// Move last vertex // Move last vertex
simulateEvent('pointermove', 40, 0, null, 0); simulateEvent('pointermove', 40, 0, false, 0);
simulateEvent('pointerdown', 40, 0, null, 0); simulateEvent('pointerdown', 40, 0, false, 0);
simulateEvent('pointermove', 50, -10, null, 0); simulateEvent('pointermove', 50, -10, false, 0);
simulateEvent('pointerdrag', 50, -10, null, 0); simulateEvent('pointerdrag', 50, -10, false, 0);
simulateEvent('pointerup', 50, -10, null, 0); simulateEvent('pointerup', 50, -10, false, 0);
expect(lineFeature.getGeometry().getCoordinates()[0][2]).to.equal(10); expect(lineFeature.getGeometry().getCoordinates()[0][2]).to.equal(10);
expect(lineFeature.getGeometry().getCoordinates()[2][2]).to.equal(30); expect(lineFeature.getGeometry().getCoordinates()[2][2]).to.equal(30);
@@ -393,21 +382,21 @@ describe('ol.interaction.Modify', function() {
map.addInteraction(modify); map.addInteraction(modify);
// Change center // Change center
simulateEvent('pointermove', 10, -10, null, 0); simulateEvent('pointermove', 10, -10, false, 0);
simulateEvent('pointerdown', 10, -10, null, 0); simulateEvent('pointerdown', 10, -10, false, 0);
simulateEvent('pointermove', 5, -5, null, 0); simulateEvent('pointermove', 5, -5, false, 0);
simulateEvent('pointerdrag', 5, -5, null, 0); simulateEvent('pointerdrag', 5, -5, false, 0);
simulateEvent('pointerup', 5, -5, null, 0); simulateEvent('pointerup', 5, -5, false, 0);
expect(circleFeature.getGeometry().getRadius()).to.equal(20); expect(circleFeature.getGeometry().getRadius()).to.equal(20);
expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]); expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]);
// Increase radius // Increase radius
simulateEvent('pointermove', 25, -4, null, 0); simulateEvent('pointermove', 25, -4, false, 0);
simulateEvent('pointerdown', 25, -4, null, 0); simulateEvent('pointerdown', 25, -4, false, 0);
simulateEvent('pointermove', 30, -5, null, 0); simulateEvent('pointermove', 30, -5, false, 0);
simulateEvent('pointerdrag', 30, -5, null, 0); simulateEvent('pointerdrag', 30, -5, false, 0);
simulateEvent('pointerup', 30, -5, null, 0); simulateEvent('pointerup', 30, -5, false, 0);
expect(circleFeature.getGeometry().getRadius()).to.equal(25); expect(circleFeature.getGeometry().getRadius()).to.equal(25);
expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]); expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]);
@@ -432,10 +421,10 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointerdown', 10, -20, {alt: true}, 0); simulateEvent('pointerdown', 10, -20, false, 0);
simulateEvent('pointerup', 10, -20, {alt: true}, 0); simulateEvent('pointerup', 10, -20, false, 0);
simulateEvent('click', 10, -20, {alt: true}, 0); simulateEvent('click', 10, -20, false, 0);
simulateEvent('singleclick', 10, -20, {alt: true}, 0); simulateEvent('singleclick', 10, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(2); expect(feature.getGeometry().getRevision()).to.equal(2);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(4); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(4);
@@ -447,10 +436,10 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointerdown', 40, -20, null, 0); simulateEvent('pointerdown', 40, -20, false, 0);
simulateEvent('pointerup', 40, -20, null, 0); simulateEvent('pointerup', 40, -20, false, 0);
simulateEvent('click', 40, -20, null, 0); simulateEvent('click', 40, -20, false, 0);
simulateEvent('singleclick', 40, -20, null, 0); simulateEvent('singleclick', 40, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(2); expect(feature.getGeometry().getRevision()).to.equal(2);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6);
@@ -462,10 +451,10 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointerdown', 40, -20, null, 0); simulateEvent('pointerdown', 40, -20, false, 0);
simulateEvent('pointerup', 40, -20, null, 0); simulateEvent('pointerup', 40, -20, false, 0);
simulateEvent('click', 40, -20, null, 0); simulateEvent('click', 40, -20, false, 0);
simulateEvent('singleclick', 40, -20, null, 0); simulateEvent('singleclick', 40, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(2); expect(feature.getGeometry().getRevision()).to.equal(2);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6);
@@ -473,10 +462,10 @@ describe('ol.interaction.Modify', function() {
validateEvents(events, [feature]); validateEvents(events, [feature]);
events.length = 0; events.length = 0;
simulateEvent('pointerdown', 40, -20, {alt: true}, 0); simulateEvent('pointerdown', 40, -20, false, 0);
simulateEvent('pointerup', 40, -20, {alt: true}, 0); simulateEvent('pointerup', 40, -20, false, 0);
simulateEvent('click', 40, -20, {alt: true}, 0); simulateEvent('click', 40, -20, false, 0);
simulateEvent('singleclick', 40, -20, {alt: true}, 0); simulateEvent('singleclick', 40, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(3); expect(feature.getGeometry().getRevision()).to.equal(3);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
@@ -488,11 +477,11 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointermove', 40, -20, null, 0); simulateEvent('pointermove', 40, -20, false, 0);
simulateEvent('pointerdown', 40, -20, null, 0); simulateEvent('pointerdown', 40, -20, false, 0);
simulateEvent('pointermove', 30, -20, null, 0); simulateEvent('pointermove', 30, -20, false, 0);
simulateEvent('pointerdrag', 30, -20, null, 0); simulateEvent('pointerdrag', 30, -20, false, 0);
simulateEvent('pointerup', 30, -20, null, 0); simulateEvent('pointerup', 30, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(4); expect(feature.getGeometry().getRevision()).to.equal(4);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6);
@@ -504,12 +493,12 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointermove', 40, -20, null, 0); simulateEvent('pointermove', 40, -20, false, 0);
// right click // right click
simulateEvent('pointerdown', 40, -20, null, 1); simulateEvent('pointerdown', 40, -20, false, 1);
simulateEvent('pointermove', 30, -20, null, 1); simulateEvent('pointermove', 30, -20, false, 1);
simulateEvent('pointerdrag', 30, -20, null, 1); simulateEvent('pointerdrag', 30, -20, false, 1);
simulateEvent('pointerup', 30, -20, null, 1); simulateEvent('pointerup', 30, -20, false, 1);
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
@@ -539,13 +528,13 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointerdown', 10, -20, null, 0); simulateEvent('pointerdown', 10, -20, false, 0);
simulateEvent('pointerup', 10, -20, null, 0); simulateEvent('pointerup', 10, -20, false, 0);
simulateEvent('click', 10, -20, null, 0); simulateEvent('click', 10, -20, false, 0);
simulateEvent('pointerdown', 10, -20, null, 0); simulateEvent('pointerdown', 10, -20, false, 0);
simulateEvent('pointerup', 10, -20, null, 0); simulateEvent('pointerup', 10, -20, false, 0);
simulateEvent('click', 10, -20, null, 0); simulateEvent('click', 10, -20, false, 0);
simulateEvent('dblclick', 10, -20, null, 0); simulateEvent('dblclick', 10, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(2); expect(feature.getGeometry().getRevision()).to.equal(2);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(4); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(4);
@@ -558,10 +547,10 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
simulateEvent('pointerdown', 10, -20, null, 0); simulateEvent('pointerdown', 10, -20, false, 0);
simulateEvent('pointerup', 10, -20, null, 0); simulateEvent('pointerup', 10, -20, false, 0);
simulateEvent('click', 10, -20, null, 0); simulateEvent('click', 10, -20, false, 0);
simulateEvent('singleclick', 10, -20, null, 0); simulateEvent('singleclick', 10, -20, false, 0);
expect(feature.getGeometry().getRevision()).to.equal(1); expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
@@ -584,20 +573,20 @@ describe('ol.interaction.Modify', function() {
var feature = features[0]; var feature = features[0];
// move first vertex // move first vertex
simulateEvent('pointermove', 0, 0, null, 0); simulateEvent('pointermove', 0, 0, false, 0);
simulateEvent('pointerdown', 0, 0, null, 0); simulateEvent('pointerdown', 0, 0, false, 0);
simulateEvent('pointermove', -10, -10, null, 0); simulateEvent('pointermove', -10, -10, false, 0);
simulateEvent('pointerdrag', -10, -10, null, 0); simulateEvent('pointerdrag', -10, -10, false, 0);
simulateEvent('pointerup', -10, -10, null, 0); simulateEvent('pointerup', -10, -10, false, 0);
expect(listenerSpy.callCount).to.be(0); expect(listenerSpy.callCount).to.be(0);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
// try to add vertex // try to add vertex
simulateEvent('pointerdown', 40, -20, null, 0); simulateEvent('pointerdown', 40, -20, false, 0);
simulateEvent('pointerup', 40, -20, null, 0); simulateEvent('pointerup', 40, -20, false, 0);
simulateEvent('click', 40, -20, null, 0); simulateEvent('click', 40, -20, false, 0);
simulateEvent('singleclick', 40, -20, null, 0); simulateEvent('singleclick', 40, -20, false, 0);
expect(listenerSpy.callCount).to.be(1); expect(listenerSpy.callCount).to.be(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5); expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
@@ -704,7 +693,7 @@ describe('ol.interaction.Modify', function() {
map.addInteraction(modify); map.addInteraction(modify);
expect(modify.vertexFeature_).to.be(null); expect(modify.vertexFeature_).to.be(null);
simulateEvent('pointermove', 10, -20, null, 0); simulateEvent('pointermove', 10, -20, false, 0);
expect(modify.vertexFeature_).to.not.be(null); expect(modify.vertexFeature_).to.not.be(null);
modify.setActive(false); modify.setActive(false);
-51
View File
@@ -183,57 +183,6 @@ describe('ol.Map', function() {
}); });
describe('#getFeaturesAtPixel', function() {
var target, map;
beforeEach(function() {
target = document.createElement('div');
target.style.width = target.style.height = '100px';
document.body.appendChild(target);
map = new ol.Map({
target: target,
layers: [new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature(new ol.geom.Point([0, 0]))]
})
})],
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
map.renderSync();
});
afterEach(function() {
document.body.removeChild(target);
});
it('returns null if no feature was found', function() {
var features = map.getFeaturesAtPixel([0, 0]);
expect(features).to.be(null);
});
it('returns an array of found features', function() {
var features = map.getFeaturesAtPixel([50, 50]);
expect(features).to.be.an(Array);
expect(features[0]).to.be.an(ol.Feature);
});
it('respects options', function() {
var otherLayer = new ol.layer.Vector({
source: new ol.source.Vector
});
map.addLayer(otherLayer);
var features = map.getFeaturesAtPixel([50, 50], {
layerFilter: function(layer) {
return layer == otherLayer;
}
});
expect(features).to.be(null);
});
});
describe('#forEachLayerAtPixel()', function() { describe('#forEachLayerAtPixel()', function() {
var target, map, original, log; var target, map, original, log;
-27
View File
@@ -212,33 +212,6 @@ describe('ol.proj', function() {
}); });
describe('getPointResolution()', function() {
it('returns the correct point resolution for EPSG:4326', function() {
var pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 0]);
expect (pointResolution).to.be(1);
pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 52]);
expect (pointResolution).to.be(1);
});
it('returns the correct point resolution for EPSG:4326 with custom units', function() {
var pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 0], 'm');
expect (pointResolution).to.roughlyEqual(111194.874284, 1e-5);
pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, [0, 52], 'm');
expect (pointResolution).to.roughlyEqual(89826.367538, 1e-5);
});
it('returns the correct point resolution for EPSG:3857', function() {
var pointResolution = ol.proj.getPointResolution('EPSG:3857', 1, [0, 0]);
expect (pointResolution).to.be(1);
pointResolution = ol.proj.getPointResolution('EPSG:3857', 1, ol.proj.fromLonLat([0, 52]));
expect (pointResolution).to.roughlyEqual(0.615661, 1e-5);
});
it('returns the correct point resolution for EPSG:3857 with custom units', function() {
var pointResolution = ol.proj.getPointResolution('EPSG:3857', 1, [0, 0], 'degrees');
expect (pointResolution).to.be(1);
pointResolution = ol.proj.getPointResolution('EPSG:4326', 1, ol.proj.fromLonLat([0, 52]), 'degrees');
expect (pointResolution).to.be(1);
});
});
describe('Proj4js integration', function() { describe('Proj4js integration', function() {
var proj4 = window.proj4; var proj4 = window.proj4;
@@ -205,67 +205,6 @@ describe('ol.render.canvas.ReplayGroup', function() {
expect(style2.getStroke().getLineDashOffset()).to.be(2); expect(style2.getStroke().getLineDashOffset()).to.be(2);
expect(lineDashOffset).to.be(4); expect(lineDashOffset).to.be(4);
}); });
it('calls the renderer function configured for the style', function() {
var calls = [];
var style = new ol.style.Style({
renderer: function(coords, state) {
calls.push({
coords: coords,
geometry: state.geometry,
feature: state.feature,
context: state.context,
pixelRatio: state.pixelRatio,
rotation: state.rotation,
resolution: state.resolution
});
}
});
var point = new ol.Feature(new ol.geom.Point([45, 90]));
var multipoint = new ol.Feature(new ol.geom.MultiPoint(
[[45, 90], [90, 45]]));
var linestring = new ol.Feature(new ol.geom.LineString(
[[45, 90], [45, 45], [90, 45]]));
var multilinestring = new ol.Feature(new ol.geom.MultiLineString(
[linestring.getGeometry().getCoordinates(), linestring.getGeometry().getCoordinates()]));
var polygon = feature1;
var multipolygon = new ol.Feature(new ol.geom.MultiPolygon(
[polygon.getGeometry().getCoordinates(), polygon.getGeometry().getCoordinates()]));
var geometrycollection = new ol.Feature(new ol.geom.GeometryCollection(
[point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()]));
replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, true);
ol.renderer.vector.renderFeature(replay, point, style, 1);
ol.renderer.vector.renderFeature(replay, multipoint, style, 1);
ol.renderer.vector.renderFeature(replay, linestring, style, 1);
ol.renderer.vector.renderFeature(replay, multilinestring, style, 1);
ol.renderer.vector.renderFeature(replay, polygon, style, 1);
ol.renderer.vector.renderFeature(replay, multipolygon, style, 1);
ol.renderer.vector.renderFeature(replay, geometrycollection, style, 1);
ol.transform.scale(transform, 0.1, 0.1);
replay.replay(context, 1, transform, 0, {});
expect(calls.length).to.be(9);
expect(calls[0].geometry).to.be(point.getGeometry());
expect(calls[0].feature).to.be(point);
expect(calls[0].context).to.be(context);
expect(calls[0].pixelRatio).to.be(1);
expect(calls[0].rotation).to.be(0);
expect(calls[0].resolution).to.be(1);
expect(calls[0].coords).to.eql([4.5, 9]);
expect(calls[1].feature).to.be(multipoint);
expect(calls[1].coords[0]).to.eql([4.5, 9]);
expect(calls[2].feature).to.be(linestring);
expect(calls[2].coords[0]).to.eql([4.5, 9]);
expect(calls[3].feature).to.be(multilinestring);
expect(calls[3].coords[0][0]).to.eql([4.5, 9]);
expect(calls[4].feature).to.be(polygon);
expect(calls[4].coords[0][0]).to.eql([-9, -4.5]);
expect(calls[5].feature).to.be(multipolygon);
expect(calls[5].coords[0][0][0]).to.eql([-9, -4.5]);
expect(calls[6].feature).to.be(geometrycollection);
expect(calls[6].geometry.getCoordinates()).to.eql([45, 90]);
expect(calls[7].geometry.getCoordinates()[0]).to.eql([45, 90]);
expect(calls[8].geometry.getCoordinates()[0][0]).to.eql([-90, -45]);
});
}); });
}); });
@@ -121,18 +121,6 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
spy2.restore(); spy2.restore();
}); });
it('renders replays with custom renderers as direct replays', function() {
layer.renderMode_ = 'image';
layer.setStyle(new ol.style.Style({
renderer: function() {}
}));
var spy = sinon.spy(ol.renderer.canvas.VectorTileLayer.prototype,
'getReplayTransform_');
map.renderSync();
expect(spy.callCount).to.be(1);
spy.restore();
});
it('gives precedence to feature styles over layer styles', function() { it('gives precedence to feature styles over layer styles', function() {
var spy = sinon.spy(map.getRenderer().getLayerRenderer(layer), var spy = sinon.spy(map.getRenderer().getLayerRenderer(layer),
'renderFeature'); 'renderFeature');
@@ -186,14 +174,6 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
spy2.restore(); spy2.restore();
}); });
it('uses the extent of the source tile', function() {
var renderer = map.getRenderer().getLayerRenderer(layer);
var tile = new ol.VectorTile([0, 0, 0], 2);
tile.setExtent([0, 0, 4096, 4096]);
var tilePixelRatio = renderer.getTilePixelRatio_(source, tile);
expect(tilePixelRatio).to.be(16);
});
}); });
describe('#prepareFrame', function() { describe('#prepareFrame', function() {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

-43
View File
@@ -135,49 +135,6 @@ describe('ol.render', function() {
}); });
it('supports lineDash styles', function(done) {
var vectorContext = ol.render.toContext(context, {size: [100, 100]});
var style = new ol.style.Style({
stroke: new ol.style.Stroke({
lineDash: [10, 5]
})
});
vectorContext.setStyle(style);
vectorContext.drawGeometry(new ol.geom.Polygon([
[[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]],
[[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]]
]));
resembleCanvas(context.canvas,
'spec/ol/expected/render-polygon-linedash.png', IMAGE_TOLERANCE, done);
});
it('supports lineDashOffset', function(done) {
var vectorContext = ol.render.toContext(context, {size: [100, 100]});
var style = new ol.style.Style({
stroke: new ol.style.Stroke({
lineDash: [10, 5],
lineDashOffset: 5
})
});
vectorContext.setStyle(style);
vectorContext.drawGeometry(new ol.geom.Polygon([
[[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]],
[[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]]
]));
resembleCanvas(context.canvas,
'spec/ol/expected/render-polygon-linedashoffset.png', IMAGE_TOLERANCE, done);
});
}); });
}); });
Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 B

@@ -119,23 +119,6 @@ describe('ol.rendering.style.RegularShape', function() {
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas.png', 9.4, done); expectResemble(map, 'spec/ol/style/expected/regularshape-canvas.png', 9.4, done);
}); });
it('supports lineDash', function(done) {
map = createMap('canvas');
createFeatures(new ol.style.Stroke({
lineDash: [10, 5]
}));
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas-linedash.png', 5, done);
});
it('supports lineDashOffset', function(done) {
map = createMap('canvas');
createFeatures(new ol.style.Stroke({
lineDash: [10, 5],
lineDashOffset: 5
}));
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas-linedashoffset.png', 5, done);
});
it('tests the WebGL renderer', function(done) { it('tests the WebGL renderer', function(done) {
assertWebGL(); assertWebGL();
map = createMap('webgl'); map = createMap('webgl');