Compare commits

...

70 Commits

Author SHA1 Message Date
Andreas Hocevar
13e072cb63 Merge pull request #1955 from ahocevar/canvas-no-taint
Test canvas size with an untainted canvas
2014-04-07 13:52:09 +02:00
ahocevar
d685c79e02 Use ol.dom.createCanvasContext2D and remove canvas variable 2014-04-07 13:25:49 +02:00
Andreas Hocevar
5e7790d89c Merge pull request #1956 from ahocevar/shrink-comment
Make comment about shrinking the canvas more descriptive
2014-04-06 23:55:31 +02:00
ahocevar
3848e7f823 Make comment about shrinking the canvas more descriptive 2014-04-06 23:54:59 +02:00
ahocevar
09021dffd4 Do not shrink test canvas 2014-04-06 14:29:32 +02:00
ahocevar
95795ea301 Test canvas size with an untainted canvas 2014-04-06 11:38:51 +02:00
Tim Schaub
732ec7c2db Merge pull request #1952 from tschaub/shortdesc
No markup in shortdesc.
2014-04-04 13:14:48 -06:00
Tim Schaub
966317489e Merge pull request #1951 from tschaub/gjslint
Externs lint.
2014-04-04 10:11:34 -06:00
Tim Schaub
6fc915ba7b Strip tags from shortdesc (et al.) when parsing
This strips markup from elements with id attributes that we care about: title, shortdesc, tags.  This will only work for people who use `npm install && npm start` to browse examples.  The other example parser doesn't strip this markup, so it should still not be used in these elements.
2014-04-04 10:07:25 -06:00
Tim Schaub
2a4300085e No markup in shortdesc
The example parser and index template don't handle markup in the shortdesc element.  Use the docs element instead.
2014-04-04 10:07:02 -06:00
Tim Schaub
fe60d07ef0 Externs lint 2014-04-04 09:28:36 -06:00
Tim Schaub
f410a38c53 Merge pull request #1949 from tschaub/layer-state
Give layer state a reference to the layer.
2014-04-04 08:59:14 -06:00
Tim Schaub
7826036307 Make getLayerStatesArray return an array of layer states 2014-04-04 07:39:54 -06:00
Tim Schaub
78324fb54b Remove layers array from frame state 2014-04-04 07:36:42 -06:00
Tim Schaub
aa3a20e911 Provide layer states array in frame state 2014-04-04 07:36:42 -06:00
Tim Schaub
9d5451b1d6 Provide a reference to the layer 2014-04-04 07:36:42 -06:00
Andreas Hocevar
6c84358619 Merge pull request #1914 from ahocevar/modify-event-propagation
Modify interaction breaks mouse wheel zoom
2014-04-04 14:18:31 +02:00
ahocevar
bf06129256 Initialize snappedToVertex_ 2014-04-04 14:11:02 +02:00
ahocevar
523b51d69a Add missing goog.requires; fix types and a typo 2014-04-04 14:05:19 +02:00
ahocevar
2cb045b0b3 Better documentation for the singleclick condition 2014-04-04 14:05:19 +02:00
ahocevar
f2acbd332c Use the pixelTolerance to determine whether to snap to a vertex 2014-04-04 14:05:19 +02:00
ahocevar
8fc9b23ab8 Do not return as handled unless a geometry was modified
With this change, it is more straightforward to determine
whether an event is considered as handled, which results in the
removal of the modifiable_ and lastVertexCoordinate_ states.
Instead, we only need to know whether we're on a real vertex or
a virtual one. For that a new snappedToVertex_ flag is
introduced.

To stop a click after vertex deletion from triggering a feature
selection, vertex deletion is now triggered by a configurable
event condition, which defaults to singleclick (same as in the
select interaction) with no modifier keys.
2014-04-04 14:05:18 +02:00
Éric Lemoine
266f573922 Merge pull request #1943 from elemoine/ht
Hit detection skips layers in invisible groups
2014-04-04 09:08:29 +02:00
Bart van den Eijnden
6a3d349409 Merge pull request #1863 from htulipe/ows-capabilities
Add basic reading support for OWS Capabilities documents.
2014-04-03 19:57:27 +02:00
Éric Lemoine
8b0ae9e4da Hit detection skips layers in invisible groups 2014-04-03 16:54:39 +02:00
Tom Payne
0de380c7d2 Merge pull request #1744 from twpayne/remote-vector
ol.source.RemoteVector
2014-04-03 16:12:16 +02:00
Tom Payne
c155b70281 Export ol.source.ServerVector#readFeatures 2014-04-03 15:57:44 +02:00
Andreas Hocevar
e49b395cc4 Merge pull request #1940 from ahocevar/select-setmap
Handle skipped features when setting the map
2014-04-03 15:31:40 +02:00
Tom Payne
3a462f7076 Add a polygon layer and tweak the style of the tile-vector example 2014-04-03 15:23:24 +02:00
Tom Payne
d3a13a254c Use TopoJSON in tile-vector example 2014-04-03 15:23:24 +02:00
Tom Payne
a68d9f2299 Use openstreetmap.us vector tiles in tile-vector example 2014-04-03 15:23:24 +02:00
Tom Payne
f13debbbc9 Load vector tiles for current resolution 2014-04-03 15:23:24 +02:00
Tom Payne
96b7700d63 Use forEachFeatureInExtentAtResolution in ol.source.ImageVector 2014-04-03 15:23:24 +02:00
Tom Payne
ed586bad39 Use forEachFeatureInExtentAtResolution in ol.renderer.canvas.VectorLayer 2014-04-03 15:23:24 +02:00
Tom Payne
3a8504b799 Add ol.source.Vector#forEachFeatureInExtentAtResolution 2014-04-03 15:12:23 +02:00
Frederic Junod
fe216e3da1 Better vector style in tile-vector example 2014-04-03 15:12:23 +02:00
Tom Payne
8986ea1ef9 Add tile-vector example 2014-04-03 15:12:23 +02:00
Tom Payne
683483f8a4 Add ol.source.TileVector 2014-04-03 15:12:22 +02:00
Tom Payne
4a484a7ad3 Separate out feature reading and feature adding 2014-04-03 15:12:22 +02:00
Tom Payne
a31ad69ec4 Make tile URL functions more general 2014-04-03 15:12:22 +02:00
Tim Schaub
86c5a582c7 Rename loadingStrategy to strategy 2014-04-03 15:12:22 +02:00
Tim Schaub
ce8d805201 Rename loadingFunction to loader 2014-04-03 15:12:22 +02:00
Tom Payne
db1a06ac31 Use a BBOX loading strategy by default 2014-04-03 15:12:22 +02:00
Tom Payne
9e75684823 Replace extentUrlFunction with generic loadingFunction 2014-04-03 15:12:22 +02:00
Tom Payne
b8869805a7 Rename ol.loading to ol.loadingstrategy 2014-04-03 15:12:22 +02:00
Tom Payne
de4a17b8e2 Rename ol.source.RemoteVector to ServerVector 2014-04-03 15:12:22 +02:00
Tom Payne
b24e122d4f Add projection argument when loading features 2014-04-03 15:12:22 +02:00
Tom Payne
cbbcab926e Export ol.format.OSMXML 2014-04-03 15:08:03 +02:00
Tom Payne
10bddeae59 Load features on demand in vector-osm example 2014-04-03 15:08:03 +02:00
Tom Payne
50c4961b9f Add ol.source.RemoteVector 2014-04-03 15:08:03 +02:00
Tom Payne
2842d1b254 Add ol.loading 2014-04-03 15:08:03 +02:00
Tom Payne
8c984cc8f7 Load features before rendering 2014-04-03 15:08:03 +02:00
Tom Payne
b008dd1805 Rename ol.source.FormatVector#loadFeatures to loadFeaturesFromURL 2014-04-03 15:05:55 +02:00
Tom Payne
073f83cd22 Factor out ol.source.FormatVector 2014-04-03 15:05:55 +02:00
Tom Payne
77933d0ab3 Rename ol.source.VectorFile to ol.source.StaticVector 2014-04-03 15:05:55 +02:00
ahocevar
8df95bc674 Handle skipped features when setting the map
When a Select interaction is removed from the map, it should
remove its selected features from the map's skippedFeatures
collection. When it is added to a map, it should add them.
2014-04-03 14:30:58 +02:00
Andreas Hocevar
e44e59311b Merge pull request #1896 from ahocevar/nodragclick
Add click event as responsive alternative to singleclick
2014-04-03 13:34:14 +02:00
Andreas Hocevar
7f2a628223 Merge pull request #1928 from ahocevar/recover-from-canvas-too-big
Recover from situations where the maximum canvas size is exceeded
2014-04-03 11:46:19 +02:00
ahocevar
ea58f38275 Make testCanvasSize a static function 2014-04-03 11:18:26 +02:00
ahocevar
54ba06ae3b Initialize canvasTooBig_ member 2014-04-03 11:18:12 +02:00
ahocevar
58b5fef3da Allow to make canvas smaller when it is too big
For performance reason, we only make the canvas bigger, but not
smaller. With this change, we also make it smaller, but only
when we know that its current size exceeds the maximum
dimensions.
2014-04-02 16:44:57 +02:00
ahocevar
4dce59fe95 Add method for testing whether the canvas size is valid
This is a way to detect whether a canvas exceeds the maximum
dimensions if these are limited on the target device. See
https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html
for limitations on iOS devices.
2014-04-02 16:44:39 +02:00
ahocevar
02907b26ed Continue using singleclick for getfeatureinfo 2014-03-27 18:34:47 +01:00
ahocevar
30fc1a29fb Add unit tests for click event 2014-03-27 18:33:17 +01:00
ahocevar
7bfa15c0fd Add click event as responsive alternative to singleclick
The singleclick event makes the application feel slow because
of the 250 ms delay that is used to rule out a dblclick.
2014-03-27 18:33:17 +01:00
Hadrien Tulipe
f325cc3d7a More syntax fix for OWS format 2014-03-17 21:15:03 +01:00
Hadrien Tulipe
58e74229d2 Rename ol.format.OWSCapabilities to ol.format.OWS 2014-03-17 21:10:47 +01:00
Hadrien Tulipe
149e5c9068 Fix syntax and private functions return values for OWS format 2014-03-17 21:03:41 +01:00
Hadrien Tulipe
00da1405b6 Remove commented code 2014-03-16 20:18:14 +01:00
Hadrien Tulipe
fe2bee1577 Add basic reading support for OWS Capabilities document. 2014-03-16 19:47:13 +01:00
75 changed files with 1875 additions and 2623 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@
<div class="span4">
<h4 id="title">Drag-and-Drop image vector example</h4>
<p id="shortdesc">Example of using the drag-and-drop interaction with a <code>ol.source.ImageVector</code>. Drag and drop GPX, GeoJSON, IGC, KML, or TopoJSON files on to the map. Each file is rendered to an image on the client.</p>
<p id="shortdesc">Example of using the drag-and-drop interaction with a ol.source.ImageVector. Drag and drop GPX, GeoJSON, IGC, KML, or TopoJSON files on to the map. Each file is rendered to an image on the client.</p>
<div id="docs">
<p>See the <a href="drag-and-drop-image-vector.js" target="_blank">drag-and-drop-image-vector.js source</a> to see how this is done.</p>
</div>

View File

@@ -149,6 +149,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -145,6 +145,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -32,7 +32,7 @@
<div class="span12">
<h4 id="title">Draw features example</h4>
<p id="shortdesc">Example of using the <code>ol.interaction.Draw</code> interaction.</p>
<p id="shortdesc">Example of using the ol.interaction.Draw interaction.</p>
<form class="form-inline">
<label>Geometry type &nbsp;</label>
<select id="type">

View File

