Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label/Billboard/Point clustering #4240

Merged
merged 88 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
1c83762
Label clustering WIP.
bagnell Aug 18, 2016
41974df
Use browserify to create a UMD for kdbush instead of creating it manu…
bagnell Aug 18, 2016
63fef4f
Keep current clusters when possible.
bagnell Aug 19, 2016
7ff5b7f
Add semi-continuous clustering and fix labels clamped to the ground.
bagnell Aug 22, 2016
89785c7
Picking a cluster returns all clustered items.
bagnell Aug 22, 2016
93d3c76
Add label clustering to the entity layer.
bagnell Aug 23, 2016
91b3a13
Remove lower level, label only clustering.
bagnell Aug 23, 2016
7b56604
Merge branch 'master' into cluster
bagnell Aug 23, 2016
938a7fe
Billboards are managed by the cluster but not yet actually clustered.
bagnell Aug 23, 2016
13e0eaa
Re-add functionality to reuse billboards and labels.
bagnell Aug 23, 2016
b89e352
Add billboard clustering.
bagnell Aug 24, 2016
9c33907
Move point collection management to the cluster.
bagnell Aug 24, 2016
9c32a4e
Add point clustering.
bagnell Aug 24, 2016
77bdd47
Cluster entities with either a billboard or point and a label as one …
bagnell Aug 24, 2016
40a0895
Fix issue with combined labels and billboards where if all billboards…
bagnell Aug 24, 2016
84c7987
Use a better search range for the cluster.
bagnell Aug 24, 2016
8be0183
Add minimum cluster size and slightly improve clusters when zooming in.
bagnell Aug 25, 2016
dac90cb
Use original billboard/label/point instead of trying to clone them. B…
bagnell Aug 25, 2016
6f9bd2e
Fix disappearing billboards.
bagnell Aug 25, 2016
3668914
Expose properties for pixel range and minimum cluster size. Fix enabl…
bagnell Aug 25, 2016
d4cf6ac
Do not cull off-screen clusters.
bagnell Aug 25, 2016
5c88c82
Clean-up (sort of). Adds clustering per datasource. Can also have dat…
bagnell Aug 25, 2016
8485907
Fix issue with disappearing billboards when the minimum cluster size …
bagnell Aug 25, 2016
82cc9de
Add custom styling example.
bagnell Aug 26, 2016
d3f80ee
Update cluster picking.
bagnell Aug 26, 2016
ce58e3b
Add a new Sandcastle example.
bagnell Aug 26, 2016
b5eba31
Update new Sandcastle example image.
bagnell Aug 26, 2016
9e7c038
Merge branch 'cluster-master' into cluster
bagnell Aug 26, 2016
b148536
Merge branch 'cluster-master' into cluster
bagnell Aug 30, 2016
c62bef9
Fix billboard/label/point visualizer tests.
bagnell Sep 1, 2016
4428886
Fix DataSourceDisplay tests.
bagnell Sep 1, 2016
da84e50
Some fixes and added tests for clustering billboards.
bagnell Sep 1, 2016
ec1e31f
Add more tests and fix issue with label bounds.
bagnell Sep 2, 2016
dcb270a
Add custom cluster styling test.
bagnell Sep 2, 2016
ffba07c
Mark new tests as using WebGL.
bagnell Sep 2, 2016
768d7d1
Update documentation.
bagnell Sep 2, 2016
845bd88
Merge branch 'cluster-master' into cluster
bagnell Sep 2, 2016
76b23a8
Update CHANGES.md and LICENSE.md.
bagnell Sep 2, 2016
396dab4
Enable clustering by default and force a re-cluster when styling in t…
bagnell Sep 2, 2016
e70b63d
Fix toggling styling in the last commit.
bagnell Sep 2, 2016
0758daa
Reorganize code based on review.
bagnell Sep 2, 2016
8a3613d
Rename based on review.
bagnell Sep 2, 2016
9a942d2
Fix jsHint errors.
bagnell Sep 2, 2016
80830bc
Fix clustering when enabled before the first render and more updates …
bagnell Sep 6, 2016
eec3218
Add tests for getScreenSpaceBoundingBox for points, billboards, and l…
bagnell Sep 6, 2016
30eb4ef
Fix off by one error in compressing/decompressing texture coordinates.
kring Sep 19, 2016
48a4a5d
Use batch table for per instance geometry attributes.
bagnell Sep 21, 2016
a9c607f
Update getting and setting per instance geometry attributes to use ba…
bagnell Sep 21, 2016
7c45010
Merge branch 'master' into batch-table-primitive
bagnell Sep 21, 2016
28aa9bb
Fix primitives with show per instance attribute.
bagnell Sep 21, 2016
6a4e4f2
Remove pick color attribute that is now in the batch table. Remove pa…
bagnell Sep 21, 2016
3ece1b4
Merge remote-tracking branch 'origin/master' into compressedTextureCo…
kring Sep 22, 2016
6844759
Update CHANGES.md.
kring Sep 22, 2016
66b347e
Add specs.
kring Sep 22, 2016
02524f0
Fix test failures.
kring Sep 22, 2016
348e28e
Merge remote-tracking branch 'origin/master' into compressedTextureCo…
kring Sep 22, 2016
7c62d1d
Merge remote-tracking branch 'origin/master' into compressedTextureCo…
kring Sep 22, 2016
13a32ca
chore(package): update electron-prebuilt to version 1.4.1
greenkeeperio-bot Sep 22, 2016
f2eb439
Remove per instance vertex attribute packing/unpacking.
bagnell Sep 22, 2016
da76b71
Merge branch 'master' into cluster
bagnell Sep 22, 2016
16ee946
Cluster on add. Update Sandcastle example.
bagnell Sep 22, 2016
127d1c8
Remove more pack/unpack per instance attribute code.
bagnell Sep 22, 2016
3c3febc
Fix handling invalid geometry.
bagnell Sep 22, 2016
9d7f49f
Re-add per instance bounding spheres.
bagnell Sep 22, 2016
28f3b98
Fix GroundPrimitives.
bagnell Sep 22, 2016
7579b43
Fix DebugAppearance and its tests.
bagnell Sep 22, 2016
c6b7c56
Fix debug camera primitive tests
lilleyse Sep 23, 2016
bc66c6a
Merge pull request #4362 from AnalyticalGraphicsInc/fix-tests
pjcozzi Sep 23, 2016
72c7f4a
Removed deprecated castShadows and receiveShadows
lilleyse Sep 23, 2016
52066e9
Merge pull request #4364 from AnalyticalGraphicsInc/deprecate-cast-re…
pjcozzi Sep 24, 2016
c232b58
Merge branch 'master' into batch-table-primitive
bagnell Sep 26, 2016
aad9a76
Do not update batch table if there are no per instance attributes.
bagnell Sep 26, 2016
14d5021
Updates from review.
bagnell Sep 26, 2016
3c48667
Throw RuntimeErrors when trying to create a batch table but VTF isn't…
bagnell Sep 26, 2016
a1d0f2e
Document runtime exceptions.
bagnell Sep 26, 2016
18ebb49
Merge pull request #4361 from AnalyticalGraphicsInc/batch-table-primi…
pjcozzi Sep 27, 2016
4745bce
Reorder CHANGES.md for 1.26
pjcozzi Sep 27, 2016
6eb0c14
Fix removing points.
bagnell Sep 27, 2016
de012c1
Fix clustering for dynamic objects based on discussion with @mramato.…
bagnell Sep 27, 2016
2813522
chore(package): update aws-sdk to version 2.6.5
greenkeeperio-bot Sep 27, 2016
a251191
Merge pull request #4374 from AnalyticalGraphicsInc/greenkeeper-aws-s…
mramato Sep 28, 2016
a9c5989
Merge pull request #4357 from AnalyticalGraphicsInc/greenkeeper-elect…
mramato Sep 28, 2016
f7edb32
Merge remote-tracking branch 'origin/master' into compressedTextureCo…
kring Sep 28, 2016
ae118d5
Merge pull request #4355 from AnalyticalGraphicsInc/compressedTexture…
bagnell Sep 28, 2016
9cc4ed8
Update custom cluster styling.
bagnell Sep 28, 2016
2538ddf
Merge branch 'master' into cluster
bagnell Sep 28, 2016
c79c96a
Fix custom styling test.
bagnell Sep 28, 2016
3a7a39a
Update custom cluster styling callback doc.
bagnell Sep 29, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions Apps/Sandcastle/gallery/Clustering.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Cluster labels, billboards and points.">
<meta name="cesium-sandcastle-labels" content="Tutorials,Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
#toolbar {
background: rgba(42, 42, 42, 0.8);
padding: 4px;
border-radius: 4px;
}
#toolbar input {
vertical-align: middle;
padding-top: 2px;
padding-bottom: 2px;
}
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar">
<table>
<tbody><tr>
<td>Pixel Range</td>
<td>
<input type="range" min="1" max="200" step="1" data-bind="value: pixelRange, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: pixelRange">
</td>
</tr>
<tr>
<td>Minimum Cluster Size</td>
<td>
<input type="range" min="2" max="20" step="1" data-bind="value: minimumClusterSize, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: minimumClusterSize">
</td>
</tr>
<tr><td><input type="checkbox" data-bind="checked: enabled"/>Enabled</td></tr>
<tr><td><input type="checkbox" data-bind="checked: customStyle"/>Custom Styling</td></tr>
</tbody>
</table>
</div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');

