Skip to content

Commit

Permalink
Expose registries.
Browse files Browse the repository at this point in the history
This, or some other way, is needed to that if a feature is available in
multiple renderers, so that a compound feature doesn't have to invoke a
secondary renderer if the current renderer is sufficient (see the change
for the annotationLayer, for instance).

This also has the virtue that the geo.registries entry can be inspected
to discover available features, layers, etc.
  • Loading branch information
manthey committed May 30, 2018
1 parent d263035 commit c0ab444
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/annotationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,8 @@ var annotationLayer = function (args) {
return m_this;
}
if (!m_labelFeature) {
var renderer = registry.rendererForFeatures(['text']);
if (renderer !== m_this.renderer().api()) {
if (!(registry.registries.features[m_this.rendererName()] || {}).text) {
var renderer = registry.rendererForFeatures(['text']);
m_labelLayer = registry.createLayer('feature', m_this.map(), {renderer: renderer});
m_this.addChild(m_labelLayer);
m_labelLayer._update();
Expand Down
11 changes: 11 additions & 0 deletions src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,15 @@ util.rendererForAnnotations = function (annotationList) {
return util.rendererForFeatures(util.featuresForAnnotations(annotationList));
};

/* Expose the various registries so that the can be examined to see what
* things are registered. */
util.registries = {
annotations: annotations,
features: features,
featureCapabilities: featureCapabilities,
fileReaders: fileReaders,
layers: layers,
renderers: renderers
};

module.exports = util;
5 changes: 5 additions & 0 deletions tests/cases/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ describe('geo.registry', function () {
expect(geo.rendererForFeatures(['point'])).toBe('d3');
restoreVGLRenderer();
});
it('expose registries', function () {
expect(geo.registries.unknown).toBe(undefined);
expect(geo.registries.annotations).not.toBe(undefined);
expect(geo.registries.features).not.toBe(undefined);
});
});
});

0 comments on commit c0ab444

Please sign in to comment.