@@ -86,6 +86,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -63,7 +63,7 @@ var popup = new ol.Overlay({
map.addOverlay(popup);
// display popup on click
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel,
function(feature, layer) {
return feature;

View File

@@ -32,8 +32,9 @@
<div class="span4">
<h4 id="title">IGC example</h4>
<p id="shortdesc">Example of tracks recorded from multiple paraglider flights on the same day, read from an IGC file. The five tracks contain a total of 49,707 unique coordinates. Zoom in to see more detail. The background layer is from <a href="http://www.opencyclemap.org/">OpenCycleMap</a>.</p>
<p id="shortdesc">Example of tracks recorded from multiple paraglider flights on the same day, read from an IGC file.</p>
<div id="docs">
<p>The five tracks contain a total of 49,707 unique coordinates. Zoom in to see more detail. The background layer is from <a href="http://www.opencyclemap.org/">OpenCycleMap</a>.</p>
<p>See the <a href="igc.js" target="_blank">igc.js source</a> to see how this is done.</p>
</div>
<input id="time" type="range" value="0" steps="1"></input>

View File

@@ -125,7 +125,7 @@ $(map.getViewport()).on('mousemove', function(evt) {
displaySnap(coordinate);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displaySnap(evt.coordinate);
});

View File

@@ -85,6 +85,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -88,6 +88,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(map.getEventPixel(evt.originalEvent));
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -95,6 +95,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(map.getEventPixel(evt.originalEvent));
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -52,6 +52,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -32,8 +32,9 @@
<div class="span12">
<h4 id="title">Localized OpenStreetMap example</h4>
<p id="shortdesc">Example of a localized OpenStreetMap map with a custom tile server and a custom attribution. The base layer is <a href="http://www.opencyclemap.org/">OpenCycleMap</a> with an overlay from <a href="http://www.openseamap.org/">OpenSeaMap</a>. The OpenSeaMap tile server does not support <a href="http://enable-cors.org/">CORS</a> headers.</p>
<p id="shortdesc">Example of a localized OpenStreetMap map with a custom tile server and a custom attribution.</p>
<div id="docs">
<p>The base layer is <a href="http://www.opencyclemap.org/">OpenCycleMap</a> with an overlay from <a href="http://www.openseamap.org/">OpenSeaMap</a>. The OpenSeaMap tile server does not support <a href="http://enable-cors.org/">CORS</a> headers.</p>
<p>See the <a href="localized-openstreetmap.js" target="_blank">localized-openstreetmap.js source</a> to see how this is done.</p>
</div>
<div id="tags">cors, localized-openstreetmap, openseamap, openstreetmap</div>

View File

@@ -45,7 +45,7 @@ var popup = new ol.Overlay({
});
map.addOverlay(popup);
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
var element = popup.getElement();
var coordinate = evt.coordinate;
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(

View File

@@ -60,7 +60,7 @@ var map = new ol.Map({
/**
* Add a click handler to the map to render the popup.
*/
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
var coordinate = evt.coordinate;
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
coordinate, 'EPSG:3857', 'EPSG:4326'));

View File

@@ -32,8 +32,9 @@
<div class="span12">
<h4 id="title">Static image example</h4>
<p id="shortdesc">Example of a static image layer. Source: <a href="http://xkcd.com/256/">xkcd.com/256/</a></p>
<p id="shortdesc">Example of a static image layer.</p>
<div id="docs">
<p>Source: <a href="http://xkcd.com/256/">xkcd.com/256/</a></p>
<p>See the <a href="static-image.js" target="_blank">static-image.js source</a> to see how this is done.</p>
</div>
<div id="tags">static image, xkcd</div>

View File

@@ -94,7 +94,7 @@ $(map.getViewport()).on('mousemove', function(evt) {
displaySnap(coordinate);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displaySnap(evt.coordinate);
});

51
examples/tile-vector.html Normal file
View File

@@ -0,0 +1,51 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Tile vector example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map" style="background: white;"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Tile vector example</h4>
<p id="shortdesc">Example of vector tiles from openstreetmap.us.</p>
<div id="docs">
<p>See the <a href="tile-vector.js" target="_blank">tile-vector.js source</a> to see how this is done.</p>
</div>
<div id="tags">tile-vector, openstreetmap</div>
</div>
</div>
</div>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=tile-vector" type="text/javascript"></script>
</body>
</html>

85
examples/tile-vector.js Normal file
View File

@@ -0,0 +1,85 @@
goog.require('ol.Map');
goog.require('ol.View2D');
goog.require('ol.format.TopoJSON');
goog.require('ol.layer.Vector');
goog.require('ol.proj');
goog.require('ol.source.TileVector');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.tilegrid.XYZ');
var waterLayer = new ol.layer.Vector({
source: new ol.source.TileVector({
format: new ol.format.TopoJSON({
defaultProjection: 'EPSG:4326'
}),
projection: 'EPSG:3857',
tileGrid: new ol.tilegrid.XYZ({
maxZoom: 19
}),
url: 'http://{a-c}.tile.openstreetmap.us/' +
'vectiles-water-areas/{z}/{x}/{y}.topojson'
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: '#9db9e8'
})
})
});
var roadStyleCache = {};
var roadLayer = new ol.layer.Vector({
source: new ol.source.TileVector({
format: new ol.format.TopoJSON({
defaultProjection: 'EPSG:4326'
}),
projection: 'EPSG:3857',
tileGrid: new ol.tilegrid.XYZ({
maxZoom: 19
}),
url: 'http://{a-c}.tile.openstreetmap.us/' +
'vectiles-highroad/{z}/{x}/{y}.topojson'
}),
style: function(feature, resolution) {
var kind = feature.get('kind');
var railway = feature.get('railway');
var sort_key = feature.get('sort_key');
var styleKey = kind + '/' + railway + '/' + sort_key;
var styleArray = roadStyleCache[styleKey];
if (!styleArray) {
var color, width;
if (railway) {
color = '#7de';
width = 1;
} else {
color = {
'major_road': '#776',
'minor_road': '#ccb',
'highway': '#f39'
}[kind];
width = kind == 'highway' ? 1.5 : 1;
}
styleArray = [new ol.style.Style({
stroke: new ol.style.Stroke({
color: color,
width: width
}),
zIndex: sort_key
})];
roadStyleCache[styleKey] = styleArray;
}
return styleArray;
}
});
var map = new ol.Map({
layers: [waterLayer, roadLayer],
renderer: 'canvas',
target: document.getElementById('map'),
view: new ol.View2D({
center: ol.proj.transform([-74.0064, 40.7142], 'EPSG:4326', 'EPSG:3857'),
maxZoom: 19,
zoom: 14
})
});

View File

@@ -122,6 +122,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
displayFeatureInfo(pixel);
});
map.on('singleclick', function(evt) {
map.on('click', function(evt) {
displayFeatureInfo(evt.pixel);
});

View File

@@ -32,11 +32,11 @@
<div class="span4">
<h4 id="title">OSM XML example</h4>
<p id="shortdesc">Example of using the OSM XML source.</p>
<p id="shortdesc">Example of using the OSM XML source. Vector data is loaded dynamically from a server using a tiling strategy.</p>
<div id="docs">
<p>See the <a href="vector-osm.js" target="_blank">vector-osm.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, osm, xml</div>
<div id="tags">vector, osm, xml, loading, server</div>
</div>
<div class="span4 offset4">
<div id="info" class="alert alert-success">

View File

@@ -1,13 +1,17 @@
goog.require('ol.Map');
goog.require('ol.View2D');
goog.require('ol.format.OSMXML');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.loadingstrategy');
goog.require('ol.proj');
goog.require('ol.source.BingMaps');
goog.require('ol.source.OSMXML');
goog.require('ol.source.ServerVector');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.tilegrid.XYZ');
var styles = {
'amenity': {
@@ -83,9 +87,21 @@ var styles = {
}
};
var vectorSource = new ol.source.OSMXML({
projection: 'EPSG:3857',
url: 'data/osm/map.osm'
var vectorSource = new ol.source.ServerVector({
format: new ol.format.OSMXML(),
loader: function(extent, resolution, projection) {
var transform = ol.proj.getTransform(projection, 'EPSG:4326');
var epsg4326Extent = transform(extent, []);
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
epsg4326Extent.join(',');
$.ajax(url).then(function(response) {
vectorSource.addFeatures(vectorSource.readFeatures(response));
});
},
strategy: ol.loadingstrategy.createTile(new ol.tilegrid.XYZ({
maxZoom: 19
})),
projection: 'EPSG:3857'
});
var vector = new ol.layer.Vector({
@@ -117,6 +133,7 @@ var map = new ol.Map({
target: document.getElementById('map'),
view: new ol.View2D({
center: [739218, 5906096],
maxZoom: 19,
zoom: 17
})
});

View File

@@ -6,16 +6,15 @@
*/
/**
* @param {string|Object.<string,*>=} option
* @param {string|Object.<string,*>=} opt_option
* @return {!jQuery}
*/
jQuery.prototype.popover = function(option) {};
jQuery.prototype.popover = function(opt_option) {};
/**
* @param {string|Object.<string,*>=} option
* @param {string|Object.<string,*>=} opt_option
* @return {!jQuery}
*/
jQuery.prototype.tooltip = function(option) {};
jQuery.prototype.tooltip = function(opt_option) {};

View File

@@ -10,30 +10,37 @@
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060
/** @type {Date} */
HTMLInputElement.prototype.valueAsDate;
/** @type {number} */
HTMLInputElement.prototype.valueAsNumber;
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084
/** @type {?number} */
DeviceRotationRate.prototype.alpha;
/** @type {?number} */
DeviceRotationRate.prototype.beta;
/** @type {?number} */
DeviceRotationRate.prototype.gamma;
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088
/** @type {?number} */
DeviceOrientationEvent.prototype.webkitCompassAccuracy;
/** @type {?number} */
DeviceOrientationEvent.prototype.webkitCompassHeading;
@@ -41,15 +48,19 @@ DeviceOrientationEvent.prototype.webkitCompassHeading;
// IE 11 fullscreen API
// http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
/** @return {void} */
Element.prototype.msRequestFullscreen = function() {};
/** @return {void} */
Element.prototype.msExitFullscreen = function() {};
/** @type {boolean} */
Document.prototype.msFullscreenEnabled;
/** @type {Element} */
Document.prototype.msFullscreenElement;
@@ -57,17 +68,22 @@ Document.prototype.msFullscreenElement;
/** @type {number} */
Touch.prototype.force;
/** @type {number} */
Touch.prototype.radiusX;
/** @type {number} */
Touch.prototype.radiusY;
/** @type {number} */
Touch.prototype.webkitForce;
/** @type {number} */
Touch.prototype.webkitRadiusX;
/** @type {number} */
Touch.prototype.webkitRadiusY;

View File

@@ -36,6 +36,7 @@ oli.DrawEvent;
oli.DrawEvent.prototype.feature;
/** @interface */
oli.FrameState;
@@ -64,14 +65,14 @@ oli.FrameState.prototype.focus;
oli.FrameState.prototype.index;
/** @type {Array.<ol.layer.Layer>} */
oli.FrameState.prototype.layersArray;
/** @type {Object.<number, ol.layer.LayerState>} */
oli.FrameState.prototype.layerStates;
/** @type {Array.<ol.layer.LayerState>} */
oli.FrameState.prototype.layerStatesArray;
/** @type {Object.<string, string>} */
oli.FrameState.prototype.logos;
@@ -120,6 +121,7 @@ oli.FrameState.prototype.viewHints;
oli.FrameState.prototype.wantedTiles;
/** @interface */
oli.ObjectEvent;

View File

@@ -89,4 +89,4 @@ Proj4js.Proj.prototype.to_meter;
* @param {Proj4js.Point|{x:number, y:number}} point
* @return {Proj4js.Point}
*/
Proj4js.transform = function(source, dest, point) {};
Proj4js.transform = function(source, dest, point) {return null;};

View File

@@ -4,6 +4,7 @@
*/
/**
* FIXME check argument type
* @constructor
@@ -15,7 +16,7 @@ var VBArray = function(safeArray) {};
/**
* @return {number}
*/
VBArray.prototype.dimensions = function() {};
VBArray.prototype.dimensions = function() {return 0;};
/**
@@ -35,7 +36,7 @@ VBArray.prototype.lbound = function(opt_dimension) {};
/**
* @return {Array.<number>}
*/
VBArray.prototype.toArray = function() {};
VBArray.prototype.toArray = function() {return null;};
/**

View File

@@ -25,7 +25,8 @@ var WebGLDebugLostContextSimulatingCanvas = function() {};
* @nosideeffects
* @return {number}
*/
WebGLDebugLostContextSimulatingCanvas.prototype.getNumCalls = function() {};
WebGLDebugLostContextSimulatingCanvas.prototype.getNumCalls =
function() {return NaN;};
/**
@@ -63,7 +64,7 @@ var WebGLDebugUtils = {};
* @param {number} value
* @return {string}
*/
WebGLDebugUtils.glEnumToString = function(value) {};
WebGLDebugUtils.glEnumToString = function(value) {return '';};
/**
@@ -72,7 +73,9 @@ WebGLDebugUtils.glEnumToString = function(value) {};
* @param {Array} args Args.
* @return {string} String.
*/
WebGLDebugUtils.glFunctionArgsToString = function(functionName, args) {};
WebGLDebugUtils.glFunctionArgsToString = function(functionName, args) {
return '';
};
/**
@@ -85,7 +88,9 @@ WebGLDebugUtils.init = function(ctx) {};
* @param {HTMLCanvasElement} canvas
* @return {WebGLDebugLostContextSimulatingCanvas}
*/
WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {};
WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {
return null;
};
/**
@@ -95,4 +100,4 @@ WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {};
* @return {WebGLDebugRenderingContext}
*/
WebGLDebugUtils.makeDebugContext =
function(context, opt_onErrorFunc, opt_onFunc) {};
function(context, opt_onErrorFunc, opt_onFunc) {return null;};

View File

@@ -487,8 +487,12 @@
/**
* @typedef {Object} olx.interaction.ModifyOptions
* @property {ol.events.ConditionType|undefined} deleteCondition Condition that
* determines which event results in a vertex deletion. Default is a
* `singleclick` event with no modifier keys.
* @property {number|undefined} pixelTolerance Pixel tolerance for considering
* the pointer close enough to a vertex for editing. Default is 10 pixels.
* the pointer close enough to a segment or vertex for editing. Default is
* 10 pixels.
* @property {ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined} style FeatureOverlay style.
* @property {ol.Collection} features The features the interaction works on.
*/
@@ -668,6 +672,15 @@
* @todo stability experimental
*/
/**
* @typedef {Object} olx.source.FormatVectorOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
* @property {ol.Extent|undefined} extent Extent.
* @property {ol.format.Feature} format Format.
* @property {string|undefined} logo Logo.
* @property {ol.proj.ProjectionLike} projection Projection.
*/
/**
* @typedef {Object} olx.source.GeoJSONOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
@@ -698,6 +711,25 @@
* @property {Array.<string>|undefined} urls URLs.
*/
/**
* @typedef {Object} olx.source.TileVectorOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
* @property {ol.proj.ProjectionLike} defaultProjection Default projection.
* @property {ol.Extent|undefined} extent Extent.
* @property {string|undefined} logo Logo.
* @property {GeoJSONObject|undefined} object Object.
* @property {ol.proj.ProjectionLike} projection Destination projection. If
* provided, features will be transformed to this projection. If not
* provided, features will not be transformed.
* @property {ol.tilegrid.TileGrid} tileGrid Tile grid.
* @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional
* function to get tile URL given a tile coordinate and the projection.
* Required if url or urls are not provided.
* @property {string|undefined} url URL template. Must include `{x}`, `{y}`,
* and `{z}` placeholders.
* @property {Array.<string>|undefined} urls An array of URL templates.
*/
/**
* @typedef {Object} olx.source.TopoJSONOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
@@ -895,6 +927,17 @@
* @property {string} url Url.
*/
/**
* @typedef {Object} olx.source.ServerVectorOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
* @property {ol.Extent|undefined} extent Extent.
* @property {ol.format.Feature} format Format.
* @property {function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection)} loader Loading function.
* @property {function(ol.Extent, number): Array.<ol.Extent>|undefined} strategy Loading strategy. Default is `ol.loadingstrategy.bbox`.
* @property {string|undefined} logo Logo.
* @property {ol.proj.ProjectionLike} projection Projection.
*/
/**
* @typedef {Object} olx.source.TileJSONOptions
* @property {null|string|undefined} crossOrigin crossOrigin setting for image
@@ -952,7 +995,7 @@
*/
/**
* @typedef {Object} olx.source.VectorFileOptions
* @typedef {Object} olx.source.StaticVectorOptions
* @property {ArrayBuffer|undefined} arrayBuffer Array buffer.
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
* @property {Document|undefined} doc Document.

View File

@@ -74,13 +74,13 @@ ol.control.Attribution.prototype.getSourceAttributions =
function(frameState) {
var i, ii, j, jj, tileRanges, source, sourceAttribution,
sourceAttributionKey, sourceAttributions, sourceKey;
var layers = frameState.layersArray;
var layerStatesArray = frameState.layerStatesArray;
/** @type {Object.<string, ol.Attribution>} */
var attributions = goog.object.clone(frameState.attributions);
/** @type {Object.<string, ol.Attribution>} */
var hiddenAttributions = {};
for (i = 0, ii = layers.length; i < ii; i++) {
source = layers[i].getSource();
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
source = layerStatesArray[i].layer.getSource();
sourceKey = goog.getUid(source).toString();
sourceAttributions = source.getAttributions();
if (goog.isNull(sourceAttributions)) {

View File

@@ -66,7 +66,7 @@ ol.events.condition.never = goog.functions.FALSE;
/**
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} True if the event is a click event.
* @return {boolean} True if the event is a `singleclick` event.
* @todo stability experimental
*/
ol.events.condition.singleClick = function(mapBrowserEvent) {

View File

@@ -597,6 +597,17 @@ ol.extent.isEmpty = function(extent) {
};
/**
* @param {ol.Extent} extent Extent.
* @return {boolean} Is infinite.
* @todo stability experimental
*/
ol.extent.isInfinite = function(extent) {
return extent[0] == -Infinity || extent[1] == -Infinity ||
extent[2] == Infinity || extent[3] == Infinity;
};
/**
* @param {ol.Extent} extent Extent.
* @param {ol.Coordinate} coordinate Coordinate.

View File

@@ -0,0 +1 @@
@exportSymbol ol.format.OSMXML

502
src/ol/format/owsformat.js Normal file
View File

@@ -0,0 +1,502 @@
goog.provide('ol.format.OWS');
goog.require('goog.asserts');
goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('ol.format.XLink');
goog.require('ol.format.XML');
goog.require('ol.format.XSD');
goog.require('ol.xml');
/**
* @constructor
* @extends {ol.format.XML}
*/
ol.format.OWS = function() {
goog.base(this);
};
goog.inherits(ol.format.OWS, ol.format.XML);
/**
* @param {Document} doc Document.
* @return {Object} OWS object.
*/
ol.format.OWS.prototype.readFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT);
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readFromNode(n);
}
}
return null;
};
/**
* @param {Node} node Node.
* @return {Object} OWS object.
*/
ol.format.OWS.prototype.readFromNode = function(node) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
var owsObject = ol.xml.pushParseAndPop({},
ol.format.OWS.PARSERS_, node, []);
return goog.isDef(owsObject) ? owsObject : null;
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readAddress_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Address');
return ol.xml.pushParseAndPop({},
ol.format.OWS.ADDRESS_PARSERS_, node, objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readAllowedValues_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'AllowedValues');
return ol.xml.pushParseAndPop({},
ol.format.OWS.ALLOWED_VALUES_PARSERS_, node, objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readConstraint_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Constraint');
var object = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(object));
var name = node.getAttribute('name');
var value = ol.xml.pushParseAndPop({},
ol.format.OWS.CONSTRAINT_PARSERS_, node,
objectStack);
if (!goog.isDef(value)) {
return undefined;
}
if (!goog.isDef(object.constraints)) {
object.constraints = {};
}
object.constraints[name] = value;
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readContactInfo_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'ContactInfo');
return ol.xml.pushParseAndPop({},
ol.format.OWS.CONTACT_INFO_PARSERS_, node, objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readDcp_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'DCP');
return ol.xml.pushParseAndPop({},
ol.format.OWS.DCP_PARSERS_, node, objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readGet_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Get');
var object = objectStack[objectStack.length - 1];
var url = ol.format.XLink.readHref(node);
goog.asserts.assert(goog.isObject(object));
var value = ol.xml.pushParseAndPop({'url': url},
ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
if (!goog.isDef(value)) {
return undefined;
}
var get = goog.object.get(object, 'get');
if (!goog.isDef(get)) {
goog.object.set(object, 'get', [value]);
}else {
goog.asserts.assert(goog.isArray(get));
get.push(value);
}
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readHttp_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'HTTP');
return ol.xml.pushParseAndPop({}, ol.format.OWS.HTTP_PARSERS_,
node, objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readOperation_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Operation');
var name = node.getAttribute('name');
var value = ol.xml.pushParseAndPop({},
ol.format.OWS.OPERATION_PARSERS_, node, objectStack);
if (!goog.isDef(value)) {
return undefined;
}
var object = /** @type {Object} */
(objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isObject(object));
goog.object.set(object, name, value);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readOperationsMetadata_ = function(node,
objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'OperationsMetadata');
return ol.xml.pushParseAndPop({},
ol.format.OWS.OPERATIONS_METADATA_PARSERS_, node,
objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readPhone_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Phone');
return ol.xml.pushParseAndPop({},
ol.format.OWS.PHONE_PARSERS_, node, objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readServiceIdentification_ = function(node,
objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'ServiceIdentification');
return ol.xml.pushParseAndPop(
{}, ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_, node,
objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readServiceContact_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'ServiceContact');
return ol.xml.pushParseAndPop(
{}, ol.format.OWS.SERVICE_CONTACT_PARSERS_, node,
objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readServiceProvider_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'ServiceProvider');
return ol.xml.pushParseAndPop(
{}, ol.format.OWS.SERVICE_PROVIDER_PARSERS_, node,
objectStack);
};
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @private
* @return {Object|undefined}
*/
ol.format.OWS.readValue_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Value');
var object = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(object));
var key = ol.format.XSD.readString(node);
if (!goog.isDef(key)) {
return undefined;
}
goog.object.set(object, key, true);
};
/**
* @const
* @type {Array.<string>}
* @private
*/
ol.format.OWS.NAMESPACE_URIS_ = [
null,
'http://www.opengis.net/ows/1.1'
];
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'ServiceIdentification': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readServiceIdentification_,
'serviceIdentification'),
'ServiceProvider': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readServiceProvider_,
'serviceProvider'),
'OperationsMetadata': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readOperationsMetadata_,
'operationsMetadata')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'DeliveryPoint': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'deliveryPoint'),
'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'city'),
'AdministrativeArea': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'administrativeArea'),
'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'postalCode'),
'Country': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'country'),
'ElectronicMailAddress': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'electronicMailAddress')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Value': ol.format.OWS.readValue_
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'AllowedValues': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readAllowedValues_, 'allowedValues'
)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Phone': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readPhone_, 'phone'),
'Address': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readAddress_, 'address')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'HTTP': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readHttp_, 'http')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Get': ol.format.OWS.readGet_,
'Post': undefined // TODO
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'DCP': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readDcp_, 'dcp')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Operation': ol.format.OWS.readOperation_
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'voice'),
'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'facsimile')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Constraint': ol.format.OWS.readConstraint_
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.SERVICE_CONTACT_PARSERS_ =
ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'IndividualName': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'individualName'),
'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'positionName'),
'ContactInfo': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readContactInfo_, 'contactInfo')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ =
ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'title'),
'ServiceTypeVersion': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'serviceTypeVersion'),
'ServiceType': ol.xml.makeObjectPropertySetter(
ol.format.XSD.readString, 'serviceType')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
* @private
*/
ol.format.OWS.SERVICE_PROVIDER_PARSERS_ =
ol.xml.makeParsersNS(
ol.format.OWS.NAMESPACE_URIS_, {
'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString,
'providerName'),
'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref,
'providerSite'),
'ServiceContact': ol.xml.makeObjectPropertySetter(
ol.format.OWS.readServiceContact_, 'serviceContact')
});

