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

Create layers based on a list of features. #590

Merged
merged 5 commits into from
Jun 24, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
10 changes: 6 additions & 4 deletions examples/choropleth/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ $(function () {
'osm'
);

// Create a gl feature layer
var vglLayer = map.createLayer(
// Create a feature layer. We could either ask for a layer via a specific
// render {renderer: 'vgl'} or for a layer that supports our feature
// {features: ['choropleth']}.
var choroplethLayer = map.createLayer(
'feature',
{
renderer: 'vgl'
features: ['choropleth']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

}
);

Expand All @@ -57,7 +59,7 @@ $(function () {
});

var choropleth =
makeChoropleth(geoData.features, mockScalarData, vglLayer);
makeChoropleth(geoData.features, mockScalarData, choroplethLayer);

setTimeout(function () {
var mockScalarData2 = geoData
Expand Down
12 changes: 6 additions & 6 deletions examples/contour/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ $(function () {
'osm'
);

// Create a gl feature layer
var vglLayer = map.createLayer(
// Create a feature layer that supports contours
var contourLayer = map.createLayer(
'feature',
{
renderer: 'vgl'
features: ['contour']
}
);

// Load the data
$.ajax({
url: '../../data/oahu.json',
success: function (data) {
var contour = makeContour(data, vglLayer);
var contour = makeContour(data, contourLayer);
contour.draw();
/* After 10 second, load a denser data set */
window.setTimeout(function () {
$.ajax({
url: '../../data/oahu-dense.json',
success: function (data) {
vglLayer.deleteFeature(contour);
contour = makeContour(data, vglLayer, contour);
contourLayer.deleteFeature(contour);
contour = makeContour(data, contourLayer, contour);
contour.draw();
}
});
Expand Down
3 changes: 1 addition & 2 deletions examples/deepzoom/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ $(function () {

// Add the osm layer with a custom tile url
map.createLayer(
'tiledFish',
{renderer: 'vgl'}
'tiledFish'
);
});
4 changes: 3 additions & 1 deletion examples/dynamicData/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ $(function () {
baseUrl: 'http://otile1.mqcdn.com/tiles/1.0.0/sat'
});

// Add a feature layer with a D3 renderer
// Add a feature layer with a D3 renderer. We could, instead, ask for any
// renderer that supports point features, like so:
// var features = map.createLayer('feature', {features: ['point']});
var features = map.createLayer('feature', {renderer: 'd3'});

var numberOfFeatures = 200;
Expand Down
5 changes: 3 additions & 2 deletions examples/geoJSON/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ $(function () {
}
);

// Create a gl layer to put the features in
var layer = map.createLayer('feature');
// Create a layer to put the features in. We could need point, line, and
// polygon features, so ask for a layer that supports all of them.
var layer = map.createLayer('feature', {features: ['point', 'line', 'polygon']});
map.draw();

// Initialize the json reader.
Expand Down
2 changes: 1 addition & 1 deletion examples/heatmap/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $(function () {
var layer, heatmap, points, datapoints;

var layerOptions = {
renderer: 'canvas',
features: ['heatmap'],
opacity: 0.75
};
var heatmapOptions = {
Expand Down
4 changes: 2 additions & 2 deletions examples/hurricanes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ $(function () {
}
);

// Create a feature layer to draw on
layer = map.createLayer('feature');
// Create a feature layer to draw on.
layer = map.createLayer('feature', {features: ['line.multicolor']});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is line.multicolor refers to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that you have added options at the time of registration. Interesting idea but now we have to make sure we are consistent about it and document it as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our gl lines can vary color from point to point. The d3 lines can't.

We probably should document the feature capabilities in the base feature.


// Create a line feature
feature = layer.createFeature('line', {selectionAPI: true});
Expand Down
3 changes: 2 additions & 1 deletion examples/quads/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ $(function () {
zoom: 4
});
var layer = map.createLayer('feature', {
renderer: query.renderer ? (query.renderer === 'html' ? null : query.renderer) : 'vgl'
renderer: query.renderer ? (query.renderer === 'html' ? null : query.renderer) : undefined,
features: query.renderer ? undefined : ['quad']
});
var quads = layer.createFeature('quad', {selectionAPI: true});
var previewImage = new Image();
Expand Down
2 changes: 1 addition & 1 deletion examples/reprojection/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ $(function () {
}
// Set the tile layer defaults to use the specified renderer and opacity
var layerParams = {
renderer: 'vgl',
features: ['quad.img-full'],
zIndex: 0,
gcs: 'EPSG:3857',
attribution: $('#url-list [value="' + $('#layer-url').val() + '"]').attr(
Expand Down
3 changes: 2 additions & 1 deletion examples/tiles/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ block append mainContent
div#controls
.form-group(title="Tiles can be drawn using WebGL, Canvas, HTML, or SVG. WebGL is generally the fastest and HTML the most compatible.")
label(for="map-renderer") Renderer
select#map-renderer.mapparam(param-name="renderer", placeholder="vgl")
select#map-renderer.mapparam(param-name="renderer", placeholder="default")
option(value="default") Default
option(value="vgl") VGL (WebGL)
option(value="canvas") Canvas
option(value="d3") SVG (d3)
Expand Down
6 changes: 5 additions & 1 deletion examples/tiles/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* projection: 'parallel' or 'projection' for the camera projection.
* renderer: 'vgl' (default), 'canvas', 'd3', 'null', or 'html'. This picks
* the renderer for map tiles. null or html uses the html renderer.
* 'default' uses the default renderer for the user's platform.
* round: 'round' (default), 'floor', 'ceil'.
* subdomains: a comma-separated string of subdomains to use in the {s} part
* of the url parameter. If there are no commas in the string, each letter
Expand Down Expand Up @@ -104,7 +105,7 @@ $(function () {
};
// Set the tile layer defaults to use the specified renderer and opacity
var layerParams = {
renderer: query.renderer || 'vgl',
renderer: query.renderer && query.renderer !== 'default' ? query.renderer : undefined,
opacity: query.opacity || '1',
/* Always use a larger cache so if keepLower is changed, we still have a
* big enough cache. */
Expand Down Expand Up @@ -340,6 +341,9 @@ $(function () {
if (layerParams.renderer === 'html') {
layerParams.renderer = null;
}
if (layerParams.renderer === 'default') {
layerParams.renderer = undefined;
}
map.deleteLayer(osmLayer);
osmLayer = map.createLayer('osm', layerParams);
tileDebug.osmLayer = osmLayer;
Expand Down
2 changes: 1 addition & 1 deletion examples/transitions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $(function () {
// Add an OSM layer
map.createLayer('osm', {
baseUrl: 'http://otile1.mqcdn.com/tiles/1.0.0/map',
renderer: query.renderer ? (query.renderer === 'html' ? null : query.renderer) : 'vgl'
renderer: query.renderer ? (query.renderer === 'html' ? null : query.renderer) : undefined
});

// Bind button clicks to map transitions
Expand Down
2 changes: 1 addition & 1 deletion examples/vectors/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $(function () {

// Create a gl feature layer
var layer = map.createLayer(
'feature', { renderer: 'd3' }
'feature', {features: ['vector']}
);

var routes = [
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/quadFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@ var canvas_quadFeature = function (arg) {
inherit(canvas_quadFeature, quadFeature);

// Now register it
registerFeature('canvas', 'quad', canvas_quadFeature);
registerFeature('canvas', 'quad', canvas_quadFeature, {clr: false, img: true, 'img-full': false});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we change clr to color please? clr sometime could be confused with clear.

Copy link
Member

@aashish24 aashish24 Jun 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manthey how do control and maintain this vocabulary? May we should make it part of public interface of baseclass (keys) and then the derived classes can just refer to it like this:

registerFeature('canvas', 'quad', canvas_quadFeature, {quadFeature.color: false, quadFeature.img: true, quadFeature.img-full: false});
thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. The base class can document what the keys mean, too. I'll make those changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks for the consideration @manthey

module.exports = canvas_quadFeature;
2 changes: 1 addition & 1 deletion src/d3/lineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ var d3_lineFeature = function (arg) {

inherit(d3_lineFeature, lineFeature);

registerFeature('d3', 'line', d3_lineFeature);
registerFeature('d3', 'line', d3_lineFeature, {basic: true, multicolor: false});

module.exports = d3_lineFeature;
2 changes: 1 addition & 1 deletion src/d3/quadFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,5 @@ var d3_quadFeature = function (arg) {
inherit(d3_quadFeature, quadFeature);

// Now register it
registerFeature('d3', 'quad', d3_quadFeature);
registerFeature('d3', 'quad', d3_quadFeature, {clr: true, img: true, 'img-full': false});
module.exports = d3_quadFeature;
2 changes: 1 addition & 1 deletion src/gl/lineFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,6 @@ var gl_lineFeature = function (arg) {
inherit(gl_lineFeature, lineFeature);

// Now register it
registerFeature('vgl', 'line', gl_lineFeature);
registerFeature('vgl', 'line', gl_lineFeature, {basic: true, multicolor: true});

module.exports = gl_lineFeature;
2 changes: 1 addition & 1 deletion src/gl/quadFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,5 @@ var gl_quadFeature = function (arg) {
inherit(gl_quadFeature, quadFeature);

// Now register it
registerFeature('vgl', 'quad', gl_quadFeature);
registerFeature('vgl', 'quad', gl_quadFeature, {clr: true, img: true, 'img-full': true});
module.exports = gl_quadFeature;
7 changes: 4 additions & 3 deletions src/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var inherit = require('./inherit');
var sceneObject = require('./sceneObject');
var feature = require('./feature');
var checkRenderer = require('./registry').checkRenderer;
var rendererForFeatures = require('./registry').rendererForFeatures;

//////////////////////////////////////////////////////////////////////////////
/**
Expand Down Expand Up @@ -30,11 +31,11 @@ var layer = function (arg) {
var geo_event = require('./event');
var camera = require('./camera');

//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/**
* @private
*/
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
var m_this = this,
s_exit = this._exit,
m_id = arg.id === undefined ? layer.newLayerId() : arg.id,
Expand All @@ -44,7 +45,7 @@ var layer = function (arg) {
m_canvas = null,
m_renderer = null,
m_initialized = false,
m_rendererName = arg.renderer === undefined ? 'vgl' : arg.renderer,
m_rendererName = arg.renderer === undefined ? rendererForFeatures(arg.features) : arg.renderer,
m_dataTime = timestamp(),
m_updateTime = timestamp(),
m_sticky = arg.sticky === undefined ? true : arg.sticky,
Expand Down
8 changes: 3 additions & 5 deletions src/mapInteractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,9 @@ var mapInteractor = function (args) {
m_this.map().deleteLayer(m_selectionLayer);
m_selectionLayer = null;
}
// Create a feature layer and plane feature to show the selection bounds
m_selectionLayer = m_this.map().createLayer('feature', {renderer: 'd3'});

m_selectionQuad = m_selectionLayer.createFeature(
'quad', {gcs: m_this.map().gcs()});
m_selectionLayer = m_this.map().createLayer(
'feature', {features: ['quad.clr']});
m_selectionQuad = m_selectionLayer.createFeature('quad');
m_selectionQuad.style({
opacity: 0.25,
color: {r: 0.3, g: 0.3, b: 0.3}
Expand Down
4 changes: 3 additions & 1 deletion src/osmLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ module.exports = (function () {
});

inherit(osmLayer, tileLayer);
registry.registerLayer('osm', osmLayer);
/* By default, ask to support image quads. If the user needs full
* reprojection, they will need to require the quad.img-full feature */
registry.registerLayer('osm', osmLayer, ['quad.img']);
return osmLayer;
})();
Loading