Compare commits
70 Commits
v3.0.0-bet
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13e072cb63 | ||
|
|
d685c79e02 | ||
|
|
5e7790d89c | ||
|
|
3848e7f823 | ||
|
|
09021dffd4 | ||
|
|
95795ea301 | ||
|
|
732ec7c2db | ||
|
|
966317489e | ||
|
|
6fc915ba7b | ||
|
|
2a4300085e | ||
|
|
fe60d07ef0 | ||
|
|
f410a38c53 | ||
|
|
7826036307 | ||
|
|
78324fb54b | ||
|
|
aa3a20e911 | ||
|
|
9d5451b1d6 | ||
|
|
6c84358619 | ||
|
|
bf06129256 | ||
|
|
523b51d69a | ||
|
|
2cb045b0b3 | ||
|
|
f2acbd332c | ||
|
|
8fc9b23ab8 | ||
|
|
266f573922 | ||
|
|
6a3d349409 | ||
|
|
8b0ae9e4da | ||
|
|
0de380c7d2 | ||
|
|
c155b70281 | ||
|
|
e49b395cc4 | ||
|
|
3a462f7076 | ||
|
|
d3a13a254c | ||
|
|
a68d9f2299 | ||
|
|
f13debbbc9 | ||
|
|
96b7700d63 | ||
|
|
ed586bad39 | ||
|
|
3a8504b799 | ||
|
|
fe216e3da1 | ||
|
|
8986ea1ef9 | ||
|
|
683483f8a4 | ||
|
|
4a484a7ad3 | ||
|
|
a31ad69ec4 | ||
|
|
86c5a582c7 | ||
|
|
ce8d805201 | ||
|
|
db1a06ac31 | ||
|
|
9e75684823 | ||
|
|
b8869805a7 | ||
|
|
de4a17b8e2 | ||
|
|
b24e122d4f | ||
|
|
cbbcab926e | ||
|
|
10bddeae59 | ||
|
|
50c4961b9f | ||
|
|
2842d1b254 | ||
|
|
8c984cc8f7 | ||
|
|
b008dd1805 | ||
|
|
073f83cd22 | ||
|
|
77933d0ab3 | ||
|
|
8df95bc674 | ||
|
|
e44e59311b | ||
|
|
7f2a628223 | ||
|
|
ea58f38275 | ||
|
|
54ba06ae3b | ||
|
|
58b5fef3da | ||
|
|
4dce59fe95 | ||
|
|
02907b26ed | ||
|
|
30fc1a29fb | ||
|
|
7bfa15c0fd | ||
|
|
f325cc3d7a | ||
|
|
58e74229d2 | ||
|
|
149e5c9068 | ||
|
|
00da1405b6 | ||
|
|
fe2bee1577 |
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
<h4 id="title">Drag-and-Drop image vector example</h4>
|
<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">
|
<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>
|
<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>
|
</div>
|
||||||
|
|||||||
@@ -149,6 +149,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -145,6 +145,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Draw features example</h4>
|
<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">
|
<form class="form-inline">
|
||||||
<label>Geometry type </label>
|
<label>Geometry type </label>
|
||||||
<select id="type">
|
<select id="type">
|
||||||
|
|||||||
@@ -86,6 +86,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ var popup = new ol.Overlay({
|
|||||||
map.addOverlay(popup);
|
map.addOverlay(popup);
|
||||||
|
|
||||||
// display popup on click
|
// display popup on click
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
var feature = map.forEachFeatureAtPixel(evt.pixel,
|
var feature = map.forEachFeatureAtPixel(evt.pixel,
|
||||||
function(feature, layer) {
|
function(feature, layer) {
|
||||||
return feature;
|
return feature;
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
<h4 id="title">IGC example</h4>
|
<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">
|
<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>
|
<p>See the <a href="igc.js" target="_blank">igc.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<input id="time" type="range" value="0" steps="1"></input>
|
<input id="time" type="range" value="0" steps="1"></input>
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displaySnap(coordinate);
|
displaySnap(coordinate);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displaySnap(evt.coordinate);
|
displaySnap(evt.coordinate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -88,6 +88,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(map.getEventPixel(evt.originalEvent));
|
displayFeatureInfo(map.getEventPixel(evt.originalEvent));
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,6 +95,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(map.getEventPixel(evt.originalEvent));
|
displayFeatureInfo(map.getEventPixel(evt.originalEvent));
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,6 +52,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Localized OpenStreetMap example</h4>
|
<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">
|
<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>
|
<p>See the <a href="localized-openstreetmap.js" target="_blank">localized-openstreetmap.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">cors, localized-openstreetmap, openseamap, openstreetmap</div>
|
<div id="tags">cors, localized-openstreetmap, openseamap, openstreetmap</div>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ var popup = new ol.Overlay({
|
|||||||
});
|
});
|
||||||
map.addOverlay(popup);
|
map.addOverlay(popup);
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
var element = popup.getElement();
|
var element = popup.getElement();
|
||||||
var coordinate = evt.coordinate;
|
var coordinate = evt.coordinate;
|
||||||
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
|
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ var map = new ol.Map({
|
|||||||
/**
|
/**
|
||||||
* Add a click handler to the map to render the popup.
|
* 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 coordinate = evt.coordinate;
|
||||||
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
|
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
|
||||||
coordinate, 'EPSG:3857', 'EPSG:4326'));
|
coordinate, 'EPSG:3857', 'EPSG:4326'));
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h4 id="title">Static image example</h4>
|
<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">
|
<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>
|
<p>See the <a href="static-image.js" target="_blank">static-image.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">static image, xkcd</div>
|
<div id="tags">static image, xkcd</div>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displaySnap(coordinate);
|
displaySnap(coordinate);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displaySnap(evt.coordinate);
|
displaySnap(evt.coordinate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
51
examples/tile-vector.html
Normal file
51
examples/tile-vector.html
Normal 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
85
examples/tile-vector.js
Normal 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
|
||||||
|
})
|
||||||
|
});
|
||||||
@@ -122,6 +122,6 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('singleclick', function(evt) {
|
map.on('click', function(evt) {
|
||||||
displayFeatureInfo(evt.pixel);
|
displayFeatureInfo(evt.pixel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,11 +32,11 @@
|
|||||||
|
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
<h4 id="title">OSM XML example</h4>
|
<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">
|
<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>
|
<p>See the <a href="vector-osm.js" target="_blank">vector-osm.js source</a> to see how this is done.</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="tags">vector, osm, xml</div>
|
<div id="tags">vector, osm, xml, loading, server</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4 offset4">
|
<div class="span4 offset4">
|
||||||
<div id="info" class="alert alert-success">
|
<div id="info" class="alert alert-success">
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
|
goog.require('ol.format.OSMXML');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
|
goog.require('ol.loadingstrategy');
|
||||||
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.BingMaps');
|
goog.require('ol.source.BingMaps');
|
||||||
goog.require('ol.source.OSMXML');
|
goog.require('ol.source.ServerVector');
|
||||||
goog.require('ol.style.Circle');
|
goog.require('ol.style.Circle');
|
||||||
goog.require('ol.style.Fill');
|
goog.require('ol.style.Fill');
|
||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
|
goog.require('ol.tilegrid.XYZ');
|
||||||
|
|
||||||
var styles = {
|
var styles = {
|
||||||
'amenity': {
|
'amenity': {
|
||||||
@@ -83,9 +87,21 @@ var styles = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var vectorSource = new ol.source.OSMXML({
|
var vectorSource = new ol.source.ServerVector({
|
||||||
projection: 'EPSG:3857',
|
format: new ol.format.OSMXML(),
|
||||||
url: 'data/osm/map.osm'
|
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({
|
var vector = new ol.layer.Vector({
|
||||||
@@ -117,6 +133,7 @@ var map = new ol.Map({
|
|||||||
target: document.getElementById('map'),
|
target: document.getElementById('map'),
|
||||||
view: new ol.View2D({
|
view: new ol.View2D({
|
||||||
center: [739218, 5906096],
|
center: [739218, 5906096],
|
||||||
|
maxZoom: 19,
|
||||||
zoom: 17
|
zoom: 17
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
9
externs/bootstrap.js
vendored
9
externs/bootstrap.js
vendored
@@ -6,16 +6,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string|Object.<string,*>=} option
|
* @param {string|Object.<string,*>=} opt_option
|
||||||
* @return {!jQuery}
|
* @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}
|
* @return {!jQuery}
|
||||||
*/
|
*/
|
||||||
jQuery.prototype.tooltip = function(option) {};
|
jQuery.prototype.tooltip = function(opt_option) {};
|
||||||
|
|||||||
@@ -10,30 +10,37 @@
|
|||||||
|
|
||||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060
|
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1060
|
||||||
|
|
||||||
|
|
||||||
/** @type {Date} */
|
/** @type {Date} */
|
||||||
HTMLInputElement.prototype.valueAsDate;
|
HTMLInputElement.prototype.valueAsDate;
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
HTMLInputElement.prototype.valueAsNumber;
|
HTMLInputElement.prototype.valueAsNumber;
|
||||||
|
|
||||||
|
|
||||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084
|
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1084
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
/** @type {?number} */
|
||||||
DeviceRotationRate.prototype.alpha;
|
DeviceRotationRate.prototype.alpha;
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
/** @type {?number} */
|
||||||
DeviceRotationRate.prototype.beta;
|
DeviceRotationRate.prototype.beta;
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
/** @type {?number} */
|
||||||
DeviceRotationRate.prototype.gamma;
|
DeviceRotationRate.prototype.gamma;
|
||||||
|
|
||||||
|
|
||||||
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088
|
// @see https://code.google.com/p/closure-compiler/issues/detail?id=1088
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
/** @type {?number} */
|
||||||
DeviceOrientationEvent.prototype.webkitCompassAccuracy;
|
DeviceOrientationEvent.prototype.webkitCompassAccuracy;
|
||||||
|
|
||||||
|
|
||||||
/** @type {?number} */
|
/** @type {?number} */
|
||||||
DeviceOrientationEvent.prototype.webkitCompassHeading;
|
DeviceOrientationEvent.prototype.webkitCompassHeading;
|
||||||
|
|
||||||
@@ -41,15 +48,19 @@ DeviceOrientationEvent.prototype.webkitCompassHeading;
|
|||||||
// IE 11 fullscreen API
|
// IE 11 fullscreen API
|
||||||
// http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
|
// http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
|
||||||
|
|
||||||
|
|
||||||
/** @return {void} */
|
/** @return {void} */
|
||||||
Element.prototype.msRequestFullscreen = function() {};
|
Element.prototype.msRequestFullscreen = function() {};
|
||||||
|
|
||||||
|
|
||||||
/** @return {void} */
|
/** @return {void} */
|
||||||
Element.prototype.msExitFullscreen = function() {};
|
Element.prototype.msExitFullscreen = function() {};
|
||||||
|
|
||||||
|
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
Document.prototype.msFullscreenEnabled;
|
Document.prototype.msFullscreenEnabled;
|
||||||
|
|
||||||
|
|
||||||
/** @type {Element} */
|
/** @type {Element} */
|
||||||
Document.prototype.msFullscreenElement;
|
Document.prototype.msFullscreenElement;
|
||||||
|
|
||||||
@@ -57,17 +68,22 @@ Document.prototype.msFullscreenElement;
|
|||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.force;
|
Touch.prototype.force;
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.radiusX;
|
Touch.prototype.radiusX;
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.radiusY;
|
Touch.prototype.radiusY;
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.webkitForce;
|
Touch.prototype.webkitForce;
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.webkitRadiusX;
|
Touch.prototype.webkitRadiusX;
|
||||||
|
|
||||||
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
Touch.prototype.webkitRadiusY;
|
Touch.prototype.webkitRadiusY;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ oli.DrawEvent;
|
|||||||
oli.DrawEvent.prototype.feature;
|
oli.DrawEvent.prototype.feature;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @interface */
|
/** @interface */
|
||||||
oli.FrameState;
|
oli.FrameState;
|
||||||
|
|
||||||
@@ -64,14 +65,14 @@ oli.FrameState.prototype.focus;
|
|||||||
oli.FrameState.prototype.index;
|
oli.FrameState.prototype.index;
|
||||||
|
|
||||||
|
|
||||||
/** @type {Array.<ol.layer.Layer>} */
|
|
||||||
oli.FrameState.prototype.layersArray;
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {Object.<number, ol.layer.LayerState>} */
|
/** @type {Object.<number, ol.layer.LayerState>} */
|
||||||
oli.FrameState.prototype.layerStates;
|
oli.FrameState.prototype.layerStates;
|
||||||
|
|
||||||
|
|
||||||
|
/** @type {Array.<ol.layer.LayerState>} */
|
||||||
|
oli.FrameState.prototype.layerStatesArray;
|
||||||
|
|
||||||
|
|
||||||
/** @type {Object.<string, string>} */
|
/** @type {Object.<string, string>} */
|
||||||
oli.FrameState.prototype.logos;
|
oli.FrameState.prototype.logos;
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@ oli.FrameState.prototype.viewHints;
|
|||||||
oli.FrameState.prototype.wantedTiles;
|
oli.FrameState.prototype.wantedTiles;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @interface */
|
/** @interface */
|
||||||
oli.ObjectEvent;
|
oli.ObjectEvent;
|
||||||
|
|
||||||
|
|||||||
@@ -89,4 +89,4 @@ Proj4js.Proj.prototype.to_meter;
|
|||||||
* @param {Proj4js.Point|{x:number, y:number}} point
|
* @param {Proj4js.Point|{x:number, y:number}} point
|
||||||
* @return {Proj4js.Point}
|
* @return {Proj4js.Point}
|
||||||
*/
|
*/
|
||||||
Proj4js.transform = function(source, dest, point) {};
|
Proj4js.transform = function(source, dest, point) {return null;};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME check argument type
|
* FIXME check argument type
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -15,7 +16,7 @@ var VBArray = function(safeArray) {};
|
|||||||
/**
|
/**
|
||||||
* @return {number}
|
* @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>}
|
* @return {Array.<number>}
|
||||||
*/
|
*/
|
||||||
VBArray.prototype.toArray = function() {};
|
VBArray.prototype.toArray = function() {return null;};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ var WebGLDebugLostContextSimulatingCanvas = function() {};
|
|||||||
* @nosideeffects
|
* @nosideeffects
|
||||||
* @return {number}
|
* @return {number}
|
||||||
*/
|
*/
|
||||||
WebGLDebugLostContextSimulatingCanvas.prototype.getNumCalls = function() {};
|
WebGLDebugLostContextSimulatingCanvas.prototype.getNumCalls =
|
||||||
|
function() {return NaN;};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +64,7 @@ var WebGLDebugUtils = {};
|
|||||||
* @param {number} value
|
* @param {number} value
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
WebGLDebugUtils.glEnumToString = function(value) {};
|
WebGLDebugUtils.glEnumToString = function(value) {return '';};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +73,9 @@ WebGLDebugUtils.glEnumToString = function(value) {};
|
|||||||
* @param {Array} args Args.
|
* @param {Array} args Args.
|
||||||
* @return {string} String.
|
* @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
|
* @param {HTMLCanvasElement} canvas
|
||||||
* @return {WebGLDebugLostContextSimulatingCanvas}
|
* @return {WebGLDebugLostContextSimulatingCanvas}
|
||||||
*/
|
*/
|
||||||
WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {};
|
WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,4 +100,4 @@ WebGLDebugUtils.makeLostContextSimulatingCanvas = function(canvas) {};
|
|||||||
* @return {WebGLDebugRenderingContext}
|
* @return {WebGLDebugRenderingContext}
|
||||||
*/
|
*/
|
||||||
WebGLDebugUtils.makeDebugContext =
|
WebGLDebugUtils.makeDebugContext =
|
||||||
function(context, opt_onErrorFunc, opt_onFunc) {};
|
function(context, opt_onErrorFunc, opt_onFunc) {return null;};
|
||||||
|
|||||||
@@ -487,8 +487,12 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} olx.interaction.ModifyOptions
|
* @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
|
* @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.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined} style FeatureOverlay style.
|
||||||
* @property {ol.Collection} features The features the interaction works on.
|
* @property {ol.Collection} features The features the interaction works on.
|
||||||
*/
|
*/
|
||||||
@@ -668,6 +672,15 @@
|
|||||||
* @todo stability experimental
|
* @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
|
* @typedef {Object} olx.source.GeoJSONOptions
|
||||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||||
@@ -698,6 +711,25 @@
|
|||||||
* @property {Array.<string>|undefined} urls URLs.
|
* @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
|
* @typedef {Object} olx.source.TopoJSONOptions
|
||||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||||
@@ -895,6 +927,17 @@
|
|||||||
* @property {string} url Url.
|
* @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
|
* @typedef {Object} olx.source.TileJSONOptions
|
||||||
* @property {null|string|undefined} crossOrigin crossOrigin setting for image
|
* @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 {ArrayBuffer|undefined} arrayBuffer Array buffer.
|
||||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||||
* @property {Document|undefined} doc Document.
|
* @property {Document|undefined} doc Document.
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ ol.control.Attribution.prototype.getSourceAttributions =
|
|||||||
function(frameState) {
|
function(frameState) {
|
||||||
var i, ii, j, jj, tileRanges, source, sourceAttribution,
|
var i, ii, j, jj, tileRanges, source, sourceAttribution,
|
||||||
sourceAttributionKey, sourceAttributions, sourceKey;
|
sourceAttributionKey, sourceAttributions, sourceKey;
|
||||||
var layers = frameState.layersArray;
|
var layerStatesArray = frameState.layerStatesArray;
|
||||||
/** @type {Object.<string, ol.Attribution>} */
|
/** @type {Object.<string, ol.Attribution>} */
|
||||||
var attributions = goog.object.clone(frameState.attributions);
|
var attributions = goog.object.clone(frameState.attributions);
|
||||||
/** @type {Object.<string, ol.Attribution>} */
|
/** @type {Object.<string, ol.Attribution>} */
|
||||||
var hiddenAttributions = {};
|
var hiddenAttributions = {};
|
||||||
for (i = 0, ii = layers.length; i < ii; i++) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
|
||||||
source = layers[i].getSource();
|
source = layerStatesArray[i].layer.getSource();
|
||||||
sourceKey = goog.getUid(source).toString();
|
sourceKey = goog.getUid(source).toString();
|
||||||
sourceAttributions = source.getAttributions();
|
sourceAttributions = source.getAttributions();
|
||||||
if (goog.isNull(sourceAttributions)) {
|
if (goog.isNull(sourceAttributions)) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ ol.events.condition.never = goog.functions.FALSE;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
* @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
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
ol.events.condition.singleClick = function(mapBrowserEvent) {
|
ol.events.condition.singleClick = function(mapBrowserEvent) {
|
||||||
|
|||||||
@@ -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.Extent} extent Extent.
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol.Coordinate} coordinate Coordinate.
|
||||||
|
|||||||
1
src/ol/format/osmxmlformat.exports
Normal file
1
src/ol/format/osmxmlformat.exports
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@exportSymbol ol.format.OSMXML
|
||||||
502
src/ol/format/owsformat.js
Normal file
502
src/ol/format/owsformat.js
Normal 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')
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ goog.provide('ol.interaction.Modify');
|
|||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
|
goog.require('goog.functions');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.CollectionEventType');
|
goog.require('ol.CollectionEventType');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
@@ -10,6 +11,7 @@ goog.require('ol.FeatureOverlay');
|
|||||||
goog.require('ol.MapBrowserEvent.EventType');
|
goog.require('ol.MapBrowserEvent.EventType');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.coordinate');
|
goog.require('ol.coordinate');
|
||||||
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.feature');
|
goog.require('ol.feature');
|
||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
@@ -44,6 +46,16 @@ ol.interaction.Modify = function(options) {
|
|||||||
goog.base(this);
|
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.
|
* Editing vertex.
|
||||||
* @type {ol.Feature}
|
* @type {ol.Feature}
|
||||||
@@ -58,18 +70,6 @@ ol.interaction.Modify = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.vertexSegments_ = null;
|
this.vertexSegments_ = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {boolean}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.modifiable_ = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.Coordinate}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.lastVertexCoordinate_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Pixel}
|
* @type {ol.Pixel}
|
||||||
* @private
|
* @private
|
||||||
@@ -90,6 +90,12 @@ ol.interaction.Modify = function(options) {
|
|||||||
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
|
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ?
|
||||||
options.pixelTolerance : 10;
|
options.pixelTolerance : 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.snappedToVertex_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
* @private
|
* @private
|
||||||
@@ -404,9 +410,8 @@ ol.interaction.Modify.prototype.handlePointerDown = function(evt) {
|
|||||||
for (i = insertVertices.length - 1; i >= 0; --i) {
|
for (i = insertVertices.length - 1; i >= 0; --i) {
|
||||||
this.insertVertex_.apply(this, insertVertices[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
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
|
ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
|
||||||
var geometry = this.vertexFeature_.getGeometry();
|
var segmentData;
|
||||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point);
|
for (var i = this.dragSegments_.length - 1; i >= 0; --i) {
|
||||||
if (goog.array.equals(this.lastVertexCoordinate_,
|
segmentData = this.dragSegments_[i][0];
|
||||||
geometry.getCoordinates())) {
|
this.rBush_.update(ol.extent.boundingExtent(segmentData.segment),
|
||||||
this.removeVertex_();
|
segmentData);
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -483,12 +480,18 @@ ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Modify.prototype.handleMapBrowserEvent =
|
ol.interaction.Modify.prototype.handleMapBrowserEvent =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
|
var handled;
|
||||||
if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
|
if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
|
||||||
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) {
|
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) {
|
||||||
this.handlePointerMove_(mapBrowserEvent);
|
this.handlePointerMove_(mapBrowserEvent);
|
||||||
}
|
}
|
||||||
return (goog.base(this, 'handleMapBrowserEvent', mapBrowserEvent) &&
|
if (!goog.isNull(this.vertexFeature_) && this.snappedToVertex_ &&
|
||||||
!this.modifiable_);
|
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_]);
|
[pixel[0] + this.pixelTolerance_, pixel[1] - this.pixelTolerance_]);
|
||||||
var box = ol.extent.boundingExtent([lowerLeft, upperRight]);
|
var box = ol.extent.boundingExtent([lowerLeft, upperRight]);
|
||||||
|
|
||||||
this.modifiable_ = false;
|
|
||||||
var rBush = this.rBush_;
|
var rBush = this.rBush_;
|
||||||
var nodes = rBush.getInExtent(box);
|
var nodes = rBush.getInExtent(box);
|
||||||
if (nodes.length > 0) {
|
if (nodes.length > 0) {
|
||||||
@@ -537,7 +539,8 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
|
|||||||
var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
|
var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
|
||||||
var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
|
var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
|
||||||
var dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
|
var dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
|
||||||
if (dist <= 10) {
|
this.snappedToVertex_ = dist <= this.pixelTolerance_;
|
||||||
|
if (this.snappedToVertex_) {
|
||||||
vertex = squaredDist1 > squaredDist2 ?
|
vertex = squaredDist1 > squaredDist2 ?
|
||||||
closestSegment[1] : closestSegment[0];
|
closestSegment[1] : closestSegment[0];
|
||||||
}
|
}
|
||||||
@@ -557,7 +560,6 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.vertexSegments_ = vertexSegments;
|
this.vertexSegments_ = vertexSegments;
|
||||||
this.modifiable_ = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,12 +640,14 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a vertex from all matching features.
|
* Removes a vertex from all matching features.
|
||||||
|
* @return {boolean} True when a vertex was removed.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.interaction.Modify.prototype.removeVertex_ = function() {
|
ol.interaction.Modify.prototype.removeVertex_ = function() {
|
||||||
var dragSegments = this.dragSegments_;
|
var dragSegments = this.dragSegments_;
|
||||||
var segmentsByFeature = {};
|
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;
|
var newIndex, newSegment, right, segmentData, uid;
|
||||||
for (i = dragSegments.length - 1; i >= 0; --i) {
|
for (i = dragSegments.length - 1; i >= 0; --i) {
|
||||||
dragSegment = dragSegments[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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,20 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.setMap = function(map) {
|
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);
|
goog.base(this, 'setMap', map);
|
||||||
this.featureOverlay_.setMap(map);
|
this.featureOverlay_.setMap(map);
|
||||||
|
if (!goog.isNull(map)) {
|
||||||
|
selectedFeatures.forEach(function(feature) {
|
||||||
|
map.getSkippedFeatures().push(feature);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,15 +57,10 @@ ol.layer.Layer.prototype.getLayersArray = function(opt_array) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_obj) {
|
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
|
||||||
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
|
var states = (goog.isDef(opt_states)) ? opt_states : [];
|
||||||
layers: [],
|
states.push(this.getLayerState());
|
||||||
layerStates: []
|
return states;
|
||||||
};
|
|
||||||
goog.asserts.assert(obj.layers.length === obj.layerStates.length);
|
|
||||||
obj.layers.push(this);
|
|
||||||
obj.layerStates.push(this.getLayerState());
|
|
||||||
return obj;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ ol.layer.LayerProperty = {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{brightness: number,
|
* @typedef {{layer: ol.layer.Layer,
|
||||||
|
* brightness: number,
|
||||||
* contrast: number,
|
* contrast: number,
|
||||||
* hue: number,
|
* hue: number,
|
||||||
* opacity: number,
|
* opacity: number,
|
||||||
@@ -126,6 +127,7 @@ ol.layer.Base.prototype.getLayerState = function() {
|
|||||||
var maxResolution = this.getMaxResolution();
|
var maxResolution = this.getMaxResolution();
|
||||||
var minResolution = this.getMinResolution();
|
var minResolution = this.getMinResolution();
|
||||||
return {
|
return {
|
||||||
|
layer: /** @type {ol.layer.Layer} */ (this),
|
||||||
brightness: goog.isDef(brightness) ? goog.math.clamp(brightness, -1, 1) : 0,
|
brightness: goog.isDef(brightness) ? goog.math.clamp(brightness, -1, 1) : 0,
|
||||||
contrast: goog.isDef(contrast) ? Math.max(contrast, 0) : 1,
|
contrast: goog.isDef(contrast) ? Math.max(contrast, 0) : 1,
|
||||||
hue: goog.isDef(hue) ? hue : 0,
|
hue: goog.isDef(hue) ? hue : 0,
|
||||||
@@ -148,14 +150,9 @@ ol.layer.Base.prototype.getLayersArray = goog.abstractMethod;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{
|
* @param {Array.<ol.layer.LayerState>=} opt_states Optional list of layer
|
||||||
* layers: Array.<ol.layer.Layer>,
|
* states (to be modified in place).
|
||||||
* layerStates: Array.<ol.layer.LayerState>}=} opt_obj Object that store
|
* @return {Array.<ol.layer.LayerState>} List of layer states.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getLayerStatesArray = goog.abstractMethod;
|
ol.layer.Base.prototype.getLayerStatesArray = goog.abstractMethod;
|
||||||
|
|
||||||
|
|||||||
@@ -183,22 +183,19 @@ ol.layer.Group.prototype.getLayersArray = function(opt_array) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
|
ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
|
||||||
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
|
var states = (goog.isDef(opt_states)) ? opt_states : [];
|
||||||
layers: [],
|
|
||||||
layerStates: []
|
var pos = states.length;
|
||||||
};
|
|
||||||
goog.asserts.assert(obj.layers.length === obj.layerStates.length);
|
|
||||||
var pos = obj.layers.length;
|
|
||||||
|
|
||||||
this.getLayers().forEach(function(layer) {
|
this.getLayers().forEach(function(layer) {
|
||||||
layer.getLayerStatesArray(obj);
|
layer.getLayerStatesArray(states);
|
||||||
});
|
});
|
||||||
|
|
||||||
var ownLayerState = this.getLayerState();
|
var ownLayerState = this.getLayerState();
|
||||||
var i, ii, layerState;
|
var i, ii, layerState;
|
||||||
for (i = pos, ii = obj.layerStates.length; i < ii; i++) {
|
for (i = pos, ii = states.length; i < ii; i++) {
|
||||||
layerState = obj.layerStates[i];
|
layerState = states[i];
|
||||||
layerState.brightness = goog.math.clamp(
|
layerState.brightness = goog.math.clamp(
|
||||||
layerState.brightness + ownLayerState.brightness, -1, 1);
|
layerState.brightness + ownLayerState.brightness, -1, 1);
|
||||||
layerState.contrast *= ownLayerState.contrast;
|
layerState.contrast *= ownLayerState.contrast;
|
||||||
@@ -212,7 +209,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
|
|||||||
layerState.minResolution, ownLayerState.minResolution);
|
layerState.minResolution, ownLayerState.minResolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return states;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
src/ol/loadingstrategy.exports
Normal file
3
src/ol/loadingstrategy.exports
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@exportSymbol ol.loadingstrategy.all
|
||||||
|
@exportSymbol ol.loadingstrategy.bbox
|
||||||
|
@exportSymbol ol.loadingstrategy.createTile
|
||||||
52
src/ol/loadingstrategy.js
Normal file
52
src/ol/loadingstrategy.js
Normal 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;
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1207,14 +1207,10 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
|||||||
if (goog.isDef(size) && hasArea(size) &&
|
if (goog.isDef(size) && hasArea(size) &&
|
||||||
goog.isDef(view2D) && view2D.isDef()) {
|
goog.isDef(view2D) && view2D.isDef()) {
|
||||||
var viewHints = view.getHints();
|
var viewHints = view.getHints();
|
||||||
var obj = this.getLayerGroup().getLayerStatesArray();
|
var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
|
||||||
var layersArray = obj.layers;
|
|
||||||
var layerStatesArray = obj.layerStates;
|
|
||||||
var layerStates = {};
|
var layerStates = {};
|
||||||
var layer;
|
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = layersArray.length; i < ii; ++i) {
|
layerStates[goog.getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
|
||||||
layer = layersArray[i];
|
|
||||||
layerStates[goog.getUid(layer)] = layerStatesArray[i];
|
|
||||||
}
|
}
|
||||||
view2DState = view2D.getView2DState();
|
view2DState = view2D.getView2DState();
|
||||||
frameState = /** @type {oli.FrameState} */ ({
|
frameState = /** @type {oli.FrameState} */ ({
|
||||||
@@ -1224,8 +1220,8 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
|||||||
extent: null,
|
extent: null,
|
||||||
focus: goog.isNull(this.focus_) ? view2DState.center : this.focus_,
|
focus: goog.isNull(this.focus_) ? view2DState.center : this.focus_,
|
||||||
index: this.frameIndex_++,
|
index: this.frameIndex_++,
|
||||||
layersArray: layersArray,
|
|
||||||
layerStates: layerStates,
|
layerStates: layerStates,
|
||||||
|
layerStatesArray: layerStatesArray,
|
||||||
logos: {},
|
logos: {},
|
||||||
pixelRatio: this.pixelRatio_,
|
pixelRatio: this.pixelRatio_,
|
||||||
pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_,
|
pixelToCoordinateMatrix: this.pixelToCoordinateMatrix_,
|
||||||
|
|||||||
@@ -248,11 +248,15 @@ ol.MapBrowserEventHandler.prototype.emulateClickLegacyIE_ =
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
|
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) {
|
if (this.clickTimeoutId_ !== 0) {
|
||||||
// double-click
|
// double-click
|
||||||
goog.global.clearTimeout(this.clickTimeoutId_);
|
goog.global.clearTimeout(this.clickTimeoutId_);
|
||||||
this.clickTimeoutId_ = 0;
|
this.clickTimeoutId_ = 0;
|
||||||
var newEvent = new ol.MapBrowserPointerEvent(
|
newEvent = new ol.MapBrowserPointerEvent(
|
||||||
ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, pointerEvent);
|
ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, pointerEvent);
|
||||||
this.dispatchEvent(newEvent);
|
this.dispatchEvent(newEvent);
|
||||||
} else {
|
} else {
|
||||||
@@ -470,6 +474,12 @@ ol.MapBrowserEvent.EventType = {
|
|||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
SINGLECLICK: 'singleclick',
|
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.
|
* A true double click, with no dragging.
|
||||||
* @event ol.MapBrowserEvent#dblclick
|
* @event ol.MapBrowserEvent#dblclick
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
goog.provide('ol.renderer.canvas.Layer');
|
goog.provide('ol.renderer.canvas.Layer');
|
||||||
|
|
||||||
|
goog.require('goog.array');
|
||||||
goog.require('goog.vec.Mat4');
|
goog.require('goog.vec.Mat4');
|
||||||
|
goog.require('ol.dom');
|
||||||
goog.require('ol.layer.Layer');
|
goog.require('ol.layer.Layer');
|
||||||
goog.require('ol.render.Event');
|
goog.require('ol.render.Event');
|
||||||
goog.require('ol.render.EventType');
|
goog.require('ol.render.EventType');
|
||||||
@@ -163,3 +165,46 @@ ol.renderer.canvas.Layer.prototype.getTransform = function(frameState) {
|
|||||||
-view2DState.rotation,
|
-view2DState.rotation,
|
||||||
-view2DState.center[0], -view2DState.center[1]);
|
-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;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|||||||
@@ -151,15 +151,14 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
|
|||||||
|
|
||||||
this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState);
|
this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState);
|
||||||
|
|
||||||
var layerStates = frameState.layerStates;
|
var layerStatesArray = frameState.layerStatesArray;
|
||||||
var layersArray = frameState.layersArray;
|
|
||||||
var viewResolution = frameState.view2DState.resolution;
|
var viewResolution = frameState.view2DState.resolution;
|
||||||
var i, ii, layer, layerRenderer, layerState;
|
var i, ii, layer, layerRenderer, layerState;
|
||||||
for (i = 0, ii = layersArray.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||||
layer = layersArray[i];
|
layerState = layerStatesArray[i];
|
||||||
|
layer = layerState.layer;
|
||||||
layerRenderer = this.getLayerRenderer(layer);
|
layerRenderer = this.getLayerRenderer(layer);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.canvas.Layer);
|
||||||
layerState = layerStates[goog.getUid(layer)];
|
|
||||||
if (!layerState.visible ||
|
if (!layerState.visible ||
|
||||||
layerState.sourceState != ol.source.State.READY ||
|
layerState.sourceState != ol.source.State.READY ||
|
||||||
viewResolution >= layerState.maxResolution ||
|
viewResolution >= layerState.maxResolution ||
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ ol.renderer.canvas.TileLayer = function(mapRenderer, tileLayer) {
|
|||||||
*/
|
*/
|
||||||
this.canvasSize_ = null;
|
this.canvasSize_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.canvasTooBig_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {CanvasRenderingContext2D}
|
* @type {CanvasRenderingContext2D}
|
||||||
@@ -203,17 +209,24 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
this.canvas_ = context.canvas;
|
this.canvas_ = context.canvas;
|
||||||
this.canvasSize_ = [canvasWidth, canvasHeight];
|
this.canvasSize_ = [canvasWidth, canvasHeight];
|
||||||
this.context_ = context;
|
this.context_ = context;
|
||||||
|
this.canvasTooBig_ =
|
||||||
|
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.assert(!goog.isNull(this.canvasSize_));
|
goog.asserts.assert(!goog.isNull(this.canvasSize_));
|
||||||
goog.asserts.assert(!goog.isNull(this.context_));
|
goog.asserts.assert(!goog.isNull(this.context_));
|
||||||
canvas = this.canvas_;
|
canvas = this.canvas_;
|
||||||
context = this.context_;
|
context = this.context_;
|
||||||
if (this.canvasSize_[0] < canvasWidth ||
|
if (this.canvasSize_[0] < canvasWidth ||
|
||||||
this.canvasSize_[1] < canvasHeight) {
|
this.canvasSize_[1] < canvasHeight ||
|
||||||
// Canvas is too small, make it bigger
|
(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.width = canvasWidth;
|
||||||
canvas.height = canvasHeight;
|
canvas.height = canvasHeight;
|
||||||
this.canvasSize_ = [canvasWidth, canvasHeight];
|
this.canvasSize_ = [canvasWidth, canvasHeight];
|
||||||
|
this.canvasTooBig_ =
|
||||||
|
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
|
||||||
this.renderedCanvasTileRange_ = null;
|
this.renderedCanvasTileRange_ = null;
|
||||||
} else {
|
} else {
|
||||||
canvasWidth = this.canvasSize_[0];
|
canvasWidth = this.canvasSize_[0];
|
||||||
|
|||||||
@@ -170,7 +170,9 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
|
|||||||
}
|
}
|
||||||
|
|
||||||
var frameStateExtent = frameState.extent;
|
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 pixelRatio = frameState.pixelRatio;
|
||||||
var vectorLayerRevision = vectorLayer.getRevision();
|
var vectorLayerRevision = vectorLayer.getRevision();
|
||||||
var vectorLayerRenderOrder = vectorLayer.getRenderOrder();
|
var vectorLayerRenderOrder = vectorLayer.getRenderOrder();
|
||||||
@@ -179,7 +181,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.dirty_ &&
|
if (!this.dirty_ &&
|
||||||
this.renderedResolution_ == frameStateResolution &&
|
this.renderedResolution_ == resolution &&
|
||||||
this.renderedRevision_ == vectorLayerRevision &&
|
this.renderedRevision_ == vectorLayerRevision &&
|
||||||
this.renderedRenderOrder_ == vectorLayerRenderOrder &&
|
this.renderedRenderOrder_ == vectorLayerRenderOrder &&
|
||||||
ol.extent.containsExtent(this.renderedExtent_, frameStateExtent)) {
|
ol.extent.containsExtent(this.renderedExtent_, frameStateExtent)) {
|
||||||
@@ -204,9 +206,10 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
|
|||||||
if (!goog.isDef(styleFunction)) {
|
if (!goog.isDef(styleFunction)) {
|
||||||
styleFunction = ol.feature.defaultStyleFunction;
|
styleFunction = ol.feature.defaultStyleFunction;
|
||||||
}
|
}
|
||||||
var tolerance = frameStateResolution / (2 * pixelRatio);
|
var tolerance = resolution / (2 * pixelRatio);
|
||||||
var replayGroup = new ol.render.canvas.ReplayGroup(tolerance, extent,
|
var replayGroup =
|
||||||
frameStateResolution);
|
new ol.render.canvas.ReplayGroup(tolerance, extent, resolution);
|
||||||
|
vectorSource.loadFeatures(extent, resolution, projection);
|
||||||
var renderFeature =
|
var renderFeature =
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature} feature Feature.
|
* @param {ol.Feature} feature Feature.
|
||||||
@@ -215,19 +218,28 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
|
|||||||
function(feature) {
|
function(feature) {
|
||||||
goog.asserts.assert(goog.isDef(styleFunction));
|
goog.asserts.assert(goog.isDef(styleFunction));
|
||||||
var dirty = this.renderFeature(
|
var dirty = this.renderFeature(
|
||||||
feature, frameStateResolution, pixelRatio, styleFunction, replayGroup);
|
feature, resolution, pixelRatio, styleFunction, replayGroup);
|
||||||
this.dirty_ = this.dirty_ || dirty;
|
this.dirty_ = this.dirty_ || dirty;
|
||||||
};
|
};
|
||||||
if (!goog.isNull(vectorLayerRenderOrder)) {
|
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.sort(features, vectorLayerRenderOrder);
|
||||||
goog.array.forEach(features, renderFeature, this);
|
goog.array.forEach(features, renderFeature, this);
|
||||||
} else {
|
} else {
|
||||||
vectorSource.forEachFeatureInExtent(extent, renderFeature, this);
|
vectorSource.forEachFeatureInExtentAtResolution(
|
||||||
|
extent, resolution, renderFeature, this);
|
||||||
}
|
}
|
||||||
replayGroup.finish();
|
replayGroup.finish();
|
||||||
|
|
||||||
this.renderedResolution_ = frameStateResolution;
|
this.renderedResolution_ = resolution;
|
||||||
this.renderedRevision_ = vectorLayerRevision;
|
this.renderedRevision_ = vectorLayerRevision;
|
||||||
this.renderedRenderOrder_ = vectorLayerRenderOrder;
|
this.renderedRenderOrder_ = vectorLayerRenderOrder;
|
||||||
this.replayGroup_ = replayGroup;
|
this.replayGroup_ = replayGroup;
|
||||||
|
|||||||
@@ -117,21 +117,21 @@ ol.renderer.dom.Map.prototype.renderFrame = function(frameState) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var layerStates = frameState.layerStates;
|
var layerStatesArray = frameState.layerStatesArray;
|
||||||
var layersArray = frameState.layersArray;
|
|
||||||
var i, ii, layer, layerRenderer, layerState;
|
var i, ii, layer, layerRenderer, layerState;
|
||||||
for (i = 0, ii = layersArray.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||||
layer = layersArray[i];
|
layerState = layerStatesArray[i];
|
||||||
|
layer = layerState.layer;
|
||||||
layerRenderer = /** @type {ol.renderer.dom.Layer} */ (
|
layerRenderer = /** @type {ol.renderer.dom.Layer} */ (
|
||||||
this.getLayerRenderer(layer));
|
this.getLayerRenderer(layer));
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.dom.Layer);
|
||||||
addChild.call(this, layerRenderer.getTarget(), i);
|
addChild.call(this, layerRenderer.getTarget(), i);
|
||||||
layerState = frameState.layerStates[goog.getUid(layer)];
|
|
||||||
if (layerState.sourceState == ol.source.State.READY) {
|
if (layerState.sourceState == ol.source.State.READY) {
|
||||||
layerRenderer.prepareFrame(frameState, layerState);
|
layerRenderer.prepareFrame(frameState, layerState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var layerStates = frameState.layerStates;
|
||||||
var layerKey;
|
var layerKey;
|
||||||
for (layerKey in this.getLayerRenderers()) {
|
for (layerKey in this.getLayerRenderers()) {
|
||||||
if (!(layerKey in layerStates)) {
|
if (!(layerKey in layerStates)) {
|
||||||
|
|||||||
@@ -97,11 +97,13 @@ ol.renderer.Map.prototype.disposeInternal = function() {
|
|||||||
ol.renderer.Map.prototype.forEachFeatureAtPixel =
|
ol.renderer.Map.prototype.forEachFeatureAtPixel =
|
||||||
function(coordinate, frameState, callback, thisArg,
|
function(coordinate, frameState, callback, thisArg,
|
||||||
layerFilter, thisArg2) {
|
layerFilter, thisArg2) {
|
||||||
var layersArray = this.map_.getLayerGroup().getLayersArray();
|
var layerStates = this.map_.getLayerGroup().getLayerStatesArray();
|
||||||
|
var numLayers = layerStates.length;
|
||||||
var i;
|
var i;
|
||||||
for (i = layersArray.length - 1; i >= 0; --i) {
|
for (i = numLayers - 1; i >= 0; --i) {
|
||||||
var layer = layersArray[i];
|
var layerState = layerStates[i];
|
||||||
if (layer.getVisible() && layerFilter.call(thisArg2, layer)) {
|
var layer = layerState.layer;
|
||||||
|
if (layerState.visible && layerFilter.call(thisArg2, layer)) {
|
||||||
var layerRenderer = this.getLayerRenderer(layer);
|
var layerRenderer = this.getLayerRenderer(layer);
|
||||||
var result = layerRenderer.forEachFeatureAtPixel(
|
var result = layerRenderer.forEachFeatureAtPixel(
|
||||||
coordinate, frameState, callback, thisArg);
|
coordinate, frameState, callback, thisArg);
|
||||||
|
|||||||
@@ -441,27 +441,26 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
|||||||
this.textureCache_.set((-frameState.index).toString(), null);
|
this.textureCache_.set((-frameState.index).toString(), null);
|
||||||
++this.textureCacheFrameMarkerCount_;
|
++this.textureCacheFrameMarkerCount_;
|
||||||
|
|
||||||
/** @type {Array.<ol.layer.Layer>} */
|
/** @type {Array.<ol.layer.LayerState>} */
|
||||||
var layersToDraw = [];
|
var layerStatesToDraw = [];
|
||||||
var layersArray = frameState.layersArray;
|
var layerStatesArray = frameState.layerStatesArray;
|
||||||
var viewResolution = frameState.view2DState.resolution;
|
var viewResolution = frameState.view2DState.resolution;
|
||||||
var i, ii, layer, layerRenderer, layerState;
|
var i, ii, layerState;
|
||||||
for (i = 0, ii = layersArray.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||||
layer = layersArray[i];
|
layerState = layerStatesArray[i];
|
||||||
layerState = frameState.layerStates[goog.getUid(layer)];
|
|
||||||
if (layerState.visible &&
|
if (layerState.visible &&
|
||||||
layerState.sourceState == ol.source.State.READY &&
|
layerState.sourceState == ol.source.State.READY &&
|
||||||
viewResolution < layerState.maxResolution &&
|
viewResolution < layerState.maxResolution &&
|
||||||
viewResolution >= layerState.minResolution) {
|
viewResolution >= layerState.minResolution) {
|
||||||
layersToDraw.push(layer);
|
layerStatesToDraw.push(layerState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, ii = layersToDraw.length; i < ii; ++i) {
|
var layerRenderer;
|
||||||
layer = layersToDraw[i];
|
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
||||||
layerRenderer = this.getLayerRenderer(layer);
|
layerState = layerStatesToDraw[i];
|
||||||
|
layerRenderer = this.getLayerRenderer(layerState.layer);
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
||||||
layerState = frameState.layerStates[goog.getUid(layer)];
|
|
||||||
layerRenderer.prepareFrame(frameState, layerState);
|
layerRenderer.prepareFrame(frameState, layerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,10 +480,9 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
|||||||
|
|
||||||
this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState);
|
this.dispatchComposeEvent_(ol.render.EventType.PRECOMPOSE, frameState);
|
||||||
|
|
||||||
for (i = 0, ii = layersToDraw.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
||||||
layer = layersToDraw[i];
|
layerState = layerStatesToDraw[i];
|
||||||
layerState = frameState.layerStates[goog.getUid(layer)];
|
layerRenderer = this.getLayerRenderer(layerState.layer);
|
||||||
layerRenderer = this.getLayerRenderer(layer);
|
|
||||||
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
goog.asserts.assertInstanceof(layerRenderer, ol.renderer.webgl.Layer);
|
||||||
layerRenderer.composeFrame(frameState, layerState, context);
|
layerRenderer.composeFrame(frameState, layerState, context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
this.tileGrid = tileGrid;
|
this.tileGrid = tileGrid;
|
||||||
|
|
||||||
var culture = this.culture_;
|
var culture = this.culture_;
|
||||||
|
var sourceProjection = this.getProjection();
|
||||||
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
tileGrid.createTileCoordTransform(),
|
tileGrid.createTileCoordTransform(),
|
||||||
ol.TileUrlFunction.createFromTileUrlFunctions(
|
ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||||
@@ -102,7 +103,6 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
.replace('{culture}', culture);
|
.replace('{culture}', culture);
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.BingMaps}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -110,7 +110,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
*/
|
*/
|
||||||
function(tileCoord, pixelRatio, projection) {
|
function(tileCoord, pixelRatio, projection) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(
|
goog.asserts.assert(ol.proj.equivalent(
|
||||||
projection, this.getProjection()));
|
projection, sourceProjection));
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
135
src/ol/source/formatvectorsource.js
Normal file
135
src/ol/source/formatvectorsource.js
Normal 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;
|
||||||
|
};
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.source.GeoJSON');
|
goog.provide('ol.source.GeoJSON');
|
||||||
|
|
||||||
goog.require('ol.format.GeoJSON');
|
goog.require('ol.format.GeoJSON');
|
||||||
goog.require('ol.source.VectorFile');
|
goog.require('ol.source.StaticVector');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.VectorFile}
|
* @extends {ol.source.StaticVector}
|
||||||
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
||||||
* @param {olx.source.GeoJSONOptions=} opt_options Options.
|
* @param {olx.source.GeoJSONOptions=} opt_options Options.
|
||||||
* @todo stability experimental
|
* @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);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.source.GPX');
|
goog.provide('ol.source.GPX');
|
||||||
|
|
||||||
goog.require('ol.format.GPX');
|
goog.require('ol.format.GPX');
|
||||||
goog.require('ol.source.VectorFile');
|
goog.require('ol.source.StaticVector');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.VectorFile}
|
* @extends {ol.source.StaticVector}
|
||||||
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
||||||
* @param {olx.source.GPXOptions=} opt_options Options.
|
* @param {olx.source.GPXOptions=} opt_options Options.
|
||||||
* @todo stability experimental
|
* @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);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.source.IGC');
|
goog.provide('ol.source.IGC');
|
||||||
|
|
||||||
goog.require('ol.format.IGC');
|
goog.require('ol.format.IGC');
|
||||||
goog.require('ol.source.VectorFile');
|
goog.require('ol.source.StaticVector');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.VectorFile}
|
* @extends {ol.source.StaticVector}
|
||||||
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
||||||
* @param {olx.source.IGCOptions=} opt_options Options.
|
* @param {olx.source.IGCOptions=} opt_options Options.
|
||||||
* @todo stability experimental
|
* @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);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
|
|||||||
resolution);
|
resolution);
|
||||||
|
|
||||||
var loading = false;
|
var loading = false;
|
||||||
this.source_.forEachFeatureInExtent(extent,
|
this.source_.forEachFeatureInExtentAtResolution(extent, resolution,
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature} feature Feature.
|
* @param {ol.Feature} feature Feature.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.source.KML');
|
goog.provide('ol.source.KML');
|
||||||
|
|
||||||
goog.require('ol.format.KML');
|
goog.require('ol.format.KML');
|
||||||
goog.require('ol.source.VectorFile');
|
goog.require('ol.source.StaticVector');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.VectorFile}
|
* @extends {ol.source.StaticVector}
|
||||||
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
||||||
* @param {olx.source.KMLOptions=} opt_options Options.
|
* @param {olx.source.KMLOptions=} opt_options Options.
|
||||||
* @todo stability experimental
|
* @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);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.source.OSMXML');
|
goog.provide('ol.source.OSMXML');
|
||||||
|
|
||||||
goog.require('ol.format.OSMXML');
|
goog.require('ol.format.OSMXML');
|
||||||
goog.require('ol.source.VectorFile');
|
goog.require('ol.source.StaticVector');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.VectorFile}
|
* @extends {ol.source.StaticVector}
|
||||||
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
||||||
* @param {olx.source.OSMXMLOptions=} opt_options Options.
|
* @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);
|
||||||
|
|||||||
2
src/ol/source/servervectorsource.exports
Normal file
2
src/ol/source/servervectorsource.exports
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@exportSymbol ol.source.ServerVector
|
||||||
|
@exportProperty ol.source.ServerVector.prototype.readFeatures
|
||||||
99
src/ol/source/servervectorsource.js
Normal file
99
src/ol/source/servervectorsource.js
Normal 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()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
1
src/ol/source/staticvectorsource.exports
Normal file
1
src/ol/source/staticvectorsource.exports
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@exportSymbol ol.source.StaticVector
|
||||||
76
src/ol/source/staticvectorsource.js
Normal file
76
src/ol/source/staticvectorsource.js
Normal 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);
|
||||||
1
src/ol/source/tilevectorsource.exports
Normal file
1
src/ol/source/tilevectorsource.exports
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@exportSymbol ol.source.TileVector
|
||||||
245
src/ol/source/tilevectorsource.js
Normal file
245
src/ol/source/tilevectorsource.js
Normal 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));
|
||||||
|
};
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
goog.provide('ol.source.TopoJSON');
|
goog.provide('ol.source.TopoJSON');
|
||||||
|
|
||||||
goog.require('ol.format.TopoJSON');
|
goog.require('ol.format.TopoJSON');
|
||||||
goog.require('ol.source.VectorFile');
|
goog.require('ol.source.StaticVector');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.VectorFile}
|
* @extends {ol.source.StaticVector}
|
||||||
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
* @fires {@link ol.source.VectorEvent} ol.source.VectorEvent
|
||||||
* @param {olx.source.TopoJSONOptions=} opt_options Options.
|
* @param {olx.source.TopoJSONOptions=} opt_options Options.
|
||||||
* @todo stability experimental
|
* @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);
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
@exportSymbol ol.source.VectorFile
|
|
||||||
@@ -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);
|
|
||||||
};
|
|
||||||
@@ -13,6 +13,7 @@ goog.require('goog.events.Event');
|
|||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('ol.ObjectEventType');
|
goog.require('ol.ObjectEventType');
|
||||||
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.Source');
|
goog.require('ol.source.Source');
|
||||||
goog.require('ol.structs.RBush');
|
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.
|
* @return {Array.<ol.Feature>} Features.
|
||||||
* @todo stability experimental
|
* @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.
|
* @param {ol.Feature} feature Feature.
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ goog.require('ol.TileCoord');
|
|||||||
* A function that takes an {@link ol.TileCoord} for the tile coordinate,
|
* A function that takes an {@link ol.TileCoord} for the tile coordinate,
|
||||||
* a `{number}` representing the pixel ratio and an {@link ol.proj.Projection}
|
* a `{number}` representing the pixel ratio and an {@link ol.proj.Projection}
|
||||||
* for the projection as arguments and returns a `{string}` or
|
* for the projection as arguments and returns a `{string}` or
|
||||||
* undefined representing the tile URL. The this keyword inside the function
|
* undefined representing the tile URL.
|
||||||
* references the {@link ol.source.TileImage}.
|
|
||||||
*
|
*
|
||||||
* @typedef {function(this: ol.source.TileImage, ol.TileCoord,
|
* @typedef {function(ol.TileCoord, number,
|
||||||
* number, ol.proj.Projection): (string|undefined)}
|
* ol.proj.Projection): (string|undefined)}
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
ol.TileUrlFunctionType;
|
ol.TileUrlFunctionType;
|
||||||
@@ -34,7 +33,6 @@ ol.TileCoordTransformType;
|
|||||||
ol.TileUrlFunction.createFromTemplate = function(template) {
|
ol.TileUrlFunction.createFromTemplate = function(template) {
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -72,7 +70,6 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -84,15 +81,13 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
|||||||
} else {
|
} else {
|
||||||
var index =
|
var index =
|
||||||
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
||||||
return tileUrlFunctions[index].call(
|
return tileUrlFunctions[index](tileCoord, pixelRatio, projection);
|
||||||
this, tileCoord, pixelRatio, projection);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -114,7 +109,6 @@ ol.TileUrlFunction.withTileCoordTransform =
|
|||||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -124,9 +118,8 @@ ol.TileUrlFunction.withTileCoordTransform =
|
|||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return tileUrlFunction.call(
|
return tileUrlFunction(
|
||||||
this,
|
transformFn(tileCoord, projection, tmpTileCoord),
|
||||||
transformFn.call(this, tileCoord, projection, tmpTileCoord),
|
|
||||||
pixelRatio,
|
pixelRatio,
|
||||||
projection);
|
projection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,21 +49,25 @@ function parseExamples(examplePaths, callback) {
|
|||||||
tags: ''
|
tags: ''
|
||||||
};
|
};
|
||||||
var key;
|
var key;
|
||||||
|
var openTag;
|
||||||
var parser = new Parser({
|
var parser = new Parser({
|
||||||
onopentag: function(name, attrs) {
|
onopentag: function(tag, attrs) {
|
||||||
if (attrs.id in info) {
|
if (attrs.id in info) {
|
||||||
key = attrs.id;
|
key = attrs.id;
|
||||||
} else {
|
openTag = tag;
|
||||||
key = undefined;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ontext: function(text) {
|
ontext: function(text) {
|
||||||
if (key) {
|
if (key) {
|
||||||
info[key] = text.replace(/\n/g, '').trim();
|
info[key] += text.replace(/\n/g, '').trim() + ' ';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onclosetag: function(name) {
|
onclosetag: function(tag) {
|
||||||
key = undefined;
|
if (tag === openTag) {
|
||||||
|
info[key] = info[key].trim();
|
||||||
|
key = undefined;
|
||||||
|
openTag = undefined;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onerror: function(err2) {
|
onerror: function(err2) {
|
||||||
var message = 'Trouble parsing ' + examplePath + '\n' + err2.message;
|
var message = 'Trouble parsing ' + examplePath + '\n' + err2.message;
|
||||||
|
|||||||
154
test/spec/ol/format/owsformat.test.js
Normal file
154
test/spec/ol/format/owsformat.test.js
Normal 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');
|
||||||
@@ -48,6 +48,7 @@ describe('ol.layer.Layer', function() {
|
|||||||
|
|
||||||
it('provides default layerState', function() {
|
it('provides default layerState', function() {
|
||||||
expect(layer.getLayerState()).to.eql({
|
expect(layer.getLayerState()).to.eql({
|
||||||
|
layer: layer,
|
||||||
brightness: 0,
|
brightness: 0,
|
||||||
contrast: 1,
|
contrast: 1,
|
||||||
hue: 0,
|
hue: 0,
|
||||||
@@ -90,6 +91,7 @@ describe('ol.layer.Layer', function() {
|
|||||||
expect(layer.getMinResolution()).to.be(0.25);
|
expect(layer.getMinResolution()).to.be(0.25);
|
||||||
expect(layer.get('foo')).to.be(42);
|
expect(layer.get('foo')).to.be(42);
|
||||||
expect(layer.getLayerState()).to.eql({
|
expect(layer.getLayerState()).to.eql({
|
||||||
|
layer: layer,
|
||||||
brightness: 0.5,
|
brightness: 0.5,
|
||||||
contrast: 10,
|
contrast: 10,
|
||||||
hue: 180,
|
hue: 180,
|
||||||
@@ -132,6 +134,7 @@ describe('ol.layer.Layer', function() {
|
|||||||
layer.setMaxResolution(500);
|
layer.setMaxResolution(500);
|
||||||
layer.setMinResolution(0.25);
|
layer.setMinResolution(0.25);
|
||||||
expect(layer.getLayerState()).to.eql({
|
expect(layer.getLayerState()).to.eql({
|
||||||
|
layer: layer,
|
||||||
brightness: -0.7,
|
brightness: -0.7,
|
||||||
contrast: 0.3,
|
contrast: 0.3,
|
||||||
hue: -0.3,
|
hue: -0.3,
|
||||||
@@ -152,6 +155,7 @@ describe('ol.layer.Layer', function() {
|
|||||||
layer.setSaturation(-0.7);
|
layer.setSaturation(-0.7);
|
||||||
layer.setVisible(false);
|
layer.setVisible(false);
|
||||||
expect(layer.getLayerState()).to.eql({
|
expect(layer.getLayerState()).to.eql({
|
||||||
|
layer: layer,
|
||||||
brightness: 1,
|
brightness: 1,
|
||||||
contrast: 0,
|
contrast: 0,
|
||||||
hue: 42,
|
hue: 42,
|
||||||
@@ -170,6 +174,7 @@ describe('ol.layer.Layer', function() {
|
|||||||
layer.setSaturation(42);
|
layer.setSaturation(42);
|
||||||
layer.setVisible(true);
|
layer.setVisible(true);
|
||||||
expect(layer.getLayerState()).to.eql({
|
expect(layer.getLayerState()).to.eql({
|
||||||
|
layer: layer,
|
||||||
brightness: -1,
|
brightness: -1,
|
||||||
contrast: 42,
|
contrast: 42,
|
||||||
hue: -100,
|
hue: -100,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ describe('ol.layer.Group', function() {
|
|||||||
|
|
||||||
it('provides default layerState', function() {
|
it('provides default layerState', function() {
|
||||||
expect(layerGroup.getLayerState()).to.eql({
|
expect(layerGroup.getLayerState()).to.eql({
|
||||||
|
layer: layerGroup,
|
||||||
brightness: 0,
|
brightness: 0,
|
||||||
contrast: 1,
|
contrast: 1,
|
||||||
hue: 0,
|
hue: 0,
|
||||||
@@ -170,6 +171,7 @@ describe('ol.layer.Group', function() {
|
|||||||
expect(layerGroup.getMaxResolution()).to.be(500);
|
expect(layerGroup.getMaxResolution()).to.be(500);
|
||||||
expect(layerGroup.getMinResolution()).to.be(0.25);
|
expect(layerGroup.getMinResolution()).to.be(0.25);
|
||||||
expect(layerGroup.getLayerState()).to.eql({
|
expect(layerGroup.getLayerState()).to.eql({
|
||||||
|
layer: layerGroup,
|
||||||
brightness: 0.5,
|
brightness: 0.5,
|
||||||
contrast: 10,
|
contrast: 10,
|
||||||
hue: 180,
|
hue: 180,
|
||||||
@@ -212,6 +214,7 @@ describe('ol.layer.Group', function() {
|
|||||||
layerGroup.setMaxResolution(500);
|
layerGroup.setMaxResolution(500);
|
||||||
layerGroup.setMinResolution(0.25);
|
layerGroup.setMinResolution(0.25);
|
||||||
expect(layerGroup.getLayerState()).to.eql({
|
expect(layerGroup.getLayerState()).to.eql({
|
||||||
|
layer: layerGroup,
|
||||||
brightness: -0.7,
|
brightness: -0.7,
|
||||||
contrast: 0.3,
|
contrast: 0.3,
|
||||||
hue: -0.3,
|
hue: -0.3,
|
||||||
@@ -232,6 +235,7 @@ describe('ol.layer.Group', function() {
|
|||||||
layerGroup.setSaturation(-0.7);
|
layerGroup.setSaturation(-0.7);
|
||||||
layerGroup.setVisible(false);
|
layerGroup.setVisible(false);
|
||||||
expect(layerGroup.getLayerState()).to.eql({
|
expect(layerGroup.getLayerState()).to.eql({
|
||||||
|
layer: layerGroup,
|
||||||
brightness: 1,
|
brightness: 1,
|
||||||
contrast: 0,
|
contrast: 0,
|
||||||
hue: 42,
|
hue: 42,
|
||||||
@@ -250,6 +254,7 @@ describe('ol.layer.Group', function() {
|
|||||||
layerGroup.setSaturation(42);
|
layerGroup.setSaturation(42);
|
||||||
layerGroup.setVisible(true);
|
layerGroup.setVisible(true);
|
||||||
expect(layerGroup.getLayerState()).to.eql({
|
expect(layerGroup.getLayerState()).to.eql({
|
||||||
|
layer: layerGroup,
|
||||||
brightness: -1,
|
brightness: -1,
|
||||||
contrast: 42,
|
contrast: 42,
|
||||||
hue: -100,
|
hue: -100,
|
||||||
@@ -292,19 +297,10 @@ describe('ol.layer.Group', function() {
|
|||||||
|
|
||||||
describe('#getLayerStatesArray', function() {
|
describe('#getLayerStatesArray', function() {
|
||||||
|
|
||||||
var layerGroup;
|
|
||||||
var layersArray;
|
|
||||||
var layerStatesArray;
|
|
||||||
var obj;
|
|
||||||
|
|
||||||
it('returns an empty array if no layer', function() {
|
it('returns an empty array if no layer', function() {
|
||||||
layerGroup = new ol.layer.Group();
|
var layerGroup = new ol.layer.Group();
|
||||||
|
|
||||||
obj = layerGroup.getLayerStatesArray();
|
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||||
layersArray = obj.layers;
|
|
||||||
layerStatesArray = obj.layerStates;
|
|
||||||
expect(layersArray).to.be.a(Array);
|
|
||||||
expect(layersArray.length).to.be(0);
|
|
||||||
expect(layerStatesArray).to.be.a(Array);
|
expect(layerStatesArray).to.be.a(Array);
|
||||||
expect(layerStatesArray.length).to.be(0);
|
expect(layerStatesArray.length).to.be(0);
|
||||||
|
|
||||||
@@ -331,28 +327,29 @@ describe('ol.layer.Group', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not transform layerStates by default', function() {
|
it('does not transform layerStates by default', function() {
|
||||||
layerGroup = new ol.layer.Group({
|
var layerGroup = new ol.layer.Group({
|
||||||
layers: [layer1, layer2]
|
layers: [layer1, layer2]
|
||||||
});
|
});
|
||||||
|
|
||||||
obj = layerGroup.getLayerStatesArray();
|
var layerStatesArray = 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);
|
|
||||||
expect(layerStatesArray).to.be.a(Array);
|
expect(layerStatesArray).to.be.a(Array);
|
||||||
expect(layerStatesArray.length).to.be(2);
|
expect(layerStatesArray.length).to.be(2);
|
||||||
expect(layerStatesArray[0]).to.eql(layer1.getLayerState());
|
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());
|
expect(layerStatesArray[1]).to.eql(layer2.getLayerState());
|
||||||
|
|
||||||
goog.dispose(layerGroup);
|
goog.dispose(layerGroup);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('transforms layerStates correctly', function() {
|
it('transforms layerStates correctly', function() {
|
||||||
layerGroup = new ol.layer.Group({
|
var layerGroup = new ol.layer.Group({
|
||||||
layers: [layer1, layer2],
|
layers: [layer1, layer2],
|
||||||
brightness: 0.5,
|
brightness: 0.5,
|
||||||
contrast: 10,
|
contrast: 10,
|
||||||
@@ -364,11 +361,22 @@ describe('ol.layer.Group', function() {
|
|||||||
minResolution: 0.2
|
minResolution: 0.2
|
||||||
});
|
});
|
||||||
|
|
||||||
obj = layerGroup.getLayerStatesArray();
|
var layerStatesArray = layerGroup.getLayerStatesArray();
|
||||||
layersArray = obj.layers;
|
|
||||||
layerStatesArray = obj.layerStates;
|
// compare layer state to group state
|
||||||
expect(layerStatesArray[0]).to.eql(layerGroup.getLayerState());
|
var groupState, layerState;
|
||||||
expect(layerStatesArray[1]).to.eql({
|
|
||||||
|
// 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,
|
brightness: 1,
|
||||||
contrast: 100,
|
contrast: 100,
|
||||||
hue: 360,
|
hue: 360,
|
||||||
@@ -392,6 +400,7 @@ describe('ol.layer.Group', function() {
|
|||||||
|
|
||||||
goog.require('goog.dispose');
|
goog.require('goog.dispose');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
|
goog.require('goog.object');
|
||||||
goog.require('ol.ObjectEventType');
|
goog.require('ol.ObjectEventType');
|
||||||
goog.require('ol.layer.Layer');
|
goog.require('ol.layer.Layer');
|
||||||
goog.require('ol.layer.Group');
|
goog.require('ol.layer.Group');
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
describe('#emulateClick_', function() {
|
describe('#emulateClick_', function() {
|
||||||
var clock;
|
var clock;
|
||||||
var handler;
|
var handler;
|
||||||
|
var clickSpy;
|
||||||
var singleclickSpy;
|
var singleclickSpy;
|
||||||
var dblclickSpy;
|
var dblclickSpy;
|
||||||
var target;
|
var target;
|
||||||
@@ -15,6 +16,9 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
target: target
|
target: target
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
clickSpy = sinon.spy();
|
||||||
|
goog.events.listen(handler, 'click', clickSpy);
|
||||||
|
|
||||||
singleclickSpy = sinon.spy();
|
singleclickSpy = sinon.spy();
|
||||||
goog.events.listen(handler, 'singleclick', singleclickSpy);
|
goog.events.listen(handler, 'singleclick', singleclickSpy);
|
||||||
|
|
||||||
@@ -28,6 +32,17 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emulates click', 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',
|
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
|
||||||
new goog.events.BrowserEvent({
|
new goog.events.BrowserEvent({
|
||||||
type: 'mousedown',
|
type: 'mousedown',
|
||||||
@@ -54,12 +69,13 @@ describe('ol.MapBrowserEventHandler', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emulates dblclick', function() {
|
it('emulates dblclick', function() {
|
||||||
handler.emulateClick_({
|
handler.emulateClick_(new ol.pointer.PointerEvent('pointerdown',
|
||||||
type: 'mousedown',
|
new goog.events.BrowserEvent({
|
||||||
target: target,
|
type: 'mousedown',
|
||||||
clientX: 0,
|
target: target,
|
||||||
clientY: 0
|
clientX: 0,
|
||||||
});
|
clientY: 0
|
||||||
|
})));
|
||||||
expect(singleclickSpy.called).to.not.be.ok();
|
expect(singleclickSpy.called).to.not.be.ok();
|
||||||
expect(dblclickSpy.called).to.not.be.ok();
|
expect(dblclickSpy.called).to.not.be.ok();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user