View File

@@ -3,6 +3,7 @@ goog.provide('ol.interaction.Modify');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.functions');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');
goog.require('ol.Feature');
@@ -10,6 +11,7 @@ goog.require('ol.FeatureOverlay');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.ViewHint');
goog.require('ol.coordinate');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.feature');
goog.require('ol.geom.GeometryType');
@@ -44,6 +46,16 @@ ol.interaction.Modify = function(options) {
goog.base(this);
/**
* @type {ol.events.ConditionType}
* @private
*/
this.deleteCondition_ = goog.isDef(options.deleteCondition) ?
options.deleteCondition :
/** @type {ol.events.ConditionType} */ (goog.functions.and(
ol.events.condition.noModifierKeys,
ol.events.condition.singleClick));
/**
* Editing vertex.
* @type {ol.Feature}
@@ -58,18 +70,6 @@ ol.interaction.Modify = function(options) {
*/
this.vertexSegments_ = null;
/**
* @type {boolean}
* @private
*/
this.modifiable_ = false;
/**
* @type {ol.Coordinate}
* @private
*/
this.lastVertexCoordinate_;
/**
* @type {ol.Pixel}
* @private
@@ -90,6 +90,12 @@ ol.interaction.Modify = function(options) {
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
options.pixelTolerance : 10;
/**
* @type {boolean}
* @private
*/
this.snappedToVertex_ = false;
/**
* @type {Array}
* @private
@@ -404,9 +410,8 @@ ol.interaction.Modify.prototype.handlePointerDown = function(evt) {
for (i = insertVertices.length - 1; i >= 0; --i) {
this.insertVertex_.apply(this, insertVertices[i]);
}
this.lastVertexCoordinate_ = goog.array.clone(vertex);
}
return this.modifiable_;
return !goog.isNull(this.vertexFeature_);
};
@@ -461,20 +466,12 @@ ol.interaction.Modify.prototype.handlePointerDrag = function(evt) {
* @inheritDoc
*/
ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
var geometry = this.vertexFeature_.getGeometry();
goog.asserts.assertInstanceof(geometry, ol.geom.Point);
if (goog.array.equals(this.lastVertexCoordinate_,
geometry.getCoordinates())) {
this.removeVertex_();
} else {
var segmentData;
for (var i = this.dragSegments_.length - 1; i >= 0; --i) {
segmentData = this.dragSegments_[i][0];
this.rBush_.update(ol.extent.boundingExtent(segmentData.segment),
segmentData);
}
var segmentData;
for (var i = this.dragSegments_.length - 1; i >= 0; --i) {
segmentData = this.dragSegments_[i][0];
this.rBush_.update(ol.extent.boundingExtent(segmentData.segment),
segmentData);
}
return false;
};
@@ -483,12 +480,18 @@ ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
*/
ol.interaction.Modify.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) {
var handled;
if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) {
this.handlePointerMove_(mapBrowserEvent);
}
return (goog.base(this, 'handleMapBrowserEvent', mapBrowserEvent) &&
!this.modifiable_);
if (!goog.isNull(this.vertexFeature_) && this.snappedToVertex_ &&
this.deleteCondition_(mapBrowserEvent)) {
var geometry = this.vertexFeature_.getGeometry();
goog.asserts.assertInstanceof(geometry, ol.geom.Point);
handled = this.removeVertex_();
}
return goog.base(this, 'handleMapBrowserEvent', mapBrowserEvent) && !handled;
};
@@ -520,7 +523,6 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
[pixel[0] + this.pixelTolerance_, pixel[1] - this.pixelTolerance_]);
var box = ol.extent.boundingExtent([lowerLeft, upperRight]);
this.modifiable_ = false;
var rBush = this.rBush_;
var nodes = rBush.getInExtent(box);
if (nodes.length > 0) {
@@ -537,7 +539,8 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
var dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
if (dist <= 10) {
this.snappedToVertex_ = dist <= this.pixelTolerance_;
if (this.snappedToVertex_) {
vertex = squaredDist1 > squaredDist2 ?
closestSegment[1] : closestSegment[0];
}
@@ -557,7 +560,6 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
}
}
this.vertexSegments_ = vertexSegments;
this.modifiable_ = true;
return;
}
}
@@ -638,12 +640,14 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
/**
* Removes a vertex from all matching features.
* @return {boolean} True when a vertex was removed.
* @private
*/
ol.interaction.Modify.prototype.removeVertex_ = function() {
var dragSegments = this.dragSegments_;
var segmentsByFeature = {};
var component, coordinates, deleted, dragSegment, geometry, i, index, left;
var deleted = false;
var component, coordinates, dragSegment, geometry, i, index, left;
var newIndex, newSegment, right, segmentData, uid;
for (i = dragSegments.length - 1; i >= 0; --i) {
dragSegment = dragSegments[i];
@@ -724,6 +728,15 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
}
}
}
return deleted;
};
/**
* @inheritDoc
*/
ol.interaction.Modify.prototype.shouldStopEvent = function(handled) {
return handled;
};

