Skip to content

Commit

Permalink
Ongoing ease of use work.
Browse files Browse the repository at this point in the history
Add a CustomDataSource to easily add entities programmatically.
Also sort requires.
  • Loading branch information
mramato committed Dec 10, 2014
1 parent 7bfee7f commit d5b5c07
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Source/DataSources/ColorMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ define([
'../Core/DeveloperError',
'../Core/Event',
'./ConstantProperty',
'./PropertyHelper',
'./Property'
'./Property',
'./PropertyHelper'
], function(
Color,
defined,
Expand All @@ -17,8 +17,8 @@ define([
DeveloperError,
Event,
ConstantProperty,
PropertyHelper,
Property) {
Property,
PropertyHelper) {
"use strict";

/**
Expand Down
125 changes: 125 additions & 0 deletions Source/DataSources/CustomDataSource.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*global define*/
define([
'../Core/defineProperties',
'../Core/Event',
'./DataSource',
'./EntityCollection'
], function(
defineProperties,
Event,
DataSource,
EntityCollection) {
"use strict";

/**
* A {@link DataSource} which processes both
* {@link http://www.geojson.org/|GeoJSON} and {@link https://github.com/mbostock/topojson|TopoJSON} data.
* {@link https://github.com/mapbox/simplestyle-spec|Simplestyle} properties will also be used if they
* are present.
*
* @alias CustomDataSource
* @constructor
*
* @param {String} [name] The name of this data source. If undefined, a name will be taken from
* the name of the GeoJSON file.
*/
var CustomDataSource = function() {
this._name = undefined;
this._clock = undefined;
this._changed = new Event();
this._error = new Event();
this._isLoading = false;
this._loading = new Event();
this._entityCollection = new EntityCollection();
};

defineProperties(CustomDataSource.prototype, {
/**
* Gets a human-readable name for this instance.
* @memberof CustomDataSource.prototype
* @type {String}
*/
name : {
get : function() {
return this._name;
},
set : function(value) {
if (this._name !== value) {
this._name = value;
this._changed.raiseEvent(this);
}
}
},
/**
* This DataSource only defines static data, therefore this property is always undefined.
* @memberof CustomDataSource.prototype
* @type {DataSourceClock}
*/
clock : {
get : function() {
return this._clock;
},
set : function(value) {
if (this._clock !== value) {
this._clock = value;
this._changed.raiseEvent(this);
}
}
},
/**
* Gets the collection of {@link Entity} instances.
* @memberof CustomDataSource.prototype
* @type {EntityCollection}
*/
entities : {
get : function() {
return this._entityCollection;
}
},
/**
* Gets a value indicating if the data source is currently loading data.
* @memberof CustomDataSource.prototype
* @type {Boolean}
*/
isLoading : {
get : function() {
return this._isLoading;
},
set : function(value) {
DataSource.setLoading(this, value);
}
},
/**
* Gets an event that will be raised when the underlying data changes.
* @memberof CustomDataSource.prototype
* @type {Event}
*/
changedEvent : {
get : function() {
return this._changed;
}
},
/**
* Gets an event that will be raised if an error is encountered during processing.
* @memberof CustomDataSource.prototype
* @type {Event}
*/
errorEvent : {
get : function() {
return this._error;
}
},
/**
* Gets an event that will be raised when the data source either starts or stops loading.
* @memberof CustomDataSource.prototype
* @type {Event}
*/
loadingEvent : {
get : function() {
return this._loading;
}
}
});

return CustomDataSource;
});
1 change: 1 addition & 0 deletions Source/DataSources/EntityCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ define([
entity.definitionChanged.addEventListener(EntityCollection.prototype._onEntityDefinitionChanged, this);

fireChangedEvent(this);
return entity;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions Source/DataSources/GeoJsonDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ define([
'../ThirdParty/topojson',
'../ThirdParty/when',
'./BillboardGraphics',
'./CallbackProperty',
'./ColorMaterialProperty',
'./ConstantPositionProperty',
'./ConstantProperty',
'./DataSource',
'./EntityCollection',
'./CallbackProperty',
'./PolygonGraphics',
'./PolylineGraphics'
], function(
Expand All @@ -43,12 +43,12 @@ define([
topojson,
when,
BillboardGraphics,
CallbackProperty,
ColorMaterialProperty,
ConstantPositionProperty,
ConstantProperty,
DataSource,
EntityCollection,
CallbackProperty,
PolygonGraphics,
PolylineGraphics) {
"use strict";
Expand Down
8 changes: 4 additions & 4 deletions Source/DataSources/GridMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
'./PropertyHelper',
'./Property'
'./Property',
'./PropertyHelper'
], function(
Cartesian2,
Color,
defined,
defineProperties,
Event,
PropertyHelper,
Property) {
Property,
PropertyHelper) {
"use strict";

var defaultColor = Color.WHITE;
Expand Down
8 changes: 4 additions & 4 deletions Source/DataSources/ImageMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
'./PropertyHelper',
'./Property'
'./Property',
'./PropertyHelper'
], function(
Cartesian2,
defined,
defineProperties,
Event,
PropertyHelper,
Property) {
Property,
PropertyHelper) {
"use strict";

var defaultRepeat = new Cartesian2(1, 1);
Expand Down
8 changes: 4 additions & 4 deletions Source/DataSources/PolylineGlowMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
'./PropertyHelper',
'./Property'
'./Property',
'./PropertyHelper'
], function(
Color,
defined,
defineProperties,
Event,
PropertyHelper,
Property) {
Property,
PropertyHelper) {
"use strict";

var defaultColor = Color.WHITE;
Expand Down
8 changes: 4 additions & 4 deletions Source/DataSources/PolylineOutlineMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
'./PropertyHelper',
'./Property'
'./Property',
'./PropertyHelper'
], function(
Color,
defined,
defineProperties,
Event,
PropertyHelper,
Property) {
Property,
PropertyHelper) {
"use strict";

var defaultColor = Color.WHITE;
Expand Down
4 changes: 2 additions & 2 deletions Source/DataSources/PropertyHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ define([
'../Core/defaultValue',
'../Core/defined',
'../Core/DeveloperError',
'./ConstantProperty',
'./ConstantPositionProperty',
'./ConstantProperty',
'require'
], function(
Color,
defaultValue,
defined,
DeveloperError,
ConstantProperty,
ConstantPositionProperty,
ConstantProperty,
require) {
"use strict";

Expand Down
4 changes: 2 additions & 2 deletions Source/DataSources/StripeMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
'./PropertyHelper',
'./Property',
'./PropertyHelper',
'./StripeOrientation'
], function(
Color,
defined,
defineProperties,
Event,
PropertyHelper,
Property,
PropertyHelper,
StripeOrientation) {
"use strict";

Expand Down

0 comments on commit d5b5c07

Please sign in to comment.