Skip to content

Commit

Permalink
Merge pull request #890 from AnalyticalGraphicsInc/geojson
Browse files Browse the repository at this point in the history
GeoJSON support
  • Loading branch information
shunter committed Jun 24, 2013
2 parents 0a0447f + 490a8f2 commit fd6d625
Show file tree
Hide file tree
Showing 11 changed files with 1,175 additions and 27 deletions.
15 changes: 14 additions & 1 deletion Apps/CesiumViewer/CesiumViewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*global define*/
define([
'DynamicScene/CzmlDataSource',
'DynamicScene/GeoJsonDataSource',
'Scene/PerformanceDisplay',
'Widgets/checkForChromeFrame',
'Widgets/Viewer/Viewer',
Expand All @@ -9,6 +10,7 @@ define([
'domReady!'
], function(
CzmlDataSource,
GeoJsonDataSource,
PerformanceDisplay,
checkForChromeFrame,
Viewer,
Expand Down Expand Up @@ -50,6 +52,12 @@ define([
window.alert(e);
});

function endsWith(str, suffix) {
var strLength = str.length;
var suffixLength = suffix.length;
return (suffixLength < strLength) && (str.indexOf(suffix, strLength - suffixLength) !== -1);
}

function startup() {
var viewer = new Viewer('cesiumContainer');
viewer.extend(viewerDragDropMixin);
Expand All @@ -75,7 +83,12 @@ define([
}

if (typeof endUserOptions.source !== 'undefined') {
var source = new CzmlDataSource();
var source;
if (endsWith(endUserOptions.source.toUpperCase(), ".GEOJSON")) {
source = new GeoJsonDataSource();
} else {
source = new CzmlDataSource();
}
source.loadUrl(endUserOptions.source).then(function() {
viewer.dataSources.add(source);

Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Beta Releases
* `ImageryProvider.loadImage` now requires that the calling imagery provider instance be passed as its first parameter.
* Removed `CesiumViewerWidget` and replaced it with a new `Viewer` widget with mixin architecture. This new widget does not depend on Dojo and is part of the combined Cesium.js file. It is intended to be a flexible base widget for easily building robust applications. See [#838](https://github.com/AnalyticalGraphicsInc/cesium/pull/838) for the full details.
* Removed the Dojo-based `checkForChromeFrame` function, and replaced it with a new standalone version that returns a promise to signal when the asynchronous check has completed.
* Added initial support for [GeoJSON](http://www.geojson.org/) see [#890](https://github.com/AnalyticalGraphicsInc/cesium/pull/890) for details.
* Added `Context.getAntialias`.
* Added rotation, aligned axis, width, and height properties to `Billboard`s.
* Improved the performance of "missing tile" checking, especially for Bing imagery.
Expand Down
35 changes: 35 additions & 0 deletions Source/DynamicScene/ConstantProperty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*global define*/
define(function() {
"use strict";

/**
* Represents a single value which does not change with regard to simulation time.
*
* @alias ConstantProperty
* @constructor
*
* @see DynamicProperty
*/
var ConstantProperty = function(value) {
this._value = value;
this._clonable = typeof value !== 'undefined' && typeof value.clone === 'function';
};

/**
* Gets the value of the property, optionally cloning it.
* @memberof ConstantProperty
*
* @param {JulianDate} time The time for which to retrieve the value. This parameter is unused.
* @param {Object} [result] The object to store the value into if the value is clonable. If the result is omitted or the value does not implement clone, the actual value is returned.
* @returns The modified result parameter or the actual value instance if the value is not clonable.
*/
ConstantProperty.prototype.getValue = function(time, result) {
var value = this._value;
if (this._clonable) {
return value.clone(result);
}
return value;
};

return ConstantProperty;
});
12 changes: 6 additions & 6 deletions Source/DynamicScene/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ define(['../Core/ClockRange',
'../Core/Event',
'../Core/Iso8601',
'../Core/loadJson',
'../DynamicScene/DynamicClock',
'../DynamicScene/processCzml',
'../DynamicScene/DynamicObjectCollection'
'./DynamicClock',
'./processCzml',
'./DynamicObjectCollection'
], function(
ClockRange,
ClockStep,
Expand Down Expand Up @@ -65,7 +65,7 @@ define(['../Core/ClockRange',
/**
* Gets an event that will be raised when non-time-varying data changes
* or if the return value of getIsTimeVarying changes.
* @memberof DataSource
* @memberof CzmlDataSource
*
* @returns {Event} The event.
*/
Expand Down Expand Up @@ -97,7 +97,7 @@ define(['../Core/ClockRange',

/**
* Gets the DynamicObjectCollection generated by this data source.
* @memberof DataSource
* @memberof CzmlDataSource
*
* @returns {DynamicObjectCollection} The collection of objects generated by this data source.
*/
Expand All @@ -108,7 +108,7 @@ define(['../Core/ClockRange',
/**
* Gets a value indicating if the data varies with simulation time. If the return value of
* this function changes, the changed event will be raised.
* @memberof DataSource
* @memberof CzmlDataSource
*
* @returns {Boolean} True if the data is varies with simulation time, false otherwise.
*/
Expand Down
17 changes: 17 additions & 0 deletions Source/DynamicScene/DynamicObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,23 @@ define([
return availabilityValue;
};

/**
* Merge all of the properties of the supplied object onto this object.
* Properties which are already defined are not overwritten.
* @param other {DynamicObject} The object to merge.
* @private
*/
DynamicObject.prototype.merge = function(other) {
if (typeof other === 'undefined') {
throw new DeveloperError('other is required');
}
for ( var property in other) {
if (other.hasOwnProperty(property)) {
this[property] = defaultValue(this[property], other[property]);
}
}
};

/**
* Processes a single CZML packet and merges its data into the provided DynamicObject's position
* property. This method is not normally called directly, but is part of the array of CZML processing
Expand Down
Loading

0 comments on commit fd6d625

Please sign in to comment.