View File

@@ -179,8 +179,20 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
* @inheritDoc
*/
ol.interaction.Select.prototype.setMap = function(map) {
var currentMap = this.getMap();
var selectedFeatures = this.featureOverlay_.getFeatures();
if (!goog.isNull(currentMap)) {
selectedFeatures.forEach(function(feature) {
currentMap.getSkippedFeatures().remove(feature);
});
}
goog.base(this, 'setMap', map);
this.featureOverlay_.setMap(map);
if (!goog.isNull(map)) {
selectedFeatures.forEach(function(feature) {
map.getSkippedFeatures().push(feature);
});
}
};

View File

@@ -57,15 +57,10 @@ ol.layer.Layer.prototype.getLayersArray = function(opt_array) {
/**
* @inheritDoc
*/
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_obj) {
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
layers: [],
layerStates: []
};
goog.asserts.assert(obj.layers.length === obj.layerStates.length);
obj.layers.push(this);
obj.layerStates.push(this.getLayerState());
return obj;
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
var states = (goog.isDef(opt_states)) ? opt_states : [];
states.push(this.getLayerState());
return states;
};

View File

@@ -25,7 +25,8 @@ ol.layer.LayerProperty = {
/**
* @typedef {{brightness: number,
* @typedef {{layer: ol.layer.Layer,
* brightness: number,
* contrast: number,
* hue: number,
* opacity: number,
@@ -126,6 +127,7 @@ ol.layer.Base.prototype.getLayerState = function() {
var maxResolution = this.getMaxResolution();
var minResolution = this.getMinResolution();
return {
layer: /** @type {ol.layer.Layer} */ (this),
brightness: goog.isDef(brightness) ? goog.math.clamp(brightness, -1, 1) : 0,
contrast: goog.isDef(contrast) ? Math.max(contrast, 0) : 1,
hue: goog.isDef(hue) ? hue : 0,
@@ -148,14 +150,9 @@ ol.layer.Base.prototype.getLayersArray = goog.abstractMethod;
/**
* @param {{
* layers: Array.<ol.layer.Layer>,
* layerStates: Array.<ol.layer.LayerState>}=} opt_obj Object that store
* both the layers and the layerStates (to be modified in place).
* @return {{
* layers: Array.<ol.layer.Layer>,
* layerStates: Array.<ol.layer.LayerState>}} Object that store both the
* layers and the layerStates.
* @param {Array.<ol.layer.LayerState>=} opt_states Optional list of layer
* states (to be modified in place).
* @return {Array.<ol.layer.LayerState>} List of layer states.
*/
ol.layer.Base.prototype.getLayerStatesArray = goog.abstractMethod;

View File

@@ -183,22 +183,19 @@ ol.layer.Group.prototype.getLayersArray = function(opt_array) {
/**
* @inheritDoc
*/
ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
layers: [],
layerStates: []
};
goog.asserts.assert(obj.layers.length === obj.layerStates.length);
var pos = obj.layers.length;
ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
var states = (goog.isDef(opt_states)) ? opt_states : [];
var pos = states.length;
this.getLayers().forEach(function(layer) {
layer.getLayerStatesArray(obj);
layer.getLayerStatesArray(states);
});
var ownLayerState = this.getLayerState();
var i, ii, layerState;
for (i = pos, ii = obj.layerStates.length; i < ii; i++) {
layerState = obj.layerStates[i];
for (i = pos, ii = states.length; i < ii; i++) {
layerState = states[i];
layerState.brightness = goog.math.clamp(
layerState.brightness + ownLayerState.brightness, -1, 1);
layerState.contrast *= ownLayerState.contrast;
@@ -212,7 +209,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
layerState.minResolution, ownLayerState.minResolution);
}
return obj;
return states;
};

View File

@@ -0,0 +1,3 @@
@exportSymbol ol.loadingstrategy.all
@exportSymbol ol.loadingstrategy.bbox
@exportSymbol ol.loadingstrategy.createTile

52
src/ol/loadingstrategy.js Normal file
View File

@@ -0,0 +1,52 @@
goog.provide('ol.loadingstrategy');
goog.require('ol.TileCoord');
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array.<ol.Extent>} Extents.
*/
ol.loadingstrategy.all = function(extent, resolution) {
return [[-Infinity, -Infinity, Infinity, Infinity]];
};
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array.<ol.Extent>} Extents.
*/
ol.loadingstrategy.bbox = function(extent, resolution) {
return [extent];
};
/**
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
* @return {function(ol.Extent, number): Array.<ol.Extent>} Loading strategy.
*/
ol.loadingstrategy.createTile = function(tileGrid) {
return (
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @return {Array.<ol.Extent>} Extents.
*/
function(extent, resolution) {
var z = tileGrid.getZForResolution(resolution);
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
/** @type {Array.<ol.Extent>} */
var extents = [];
var tileCoord = new ol.TileCoord(z, 0, 0);
for (tileCoord.x = tileRange.minX; tileCoord.x <= tileRange.maxX;
++tileCoord.x) {
for (tileCoord.y = tileRange.minY; tileCoord.y <= tileRange.maxY;
++tileCoord.y) {
extents.push(tileGrid.getTileCoordExtent(tileCoord));
}
}
return extents;
});
};

View File

