-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cesium): use classes for converters
This differs more from the original implementation but it helps work around a forward-referenced type bug in the compiler when declaring the @type of a function as a @typedef.
- Loading branch information
1 parent
b55cc8c
commit 7527875
Showing
26 changed files
with
617 additions
and
634 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
goog.module('plugin.cesium.sync.BaseConverter'); | ||
|
||
const {getPrimitive, deletePrimitive} = goog.require('plugin.cesium.primitive'); | ||
|
||
const IConverter = goog.requireType('plugin.cesium.sync.IConverter'); | ||
|
||
|
||
/** | ||
* @abstract | ||
* @implements {IConverter} | ||
*/ | ||
class BaseConverter {} | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
BaseConverter.prototype.retrieve = getPrimitive; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
BaseConverter.prototype.delete = deletePrimitive; | ||
|
||
exports = BaseConverter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
goog.module('plugin.cesium.sync.DynamicLineStringConverter'); | ||
|
||
const {deletePrimitive, getPrimitive, shouldUpdatePrimitive} = goog.require('plugin.cesium.primitive'); | ||
const BaseConverter = goog.require('plugin.cesium.sync.BaseConverter'); | ||
const {shouldUpdatePrimitive} = goog.require('plugin.cesium.primitive'); | ||
const {createPolyline, updatePolyline} = goog.require('plugin.cesium.sync.DynamicLineString'); | ||
|
||
const {CreateFunction, UpdateFunction, Converter} = goog.requireType('plugin.cesium.sync.ConverterTypes'); | ||
|
||
/** | ||
* @type {CreateFunction} | ||
* Converter for DynamicFeature lines | ||
*/ | ||
const create = (feature, geometry, style, context) => { | ||
const polylineOptions = createPolyline(feature, geometry, style, context); | ||
context.addPolyline(polylineOptions, feature, geometry); | ||
return true; | ||
}; | ||
class DynamicLineStringConverter extends BaseConverter { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
create(feature, geometry, style, context) { | ||
const polylineOptions = createPolyline(feature, geometry, style, context); | ||
context.addPolyline(polylineOptions, feature, geometry); | ||
return true; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
update(feature, geometry, style, context, primitive) { | ||
if (!shouldUpdatePrimitive(feature, geometry, style, context, primitive)) { | ||
return false; | ||
} | ||
|
||
/** | ||
* @type {UpdateFunction} | ||
*/ | ||
const update = (feature, geometry, style, context, primitive) => { | ||
if (!shouldUpdatePrimitive(feature, geometry, style, context, primitive)) { | ||
return false; | ||
updatePolyline(feature, geometry, style, context, primitive); | ||
return true; | ||
} | ||
} | ||
|
||
updatePolyline(feature, geometry, style, context, primitive); | ||
return true; | ||
}; | ||
|
||
|
||
/** | ||
* @type {Converter} | ||
*/ | ||
exports = { | ||
create, | ||
retrieve: getPrimitive, | ||
update, | ||
delete: deletePrimitive | ||
}; | ||
exports = DynamicLineStringConverter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.