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

Fixes for default altitude mode and incorrect parameters to style.generate #885

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nasaworldwind/worldwind",
"version": "0.11.0",
"version": "0.11.1",
"description": "Web WorldWind",
"main": "build/dist/worldwind.min.js",
"homepage": "https://worldwind.arc.nasa.gov",
Expand Down Expand Up @@ -71,4 +71,4 @@
"publishConfig": {
"access": "public"
}
}
}
42 changes: 21 additions & 21 deletions src/formats/kml/geom/KmlLineString.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ define([
'../../../shapes/SurfacePolyline',
'../../../util/WWUtil'
], function (Color,
KmlElements,
KmlGeometry,
KmlStyle,
Location,
NodeTransformers,
Path,
Position,
ShapeAttributes,
SurfacePolyline,
WWUtil) {
KmlElements,
KmlGeometry,
KmlStyle,
Location,
NodeTransformers,
Path,
Position,
ShapeAttributes,
SurfacePolyline,
WWUtil) {
"use strict";

/**
Expand Down Expand Up @@ -78,7 +78,7 @@ define([
*/
kmlExtrude: {
get: function () {
return this._factory.specific(this, {name: 'extrude', transformer: NodeTransformers.boolean}) || false;
return this._factory.specific(this, { name: 'extrude', transformer: NodeTransformers.boolean }) || false;
}
},

Expand All @@ -90,7 +90,7 @@ define([
*/
kmlTessellate: {
get: function () {
return this._factory.specific(this, {name: 'tessellate', transformer: NodeTransformers.boolean}) || false;
return this._factory.specific(this, { name: 'tessellate', transformer: NodeTransformers.boolean }) || false;
}
},

Expand All @@ -103,7 +103,7 @@ define([
*/
kmlAltitudeMode: {
get: function () {
return this._factory.specific(this, {name: 'altitudeMode', transformer: NodeTransformers.string}) || WorldWind.ABSOLUTE;
return this._factory.specific(this, { name: 'altitudeMode', transformer: NodeTransformers.string }) || WorldWind.CLAMP_TO_GROUND;
}
},

Expand All @@ -115,7 +115,7 @@ define([
*/
kmlPositions: {
get: function () {
return this._factory.specific(this, {name: 'coordinates', transformer: NodeTransformers.positions});
return this._factory.specific(this, { name: 'coordinates', transformer: NodeTransformers.positions });
}
},

Expand Down Expand Up @@ -153,26 +153,26 @@ define([
* @param styles.highlight {KmlStyle} Style applied when item is highlighted
*/
KmlLineString.prototype.createPath = function (styles, fileCache) {
if(this.kmlAltitudeMode == WorldWind.CLAMP_TO_GROUND) {
if (this.kmlAltitudeMode == WorldWind.CLAMP_TO_GROUND) {
this._renderable = new SurfacePolyline(this.prepareLocations(), this.prepareAttributes(styles.normal, fileCache));
} else {
this._renderable = new Path(this.prepareLocations(), this.prepareAttributes(styles.normal, fileCache));
}
if(styles.highlight) {
if (styles.highlight) {
this._renderable.highlightAttributes = this.prepareAttributes(styles.highlight, fileCache);
}
this.moveValidProperties();
};

KmlLineString.prototype.render = function(dc, kmlOptions) {
KmlLineString.prototype.render = function (dc, kmlOptions) {
KmlGeometry.prototype.render.call(this, dc, kmlOptions);

if(kmlOptions.lastStyle && !this._renderable) {
if (kmlOptions.lastStyle && !this._renderable) {
this.createPath(kmlOptions.lastStyle, kmlOptions.fileCache);
dc.redrawRequested = true;
}

if(this._renderable) {
if (this._renderable) {
this._renderable.enabled = this.enabled;
this._renderable.render(dc);
}
Expand All @@ -182,7 +182,7 @@ define([
* @inheritDoc
*/
KmlLineString.prototype.prepareAttributes = function (style, fileCache) {
var shapeOptions = style && style.generate(fileCache) || {};
var shapeOptions = style && style.generate({}, fileCache) || {};

shapeOptions._applyLighting = true;
shapeOptions._drawOutline = true;
Expand All @@ -208,7 +208,7 @@ define([
*/
KmlLineString.prototype.moveValidProperties = function () {
this._renderable.extrude = this.kmlExtrude || false;
this._renderable.altitudeMode = this.kmlAltitudeMode || WorldWind.ABSOLUTE;
this._renderable.altitudeMode = this.kmlAltitudeMode || WorldWind.CLAMP_TO_GROUND;
//noinspection JSUnusedGlobalSymbols
this._renderable.tesselate = this.kmlTesselate || false;
};
Expand Down
27 changes: 13 additions & 14 deletions src/formats/kml/geom/KmlPolygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ define([
'../../../shapes/ShapeAttributes',
'../../../shapes/SurfacePolygon'
], function (Color,
KmlElements,
KmlGeometry,
KmlLinearRing,
KmlStyle,
Location,
NodeTransformers,
Polygon,
ShapeAttributes,
SurfacePolygon) {
KmlElements,
KmlGeometry,
KmlLinearRing,
KmlStyle,
Location,
NodeTransformers,
Polygon,
ShapeAttributes,
SurfacePolygon) {
"use strict";
/**
* Constructs an KmlPolygon. Application usually don't call this constructor. It is called by {@link KmlFile} as
Expand Down Expand Up @@ -78,7 +78,7 @@ define([
*/
kmlExtrude: {
get: function () {
return this._factory.specific(this, {name: 'extrude', transformer: NodeTransformers.boolean});
return this._factory.specific(this, { name: 'extrude', transformer: NodeTransformers.boolean });
}
},

Expand All @@ -90,7 +90,7 @@ define([
*/
kmlTessellate: {
get: function () {
return this._factory.specific(this, {name: 'tessellate', transformer: NodeTransformers.boolean});
return this._factory.specific(this, { name: 'tessellate', transformer: NodeTransformers.boolean });
}
},

Expand All @@ -103,7 +103,7 @@ define([
*/
kmlAltitudeMode: {
get: function () {
return this._factory.specific(this, {name: 'altitudeMode', transformer: NodeTransformers.string});
return this._factory.specific(this, { name: 'altitudeMode', transformer: NodeTransformers.string });
}
},

Expand Down Expand Up @@ -157,7 +157,6 @@ define([
* @param styles.highlight {KmlStyle} Style to apply when item is highlighted. Currently ignored.
*/
KmlPolygon.prototype.createPolygon = function (styles, fileCache) {
console.log(this.kmlInnerBoundary && this.kmlInnerBoundary.kmlAltitudeMode === WorldWind.CLAMP_TO_GROUND);
// TODO: KML boundaries are displaying graphic glitches when the camera is zoomed out
if (
!this.isValidAltitudeMode(this.kmlAltitudeMode) ||
Expand Down Expand Up @@ -202,7 +201,7 @@ define([
* @inheritDoc
*/
KmlPolygon.prototype.prepareAttributes = function (style, fileCache) {
var shapeOptions = style && style.generate(fileCache) || {};
var shapeOptions = style && style.generate({}, fileCache) || {};

shapeOptions._drawVerticals = this.kmlExtrude || false;
shapeOptions._applyLighting = true;
Expand Down
2 changes: 1 addition & 1 deletion test/formats/kml/geom/KmlLineString.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define([
kmlPositions: [
new Position(37.824787, -122.364167, 0),
new Position(37.824423, -122.363917, 0)],
kmlAltitudeMode: 'absolute',
kmlAltitudeMode: 'clampToGround',
kmlExtrude: false,
kmlTessellate: false
})).toBeTruthy();
Expand Down