Merge remote-tracking branch 'upstream/master' into webgl-point

Conflicts:
	src/ol/style/circlestyle.js
	src/ol/style/regularshapestyle.js
	test/spec/ol/style/regularshapestyle.test.js
This commit is contained in:
Éric Lemoine
2014-12-04 12:57:46 +01:00
47 changed files with 1117 additions and 174 deletions

View File

@@ -673,8 +673,11 @@ def host_examples(t):
t.rm_rf('build/hosted/%(BRANCH)s/ol')
t.makedirs('build/hosted/%(BRANCH)s/ol')
t.cp_r('src/ol', 'build/hosted/%(BRANCH)s/ol/ol')
t.rm_rf('build/hosted/%(BRANCH)s/ol.ext')
t.cp_r('build/ol.ext', 'build/hosted/%(BRANCH)s/ol.ext')
t.run('%(PYTHON)s', closure_lib_path + '/closure/bin/build/depswriter.py',
'--root_with_prefix', 'src ../../../ol',
'--root_with_prefix', 'build/ol.ext ../../../ol.ext',
'--root', 'build/hosted/%(BRANCH)s/closure-library/closure/goog',
'--root_with_prefix', 'build/hosted/%(BRANCH)s/closure-library/'
'third_party ../../third_party',

View File

@@ -54,11 +54,25 @@ $(function () {
_onResize();
// show/hide unstable items
var links = $('a[href^="ol."]');
var unstable = $('.unstable');
var stabilityToggle = $('#stability-toggle');
stabilityToggle.change(function() {
unstable.toggleClass('hidden', this.checked);
var search = this.checked ? '' : '?unstable=true';
links.each(function(i, el) {
this.href = this.pathname + search + this.hash;
});
if (history.replaceState) {
var url = window.location.pathname + search + window.location.hash;
history.replaceState({}, '', url);
}
return false;
});
var search = window.location.search;
links.each(function(i, el) {
this.href = this.pathname + search + this.hash;
});
stabilityToggle.prop('checked', search !== '?unstable=true');
unstable.toggleClass('hidden', stabilityToggle[0].checked);
});

View File

@@ -99,7 +99,6 @@
}
.ol-compass {
display: block;
font-family: Arial;
font-weight: normal;
font-size: 1.2em;
}
@@ -222,12 +221,6 @@ button.ol-full-screen-true:after {
width: 1.8em;
}
.ol-control button,
.ol-attribution,
.ol-scale-line-inner {
font-family: 'Lucida Grande',Verdana,Geneva,Lucida,Arial,Helvetica,sans-serif;
}
.ol-overviewmap {
position: absolute;
left: 0.5em;

View File

@@ -9,7 +9,7 @@ goog.require('ol.source.TileWMS');
var layers = [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}

View File

@@ -5,7 +5,7 @@ goog.require('ol.source.ImageWMS');
var wmsSource = new ol.source.ImageWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'ne:ne'},
serverType: 'geoserver'
});

View File

@@ -5,7 +5,7 @@ goog.require('ol.source.TileWMS');
var wmsSource = new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'ne:ne'},
serverType: 'geoserver'
});

View File

@@ -0,0 +1,68 @@
<!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>Limited Layer Extent</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"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Limited layer extent</h4>
<p id="shortdesc">Restricting layer rendering to a limited extent.</p>
<div id="docs">
<p>
This example uses the <code>layer.setExtent()</code> method to
modify the extent of the overlay layer. Use the controls below
to limit rendering based on an extent.
</p>
<p>
<div class="btn-group">
<button type="button" class="btn btn-default" id="northwest">northwest</button>
<button type="button" class="btn btn-default" id="northeast">northeast</button>
<button type="button" class="btn btn-default" id="southeast">southeast</button>
<button type="button" class="btn btn-default" id="southwest">southwest</button>
<button type="button" class="btn btn-default" id="world">world</button>
</div>
</p>
<p>
See the <a href="layer-extent.js" target="_blank">layer-extent.js
source</a> for details on how this is done.
</p>
</div>
<div id="tags">extent, tilejson</div>
</div>
</div>
</div>
<script src="../resources/jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=layer-extent" type="text/javascript"></script>
</body>
</html>

50
examples/layer-extent.js Normal file
View File

@@ -0,0 +1,50 @@
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.proj');
goog.require('ol.source.TileJSON');
function transform(extent) {
return ol.proj.transformExtent(extent, 'EPSG:4326', 'EPSG:3857');
}
var extents = {
northwest: transform([-180, 0, 0, 85]),
northeast: transform([0, 0, 180, 85]),
southeast: transform([0, -85, 180, 0]),
southwest: transform([-180, -85, 0, 0]),
world: transform([-180, -85, 180, 85])
};
var base = new ol.layer.Tile({
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/' +
'mapbox.world-black.jsonp',
crossOrigin: 'anonymous'
})
});
var overlay = new ol.layer.Tile({
extent: extents.northwest,
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/' +
'mapbox.world-glass.jsonp',
crossOrigin: 'anonymous'
})
});
var map = new ol.Map({
layers: [base, overlay],
renderer: exampleNS.getRendererFromQueryString(),
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 1
})
});
for (var key in extents) {
document.getElementById(key).onclick = function(event) {
overlay.setExtent(extents[event.target.id]);
};
}

View File

@@ -0,0 +1,51 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="../css/ol.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Regular Shape 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"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<h4 id="title">Regular Shape example</h4>
<p id="shortdesc">Example of some Regular Shape styles.</p>
<div id="docs">
<p>See the <a href="regularshape.js" target="_blank">regularshape.js source</a> to see how this is done.</p>
</div>
<div id="tags">vector, symbol, regularshape, style, square, cross, star, triangle, x</div>
</div>
</div>
</div>
<script src="../resources/jquery.min.js" type="text/javascript"></script>
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
<script src="loader.js?id=regularshape" type="text/javascript"></script>
</body>
</html>

100
examples/regularshape.js Normal file
View File

@@ -0,0 +1,100 @@
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.geom.Point');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Fill');
goog.require('ol.style.RegularShape');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
var stroke = new ol.style.Stroke({color: 'black', width: 2});
var fill = new ol.style.Fill({color: 'red'});
var styles = {
'square': [new ol.style.Style({
image: new ol.style.RegularShape(
/** @type {olx.style.RegularShapeOptions} */({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
angle: Math.PI / 4
}))
})],
'triangle': [new ol.style.Style({
image: new ol.style.RegularShape(
/** @type {olx.style.RegularShapeOptions} */({
fill: fill,
stroke: stroke,
points: 3,
radius: 10,
angle: 0
}))
})],
'star': [new ol.style.Style({
image: new ol.style.RegularShape(
/** @type {olx.style.RegularShapeOptions} */({
fill: fill,
stroke: stroke,
points: 5,
radius: 10,
radius2: 4,
angle: 0
}))
})],
'cross': [new ol.style.Style({
image: new ol.style.RegularShape(
/** @type {olx.style.RegularShapeOptions} */({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
radius2: 0,
angle: 0
}))
})],
'x': [new ol.style.Style({
image: new ol.style.RegularShape(
/** @type {olx.style.RegularShapeOptions} */({
fill: fill,
stroke: stroke,
points: 4,
radius: 10,
radius2: 0,
angle: Math.PI / 4
}))
})]
};
var styleKeys = ['x', 'cross', 'star', 'triangle', 'square'];
var count = 250;
var features = new Array(count);
var e = 4500000;
for (var i = 0; i < count; ++i) {
var coordinates = [2 * e * Math.random() - e, 2 * e * Math.random() - e];
features[i] = new ol.Feature(new ol.geom.Point(coordinates));
features[i].setStyle(styles[styleKeys[Math.floor(Math.random() * 5)]]);
}
var source = new ol.source.Vector({
features: features
});
var vectorLayer = new ol.layer.Vector({
source: source
});
var map = new ol.Map({
layers: [
vectorLayer
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});

View File

@@ -20,7 +20,7 @@ var map4326 = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
@@ -41,7 +41,7 @@ var map3857 = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}