@@ -1207,14 +1207,10 @@ ol.Map.prototype.renderFrame_ = function(time) {
if (goog.isDef(size) && hasArea(size) &&
goog.isDef(view2D) && view2D.isDef()) {
var viewHints = view.getHints();
var obj = this.getLayerGroup().getLayerStatesArray();
var layersArray = obj.layers;
var layerStatesArray = obj.layerStates;
var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
var layerStates = {};
var layer;
for (i = 0, ii = layersArray.length; i < ii; ++i) {
layer = layersArray[i];
layerStates[goog.getUid(layer)] = layerStatesArray[i];
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
layerStates[goog.getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
}
view2DState = view2D.getView2DState();
frameState = /** @type {oli.FrameState} */ ({
@@ -1224,8 +1220,8 @@ ol.Map.prototype.renderFrame_ = function(time) {
extent: null,
focus: goog.isNull(this.focus_) ? view2DState.center : this.focus_,
index: this.frameIndex_++,
layersArray: layersArray,
layerStates: layerStates,
layerStatesArray: layerStatesArray,
logos: {},
pixelRatio: this.pixelRatio_,
pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_,

View File

@@ -248,11 +248,15 @@ ol.MapBrowserEventHandler.prototype.emulateClickLegacyIE_ =
* @private
*/
ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
var newEvent;
newEvent = new ol.MapBrowserPointerEvent(
ol.MapBrowserEvent.EventType.CLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
if (this.clickTimeoutId_ !== 0) {
// double-click
goog.global.clearTimeout(this.clickTimeoutId_);
this.clickTimeoutId_ = 0;
var newEvent = new ol.MapBrowserPointerEvent(
newEvent = new ol.MapBrowserPointerEvent(
ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
} else {
@@ -470,6 +474,12 @@ ol.MapBrowserEvent.EventType = {
* @todo stability experimental
*/
SINGLECLICK: 'singleclick',
/**
* A click with no dragging. A double click will fire two of this.
* @event ol.MapBrowserEvent#click
* @todo stability experimental
*/
CLICK: goog.events.EventType.CLICK,
/**
* A true double click, with no dragging.
* @event ol.MapBrowserEvent#dblclick

View File

@@ -1,6 +1,8 @@
goog.provide('ol.renderer.canvas.Layer');
goog.require('goog.array');
goog.require('goog.vec.Mat4');
goog.require('ol.dom');
goog.require('ol.layer.Layer');
goog.require('ol.render.Event');
goog.require('ol.render.EventType');
@@ -163,3 +165,46 @@ ol.renderer.canvas.Layer.prototype.getTransform = function(frameState) {
-view2DState.rotation,
-view2DState.center[0], -view2DState.center[1]);
};
/**
* @param {ol.Size} size Size.
* @return {boolean} True when the canvas with the current size does not exceed
* the maximum dimensions.
*/
ol.renderer.canvas.Layer.testCanvasSize = (function() {
/**
* @type {CanvasRenderingContext2D}
*/
var context = null;
/**
* @type {ImageData}
*/
var imageData = null;
return function(size) {
if (goog.isNull(context)) {
context = ol.dom.createCanvasContext2D(1, 1);
imageData = context.createImageData(1, 1);
var data = imageData.data;
data[0] = 42;
data[1] = 84;
data[2] = 126;
data[3] = 255;
}
var canvas = context.canvas;
var good = size[0] <= canvas.width && size[1] <= canvas.height;
if (!good) {
canvas.width = size[0];
canvas.height = size[1];
var x = size[0] - 1;
var y = size[1] - 1;
context.putImageData(imageData, x, y);
var result = context.getImageData(x, y, 1, 1);
good = goog.array.equals(imageData.data, result.data);
}
return good;
};
})();

View File

@@ -151,15 +151,14 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState);
var layerStates = frameState.layerStates;
var layersArray = frameState.layersArray;
var layerStatesArray = frameState.layerStatesArray;
var viewResolution = frameState.view2DState.resolution;
var i, ii, layer, layerRenderer, layerState;
for (i = 0, ii = layersArray.length; i < ii; ++i) {
layer = layersArray[i];
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
layerState = layerStatesArray[i];
layer = layerState.layer;
layerRenderer = this.getLayerRenderer(layer);
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer);
layerState = layerStates[goog.getUid(layer)];
if (!layerState.visible ||
layerState.sourceState != ol.source.State.READY ||
viewResolution >= layerState.maxResolution ||

View File

@@ -44,6 +44,12 @@ ol.renderer.canvas.TileLayer = function(mapRenderer, tileLayer) {
*/
this.canvasSize_ = null;
/**
* @private
* @type {boolean}
*/
this.canvasTooBig_ = false;
/**
* @private
* @type {CanvasRenderingContext2D}
@@ -203,17 +209,24 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
this.canvas_ = context.canvas;
this.canvasSize_ = [canvasWidth, canvasHeight];
this.context_ = context;
this.canvasTooBig_ =
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
} else {
goog.asserts.assert(!goog.isNull(this.canvasSize_));
goog.asserts.assert(!goog.isNull(this.context_));
canvas = this.canvas_;
context = this.context_;
if (this.canvasSize_[0] < canvasWidth ||
this.canvasSize_[1] < canvasHeight) {
// Canvas is too small, make it bigger
this.canvasSize_[1] < canvasHeight ||
(this.canvasTooBig_ && (this.canvasSize_[0] > canvasWidth ||
this.canvasSize_[1] > canvasHeight))) {
// Canvas is too small, resize it. We never shrink the canvas, unless
// we know that the current canvas size exceeds the maximum size
canvas.width = canvasWidth;
canvas.height = canvasHeight;
this.canvasSize_ = [canvasWidth, canvasHeight];
this.canvasTooBig_ =
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
this.renderedCanvasTileRange_ = null;
} else {
canvasWidth = this.canvasSize_[0];

View File

@@ -170,7 +170,9 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
}
var frameStateExtent = frameState.extent;
var frameStateResolution = frameState.view2DState.resolution;
var view2DState = frameState.view2DState;
var projection = view2DState.projection;
var resolution = view2DState.resolution;
var pixelRatio = frameState.pixelRatio;
var vectorLayerRevision = vectorLayer.getRevision();
var vectorLayerRenderOrder = vectorLayer.getRenderOrder();
@@ -179,7 +181,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
}
if (!this.dirty_ &&
this.renderedResolution_ == frameStateResolution &&
this.renderedResolution_ == resolution &&
this.renderedRevision_ == vectorLayerRevision &&
this.renderedRenderOrder_ == vectorLayerRenderOrder &&
ol.extent.containsExtent(this.renderedExtent_, frameStateExtent)) {
@@ -204,9 +206,10 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
if (!goog.isDef(styleFunction)) {
styleFunction = ol.feature.defaultStyleFunction;
}
var tolerance = frameStateResolution / (2 * pixelRatio);
var replayGroup = new ol.render.canvas.ReplayGroup(tolerance, extent,
frameStateResolution);
var tolerance = resolution / (2 * pixelRatio);
var replayGroup =
new ol.render.canvas.ReplayGroup(tolerance, extent, resolution);
vectorSource.loadFeatures(extent, resolution, projection);
var renderFeature =
/**
* @param {ol.Feature} feature Feature.
@@ -215,19 +218,28 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
function(feature) {
goog.asserts.assert(goog.isDef(styleFunction));
var dirty = this.renderFeature(
feature, frameStateResolution, pixelRatio, styleFunction, replayGroup);
feature, resolution, pixelRatio, styleFunction, replayGroup);
this.dirty_ = this.dirty_ || dirty;
};
if (!goog.isNull(vectorLayerRenderOrder)) {
var features = vectorSource.getFeaturesInExtent(extent);
/** @type {Array.<ol.Feature>} */
var features = [];
vectorSource.forEachFeatureInExtentAtResolution(extent, resolution,
/**
* @param {ol.Feature} feature Feature.
*/
function(feature) {
features.push(feature);
}, this);
goog.array.sort(features, vectorLayerRenderOrder);
goog.array.forEach(features, renderFeature, this);
} else {
vectorSource.forEachFeatureInExtent(extent, renderFeature, this);
vectorSource.forEachFeatureInExtentAtResolution(
extent, resolution, renderFeature, this);
}
replayGroup.finish();
this.renderedResolution_ = frameStateResolution;
this.renderedResolution_ = resolution;
this.renderedRevision_ = vectorLayerRevision;
this.renderedRenderOrder_ = vectorLayerRenderOrder;
this.replayGroup_ = replayGroup;

View File

@@ -117,21 +117,21 @@ ol.renderer.dom.Map.prototype.renderFrame = function(frameState) {
});
}
var layerStates = frameState.layerStates;
var layersArray = frameState.layersArray;
var layerStatesArray = frameState.layerStatesArray;
var i, ii, layer, layerRenderer, layerState;
for (i = 0, ii = layersArray.length; i < ii; ++i) {
layer = layersArray[i];
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
layerState = layerStatesArray[i];
layer = layerState.layer;
layerRenderer = /** @type {ol.renderer.dom.Layer} */ (
this.getLayerRenderer(layer));
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer);
addChild.call(this, layerRenderer.getTarget(), i);
layerState = frameState.layerStates[goog.getUid(layer)];
if (layerState.sourceState == ol.source.State.READY) {
layerRenderer.prepareFrame(frameState, layerState);
}
}
var layerStates = frameState.layerStates;
var layerKey;
for (layerKey in this.getLayerRenderers()) {
if (!(layerKey in layerStates)) {

View File

@@ -97,11 +97,13 @@ ol.renderer.Map.prototype.disposeInternal = function() {
ol.renderer.Map.prototype.forEachFeatureAtPixel =
function(coordinate, frameState, callback, thisArg,
layerFilter, thisArg2) {
var layersArray = this.map_.getLayerGroup().getLayersArray();
var layerStates = this.map_.getLayerGroup().getLayerStatesArray();
var numLayers = layerStates.length;
var i;
for (i = layersArray.length - 1; i >= 0; --i) {
var layer = layersArray[i];
if (layer.getVisible() && layerFilter.call(thisArg2, layer)) {
for (i = numLayers - 1; i >= 0; --i) {
var layerState = layerStates[i];
var layer = layerState.layer;
if (layerState.visible && layerFilter.call(thisArg2, layer)) {
var layerRenderer = this.getLayerRenderer(layer);
var result = layerRenderer.forEachFeatureAtPixel(
coordinate, frameState, callback, thisArg);

View File

@@ -441,27 +441,26 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
this.textureCache_.set((-frameState.index).toString(), null);
++this.textureCacheFrameMarkerCount_;
/** @type {Array.<ol.layer.Layer>} */
var layersToDraw = [];
var layersArray = frameState.layersArray;
/** @type {Array.<ol.layer.LayerState>} */
var layerStatesToDraw = [];
var layerStatesArray = frameState.layerStatesArray;
var viewResolution = frameState.view2DState.resolution;
var i, ii, layer, layerRenderer, layerState;
for (i = 0, ii = layersArray.length; i < ii; ++i) {
layer = layersArray[i];
layerState = frameState.layerStates[goog.getUid(layer)];
var i, ii, layerState;
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
layerState = layerStatesArray[i];
if (layerState.visible &&
layerState.sourceState == ol.source.State.READY &&
viewResolution < layerState.maxResolution &&
viewResolution >= layerState.minResolution) {
layersToDraw.push(layer);
layerStatesToDraw.push(layerState);
}
}
for (i = 0, ii = layersToDraw.length; i < ii; ++i) {
layer = layersToDraw[i];
layerRenderer = this.getLayerRenderer(layer);
var layerRenderer;
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
layerState = layerStatesToDraw[i];
layerRenderer = this.getLayerRenderer(layerState.layer);
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
layerState = frameState.layerStates[goog.getUid(layer)];
layerRenderer.prepareFrame(frameState, layerState);
}
@@ -481,10 +480,9 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState);
for (i = 0, ii = layersToDraw.length; i < ii; ++i) {
layer = layersToDraw[i];
layerState = frameState.layerStates[goog.getUid(layer)];
layerRenderer = this.getLayerRenderer(layer);
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
layerState = layerStatesToDraw[i];
layerRenderer = this.getLayerRenderer(layerState.layer);
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
layerRenderer.composeFrame(frameState, layerState, context);
}

View File

@@ -91,6 +91,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
this.tileGrid = tileGrid;
var culture = this.culture_;
var sourceProjection = this.getProjection();
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
tileGrid.createTileCoordTransform(),
ol.TileUrlFunction.createFromTileUrlFunctions(
@@ -102,7 +103,6 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
.replace('{culture}', culture);
return (
/**
* @this {ol.source.BingMaps}
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
@@ -110,7 +110,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
*/
function(tileCoord, pixelRatio, projection) {
goog.asserts.assert(ol.proj.equivalent(
projection, this.getProjection()));
projection, sourceProjection));
if (goog.isNull(tileCoord)) {
return undefined;
} else {

View File

@@ -0,0 +1,135 @@
// FIXME consider delaying feature reading so projection can be provided by
// consumer (e.g. the view)
goog.provide('ol.source.FormatVector');
goog.require('goog.asserts');
goog.require('goog.dispose');
goog.require('goog.events');
goog.require('goog.net.EventType');
goog.require('goog.net.XhrIo');
goog.require('goog.net.XhrIo.ResponseType');
goog.require('goog.userAgent');
goog.require('ol.BrowserFeature');
goog.require('ol.format.FormatType');
goog.require('ol.proj');
goog.require('ol.source.State');
goog.require('ol.source.Vector');
goog.require('ol.xml');
/**
* @constructor
* @extends {ol.source.Vector}
* @param {olx.source.FormatVectorOptions} options Options.
* @todo stability experimental
*/
ol.source.FormatVector = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
projection: options.projection
});
/**
* @protected
* @type {ol.format.Feature}
*/
this.format = options.format;
};
goog.inherits(ol.source.FormatVector, ol.source.Vector);
/**
* @param {goog.Uri|string} url URL.
* @param {function(this: T, Array.<ol.Feature>)} callback Callback.
* @param {T} thisArg Value to use as `this` when executing `callback`.
* @template T
*/
ol.source.FormatVector.prototype.loadFeaturesFromURL =
function(url, callback, thisArg) {
var xhrIo = new goog.net.XhrIo();
var type = this.format.getType();
var responseType;
// FIXME maybe use ResponseType.DOCUMENT?
if (type == ol.format.FormatType.BINARY &&
ol.BrowserFeature.HAS_ARRAY_BUFFER) {
responseType = goog.net.XhrIo.ResponseType.ARRAY_BUFFER;
} else {
responseType = goog.net.XhrIo.ResponseType.TEXT;
}
xhrIo.setResponseType(responseType);
goog.events.listen(xhrIo, goog.net.EventType.COMPLETE,
/**
* @param {Event} event Event.
* @private
* @this {ol.source.FormatVector}
*/
function(event) {
var xhrIo = event.target;
goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo);
if (xhrIo.isSuccess()) {
var type = this.format.getType();
/** @type {ArrayBuffer|Document|Node|Object|string|undefined} */
var source;
if (type == ol.format.FormatType.BINARY &&
ol.BrowserFeature.HAS_ARRAY_BUFFER) {
source = xhrIo.getResponse();
goog.asserts.assertInstanceof(source, ArrayBuffer);
} else if (type == ol.format.FormatType.JSON) {
source = xhrIo.getResponseText();
} else if (type == ol.format.FormatType.TEXT) {
source = xhrIo.getResponseText();
} else if (type == ol.format.FormatType.XML) {
if (!goog.userAgent.IE) {
source = xhrIo.getResponseXml();
}
if (!goog.isDefAndNotNull(source)) {
source = ol.xml.load(xhrIo.getResponseText());
}
} else {
goog.asserts.fail();
}
if (goog.isDefAndNotNull(source)) {
callback.call(thisArg, this.readFeatures(source));
} else {
this.setState(ol.source.State.ERROR);
goog.asserts.fail();
}
} else {
this.setState(ol.source.State.ERROR);
}
goog.dispose(xhrIo);
}, false, this);
xhrIo.send(url);
};
/**
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
* @return {Array.<ol.Feature>} Features.
*/
ol.source.FormatVector.prototype.readFeatures = function(source) {
var format = this.format;
var features = format.readFeatures(source);
var featureProjection = format.readProjection(source);
var projection = this.getProjection();
if (!goog.isNull(projection)) {
if (!ol.proj.equivalent(featureProjection, projection)) {
var transform = ol.proj.getTransform(featureProjection, projection);
var i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
var geometry = feature.getGeometry();
if (!goog.isNull(geometry)) {
geometry.transform(transform);
}
}
}
}
return features;
};

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.GeoJSON');
goog.require('ol.format.GeoJSON');
goog.require('ol.source.VectorFile');
goog.require('ol.source.StaticVector');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @extends {ol.source.StaticVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.GeoJSONOptions=} opt_options Options.
* @todo stability experimental
@@ -31,4 +31,4 @@ ol.source.GeoJSON = function(opt_options) {
});
};
goog.inherits(ol.source.GeoJSON, ol.source.VectorFile);
goog.inherits(ol.source.GeoJSON, ol.source.StaticVector);

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.GPX');
goog.require('ol.format.GPX');
goog.require('ol.source.VectorFile');
goog.require('ol.source.StaticVector');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @extends {ol.source.StaticVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.GPXOptions=} opt_options Options.
* @todo stability experimental
@@ -30,4 +30,4 @@ ol.source.GPX = function(opt_options) {
});
};
goog.inherits(ol.source.GPX, ol.source.VectorFile);
goog.inherits(ol.source.GPX, ol.source.StaticVector);

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.IGC');
goog.require('ol.format.IGC');
goog.require('ol.source.VectorFile');
goog.require('ol.source.StaticVector');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @extends {ol.source.StaticVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.IGCOptions=} opt_options Options.
* @todo stability experimental
@@ -27,4 +27,4 @@ ol.source.IGC = function(opt_options) {
});
};
goog.inherits(ol.source.IGC, ol.source.VectorFile);
goog.inherits(ol.source.IGC, ol.source.StaticVector);

View File

@@ -106,7 +106,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
resolution);
var loading = false;
this.source_.forEachFeatureInExtent(extent,
this.source_.forEachFeatureInExtentAtResolution(extent, resolution,
/**
* @param {ol.Feature} feature Feature.
*/

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.KML');
goog.require('ol.format.KML');
goog.require('ol.source.VectorFile');
goog.require('ol.source.StaticVector');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @extends {ol.source.StaticVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.KMLOptions=} opt_options Options.
* @todo stability experimental
@@ -32,4 +32,4 @@ ol.source.KML = function(opt_options) {
});
};
goog.inherits(ol.source.KML, ol.source.VectorFile);
goog.inherits(ol.source.KML, ol.source.StaticVector);

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.OSMXML');
goog.require('ol.format.OSMXML');
goog.require('ol.source.VectorFile');
goog.require('ol.source.StaticVector');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @extends {ol.source.StaticVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.OSMXMLOptions=} opt_options Options.
*/
@@ -29,4 +29,4 @@ ol.source.OSMXML = function(opt_options) {
});
};
goog.inherits(ol.source.OSMXML, ol.source.VectorFile);
goog.inherits(ol.source.OSMXML, ol.source.StaticVector);

View File

@@ -0,0 +1,2 @@
@exportSymbol ol.source.ServerVector
@exportProperty ol.source.ServerVector.prototype.readFeatures

View File

@@ -0,0 +1,99 @@
// FIXME cache expiration
goog.provide('ol.source.ServerVector');
goog.require('ol.extent');
goog.require('ol.loadingstrategy');
goog.require('ol.source.FormatVector');
goog.require('ol.structs.RBush');
/**
* @constructor
* @extends {ol.source.FormatVector}
* @param {olx.source.ServerVectorOptions} options Options.
*/
ol.source.ServerVector = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
format: options.format,
logo: options.logo,
projection: options.projection
});
/**
* @private
* @type {ol.structs.RBush.<{extent: ol.Extent}>}
*/
this.loadedExtents_ = new ol.structs.RBush();
/**
* @private
* @type {function(this: ol.source.ServerVector, ol.Extent, number,
* ol.proj.Projection): string}
*/
this.loader_ = options.loader;
/**
* @private
* @type {function(ol.Extent, number): Array.<ol.Extent>}
*/
this.strategy_ = goog.isDef(options.strategy) ?
options.strategy : ol.loadingstrategy.bbox;
/**
* @private
* @type {Object.<number|string, boolean>}
*/
this.loadedFeatures_ = {};
};
goog.inherits(ol.source.ServerVector, ol.source.FormatVector);
/**
* @inheritDoc
*/
ol.source.ServerVector.prototype.addFeaturesInternal = function(features) {
/** @type {Array.<ol.Feature>} */
var notLoadedFeatures = [];
var i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
var featureId = feature.getId();
if (!(featureId in this.loadedFeatures_)) {
notLoadedFeatures.push(feature);
this.loadedFeatures_[featureId] = true;
}
}
goog.base(this, 'addFeaturesInternal', notLoadedFeatures);
};
/**
* @inheritDoc
*/
ol.source.ServerVector.prototype.loadFeatures =
function(extent, resolution, projection) {
var loadedExtents = this.loadedExtents_;
var extentsToLoad = this.strategy_(extent, resolution);
var i, ii;
for (i = 0, ii = extentsToLoad.length; i < ii; ++i) {
var extentToLoad = extentsToLoad[i];
var alreadyLoaded = loadedExtents.forEachInExtent(extentToLoad,
/**
* @param {{extent: ol.Extent}} object Object.
* @return {boolean} Contains.
*/
function(object) {
return ol.extent.containsExtent(object.extent, extentToLoad);
});
if (!alreadyLoaded) {
this.loader_.call(this, extentToLoad, resolution, projection);
loadedExtents.insert(extentToLoad, {extent: extentToLoad.slice()});
}
}
};

