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

GeoJSON support #890

Merged
merged 27 commits into from
Jun 24, 2013
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
885a6ec
Start messing around with GeoJSON support.
mramato Jun 18, 2013
d709321
Merge branch 'master' into geojson
mramato Jun 18, 2013
5ef9066
Add drag and drop for .geojson files.
mramato Jun 18, 2013
a08508a
Merge branch 'master' into geojson
mramato Jun 18, 2013
5bcd722
Apply default styles to all GeoJSON features.
mramato Jun 19, 2013
e11f9ec
Ongoing GeoJSON prototyping.
mramato Jun 19, 2013
ff0d14d
Merge branch 'master' into geojson
mramato Jun 19, 2013
7c4dc49
Start of some specs, still a ton of work to do.
mramato Jun 19, 2013
bc36784
Ongoing GeoJSON work.
mramato Jun 20, 2013
db085c9
Merge branch 'master' into geojson
mramato Jun 20, 2013
485985e
Ongoing GeoJSON work.
mramato Jun 20, 2013
83fdd2f
Fix failing tests.
mramato Jun 20, 2013
b611ffd
Temporarily remove StaticProperty/StaticPosition property.
mramato Jun 20, 2013
ae572be
More cleanup before pull request.
mramato Jun 20, 2013
a0eb4e8
Doc cleanup.
mramato Jun 20, 2013
ddfacdc
Merge branch 'master' into geojson
mramato Jun 21, 2013
08f5258
Update CHANGES
mramato Jun 21, 2013
3e3188b
Merge branch 'master' into geojson
mramato Jun 21, 2013
7eca3c8
Merge branch 'master' into geojson
mramato Jun 24, 2013
67112b6
Changes after review.
mramato Jun 24, 2013
14e48f1
More changes.
mramato Jun 24, 2013
4b418a6
Minor tweak to ConstantProperty.
mramato Jun 24, 2013
4d7d09f
Change from DeveloperError to RuntimeError for actual GeoJSON process…
mramato Jun 24, 2013
54ae0ea
Cleanup promise usage.
mramato Jun 24, 2013
bb14a2b
Tweak to DynamicObject.merge.
mramato Jun 24, 2013
5010369
Standardize casing.
mramato Jun 24, 2013
490a8f2
More changes after review.
mramato Jun 24, 2013
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
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