var options = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas
};
var dataSourcePromise = viewer.dataSources.add(Cesium.KmlDataSource.load('../../SampleData/kml/facilities/facilities.kml', options));
dataSourcePromise.then(function(dataSource) {
var pixelRange = 15;
var minimumClusterSize = 3;
var enabled = true;

dataSource.clustering.enabled = enabled;
dataSource.clustering.pixelRange = pixelRange;
dataSource.clustering.minimumClusterSize = minimumClusterSize;

var removeListener;

var pinBuilder = new Cesium.PinBuilder();
var pin50 = pinBuilder.fromText('50+', Cesium.Color.RED, 48).toDataURL();
var pin40 = pinBuilder.fromText('40+', Cesium.Color.ORANGE, 48).toDataURL();
var pin30 = pinBuilder.fromText('30+', Cesium.Color.YELLOW, 48).toDataURL();
var pin20 = pinBuilder.fromText('20+', Cesium.Color.GREEN, 48).toDataURL();
var pin10 = pinBuilder.fromText('10+', Cesium.Color.BLUE, 48).toDataURL();

var singleDigitPins = new Array(8);
for (var i = 0; i < singleDigitPins.length; ++i) {
singleDigitPins[i] = pinBuilder.fromText('' + (i + 2), Cesium.Color.VIOLET, 48).toDataURL();
}

function customStyle() {
if (Cesium.defined(removeListener)) {
removeListener();
removeListener = undefined;
} else {
removeListener = dataSource.clustering.clusterEvent.addEventListener(function(clusteredEntities, cluster) {
cluster.label.show = false;
cluster.billboard.show = true;
cluster.billboard.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;

if (clusteredEntities.length >= 50) {
cluster.billboard.image = pin50;
} else if (clusteredEntities.length >= 40) {
cluster.billboard.image = pin40;
} else if (clusteredEntities.length >= 30) {
cluster.billboard.image = pin30;
} else if (clusteredEntities.length >= 20) {
cluster.billboard.image = pin20;
} else if (clusteredEntities.length >= 10) {
cluster.billboard.image = pin10;
} else {
cluster.billboard.image = singleDigitPins[clusteredEntities.length - 2];
}
});
}

// force a re-cluster with the new styling
var pixelRange = dataSource.clustering.pixelRange;
dataSource.clustering.pixelRange = 0;
dataSource.clustering.pixelRange = pixelRange;
}

// start with custom style
customStyle();

var viewModel = {
pixelRange: pixelRange,
minimumClusterSize: minimumClusterSize,
enabled : enabled,
customStyle : true
};
Cesium.knockout.track(viewModel);

var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);

function subscribeParameter(name) {
Cesium.knockout.getObservable(viewModel, name).subscribe(
function(newValue) {
dataSource.clustering[name] = newValue;
}
);
}

subscribeParameter('pixelRange');
subscribeParameter('minimumClusterSize');
subscribeParameter('enabled');
Cesium.knockout.getObservable(viewModel, 'customStyle').subscribe(customStyle);

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(movement) {
var pickedLabel = viewer.scene.pick(movement.position);
if (Cesium.defined(pickedLabel)) {
var ids = pickedLabel.id;
if (Cesium.isArray(ids)) {
for (var i = 0; i < ids.length; ++i) {
ids[i].label.fillColor = Cesium.Color.RED;
}
}
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
});
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/Clustering.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/development/Labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@
}
</script>
</body>
</html>
</html>
12 changes: 9 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ Change Log