View File

@@ -0,0 +1 @@
@exportSymbol ol.source.StaticVector

View File

@@ -0,0 +1,76 @@
goog.provide('ol.source.StaticVector');
goog.require('ol.source.FormatVector');
goog.require('ol.source.State');
/**
* @constructor
* @extends {ol.source.FormatVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.StaticVectorOptions} options Options.
* @todo stability experimental
*/
ol.source.StaticVector = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
format: options.format,
logo: options.logo,
projection: options.projection
});
if (goog.isDef(options.arrayBuffer)) {
this.addFeaturesInternal(this.readFeatures(options.arrayBuffer));
}
if (goog.isDef(options.doc)) {
this.addFeaturesInternal(this.readFeatures(options.doc));
}
if (goog.isDef(options.node)) {
this.addFeaturesInternal(this.readFeatures(options.node));
}
if (goog.isDef(options.object)) {
this.addFeaturesInternal(this.readFeatures(options.object));
}
if (goog.isDef(options.text)) {
this.addFeaturesInternal(this.readFeatures(options.text));
}
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
this.setState(ol.source.State.LOADING);
if (goog.isDef(options.url)) {
this.loadFeaturesFromURL(options.url,
/**
* @param {Array.<ol.Feature>} features Features.
* @this {ol.source.StaticVector}
*/
function(features) {
this.addFeaturesInternal(features);
this.setState(ol.source.State.READY);
}, this);
}
if (goog.isDef(options.urls)) {
var urls = options.urls;
var i, ii;
for (i = 0, ii = urls.length; i < ii; ++i) {
this.loadFeaturesFromURL(urls[i],
/**
* @param {Array.<ol.Feature>} features Features.
* @this {ol.source.StaticVector}
*/
function(features) {
this.addFeaturesInternal(features);
this.setState(ol.source.State.READY);
}, this);
}
}
}
};
goog.inherits(ol.source.StaticVector, ol.source.FormatVector);

View File

@@ -0,0 +1 @@
@exportSymbol ol.source.TileVector

View File