View File

@@ -13,7 +13,7 @@ goog.require('ol.tilegrid.XYZ');
var vectorSource = new ol.source.ServerVector({
format: new ol.format.GeoJSON(),
loader: function(extent, resolution, projection) {
var url = 'http://demo.opengeo.org/geoserver/wfs?service=WFS&' +
var url = 'http://demo.boundlessgeo.com/geoserver/wfs?service=WFS&' +
'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
'outputFormat=text/javascript&format_options=callback:loadFeatures' +
'&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';

View File

@@ -13,7 +13,7 @@ var layers = [
new ol.layer.Image({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.ImageWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'topp:states'},
serverType: 'geoserver'
})

View File

@@ -12,7 +12,7 @@ var layers = [
new ol.layer.Tile({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */ ({
url: 'http://demo.opengeo.org/geoserver/wms',
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {'LAYERS': 'topp:states', 'TILED': true},
serverType: 'geoserver'
}))

View File

@@ -149,7 +149,8 @@ oli.interaction.Interaction = function() {};
* through the chain of interactions. `false` means stop, `true`
* means continue.
*/
oli.interaction.Interaction.prototype.handleMapBrowserEvent = function(e) {};
oli.interaction.Interaction.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) {};
/**

View File

@@ -3569,7 +3569,11 @@ olx.source.TileImageOptions.prototype.attributions;
/**
* crossOrigin setting for image requests. Default is `null`.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api
*/
@@ -4120,7 +4124,13 @@ olx.source.OSMOptions.prototype.attributions;
/**
* crossOrigin setting for image requests. Default is `anonymous`.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
*
* Default is `anonymous`.
* @type {null|string|undefined}
* @api stable
*/
@@ -4406,7 +4416,11 @@ olx.source.ImageWMSOptions.prototype.attributions;
/**
* crossOrigin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api stable
*/
@@ -4573,7 +4587,11 @@ olx.source.ImageStaticOptions.prototype.attributions;
/**
* crossOrigin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api stable
*/
@@ -4581,7 +4599,8 @@ olx.source.ImageStaticOptions.prototype.crossOrigin;
/**
* Extent of the image.
* Extent of the image in map coordinates. This is the [left, bottom, right,
* top] map coordinates of your image.
* @type {ol.Extent}
* @api stable
*/
@@ -4589,7 +4608,7 @@ olx.source.ImageStaticOptions.prototype.imageExtent;
/**
* Size of the image.
* Size of the image in pixels.
* @type {ol.Size|undefined}
* @api stable
*/
@@ -4605,7 +4624,7 @@ olx.source.ImageStaticOptions.prototype.imageLoadFunction;
/**
* Logo.
* Optional logo.
* @type {string|olx.LogoOptions|undefined}
* @api stable
*/
@@ -4621,7 +4640,7 @@ olx.source.ImageStaticOptions.prototype.projection;
/**
* Url.
* Image URL.
* @type {string}
* @api stable
*/
@@ -4700,7 +4719,11 @@ olx.source.TileJSONOptions;
/**
* crossOrigin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api stable
*/
@@ -4769,7 +4792,11 @@ olx.source.TileWMSOptions.prototype.params;
/**
* crossOrigin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api stable
*/
@@ -5061,7 +5088,11 @@ olx.source.WMTSOptions.prototype.attributions;
/**
* crossOrigin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {string|null|undefined}
* @api
*/
@@ -5229,7 +5260,11 @@ olx.source.XYZOptions.prototype.attributions;
/**
* Cross origin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api stable
*/
@@ -5349,7 +5384,11 @@ olx.source.ZoomifyOptions.prototype.attributions;
/**
* Cross origin setting for image requests.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api stable
*/
@@ -5528,7 +5567,11 @@ olx.style.IconOptions.prototype.anchorYUnits;
/**
* crossOrigin setting for image.
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
* access pixel data with the Canvas renderer. See
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image}
* for more detail.
* @type {null|string|undefined}
* @api
*/
@@ -5621,11 +5664,13 @@ olx.style.IconOptions.prototype.src;
/**
* Specify radius for regular polygons, or radius1 and radius2 for stars.
* @typedef {{fill: (ol.style.Fill|undefined),
* points: number,
* radius: number,
* radius2: number,
* angle: number,
* radius: (number|undefined),
* radius1: (number|undefined),
* radius2: (number|undefined),
* angle: (number|undefined),
* snapToPixel: (boolean|undefined),
* stroke: (ol.style.Stroke|undefined),
* atlasManager: (ol.style.AtlasManager|undefined)}}
@@ -5652,18 +5697,24 @@ olx.style.RegularShapeOptions.prototype.points;
/**
* Shape radius.
* @type {number}
* Radius of a regular polygon.
* @type {number|undefined}
* @api
*/
olx.style.RegularShapeOptions.prototype.radius;
/**
* Shape secondary radius for drawing stars. If radius 2 is equal to radius,
* the regular shape will be a regular polygon instead of a star.
* Default value is equal to radius.
* @type {number}
* Inner radius of a star.
* @type {number|undefined}
* @api
*/
olx.style.RegularShapeOptions.prototype.radius1;
/**
* Outer radius of a star.
* @type {number|undefined}
* @api
*/
olx.style.RegularShapeOptions.prototype.radius2;
@@ -5673,7 +5724,7 @@ olx.style.RegularShapeOptions.prototype.radius2;
* Shape's rotation in radians. A value of 0 will have one of the shape's point
* facing up.
* Default value is 0.
* @type {number}
* @type {number|undefined}
* @api
*/
olx.style.RegularShapeOptions.prototype.angle;
@@ -6100,7 +6151,6 @@ olx.tilegrid.XYZOptions.prototype.tileSize;
/**
* @typedef {{resolutions: !Array.<number>}}
* @api
* @api
*/
olx.tilegrid.ZoomifyOptions;

View File

@@ -11,6 +11,10 @@ body {
.ol-attribution {
max-width: calc(100% - 3em);
}
.ol-control button, .ol-attribution, .ol-scale-line-inner {
font-family: 'Lucida Grande',Verdana,Geneva,Lucida,Arial,Helvetica,sans-serif;
}
#tags {
display: none;
}

View File

@@ -94,6 +94,8 @@ ol.color.blend = function(dst, src, opt_color) {
/**
* Return the color as an array. This function maintains a cache of calculated
* arrays which means the result should not be modified.
* @param {ol.Color|string} color Color.
* @return {ol.Color} Color.
* @api
@@ -109,6 +111,7 @@ ol.color.asArray = function(color) {
/**
* Return the color as an rgba string.
* @param {ol.Color|string} color Color.
* @return {string} Rgba string.
* @api
@@ -137,12 +140,11 @@ ol.color.equals = function(color1, color2) {
/**
* @param {string} s String.
* @param {ol.Color=} opt_color Color.
* @return {ol.Color} Color.
*/
ol.color.fromString = (
/**
* @return {function(string, ol.Color=): ol.Color}
* @return {function(string): ol.Color}
*/
function() {
@@ -169,10 +171,9 @@ ol.color.fromString = (
return (
/**
* @param {string} s String.
* @param {ol.Color=} opt_color Color.
* @return {ol.Color} Color.
*/
function(s, opt_color) {
function(s) {
var color;
if (cache.hasOwnProperty(s)) {
color = cache[s];
@@ -191,7 +192,7 @@ ol.color.fromString = (
cache[s] = color;
++cacheSize;
}
return ol.color.returnOrUpdate(color, opt_color);
return color;
});
})();
@@ -275,24 +276,6 @@ ol.color.normalize = function(color, opt_color) {
};
/**
* @param {ol.Color} color Color.
* @param {ol.Color=} opt_color Color.
* @return {ol.Color} Color.
*/
ol.color.returnOrUpdate = function(color, opt_color) {
if (goog.isDef(opt_color)) {
opt_color[0] = color[0];
opt_color[1] = color[1];
opt_color[2] = color[2];
opt_color[3] = color[3];
return opt_color;
} else {
return color;
}
};
/**
* @param {ol.Color} color Color.
* @return {string} String.

View File

@@ -6,7 +6,6 @@ goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.style');
goog.require('ol.CoordinateFormatType');
goog.require('ol.Object');
goog.require('ol.Pixel');
@@ -162,9 +161,7 @@ goog.exportProperty(
*/
ol.control.MousePosition.prototype.handleMouseMove = function(browserEvent) {
var map = this.getMap();
var eventPosition = goog.style.getRelativePosition(
browserEvent, map.getViewport());
this.lastMouseMovePixel_ = [eventPosition.x, eventPosition.y];
this.lastMouseMovePixel_ = map.getEventPixel(browserEvent.getBrowserEvent());
this.updateHTML_(this.lastMouseMovePixel_);
};

View File

@@ -100,8 +100,8 @@ ol.format.GMLBase.prototype.readFeatures_ = function(node, objectStack) {
var parsers = {};
var parsersNS = {};
parsers[featureType] = (localName == 'featureMembers') ?
ol.xml.makeArrayPusher(this.readFeature_, this) :
ol.xml.makeReplacer(this.readFeature_, this);
ol.xml.makeArrayPusher(this.readFeatureElement, this) :
ol.xml.makeReplacer(this.readFeatureElement, this);
parsersNS[goog.object.get(context, 'featureNS')] = parsers;
features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack);
}
@@ -150,9 +150,8 @@ ol.format.GMLBase.prototype.readGeometryElement = function(node, objectStack) {
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {ol.Feature} Feature.
* @private
*/
ol.format.GMLBase.prototype.readFeature_ = function(node, objectStack) {
ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
var n;
var fid = node.getAttribute('fid') ||
ol.xml.getAttributeNS(node, 'http://www.opengis.net/gml', 'id');

View File

@@ -582,7 +582,7 @@ ol.format.WKT.Parser.prototype.parse = function() {
/**
* @return {!ol.geom.Geometry|!ol.geom.GeometryCollection} The geometry.
* @return {!(ol.geom.Geometry|ol.geom.GeometryCollection)} The geometry.
* @private
*/
ol.format.WKT.Parser.prototype.parseGeometry_ = function() {

View File

@@ -0,0 +1,146 @@
goog.provide('ol.format.WMSGetFeatureInfo');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('goog.string');
goog.require('ol.format.GML');
goog.require('ol.format.GML2');
goog.require('ol.format.XMLFeature');
goog.require('ol.xml');
/**
* @classdesc
* Format for reading WMSGetFeatureInfo format. It uses
* {@link ol.format.GML2} to read features.
*
* @constructor
* @extends {ol.format.XMLFeature}
* @api
*/
ol.format.WMSGetFeatureInfo = function() {
/**
* @private
* @type {string}
*/
this.featureNS_ = 'http://mapserver.gis.umn.edu/mapserver';
/**
* @private
* @type {ol.format.GML2}
*/
this.gmlFormat_ = new ol.format.GML2();
goog.base(this);
};
goog.inherits(ol.format.WMSGetFeatureInfo, ol.format.XMLFeature);
/**
* @const
* @type {string}
* @private
*/
ol.format.WMSGetFeatureInfo.featureIdentifier_ = '_feature';
/**
* @const
* @type {string}
* @private
*/
ol.format.WMSGetFeatureInfo.layerIdentifier_ = '_layer';
/**
* @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {Array.<ol.Feature>} Features.
* @private
*/
ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
function(node, objectStack) {
node.namespaceURI = this.featureNS_;
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
var localName = ol.xml.getLocalName(node);
/** @type {Array.<ol.Feature>} */
var features = [];
if (node.childNodes.length === 0) {
return features;
}
if (localName == 'msGMLOutput') {
goog.array.forEach(node.childNodes, function(layer) {
if (layer.nodeType !== goog.dom.NodeType.ELEMENT) {
return;
}
var context = objectStack[0];
goog.asserts.assert(goog.isObject(context));
goog.asserts.assert(layer.localName.indexOf(
ol.format.WMSGetFeatureInfo.layerIdentifier_) >= 0);
var featureType = goog.string.remove(layer.localName,
ol.format.WMSGetFeatureInfo.layerIdentifier_) +
ol.format.WMSGetFeatureInfo.featureIdentifier_;
goog.object.set(context, 'featureType', featureType);
goog.object.set(context, 'featureNS', this.featureNS_);
var parsers = {};
parsers[featureType] = ol.xml.makeArrayPusher(
this.gmlFormat_.readFeatureElement, this.gmlFormat_);
var parsersNS = ol.xml.makeParsersNS(
[goog.object.get(context, 'featureNS'), null], parsers);
layer.namespaceURI = this.featureNS_;
var layerFeatures = ol.xml.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_);
if (goog.isDef(layerFeatures)) {
goog.array.extend(features, layerFeatures);
}
}, this);
}
if (localName == 'FeatureCollection') {
var gmlFeatures = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
[{}], this.gmlFormat_);
if (goog.isDef(gmlFeatures)) {
features = gmlFeatures;
}
}
return features;
};
/**
* Read all features from a WMSGetFeatureInfo response.
*
* @function
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
* @param {olx.format.ReadOptions=} opt_options Options.
* @return {Array.<ol.Feature>} Features.
* @api stable
*/
ol.format.WMSGetFeatureInfo.prototype.readFeatures;
/**
* @inheritDoc
*/
ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode =
function(node, opt_options) {
var options = {
'featureType': this.featureType,
'featureNS': this.featureNS
};
if (goog.isDef(opt_options)) {
goog.object.extend(options, this.getReadOptions(node, opt_options));
}
return this.readFeatures_(node, [options]);
};

View File

@@ -265,6 +265,7 @@ ol.geom.GeometryCollection.prototype.setGeometriesArray = function(geometries) {
/**
* @inheritDoc
* @api stable
*/
ol.geom.GeometryCollection.prototype.applyTransform = function(transformFn) {
var geometries = this.geometries_;

View File

@@ -245,6 +245,7 @@ ol.geom.SimpleGeometry.prototype.setLayout =
/**
* @inheritDoc
* @api stable
*/
ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) {
if (!goog.isNull(this.flatCoordinates)) {

View File

@@ -154,7 +154,7 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
}
} else {
// Modify the currently selected feature(s).
var /** @type {Array.<number>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ selected = [];
map.forEachFeatureAtPixel(mapBrowserEvent.pixel,
/**
@@ -169,17 +169,17 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
}
} else {
if (remove || toggle) {
deselected.push(index);
deselected.push(feature);
}
}
}, undefined, this.layerFilter_);
var i;
for (i = deselected.length - 1; i >= 0; --i) {
features.removeAt(deselected[i]);
features.remove(deselected[i]);
}
features.extend(selected);
}
return false;
return this.condition_ == ol.events.condition.mouseMove;
};

View File

@@ -214,9 +214,13 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
layerState.maxResolution, ownLayerState.maxResolution);
layerState.minResolution = Math.max(
layerState.minResolution, ownLayerState.minResolution);
if (goog.isDef(ownLayerState.extent) && goog.isDef(layerState.extent)) {
layerState.extent = ol.extent.getIntersection(
layerState.extent, ownLayerState.extent);
if (goog.isDef(ownLayerState.extent)) {
if (goog.isDef(layerState.extent)) {
layerState.extent = ol.extent.getIntersection(
layerState.extent, ownLayerState.extent);
} else {
layerState.extent = ownLayerState.extent;
}
}
}

View File

@@ -265,7 +265,7 @@ ol.Map = function(options) {
goog.events.EventType.TOUCHSTART,
goog.events.EventType.MSPOINTERDOWN,
ol.MapBrowserEvent.EventType.POINTERDOWN,
goog.events.EventType.MOUSEWHEEL
goog.userAgent.GECKO ? 'DOMMouseScroll' : 'mousewheel'
], goog.events.Event.stopPropagation);
goog.dom.appendChild(this.viewport_, this.overlayContainerStopEvent_);
@@ -592,18 +592,25 @@ ol.Map.prototype.getEventCoordinate = function(event) {
/**
* Returns the map pixel position for a browser event.
* Returns the map pixel position for a browser event relative to the viewport.
* @param {Event} event Event.
* @return {ol.Pixel} Pixel.
* @api stable
*/
ol.Map.prototype.getEventPixel = function(event) {
// goog.style.getRelativePosition is based on event.targetTouches,
// but touchend and touchcancel events have no targetTouches when
// the last finger is removed from the screen.
// So we ourselves compute the position of touch events.
// See https://github.com/google/closure-library/pull/323
if (goog.isDef(event.changedTouches)) {
// Use the offsetX and offsetY values if available.
// See http://www.w3.org/TR/cssom-view/#dom-mouseevent-offsetx and
// http://www.w3.org/TR/cssom-view/#dom-mouseevent-offsety
if (goog.isDef(event.offsetX) && goog.isDef(event.offsetY)) {
return [event.offsetX, event.offsetY];
} else if (goog.isDef(event.changedTouches)) {
// offsetX and offsetY are not defined for Touch Event
//
// goog.style.getRelativePosition is based on event.targetTouches,
// but touchend and touchcancel events have no targetTouches when
// the last finger is removed from the screen.
// So we ourselves compute the position of touch events.
// See https://github.com/google/closure-library/pull/323
var touch = event.changedTouches[0];
var viewportPosition = goog.style.getClientPosition(this.viewport_);
return [
@@ -611,6 +618,8 @@ ol.Map.prototype.getEventPixel = function(event) {
touch.clientY - viewportPosition.y
];
} else {
// Compute offsetX and offsetY values for browsers that don't implement
// cssom-view specification
var eventPosition = goog.style.getRelativePosition(event, this.viewport_);
return [eventPosition.x, eventPosition.y];
}

View File

@@ -80,6 +80,7 @@ ol.proj.EPSG3857.CODES = [
'EPSG:102113',
'EPSG:900913',
'urn:ogc:def:crs:EPSG:6.18:3:3857',
'urn:ogc:def:crs:EPSG::3857',
'http://www.opengis.net/gml/srs/epsg.xml#3857'
];

View File

@@ -59,6 +59,7 @@ ol.proj.EPSG4326.EXTENT = [-180, -90, 180, 90];
ol.proj.EPSG4326.PROJECTIONS = [
new ol.proj.EPSG4326_('CRS:84'),
new ol.proj.EPSG4326_('EPSG:4326', 'neu'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:EPSG::4326', 'neu'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.proj.EPSG4326_('urn:ogc:def:crs:OGC:2:84'),

View File

@@ -9,6 +9,7 @@ goog.require('ol.ImageState');
goog.require('ol.ViewHint');
goog.require('ol.extent');
goog.require('ol.layer.Image');
goog.require('ol.proj');
goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.Layer');
goog.require('ol.vec.Mat4');
@@ -108,8 +109,14 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection));
projection = sourceProjection;
}
image = imageSource.getImage(
renderedExtent, viewResolution, pixelRatio, viewState.projection);
renderedExtent, viewResolution, pixelRatio, projection);
if (!goog.isNull(image)) {
var imageState = image.getState();
if (imageState == ol.ImageState.IDLE) {

View File

@@ -1,8 +1,10 @@
goog.provide('ol.renderer.canvas.Layer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.vec.Mat4');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.layer.Layer');
goog.require('ol.render.Event');
goog.require('ol.render.EventType');
@@ -44,6 +46,35 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
var image = this.getImage();
if (!goog.isNull(image)) {
// clipped rendering if layer extent is set
var extent = layerState.extent;
var clipped = goog.isDef(extent);
if (clipped) {
goog.asserts.assert(goog.isDef(extent));
var topLeft = ol.extent.getTopLeft(extent);
var topRight = ol.extent.getTopRight(extent);
var bottomRight = ol.extent.getBottomRight(extent);
var bottomLeft = ol.extent.getBottomLeft(extent);
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
topLeft, topLeft);
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
topRight, topRight);
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
bottomRight, bottomRight);
ol.vec.Mat4.multVec2(frameState.coordinateToPixelMatrix,
bottomLeft, bottomLeft);
context.save();
context.beginPath();
context.moveTo(topLeft[0], topLeft[1]);
context.lineTo(topRight[0], topRight[1]);
context.lineTo(bottomRight[0], bottomRight[1]);
context.lineTo(bottomLeft[0], bottomLeft[1]);
context.clip();
}
var imageTransform = this.getImageTransform();
// for performance reasons, context.save / context.restore is not used
// to save and restore the transformation matrix and the opacity.
@@ -72,6 +103,10 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
context.setTransform(1, 0, 0, 1, 0, 0);
}
context.globalAlpha = alpha;
if (clipped) {
context.restore();
}
}
this.dispatchPostComposeEvent(context, frameState);

View File

@@ -5,16 +5,13 @@ goog.provide('ol.renderer.canvas.TileLayer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.object');
goog.require('goog.vec.Mat4');
goog.require('ol.Object');
goog.require('ol.Size');
goog.require('ol.TileRange');
goog.require('ol.TileState');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.layer.LayerProperty');
goog.require('ol.layer.Tile');
goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.Layer');
@@ -81,32 +78,10 @@ ol.renderer.canvas.TileLayer = function(mapRenderer, tileLayer) {
*/
this.renderedTiles_ = null;
/**
* @private
* @type {Array.<goog.events.Key>}
*/
this.eventKeys_ = [
goog.events.listen(
tileLayer, ol.Object.getChangeEventType(ol.layer.LayerProperty.EXTENT),
this.handleLayerExtentChanged_, false, this)
];
};
goog.inherits(ol.renderer.canvas.TileLayer, ol.renderer.canvas.Layer);
/**
* @inheritDoc
*/
ol.renderer.canvas.TileLayer.prototype.disposeInternal = function() {
for (var i = 0, ii = this.eventKeys_.length; i < ii; ++i) {
goog.events.unlistenByKey(this.eventKeys_[i]);
}
this.eventKeys_.length = 0;
goog.base(this, 'disposeInternal');
};
/**
* @inheritDoc
*/
@@ -123,19 +98,6 @@ ol.renderer.canvas.TileLayer.prototype.getImageTransform = function() {
};
/**
* Handle layer extent changes. We clear the canvas any time the layer extent
* changes.
* @private
*/
ol.renderer.canvas.TileLayer.prototype.handleLayerExtentChanged_ = function() {
if (!goog.isNull(this.context_)) {
this.context_.clearRect(0, 0, this.canvasSize_[0], this.canvasSize_[1]);
this.renderedCanvasZ_ = NaN;
}
};
/**
* @inheritDoc
*/
@@ -278,11 +240,6 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
if (z != this.renderedCanvasZ_ ||
!this.renderedCanvasTileRange_.containsTileRange(tileRange)) {
this.renderedCanvasTileRange_ = null;
// Due to limited layer extent, we may be rendering tiles on a small
// portion of the canvas.
if (z < this.renderedCanvasZ_) {
this.context_.clearRect(0, 0, canvasWidth, canvasHeight);
}
}
}
}

View File

@@ -12,6 +12,7 @@ goog.require('ol.ViewHint');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.layer.Image');
goog.require('ol.proj');
goog.require('ol.renderer.dom.Layer');
goog.require('ol.vec.Mat4');
@@ -104,8 +105,14 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection));
projection = sourceProjection;
}
var image_ = imageSource.getImage(renderedExtent, viewResolution,
frameState.pixelRatio, viewState.projection);
frameState.pixelRatio, projection);
if (!goog.isNull(image_)) {
var imageState = image_.getState();
if (imageState == ol.ImageState.IDLE) {

View File

@@ -12,6 +12,7 @@ goog.require('ol.ImageState');
goog.require('ol.ViewHint');
goog.require('ol.extent');
goog.require('ol.layer.Image');
goog.require('ol.proj');
goog.require('ol.renderer.webgl.Layer');
@@ -124,8 +125,14 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection));
projection = sourceProjection;
}
var image_ = imageSource.getImage(renderedExtent, viewResolution,
frameState.pixelRatio, viewState.projection);
frameState.pixelRatio, projection);
if (!goog.isNull(image_)) {
var imageState = image_.getState();
if (imageState == ol.ImageState.IDLE) {

View File

@@ -48,12 +48,14 @@ 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`.
* @param {function(this: T, Array.<ol.Feature>)} success Success Callback.
* @param {function(this: T)} error Error callback.
* @param {T} thisArg Value to use as `this` when executing `success` or
* `error`.
* @template T
*/
ol.source.FormatVector.prototype.loadFeaturesFromURL =
function(url, callback, thisArg) {
function(url, success, error, thisArg) {
var xhrIo = new goog.net.XhrIo();
var type = this.format.getType();
var responseType;
@@ -97,13 +99,13 @@ ol.source.FormatVector.prototype.loadFeaturesFromURL =
goog.asserts.fail();
}
if (goog.isDefAndNotNull(source)) {
callback.call(thisArg, this.readFeatures(source));
success.call(thisArg, this.readFeatures(source));
} else {
this.setState(ol.source.State.ERROR);
goog.asserts.fail();
}
} else {
this.setState(ol.source.State.ERROR);
error.call(thisArg);
}
goog.dispose(xhrIo);
}, false, this);

View File

@@ -10,8 +10,7 @@ goog.require('ol.source.Image');
/**
* @classdesc
* An image source for 'static', that is, non-georeferenced, images.
* See examples/static-image for example.
* A layer source for displaying a single, static image.
*
* @constructor
* @extends {ol.source.Image}

View File

@@ -56,7 +56,7 @@ ol.source.MapQuest.TILE_ATTRIBUTION = new ol.Attribution({
*/
ol.source.MapQuestConfig = {
'osm': {
maxZoom: 28,
maxZoom: 19,
attributions: [
ol.source.MapQuest.TILE_ATTRIBUTION,
ol.source.OSM.ATTRIBUTION

View File

@@ -48,13 +48,15 @@ ol.source.StaticVector = function(options) {
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
this.setState(ol.source.State.LOADING);
if (goog.isDef(options.url)) {
this.loadFeaturesFromURL(options.url, this.onFeaturesLoaded_, this);
this.loadFeaturesFromURL(options.url,
this.onFeaturesLoadedSuccess_, this.onFeaturesLoadedError_, 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], this.onFeaturesLoaded_, this);
this.loadFeaturesFromURL(urls[i],
this.onFeaturesLoadedSuccess_, this.onFeaturesLoadedError_, this);
}
}
}
@@ -63,11 +65,19 @@ ol.source.StaticVector = function(options) {
goog.inherits(ol.source.StaticVector, ol.source.FormatVector);
/**
* @private
*/
ol.source.StaticVector.prototype.onFeaturesLoadedError_ = function() {
this.setState(ol.source.State.ERROR);
};
/**
* @param {Array.<ol.Feature>} features Features.
* @private
*/
ol.source.StaticVector.prototype.onFeaturesLoaded_ = function(features) {
ol.source.StaticVector.prototype.onFeaturesLoadedSuccess_ = function(features) {
this.addFeaturesInternal(features);
this.setState(ol.source.State.READY);
};

View File

@@ -1,6 +1,7 @@
goog.provide('ol.source.TileVector');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.object');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
@@ -91,6 +92,48 @@ ol.source.TileVector.prototype.clear = function() {
ol.source.TileVector.prototype.forEachFeature = goog.abstractMethod;
/**
* Iterate through all features whose geometries contain the provided
* coordinate at the provided resolution, calling the callback with each
* feature. If the callback returns a "truthy" value, iteration will stop and
* the function will return the same value.
*
* @param {ol.Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @param {function(this: T, ol.Feature): S} callback Called with each feature
* whose goemetry contains the provided coordinate.
* @param {T=} opt_this The object to use as `this` in the callback.
* @return {S|undefined} The return value from the last call to the callback.
* @template T,S
*/
ol.source.TileVector.prototype.forEachFeatureAtCoordinateAndResolution =
function(coordinate, resolution, callback, opt_this) {
var tileGrid = this.tileGrid_;
var tiles = this.tiles_;
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate,
resolution);
var tileKey = this.getTileKeyZXY_(tileCoord[0], tileCoord[1], tileCoord[2]);
var features = tiles[tileKey];
if (goog.isDef(features)) {
var i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
var geometry = feature.getGeometry();
goog.asserts.assert(goog.isDefAndNotNull(geometry));
if (geometry.containsCoordinate(coordinate)) {
var result = callback.call(opt_this, feature);
if (result) {
return result;
}
}
}
}
return undefined;
};
/**
* @inheritDoc
*/
@@ -141,6 +184,7 @@ ol.source.TileVector.prototype.getExtent = goog.abstractMethod;
/**
* @inheritDoc
* @api
*/
ol.source.TileVector.prototype.getFeatures = function() {
var tiles = this.tiles_;
@@ -153,6 +197,28 @@ ol.source.TileVector.prototype.getFeatures = function() {
};
/**
* Get all features whose geometry intersects the provided coordinate for the
* provided resolution.
* @param {ol.Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
* @return {Array.<ol.Feature>} Features.
* @api
*/
ol.source.TileVector.prototype.getFeaturesAtCoordinateAndResolution =
function(coordinate, resolution) {
var features = [];
this.forEachFeatureAtCoordinateAndResolution(coordinate, resolution,
/**
* @param {ol.Feature} feature Feature.
*/
function(feature) {
features.push(feature);
});
return features;
};
/**
* @inheritDoc
*/
@@ -184,6 +250,15 @@ ol.source.TileVector.prototype.loadFeatures =
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
var tileCoord = [z, 0, 0];
var x, y;
/**
* @param {string} tileKey Tile key.
* @param {Array.<ol.Feature>} features Features.
* @this {ol.source.TileVector}
*/
function success(tileKey, features) {
tiles[tileKey] = features;
this.setState(ol.source.State.READY);
}
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
var tileKey = this.getTileKeyZXY_(z, x, y);
@@ -195,16 +270,8 @@ ol.source.TileVector.prototype.loadFeatures =
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);
this.loadFeaturesFromURL(url, goog.partial(success, tileKey),
goog.nullFunction, this);
}
}
}

View File

@@ -68,7 +68,6 @@ ol.source.WMTS = function(options) {
var context = {
'Layer': options.layer,
'style': options.style,
'Style': options.style,
'TileMatrixSet': options.matrixSet
};

View File

@@ -4,6 +4,7 @@ goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('ol.color');
goog.require('ol.has');
goog.require('ol.render.canvas');
goog.require('ol.structs.IHasChecksum');
goog.require('ol.style.Fill');
@@ -243,7 +244,7 @@ ol.style.Circle.prototype.unlistenImageChange = goog.nullFunction;
/**
* @typedef {{strokeStyle: (string|undefined), strokeWidth: number,
* size: number}}
* size: number, lineDash: Array.<number>}}
*/
ol.style.Circle.RenderOptions;
@@ -253,7 +254,10 @@ ol.style.Circle.RenderOptions;
* @param {ol.style.AtlasManager|undefined} atlasManager
*/
ol.style.Circle.prototype.render_ = function(atlasManager) {
var strokeStyle, strokeWidth = 0, imageSize;
var imageSize;
var lineDash = null;
var strokeStyle;
var strokeWidth = 0;
if (!goog.isNull(this.stroke_)) {
strokeStyle = ol.color.asString(this.stroke_.getColor());
@@ -261,15 +265,21 @@ ol.style.Circle.prototype.render_ = function(atlasManager) {
if (!goog.isDef(strokeWidth)) {
strokeWidth = ol.render.canvas.defaultLineWidth;
}
lineDash = this.stroke_.getLineDash();
if (!ol.has.CANVAS_LINE_DASH) {
lineDash = null;
}
}
var size = 2 * (this.radius_ + strokeWidth) + 1;
/** @type {ol.style.Circle.RenderOptions} */
var renderOptions = {
strokeStyle: strokeStyle,
strokeWidth: strokeWidth,
size: size
size: size,
lineDash: lineDash
};
if (!goog.isDef(atlasManager)) {
@@ -355,6 +365,9 @@ ol.style.Circle.prototype.draw_ = function(renderOptions, context, x, y) {
if (!goog.isNull(this.stroke_)) {
context.strokeStyle = renderOptions.strokeStyle;
context.lineWidth = renderOptions.strokeWidth;
if (!goog.isNull(renderOptions.lineDash)) {
context.setLineDash(renderOptions.lineDash);
}
context.stroke();
}
context.closePath();
@@ -412,6 +425,9 @@ ol.style.Circle.prototype.drawHitDetectionCanvas_ =
if (!goog.isNull(this.stroke_)) {
context.strokeStyle = renderOptions.strokeStyle;
context.lineWidth = renderOptions.strokeWidth;
if (!goog.isNull(renderOptions.lineDash)) {
context.setLineDash(renderOptions.lineDash);
}
context.stroke();
}
context.closePath();

View File

@@ -4,6 +4,7 @@ goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('ol.color');
goog.require('ol.has');
goog.require('ol.render.canvas');
goog.require('ol.style.Fill');
goog.require('ol.style.Image');
@@ -14,7 +15,9 @@ goog.require('ol.style.Stroke');
/**
* @classdesc
* Set regular shape style for vector features.
* Set regular shape style for vector features. The resulting shape will be
* a regular polygon when `radius` is provided, or a star when `radius1` and
* `radius2` are provided.
*
* @constructor
* @param {olx.style.RegularShapeOptions=} opt_options Options.
@@ -68,18 +71,22 @@ ol.style.RegularShape = function(opt_options) {
*/
this.points_ = options.points;
goog.asserts.assert(goog.isDef(options.radius) ||
goog.isDef(options.radius1));
/**
* @private
* @type {number}
*/
this.radius_ = options.radius;
this.radius_ = /** @type {number} */ (goog.isDef(options.radius) ?
options.radius : options.radius1);
/**
* @private
* @type {number}
*/
this.radius2_ =
goog.isDef(options.radius2) ? options.radius2 : options.radius;
goog.isDef(options.radius2) ? options.radius2 : this.radius_;
/**
* @private
@@ -222,6 +229,15 @@ ol.style.RegularShape.prototype.getRadius = function() {
};
/**
* @return {number} Radius2.
* @api
*/
ol.style.RegularShape.prototype.getRadius2 = function() {
return this.radius2_;
};
/**
* @inheritDoc
* @api
@@ -260,7 +276,7 @@ ol.style.RegularShape.prototype.unlistenImageChange = goog.nullFunction;
/**
* @typedef {{strokeStyle: (string|undefined), strokeWidth: number,
* size: number}}
* size: number, lineDash: Array.<number>}}
*/
ol.style.RegularShape.RenderOptions;
@@ -270,7 +286,10 @@ ol.style.RegularShape.RenderOptions;
* @param {ol.style.AtlasManager|undefined} atlasManager
*/
ol.style.RegularShape.prototype.render_ = function(atlasManager) {
var strokeStyle, strokeWidth = 0, imageSize;
var imageSize;
var lineDash = null;
var strokeStyle;
var strokeWidth = 0;
if (!goog.isNull(this.stroke_)) {
strokeStyle = ol.color.asString(this.stroke_.getColor());
@@ -278,6 +297,10 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
if (!goog.isDef(strokeWidth)) {
strokeWidth = ol.render.canvas.defaultLineWidth;
}
lineDash = this.stroke_.getLineDash();
if (!ol.has.CANVAS_LINE_DASH) {
lineDash = null;
}
}
var size = 2 * (this.radius_ + strokeWidth) + 1;
@@ -286,7 +309,8 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
var renderOptions = {
strokeStyle: strokeStyle,
strokeWidth: strokeWidth,
size: size
size: size,
lineDash: lineDash
};
if (!goog.isDef(atlasManager)) {
@@ -379,6 +403,9 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
if (!goog.isNull(this.stroke_)) {
context.strokeStyle = renderOptions.strokeStyle;
context.lineWidth = renderOptions.strokeWidth;
if (!goog.isNull(renderOptions.lineDash)) {
context.setLineDash(renderOptions.lineDash);
}
context.stroke();
}
context.closePath();
@@ -444,6 +471,9 @@ ol.style.RegularShape.prototype.drawHitDetectionCanvas_ =
if (!goog.isNull(this.stroke_)) {
context.strokeStyle = renderOptions.strokeStyle;
context.lineWidth = renderOptions.strokeWidth;
if (!goog.isNull(renderOptions.lineDash)) {
context.setLineDash(renderOptions.lineDash);
}
context.stroke();
}
context.closePath();

View File

@@ -2,6 +2,7 @@ goog.provide('ol.tilegrid.TileGrid');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.TileCoord');
@@ -101,12 +102,16 @@ ol.tilegrid.TileGrid.tmpTileCoord_ = [0, 0, 0];
/**
* Returns the identity function. May be overridden in subclasses.
* @param {{extent: (ol.Extent|undefined),
* wrapX: (boolean|undefined)}=} opt_options Options.
* @return {function(ol.TileCoord, ol.proj.Projection, ol.TileCoord=):
* ol.TileCoord} Tile coordinate transform.
*/
ol.tilegrid.TileGrid.prototype.createTileCoordTransform = goog.abstractMethod;
ol.tilegrid.TileGrid.prototype.createTileCoordTransform =
function(opt_options) {
return goog.functions.identity;
};
/**
@@ -300,6 +305,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent =
* @param {number} resolution Resolution.
* @param {ol.TileCoord=} opt_tileCoord Destination ol.TileCoord object.
* @return {ol.TileCoord} Tile coordinate.
* @api
*/
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(
coordinate, resolution, opt_tileCoord) {
@@ -346,6 +352,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
* @param {number} z Z.
* @param {ol.TileCoord=} opt_tileCoord Destination ol.TileCoord object.
* @return {ol.TileCoord} Tile coordinate.
* @api
*/
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ =
function(coordinate, z, opt_tileCoord) {

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<msGMLOutput xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ADCP_2001_layer>
<gml:name>ADCP de coque 2001</gml:name>
<ADCP_2001_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:3857">
<gml:coordinates>-531138.686422,5386348.414671 -117252.819653,6144475.186022</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FID>1071</FID>
<NO_CAMPAGNE>1020050</NO_CAMPAGNE>
<NOM_CAMPAGNE>ITSAS II</NOM_CAMPAGNE>
<NAUTILUS_CAMPAGNE>http://www.ifremer.fr/sismerData/jsp/visualisationMetadata2.jsp?strPortail=ifremer&amp;langue=FR&amp;pageOrigine=CAM&amp;cle1=FI352001020050</NAUTILUS_CAMPAGNE>
<FICHIER>ITSASII_BB150_0_osite.nc</FICHIER>
<NAUTILUS_DATA>http://www.ifremer.fr/sismerData/jsp/visualisationMetadata3.jsp?strPortail=ifremer&amp;langue=FR&amp;pageOrigine=CS&amp;cle1=71053_1&amp;cle2=ADCP01</NAUTILUS_DATA>
</ADCP_2001_feature>
<ADCP_2001_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:3857">
<gml:coordinates>-531138.686422,5386348.414671 -117252.819653,6144475.186022</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FID>22431</FID>
<NO_CAMPAGNE>1020050</NO_CAMPAGNE>
<NOM_CAMPAGNE>ITSAS II</NOM_CAMPAGNE>
<NAUTILUS_CAMPAGNE>http://www.ifremer.fr/sismerData/jsp/visualisationMetadata2.jsp?strPortail=ifremer&amp;langue=FR&amp;pageOrigine=CAM&amp;cle1=FI352001020050</NAUTILUS_CAMPAGNE>
<FICHIER>ITSASII_BB150_figures.tar</FICHIER>
<NAUTILUS_DATA>http://www.ifremer.fr/sismerData/jsp/visualisationMetadata3.jsp?strPortail=ifremer&amp;langue=FR&amp;pageOrigine=CS&amp;cle1=108842_2&amp;cle2=ADCP01</NAUTILUS_DATA>
</ADCP_2001_feature>
<ADCP_2001_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:3857">
<gml:coordinates>-531138.686422,5386348.414671 -117252.819653,6144475.186022</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FID>22432</FID>
<NO_CAMPAGNE>1020050</NO_CAMPAGNE>
<NOM_CAMPAGNE>ITSAS II</NOM_CAMPAGNE>
<NAUTILUS_CAMPAGNE>http://www.ifremer.fr/sismerData/jsp/visualisationMetadata2.jsp?strPortail=ifremer&amp;langue=FR&amp;pageOrigine=CAM&amp;cle1=FI352001020050</NAUTILUS_CAMPAGNE>
<FICHIER>ITSASII_BB150_0_fhv12.nc</FICHIER>
<NAUTILUS_DATA>http://www.ifremer.fr/sismerData/jsp/visualisationMetadata3.jsp?strPortail=ifremer&amp;langue=FR&amp;pageOrigine=CS&amp;cle1=108842_3&amp;cle2=ADCP01</NAUTILUS_DATA>
</ADCP_2001_feature>
</ADCP_2001_layer>
</msGMLOutput>

View File

@@ -0,0 +1,207 @@
goog.provide('ol.test.format.WMSGetFeatureInfo');
describe('ol.format.WMSGetFeatureInfo', function() {
describe('#readFormat', function() {
describe('read Features', function() {
var features;
before(function(done) {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function(data) {
try {
features = new ol.format.WMSGetFeatureInfo().readFeatures(data);
} catch (e) {
done(e);
}
done();
});
});
after(function() {
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', undefined);
});
it('creates 3 features', function() {
expect(features).to.have.length(3);
});
it('creates a feature for 1071', function() {
var feature = features[0];
expect(feature.getId()).to.be(undefined);
expect(feature.get('FID')).to.equal('1071');
expect(feature.get('NO_CAMPAGNE')).to.equal('1020050');
});
it('read boundedBy but no geometry', function() {
var feature = features[0];
expect(feature.getGeometry()).to.be(undefined);
expect(feature.get('boundedBy')).to.eql(
[-531138.686422, 5386348.414671, -117252.819653, 6144475.186022]);
});
it('read empty response', function() {
// read empty response
var text = '<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <AAA64_layer>' +
' </AAA64_layer>' +
'</msGMLOutput>';
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
expect(features.length).to.be(0);
});
it('read empty attributes', function() {
text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <AAA64_layer>' +
' <AAA64_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:4326">' +
' <gml:coordinates>' +
' 107397.266000,460681.063000 116568.188000,480609.250000' +
' </gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <FOO>bar</FOO>' +
' <EMPTY></EMPTY>' +
' </AAA64_feature>' +
' </AAA64_layer>' +
'</msGMLOutput>';
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
expect(features.length).to.be(1);
expect(features[0].get('FOO')).to.be('bar');
// FIXME is that really wanted ?
expect(features[0].get('EMPTY')).to.be(undefined);
});
it('read features from multiple layers', function() {
text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <AAA64_layer>' +
' <AAA64_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:4326">' +
' <gml:coordinates>' +
' 129799.109000,467950.250000 133199.906000,468904.063000' +
' </gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <OBJECTID>287</OBJECTID>' +
' <ROUTE>N403</ROUTE>' +
' <ROUTE_CH>#N403</ROUTE_CH>' +
' <COUNT>1</COUNT>' +
' <BEHEERDER>P</BEHEERDER>' +
' <LENGTH>4091.25</LENGTH>' +
' <SHAPE>&lt;shape&gt;</SHAPE>' +
' <SE_ANNO_CAD_DATA>&lt;null&gt;</SE_ANNO_CAD_DATA>' +
' </AAA64_feature>' +
' </AAA64_layer>' +
' <AAA62_layer>' +
' <AAA62_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:4326">' +
' <gml:coordinates>' +
' 129936.000000,468362.000000 131686.000000,473119.000000' +
' </gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <OBJECTID>1251</OBJECTID>' +
' <VWK_ID>1515</VWK_ID>' +
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
' <VWJ_ID_END>1309</VWJ_ID_END>' +
' <VAKTYPE>D</VAKTYPE>' +
' <VRT_CODE>227</VRT_CODE>' +
' <VRT_NAAM>Vecht</VRT_NAAM>' +
' <VWG_NR>2</VWG_NR>' +
' <VWG_NAAM>Vecht</VWG_NAAM>' +
' <BEGKM>18.25</BEGKM>' +
' <ENDKM>23.995</ENDKM>' +
' <LENGTH>5745.09</LENGTH>' +
' <SHAPE>&lt;shape&gt;</SHAPE>' +
' <SE_ANNO_CAD_DATA>&lt;null&gt;</SE_ANNO_CAD_DATA>' +
' </AAA62_feature>' +
' </AAA62_layer>' +
'</msGMLOutput>';
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
expect(features.length).to.be(2);
expect(features[0].get('OBJECTID')).to.be('287');
expect(features[1].get('OBJECTID')).to.be('1251');
});
it('read geoservers response', function() {
text =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"' +
' xmlns:wfs="http://www.opengis.net/wfs"' +
' xmlns:opengeo="http://opengeo.org"' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xsi:schemaLocation="http://opengeo.org ' +
' http://demo.opengeo.org:80/geoserver/wfs?service=WFS&amp;' +
'version=1.0.0&amp;request=DescribeFeatureType&amp;' +
'typeName=opengeo:roads http://www.opengis.net/wfs ' +
' http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/' +
'WFS-basic.xsd">' +
' <gml:boundedBy>' +
' <gml:Box' +
' srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">' +
' <gml:coordinates xmlns:gml="http://www.opengis.net/gml"' +
' decimal="." cs="," ts=" ">' +
'591943.9375,4925605 593045.625,4925845' +
' </gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <gml:featureMember>' +
' <opengeo:roads fid="roads.90">' +
' <opengeo:cat>3</opengeo:cat>' +
' <opengeo:label>secondary highway, hard surface' +
' </opengeo:label>' +
' <opengeo:the_geom>' +
' <gml:MultiLineString' +
' srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">' +
' <gml:lineStringMember>' +
' <gml:LineString>' +
' <gml:coordinates xmlns:gml="http://www.opengis.net/gml"' +
' decimal="." cs="," ts=" ">' +
'593045.60746465,4925605.0059156 593024.32382915,4925606.79305411' +
' 592907.54863574,4925624.85647524 592687.35111096,' +
'4925670.76834012 592430.76279218,4925678.79393165' +
' 592285.97636109,4925715.70811767 592173.39165655,' +
'4925761.83511156 592071.1753393,4925793.95523514' +
' 591985.96972625,4925831.59842486' +
' 591943.98769455,4925844.93220071' +
' </gml:coordinates>' +
' </gml:LineString>' +
' </gml:lineStringMember>' +
' </gml:MultiLineString>' +
' </opengeo:the_geom>' +
' </opengeo:roads>' +
' </gml:featureMember>' +
'</wfs:FeatureCollection>';
var features = new ol.format.WMSGetFeatureInfo().readFeatures(text);
expect(features.length).to.be(1);
expect(features[0].get('cat')).to.be('3');
expect(features[0].getGeometry().getType()).to.be('MultiLineString');
});
});
});
});
goog.require('goog.dom');
goog.require('ol.format.WMSGetFeatureInfo');

View File

@@ -382,6 +382,12 @@ describe('ol.layer.Group', function() {
maxResolution: 500,
minResolution: 0.25
});
var layer3 = new ol.layer.Layer({
source: new ol.source.Source({
projection: 'EPSG:4326'
}),
extent: [-5, -2, 5, 2]
});
it('does not transform layerStates by default', function() {
var layerGroup = new ol.layer.Group({
@@ -405,6 +411,29 @@ describe('ol.layer.Group', function() {
goog.dispose(layerGroup);
});
it('uses the layer group extent if layer has no extent', function() {
var groupExtent = [-10, -5, 10, 5];
var layerGroup = new ol.layer.Group({
extent: groupExtent,
layers: [layer1]
});
var layerStatesArray = layerGroup.getLayerStatesArray();
expect(layerStatesArray[0].extent).to.eql(groupExtent);
goog.dispose(layerGroup);
});
it('uses the intersection of group and child extent', function() {
var groupExtent = [-10, -5, 10, 5];
var layerGroup = new ol.layer.Group({
extent: groupExtent,
layers: [layer3]
});
var layerStatesArray = layerGroup.getLayerStatesArray();
expect(layerStatesArray[0].extent).to.eql(
ol.extent.getIntersection(layer3.getExtent(), groupExtent));
goog.dispose(layerGroup);
});
it('transforms layerStates correctly', function() {
var layerGroup = new ol.layer.Group({
layers: [layer1, layer2],
@@ -451,6 +480,7 @@ describe('ol.layer.Group', function() {
goog.dispose(layer1);
goog.dispose(layer2);
goog.dispose(layer3);
});
@@ -460,6 +490,7 @@ goog.require('goog.dispose');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol.ObjectEventType');
goog.require('ol.extent');
goog.require('ol.layer.Layer');
goog.require('ol.layer.Group');
goog.require('ol.source.Source');

View File

@@ -1,10 +1,43 @@
goog.provide('ol.test.style.RegularShape');
describe('ol.style.RegularShape', function() {
describe('#constructor', function() {
it('can use radius', function() {
var style = new ol.style.RegularShape({
radius: 5,
radius2: 10
});
expect(style.getRadius()).to.eql(5);
expect(style.getRadius2()).to.eql(10);
});
it('can use radius1 as an alias for radius', function() {
var style = new ol.style.RegularShape({
radius1: 5,
radius2: 10
});
expect(style.getRadius()).to.eql(5);
expect(style.getRadius2()).to.eql(10);
});
it('will use radius for radius2 if radius2 not defined', function() {
var style = new ol.style.RegularShape({
radius: 5
});
expect(style.getRadius()).to.eql(5);
expect(style.getRadius2()).to.eql(5);
});
it('will use radius1 for radius2 if radius2 not defined', function() {
var style = new ol.style.RegularShape({
radius1: 5
});
expect(style.getRadius()).to.eql(5);
expect(style.getRadius2()).to.eql(5);
});
it('creates a canvas if no atlas is used (no fill-style)', function() {
var style = new ol.style.RegularShape({radius: 10});
expect(style.getImage()).to.be.an(HTMLCanvasElement);
@@ -79,18 +112,26 @@ describe('ol.style.RegularShape', function() {
describe('#getChecksum', function() {
it('calculates the same hash code for default options', function() {
var style1 = new ol.style.RegularShape();
var style2 = new ol.style.RegularShape();
expect(style1.getChecksum()).to.eql(style2.getChecksum());
});
it('calculates not the same hash code (radius)', function() {
var style1 = new ol.style.RegularShape({
radius: 4,
radius2: 5
});
var style2 = new ol.style.RegularShape({
radius: 5
radius: 3,
radius2: 5
});
expect(style1.getChecksum()).to.not.eql(style2.getChecksum());
});
it('calculates not the same hash code (radius2)', function() {
var style1 = new ol.style.RegularShape({
radius: 4,
radius2: 5
});
var style2 = new ol.style.RegularShape({
radius: 4,
radius2: 6
});
expect(style1.getChecksum()).to.not.eql(style2.getChecksum());
});