### 1.26 - 2016-10-03

* Deprecated
* The `scene` parameter for creating `BillboardVisualizer`, `LabelVisualizer`, and `PointVisualizer` has been deprecated and will be removed in 1.28. Instead, pass an instance of `EntityCluster`.
* Breaking changes
* Vertex texture fetch is now required to be supported to render polylines. Maximum vertex texture image units must be greater than zero.
* Removed `castShadows` and `receiveShadows` properties from `Model`, `Primitive`, and `Globe`. Instead, use `shadows` with the `ShadowMode` enum, e.g. `model.shadows = ShadowMode.ENABLED`.
* `Viewer.terrainShadows` now uses the `ShadowMode` enum instead of a Boolean, e.g. `viewer.terrainShadows = ShadowMode.RECEIVE_ONLY`.
* Removed the default gamma correction for Bing Maps aerial imagery, because it is no longer an improvement to current versions of the tiles. To restore the previous look, set the `defaultGamma` property of your `BingMapsImageryProvider` instance to 1.3.
* Fixed billboard rotation when sized in meters. [#3979](https://github.com/AnalyticalGraphicsInc/cesium/issues/3979)
* Added `DebugCameraPrimitive` to visualize the view frustum of a camera.
* Fixed touch events for the timeline [#4305](https://github.com/AnalyticalGraphicsInc/cesium/pull/4305)
* Removed the default gamma correction for Bing Maps aerial imagery, because we no longer think it is an improvement in current versions of the tiles. To restore the previous look, set the `defaultGamma` property of your `BingMapsImageryProvider` instance to 1.3.
* Fixed timeline touch events. [#4305](https://github.com/AnalyticalGraphicsInc/cesium/pull/4305)
* Fixed a bug that could lead to incorrect terrain heights when using `HeightmapTerrainData` with an encoding in which actual heights were equal to the minimum representable height.
* Fixed a bug in `AttributeCompression.compressTextureCoordinates` and `decompressTextureCoordinates` that could cause a small inaccuracy in the encoded texture coordinates.
* Added `DebugCameraPrimitive` to visualize the view frustum of a camera.
* Added support for clustering `Billboard`, `Label` and `Point` entities. [#4240](https://github.com/AnalyticalGraphicsInc/cesium/pull/4240)

### 1.25 - 2016-09-01

Expand Down
18 changes: 18 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,24 @@ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

### kdbush

https://github.com/mourner/kdbush

> Copyright (c) 2016, Vladimir Agafonkin
>
>Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
>
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

Tests
=====

Expand Down
22 changes: 12 additions & 10 deletions Source/Core/AttributeCompression.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ define([
* @param {Cartesian3} vector The normalized vector to be compressed into 2 byte 'oct' encoding.
* @param {Cartesian2} result The 2 byte oct-encoded unit length vector.
* @returns {Cartesian2} The 2 byte oct-encoded unit length vector.
*
*
* @exception {DeveloperError} vector must be normalized.
*
*
* @see AttributeCompression.octEncodeInRange
* @see AttributeCompression.octDecode
*/
Expand Down Expand Up @@ -124,14 +124,14 @@ define([

/**
* Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.
*
*
* @param {Number} x The x component of the oct-encoded unit length vector.
* @param {Number} y The y component of the oct-encoded unit length vector.
* @param {Cartesian3} result The decoded and normalized vector.
* @returns {Cartesian3} The decoded and normalized vector.
*
*
* @exception {DeveloperError} x and y must be an unsigned normalized integer between 0 and 255.
*
*
* @see AttributeCompression.octDecodeInRange
*/
AttributeCompression.octDecode = function(x, y, result) {
Expand Down Expand Up @@ -268,7 +268,7 @@ define([
/**
* Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.
*
* @param {Cartesian2} textureCoordinates The texture coordinates to compress
* @param {Cartesian2} textureCoordinates The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.
* @returns {Number} The packed texture coordinates.
*
*/
Expand All @@ -279,8 +279,9 @@ define([
}
//>>includeEnd('debug');

var x = textureCoordinates.x === 1.0 ? 4095.0 : (textureCoordinates.x * 4096.0) | 0;
var y = textureCoordinates.y === 1.0 ? 4095.0 : (textureCoordinates.y * 4096.0) | 0;
// Move x and y to the range 0-4095;
var x = (textureCoordinates.x * 4095.0) | 0;
var y = (textureCoordinates.y * 4095.0) | 0;
return 4096.0 * x + y;
};

Expand All @@ -303,8 +304,9 @@ define([
//>>includeEnd('debug');

var temp = compressed / 4096.0;
result.x = Math.floor(temp) / 4096.0;
result.y = temp - Math.floor(temp);
var xZeroTo4095 = Math.floor(temp);
result.x = xZeroTo4095 / 4095.0;
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
return result;
};

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ define([
/**
* @private
*/
this.boundingSphereCV = undefined;
this.boundingSphereCV = options.boundingSphereCV;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/GeometryPipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ define([
var instance = instances[i];
if (defined(instance.geometry)) {
instanceGeometry.push(instance);
} else {
} else if (defined(instance.westHemisphereGeometry) && defined(instance.eastHemisphereGeometry)) {
instanceSplitGeometry.push(instance);
}
}
Expand Down
Loading