@@ -0,0 +1,245 @@
goog.provide('ol.source.TileVector');
goog.require('goog.array');
goog.require('goog.object');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.source.FormatVector');
goog.require('ol.source.State');
goog.require('ol.tilegrid.TileGrid');
/**
* @constructor
* @extends {ol.source.FormatVector}
* @param {olx.source.TileVectorOptions} options Options.
*/
ol.source.TileVector = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
format: options.format,
logo: options.logo,
projection: options.projection
});
var tileGrid = options.tileGrid;
/**
* @private
* @type {ol.tilegrid.TileGrid}
*/
this.tileGrid_ = options.tileGrid;
/**
* @private
* @type {ol.TileUrlFunctionType}
*/
this.tileUrlFunction_ = ol.TileUrlFunction.nullTileUrlFunction;
/**
* @private
* @type {ol.TileCoordTransformType}
*/
this.tileCoordTransform_ = tileGrid.createTileCoordTransform({
extent: options.extent
});
/**
* @private
* @type {Object.<string, Array.<ol.Feature>>}
*/
this.tiles_ = {};
if (goog.isDef(options.tileUrlFunction)) {
this.setTileUrlFunction(options.tileUrlFunction);
} else if (goog.isDef(options.urls)) {
this.setUrls(options.urls);
} else if (goog.isDef(options.url)) {
this.setUrl(options.url);
}
};
goog.inherits(ol.source.TileVector, ol.source.FormatVector);
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.addFeature = goog.abstractMethod;
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.addFeatures = goog.abstractMethod;
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.clear = function() {
goog.object.clear(this.tiles_);
};
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.forEachFeature = goog.abstractMethod;
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.forEachFeatureInExtent = goog.abstractMethod;
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.forEachFeatureInExtentAtResolution =
function(extent, resolution, f, opt_this) {
var tileGrid = this.tileGrid_;
var tiles = this.tiles_;
var z = tileGrid.getZForResolution(resolution);
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
var x, y;
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
var tileKey = this.getTileKeyZXY_(z, x, y);
var features = tiles[tileKey];
if (goog.isDef(features)) {
var i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
var result = f.call(opt_this, features[i]);
if (result) {
return result;
}
}
}
}
}
return undefined;
};
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.getClosestFeatureToCoordinate =
goog.abstractMethod;
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.getExtent = goog.abstractMethod;
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.getFeatures = function() {
var tiles = this.tiles_;
var features = [];
var tileKey;
for (tileKey in tiles) {
goog.array.extend(features, tiles[tileKey]);
}
return features;
};
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.getFeaturesInExtent = goog.abstractMethod;
/**
* @param {number} z Z.
* @param {number} x X.
* @param {number} y Y.
* @private
* @return {string} Tile key.
*/
ol.source.TileVector.prototype.getTileKeyZXY_ = function(z, x, y) {
return z + '/' + x + '/' + y;
};
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.loadFeatures =
function(extent, resolution, projection) {
var tileCoordTransform = this.tileCoordTransform_;
var tileGrid = this.tileGrid_;
var tileUrlFunction = this.tileUrlFunction_;
var tiles = this.tiles_;
var z = tileGrid.getZForResolution(resolution);
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
var tileCoord = new ol.TileCoord(z, 0, 0);
var x, y;
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
var tileKey = this.getTileKeyZXY_(z, x, y);
if (!(tileKey in tiles)) {
tileCoord.z = z;
tileCoord.x = x;
tileCoord.y = y;
tileCoordTransform(tileCoord, projection, tileCoord);
var url = tileUrlFunction(tileCoord, 1, projection);
if (goog.isDef(url)) {
tiles[tileKey] = [];
this.loadFeaturesFromURL(url, goog.partial(
/**
* @param {string} tileKey Tile key.
* @param {Array.<ol.Feature>} features Features.
* @this {ol.source.TileVector}
*/
function(tileKey, features) {
tiles[tileKey] = features;
this.setState(ol.source.State.READY);
}, tileKey), this);
}
}
}
}
};
/**
* @inheritDoc
*/
ol.source.TileVector.prototype.removeFeature = goog.abstractMethod;
/**
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL function.
*/
ol.source.TileVector.prototype.setTileUrlFunction = function(tileUrlFunction) {
this.tileUrlFunction_ = tileUrlFunction;
this.dispatchChangeEvent();
};
/**
* @param {string} url URL.
* @todo stability experimental
*/
ol.source.TileVector.prototype.setUrl = function(url) {
this.setTileUrlFunction(ol.TileUrlFunction.createFromTemplates(
ol.TileUrlFunction.expandUrl(url)));
};
/**
* @param {Array.<string>} urls URLs.
*/
ol.source.TileVector.prototype.setUrls = function(urls) {
this.setTileUrlFunction(ol.TileUrlFunction.createFromTemplates(urls));
};

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.TopoJSON');
goog.require('ol.format.TopoJSON');
goog.require('ol.source.VectorFile');
goog.require('ol.source.StaticVector');
/**
* @constructor
* @extends {ol.source.VectorFile}
* @extends {ol.source.StaticVector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.TopoJSONOptions=} opt_options Options.
* @todo stability experimental
@@ -30,4 +30,4 @@ ol.source.TopoJSON = function(opt_options) {
});
};
goog.inherits(ol.source.TopoJSON, ol.source.VectorFile);
goog.inherits(ol.source.TopoJSON, ol.source.StaticVector);

View File

@@ -1 +0,0 @@
@exportSymbol ol.source.VectorFile

View File

@@ -1,168 +0,0 @@
// FIXME consider delaying feature reading so projection can be provided by
// consumer (e.g. the view)
goog.provide('ol.source.VectorFile');
goog.require('goog.asserts');
goog.require('goog.dispose');
goog.require('goog.events');
goog.require('goog.net.EventType');
goog.require('goog.net.XhrIo');
goog.require('goog.net.XhrIo.ResponseType');
goog.require('goog.userAgent');
goog.require('ol.BrowserFeature');
goog.require('ol.format.FormatType');
goog.require('ol.proj');
goog.require('ol.source.State');
goog.require('ol.source.Vector');
goog.require('ol.xml');
/**
* @constructor
* @extends {ol.source.Vector}
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
* @param {olx.source.VectorFileOptions=} opt_options Options.
* @todo stability experimental
*/
ol.source.VectorFile = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
projection: options.projection
});
/**
* @type {ol.format.Feature}
* @protected
*/
this.format = options.format;
if (goog.isDef(options.doc)) {
this.readFeatures_(options.doc);
}
if (goog.isDef(options.node)) {
this.readFeatures_(options.node);
}
if (goog.isDef(options.object)) {
this.readFeatures_(options.object);
}
if (goog.isDef(options.text)) {
this.readFeatures_(options.text);
}
if (goog.isDef(options.arrayBuffer)) {
this.readFeatures_(options.arrayBuffer);
}
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
this.setState(ol.source.State.LOADING);
var type = this.format.getType();
var responseType;
if (type == ol.format.FormatType.BINARY &&
ol.BrowserFeature.HAS_ARRAY_BUFFER) {
responseType = goog.net.XhrIo.ResponseType.ARRAY_BUFFER;
} else {
responseType = goog.net.XhrIo.ResponseType.TEXT;
}
var xhrIo;
if (goog.isDef(options.url)) {
xhrIo = new goog.net.XhrIo();
xhrIo.setResponseType(responseType);
goog.events.listen(xhrIo, goog.net.EventType.COMPLETE,
goog.bind(this.handleXhrIo_, this));
xhrIo.send(options.url);
}
if (goog.isDef(options.urls)) {
var urls = options.urls;
var i, ii;
for (i = 0, ii = urls.length; i < ii; ++i) {
xhrIo = new goog.net.XhrIo();
xhrIo.setResponseType(responseType);
goog.events.listen(xhrIo, goog.net.EventType.COMPLETE,
goog.bind(this.handleXhrIo_, this));
xhrIo.send(urls[i]);
}
}
}
};
goog.inherits(ol.source.VectorFile, ol.source.Vector);
/**
* @param {Event} event Event.
* @private
*/
ol.source.VectorFile.prototype.handleXhrIo_ = function(event) {
var xhrIo = event.target;
goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo);
if (xhrIo.isSuccess()) {
var type = this.format.getType();
/** @type {ArrayBuffer|Document|Node|Object|string|undefined} */
var source;
if (type == ol.format.FormatType.BINARY &&
ol.BrowserFeature.HAS_ARRAY_BUFFER) {
source = xhrIo.getResponse();
goog.asserts.assertInstanceof(source, ArrayBuffer);
} else if (type == ol.format.FormatType.JSON) {
source = xhrIo.getResponseText();
} else if (type == ol.format.FormatType.TEXT) {
source = xhrIo.getResponseText();
} else if (type == ol.format.FormatType.XML) {
if (!goog.userAgent.IE) {
source = xhrIo.getResponseXml();
}
if (!goog.isDefAndNotNull(source)) {
source = ol.xml.load(xhrIo.getResponseText());
}
} else {
goog.asserts.fail();
}
goog.dispose(xhrIo);
if (goog.isDefAndNotNull(source)) {
this.readFeatures_(source);
} else {
this.setState(ol.source.State.ERROR);
goog.asserts.fail();
}
} else {
this.setState(ol.source.State.ERROR);
}
};
/**
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
* @private
*/
ol.source.VectorFile.prototype.readFeatures_ = function(source) {
var format = this.format;
var features = format.readFeatures(source);
var featureProjection = format.readProjection(source);
var projection = this.getProjection();
if (!goog.isNull(projection)) {
if (!ol.proj.equivalent(featureProjection, projection)) {
var transform = ol.proj.getTransform(featureProjection, projection);
var i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
var geometry = feature.getGeometry();
if (!goog.isNull(geometry)) {
geometry.transform(transform);
}
}
}
}
this.addFeaturesInternal(features);
this.setState(ol.source.State.READY);
};

View File

