Skip to content

Commit

Permalink
Merge pull request #4459 from AnalyticalGraphicsInc/no-clamp
Browse files Browse the repository at this point in the history
Don't clamp KML or GeoJSON billboards and labels if `clampToGround` is false.
  • Loading branch information
Tom Fili authored Oct 20, 2016
2 parents 73de148 + 12274ea commit bc67845
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Change Log
* Fixed a bug affected models with multiple meshes without indices. [#4237](https://github.com/AnalyticalGraphicsInc/cesium/issues/4237)
* Fixed a glTF transparency bug where `blendFuncSeparate` parameters were loaded in the wrong order. [#4435](https://github.com/AnalyticalGraphicsInc/cesium/pull/4435)
* Fixed a bug where creating a custom geometry with attributes and indices that have values that are not a typed array would cause a crash. [#4419](https://github.com/AnalyticalGraphicsInc/cesium/pull/4419)
* `KmlDataSource` and `GeoJsonDataSource` were not honoring the `clampToGround` option for billboards and labels and was instead always clamping, reducing performance in cases when it was unneeded.
* Fixed a bug with rotated, textured rectangles. [#4430](https://github.com/AnalyticalGraphicsInc/cesium/pull/4430)
* Fixed a bug when morphing from 2D to 3D. [#4388](https://github.com/AnalyticalGraphicsInc/cesium/pull/4388)
* Fixed a bug where when KML features had duplicate IDs, only one was drawn. [#3941](https://github.com/AnalyticalGraphicsInc/cesium/issues/3941)
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/GeoJsonDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ define([
billboard.verticalOrigin = new ConstantProperty(VerticalOrigin.BOTTOM);

// Clamp to ground if there isn't a height specified
if (coordinates.length === 2) {
if (coordinates.length === 2 && options.clampToGround) {
billboard.heightReference = HeightReference.CLAMP_TO_GROUND;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ define([
}
}

if (defined(heightReference)) {
if (defined(heightReference) && dataSource._clampToGround) {
billboard.heightReference = heightReference;
label.heightReference = heightReference;
}
Expand Down
28 changes: 22 additions & 6 deletions Specs/DataSources/KmlDataSourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2192,15 +2192,19 @@ defineSuite([
});
});

it('Geometry Point: sets heightReference to clampToGround (the default)', function() {
it('Geometry Point: sets heightReference to clampToGround', function() {
var kml = '<?xml version="1.0" encoding="UTF-8"?>\
<Placemark>\
<Point>\
<coordinates>1,2,3</coordinates>\
</Point>\
</Placemark>';

return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) {
return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), {
camera : options.camera,
canvas : options.canvas,
clampToGround : true
}).then(function(dataSource) {
var entities = dataSource.entities.values;
expect(entities.length).toEqual(1);
expect(entities[0].billboard.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND);
Expand Down Expand Up @@ -2705,7 +2709,7 @@ defineSuite([
});
});

it('Geometry gx:Track: sets position and availability (clampToGround default)', function() {
it('Geometry gx:Track: sets position and availability', function() {
var kml = '<?xml version="1.0" encoding="UTF-8"?>\
<Placemark xmlns="http://www.opengis.net/kml/2.2"\
xmlns:gx="http://www.google.com/kml/ext/2.2">\
Expand All @@ -2719,7 +2723,11 @@ defineSuite([
</gx:Track>\
</Placemark>';

return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) {
return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), {
camera : options.camera,
canvas : options.canvas,
clampToGround : true
}).then(function(dataSource) {
var time1 = JulianDate.fromIso8601('2000-01-01T00:00:00Z');
var time2 = JulianDate.fromIso8601('2000-01-01T00:00:01Z');
var time3 = JulianDate.fromIso8601('2000-01-01T00:00:02Z');
Expand Down Expand Up @@ -2754,7 +2762,11 @@ defineSuite([
</gx:Track>\
</Placemark>';

return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) {
return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), {
camera : options.camera,
canvas : options.canvas,
clampToGround : true
}).then(function(dataSource) {
var time1 = JulianDate.fromIso8601('2000-01-01T00:00:00Z');
var time2 = JulianDate.fromIso8601('2000-01-01T00:00:01Z');
var time3 = JulianDate.fromIso8601('2000-01-01T00:00:02Z');
Expand Down Expand Up @@ -2847,7 +2859,11 @@ defineSuite([
</gx:Track>\
</Placemark>';

return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) {
return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), {
camera : options.camera,
canvas : options.canvas,
clampToGround : true
}).then(function(dataSource) {
var time1 = JulianDate.fromIso8601('2000-01-01T00:00:00Z');
var time2 = JulianDate.fromIso8601('2000-01-01T00:00:01Z');
var time3 = JulianDate.fromIso8601('2000-01-01T00:00:02Z');
Expand Down

0 comments on commit bc67845

Please sign in to comment.