@@ -13,6 +13,7 @@ goog.require('goog.events.Event');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.ObjectEventType');
goog.require('ol.proj');
goog.require('ol.source.Source');
goog.require('ol.structs.RBush');
@@ -207,6 +208,21 @@ ol.source.Vector.prototype.forEachFeatureInExtent =
};
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {function(this: T, ol.Feature): S} f Callback.
* @param {T=} opt_this The object to use as `this` in `f`.
* @return {S|undefined}
* @template T,S
* @todo stability experimental
*/
ol.source.Vector.prototype.forEachFeatureInExtentAtResolution =
function(extent, resolution, f, opt_this) {
return this.forEachFeatureInExtent(extent, f, opt_this);
};
/**
* @return {Array.<ol.Feature>} Features.
* @todo stability experimental
@@ -337,6 +353,14 @@ ol.source.Vector.prototype.isEmpty = function() {
};
/**
* @param {ol.Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {ol.proj.Projection} projection Projection.
*/
ol.source.Vector.prototype.loadFeatures = goog.nullFunction;
/**
* @param {ol.Feature} feature Feature.
* @todo stability experimental

View File

@@ -10,11 +10,10 @@ goog.require('ol.TileCoord');
* A function that takes an {@link ol.TileCoord} for the tile coordinate,
* a `{number}` representing the pixel ratio and an {@link ol.proj.Projection}
* for the projection as arguments and returns a `{string}` or
* undefined representing the tile URL. The this keyword inside the function
* references the {@link ol.source.TileImage}.
* undefined representing the tile URL.
*
* @typedef {function(this: ol.source.TileImage, ol.TileCoord,
* number, ol.proj.Projection): (string|undefined)}
* @typedef {function(ol.TileCoord, number,
* ol.proj.Projection): (string|undefined)}
* @todo stability experimental
*/
ol.TileUrlFunctionType;
@@ -34,7 +33,6 @@ ol.TileCoordTransformType;
ol.TileUrlFunction.createFromTemplate = function(template) {
return (
/**
* @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
@@ -72,7 +70,6 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
}
return (
/**
* @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
@@ -84,15 +81,13 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
} else {
var index =
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
return tileUrlFunctions[index].call(
this, tileCoord, pixelRatio, projection);
return tileUrlFunctions[index](tileCoord, pixelRatio, projection);
}
});
};
/**
* @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
@@ -114,7 +109,6 @@ ol.TileUrlFunction.withTileCoordTransform =
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
return (
/**
* @this {ol.source.TileImage}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
@@ -124,9 +118,8 @@ ol.TileUrlFunction.withTileCoordTransform =
if (goog.isNull(tileCoord)) {
return undefined;
} else {
return tileUrlFunction.call(
this,
transformFn.call(this, tileCoord, projection, tmpTileCoord),
return tileUrlFunction(
transformFn(tileCoord, projection, tmpTileCoord),
pixelRatio,
projection);
}

View File

@@ -49,21 +49,25 @@ function parseExamples(examplePaths, callback) {
tags: ''
};
var key;
var openTag;
var parser = new Parser({
onopentag: function(name, attrs) {
onopentag: function(tag, attrs) {
if (attrs.id in info) {
key = attrs.id;
} else {
key = undefined;
openTag = tag;
}
},
ontext: function(text) {
if (key) {
info[key] = text.replace(/\n/g, '').trim();
info[key] += text.replace(/\n/g, '').trim() + ' ';
}
},
onclosetag: function(name) {
key = undefined;
onclosetag: function(tag) {
if (tag === openTag) {
info[key] = info[key].trim();
key = undefined;
openTag = undefined;
}
},
onerror: function(err2) {
var message = 'Trouble parsing ' + examplePath + '\n' + err2.message;

View File

@@ -0,0 +1,154 @@
goog.provide('ol.test.format.OWS');
goog.require('ol.xml');
describe('ol.format.OWS 1.1', function() {
var parser = new ol.format.OWS();
it('should read ServiceProvider tag properly', function() {
var doc = ol.xml.load(
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
'<ows:ServiceProvider>' +
'<ows:ProviderName>MiraMon</ows:ProviderName>' +
'<ows:ProviderSite ' +
'xlink:href="http://www.creaf.uab.es/miramon"/>' +
'<ows:ServiceContact>' +
'<ows:IndividualName>Joan Maso Pau' +
'</ows:IndividualName>' +
'<ows:PositionName>Senior Software Engineer' +
'</ows:PositionName>' +
'<ows:ContactInfo>' +
'<ows:Phone>' +
'<ows:Voice>+34 93 581 1312</ows:Voice>' +
'<ows:Facsimile>+34 93 581 4151' +
'</ows:Facsimile>' +
'</ows:Phone>' +
'<ows:Address>' +
'<ows:DeliveryPoint>Fac Ciencies UAB' +
'</ows:DeliveryPoint>' +
'<ows:City>Bellaterra</ows:City>' +
'<ows:AdministrativeArea>Barcelona' +
'</ows:AdministrativeArea>' +
'<ows:PostalCode>08193</ows:PostalCode>' +
'<ows:Country>Spain</ows:Country>' +
'<ows:ElectronicMailAddress>joan.maso@uab.es' +
'</ows:ElectronicMailAddress>' +
'</ows:Address>' +
'</ows:ContactInfo>' +
'</ows:ServiceContact>' +
'</ows:ServiceProvider>' +
'</ows:GetCapabilities>'
);
var obj = parser.read(doc);
expect(obj).to.be.ok();
var serviceProvider = obj.serviceProvider;
expect(serviceProvider).to.be.ok();
expect(serviceProvider.providerName).to.eql('MiraMon');
var url = 'http://www.creaf.uab.es/miramon';
expect(serviceProvider.providerSite).to.eql(url);
var name = 'Joan Maso Pau';
expect(serviceProvider.serviceContact.individualName).to.eql(name);
var position = 'Senior Software Engineer';
expect(serviceProvider.serviceContact.positionName).to.eql(position);
});
it('should read ServiceIdentification tag properly', function() {
var doc = ol.xml.load(
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
'<ows:ServiceIdentification>' +
'<ows:Title>Web Map Tile Service</ows:Title>' +
'<ows:Abstract>Service that contrains the map access interface ' +
'to some TileMatrixSets</ows:Abstract>' +
'<ows:Keywords>' +
'<ows:Keyword>tile</ows:Keyword>' +
'<ows:Keyword>tile matrix set</ows:Keyword>' +
'<ows:Keyword>map</ows:Keyword>' +
'</ows:Keywords>' +
'<ows:ServiceType>OGC WMTS</ows:ServiceType>' +
'<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>' +
'<ows:Fees>none</ows:Fees>' +
'<ows:AccessConstraints>none</ows:AccessConstraints>' +
'</ows:ServiceIdentification>' +
'</ows:GetCapabilities>'
);
var obj = parser.readFromNode(doc.firstChild);
expect(obj).to.be.ok();
var serviceIdentification = obj.serviceIdentification;
expect(serviceIdentification).to.be.ok();
expect(serviceIdentification.title).to.eql('Web Map Tile Service');
expect(serviceIdentification.serviceTypeVersion).to.eql('1.0.0');
expect(serviceIdentification.serviceType).to.eql('OGC WMTS');
});
it('should read OperationsMetadata tag properly', function() {
var doc = ol.xml.load(
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
'<ows:OperationsMetadata>' +
'<ows:Operation name="GetCapabilities">' +
'<ows:DCP>' +
'<ows:HTTP>' +
'<ows:Get xlink:href=' +
'"http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?">' +
'<ows:Constraint name="GetEncoding">' +
'<ows:AllowedValues>' +
'<ows:Value>KVP</ows:Value>' +
'</ows:AllowedValues>' +
'</ows:Constraint>' +
'</ows:Get>' +
'</ows:HTTP>' +
'</ows:DCP>' +
'</ows:Operation>' +
'<ows:Operation name="GetTile">' +
'<ows:DCP>' +
'<ows:HTTP>' +
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
'bin/MiraMon5_0.cgi?"/>' +
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
'bin/MiraMon6_0.cgi?"/>' +
'<ows:Post xlink:href="http://www.miramon.uab.es/cgi-' +
'bin/MiraMon7_0.cgi?"/>' +
'</ows:HTTP>' +
'</ows:DCP>' +
'</ows:Operation>' +
'<ows:Operation name="GetFeatureInfo">' +
'<ows:DCP>' +
'<ows:HTTP>' +
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
'bin/MiraMon5_0.cgi?"/>' +
'</ows:HTTP>' +
'</ows:DCP>' +
'</ows:Operation>' +
'</ows:OperationsMetadata>' +
'</ows:GetCapabilities>'
);
var obj = parser.readFromNode(doc.firstChild);
expect(obj).to.be.ok();
var operationsMetadata = obj.operationsMetadata;
expect(operationsMetadata).to.be.ok();
var dcp = operationsMetadata.GetCapabilities.dcp;
var url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetCapabilities.dcp;
expect(dcp.http.get[0].constraints.GetEncoding.allowedValues).to.eql(
{'KVP': true});
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
dcp = operationsMetadata.GetFeatureInfo.dcp;
expect(dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetFeatureInfo.dcp;
expect(dcp.http.get[0].constraints).to.be(undefined);
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(operationsMetadata.GetTile.dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetTile.dcp;
expect(dcp.http.get[0].constraints).to.be(undefined);
});
});
goog.require('ol.format.OWS');

View File

@@ -48,6 +48,7 @@ describe('ol.layer.Layer', function() {
it('provides default layerState', function() {
expect(layer.getLayerState()).to.eql({
layer: layer,
brightness: 0,
contrast: 1,
hue: 0,
@@ -90,6 +91,7 @@ describe('ol.layer.Layer', function() {
expect(layer.getMinResolution()).to.be(0.25);
expect(layer.get('foo')).to.be(42);
expect(layer.getLayerState()).to.eql({
layer: layer,
brightness: 0.5,
contrast: 10,
hue: 180,
@@ -132,6 +134,7 @@ describe('ol.layer.Layer', function() {
layer.setMaxResolution(500);
layer.setMinResolution(0.25);
expect(layer.getLayerState()).to.eql({
layer: layer,
brightness: -0.7,
contrast: 0.3,
hue: -0.3,
@@ -152,6 +155,7 @@ describe('ol.layer.Layer', function() {
layer.setSaturation(-0.7);
layer.setVisible(false);
expect(layer.getLayerState()).to.eql({
layer: layer,
brightness: 1,
contrast: 0,
hue: 42,
@@ -170,6 +174,7 @@ describe('ol.layer.Layer', function() {
layer.setSaturation(42);
layer.setVisible(true);
expect(layer.getLayerState()).to.eql({
layer: layer,
brightness: -1,
contrast: 42,
hue: -100,

View File

@@ -44,6 +44,7 @@ describe('ol.layer.Group', function() {
it('provides default layerState', function() {
expect(layerGroup.getLayerState()).to.eql({
layer: layerGroup,
brightness: 0,
contrast: 1,
hue: 0,
@@ -170,6 +171,7 @@ describe('ol.layer.Group', function() {
expect(layerGroup.getMaxResolution()).to.be(500);
expect(layerGroup.getMinResolution()).to.be(0.25);
expect(layerGroup.getLayerState()).to.eql({
layer: layerGroup,
brightness: 0.5,
contrast: 10,
hue: 180,
@@ -212,6 +214,7 @@ describe('ol.layer.Group', function() {
layerGroup.setMaxResolution(500);
layerGroup.setMinResolution(0.25);
expect(layerGroup.getLayerState()).to.eql({
layer: layerGroup,
brightness: -0.7,
contrast: 0.3,
hue: -0.3,
@@ -232,6 +235,7 @@ describe('ol.layer.Group', function() {
layerGroup.setSaturation(-0.7);
layerGroup.setVisible(false);
expect(layerGroup.getLayerState()).to.eql({
layer: layerGroup,
brightness: 1,
contrast: 0,
hue: 42,
@@ -250,6 +254,7 @@ describe('ol.layer.Group', function() {
layerGroup.setSaturation(42);
layerGroup.setVisible(true);
expect(layerGroup.getLayerState()).to.eql({
layer: layerGroup,
brightness: -1,
contrast: 42,
hue: -100,
@@ -292,19 +297,10 @@ describe('ol.layer.Group', function() {
describe('#getLayerStatesArray', function() {
var layerGroup;
var layersArray;
var layerStatesArray;
var obj;
it('returns an empty array if no layer', function() {
layerGroup = new ol.layer.Group();
var layerGroup = new ol.layer.Group();
obj = layerGroup.getLayerStatesArray();
layersArray = obj.layers;
layerStatesArray = obj.layerStates;
expect(layersArray).to.be.a(Array);
expect(layersArray.length).to.be(0);
var layerStatesArray = layerGroup.getLayerStatesArray();
expect(layerStatesArray).to.be.a(Array);
expect(layerStatesArray.length).to.be(0);
@@ -331,28 +327,29 @@ describe('ol.layer.Group', function() {
});
it('does not transform layerStates by default', function() {
layerGroup = new ol.layer.Group({
var layerGroup = new ol.layer.Group({
layers: [layer1, layer2]
});
obj = layerGroup.getLayerStatesArray();
layersArray = obj.layers;
layerStatesArray = obj.layerStates;
expect(layersArray).to.be.a(Array);
expect(layersArray.length).to.be(2);
expect(layersArray[0]).to.be(layer1);
expect(layersArray[1]).to.be(layer2);
var layerStatesArray = layerGroup.getLayerStatesArray();
expect(layerStatesArray).to.be.a(Array);
expect(layerStatesArray.length).to.be(2);
expect(layerStatesArray[0]).to.eql(layer1.getLayerState());
expect(layerStatesArray[0]).to.eql(layerGroup.getLayerState());
// layer state should match except for layer reference
var layerState = goog.object.clone(layerStatesArray[0]);
delete layerState.layer;
var groupState = goog.object.clone(layerGroup.getLayerState());
delete groupState.layer;
expect(layerState).to.eql(groupState);
expect(layerStatesArray[1]).to.eql(layer2.getLayerState());
goog.dispose(layerGroup);
});
it('transforms layerStates correctly', function() {
layerGroup = new ol.layer.Group({
var layerGroup = new ol.layer.Group({
layers: [layer1, layer2],
brightness: 0.5,
contrast: 10,
@@ -364,11 +361,22 @@ describe('ol.layer.Group', function() {
minResolution: 0.2
});
obj = layerGroup.getLayerStatesArray();
layersArray = obj.layers;
layerStatesArray = obj.layerStates;
expect(layerStatesArray[0]).to.eql(layerGroup.getLayerState());
expect(layerStatesArray[1]).to.eql({
var layerStatesArray = layerGroup.getLayerStatesArray();
// compare layer state to group state
var groupState, layerState;
// layer state should match except for layer reference
layerState = goog.object.clone(layerStatesArray[0]);
delete layerState.layer;
groupState = goog.object.clone(layerGroup.getLayerState());
delete groupState.layer;
expect(layerState).to.eql(groupState);
// layer state should be transformed (and we ignore layer reference)
layerState = goog.object.clone(layerStatesArray[1]);
delete layerState.layer;
expect(layerState).to.eql({
brightness: 1,
contrast: 100,
hue: 360,
@@ -392,6 +400,7 @@ describe('ol.layer.Group', function() {
goog.require('goog.dispose');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.ObjectEventType');
goog.require('ol.layer.Layer');
goog.require('ol.layer.Group');

View File

@@ -4,6 +4,7 @@ describe('ol.MapBrowserEventHandler', function() {
describe('#emulateClick_', function() {
var clock;
var handler;
var clickSpy;
var singleclickSpy;
var dblclickSpy;
var target;
@@ -15,6 +16,9 @@ describe('ol.MapBrowserEventHandler', function() {
target: target
}));
clickSpy = sinon.spy();
goog.events.listen(handler, 'click', clickSpy);
singleclickSpy = sinon.spy();
goog.events.listen(handler, 'singleclick', singleclickSpy);
@@ -28,6 +32,17 @@ describe('ol.MapBrowserEventHandler', function() {
});
it('emulates click', function() {
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
new goog.events.BrowserEvent({
type: 'mousedown',
target: target,
clientX: 0,
clientY: 0
})));
expect(clickSpy.called).to.be.ok();
});
it('emulates singleclick', function() {
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
new goog.events.BrowserEvent({
type: 'mousedown',
@@ -54,12 +69,13 @@ describe('ol.MapBrowserEventHandler', function() {
});
it('emulates dblclick', function() {
handler.emulateClick_({
type: 'mousedown',
target: target,
clientX: 0,
clientY: 0
});
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
new goog.events.BrowserEvent({
type: 'mousedown',
target: target,
clientX: 0,
clientY: 0
})));
expect(singleclickSpy.called).to.not.be.ok();
expect(dblclickSpy.called).to.not.be.ok();