[core] Add static layer properties to mbgl::style::LayerTypeInfo
This commit is contained in:
@@ -26,11 +26,30 @@ struct LayerTypeInfo {
|
||||
* @brief contains the layer type as defined in the style specification;
|
||||
*/
|
||||
const char* type;
|
||||
|
||||
/**
|
||||
* @brief contains \c SourceRequired if the corresponding layer type requires source;
|
||||
* contains \c SourceNotRequired otherwise.
|
||||
* @brief contains \c Source::Required if the corresponding layer type
|
||||
* requires source. Contains \c Source::NotRequired otherwise.
|
||||
*/
|
||||
const enum { SourceRequired, SourceNotRequired } source;
|
||||
const enum class Source { Required, NotRequired } source;
|
||||
|
||||
/**
|
||||
* @brief contains \c Pass3D::Required if the corresponding layer type
|
||||
* requires 3D rendering pass. Contains \c Pass3D::NotRequired otherwise.
|
||||
*/
|
||||
const enum class Pass3D { Required, NotRequired } pass3d;
|
||||
|
||||
/**
|
||||
* @brief contains \c Layout::Required if the corresponding layer type
|
||||
* requires layouting. * contains \c Layout::NotRequired otherwise.
|
||||
*/
|
||||
const enum class Layout { Required, NotRequired } layout;
|
||||
|
||||
/**
|
||||
* @brief contains \c Clipping::Required if the corresponding layer type
|
||||
* requires clipping. Contains \c Clipping::NotRequired otherwise.
|
||||
*/
|
||||
const enum class Clipping { Required, NotRequired } clipping;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoBackground{ "background", LayerTypeInfo::SourceNotRequired };
|
||||
const LayerTypeInfo typeInfoBackground
|
||||
{"background",
|
||||
LayerTypeInfo::Source::NotRequired,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
BackgroundLayer::BackgroundLayer(const std::string& layerID)
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoCircle{ "circle", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoCircle
|
||||
{"circle",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
CircleLayer::CircleLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -6,7 +6,12 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoCustom{ "", LayerTypeInfo::SourceNotRequired };
|
||||
const LayerTypeInfo typeInfoCustom
|
||||
{ "",
|
||||
LayerTypeInfo::Source::NotRequired,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::Clipping::NotRequired };
|
||||
} // namespace
|
||||
|
||||
CustomLayer::CustomLayer(const std::string& layerID,
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoFillExtrusion{ "fill-extrusion", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoFillExtrusion
|
||||
{"fill-extrusion",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::Required,
|
||||
LayerTypeInfo::Layout::Required,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
FillExtrusionLayer::FillExtrusionLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoFill{ "fill", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoFill
|
||||
{"fill",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::Required,
|
||||
LayerTypeInfo::Clipping::Required
|
||||
};
|
||||
} // namespace
|
||||
|
||||
FillLayer::FillLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoHeatmap{ "heatmap", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoHeatmap
|
||||
{"heatmap",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::Required,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
HeatmapLayer::HeatmapLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoHillshade{ "hillshade", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoHillshade
|
||||
{"hillshade",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::Required,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
HillshadeLayer::HillshadeLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -19,12 +19,51 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
<% if (type === 'background') { -%>
|
||||
const LayerTypeInfo typeInfo<%- camelize(type) %>{ "<%- type %>", LayerTypeInfo::SourceNotRequired };
|
||||
<% } else { -%>
|
||||
const LayerTypeInfo typeInfo<%- camelize(type) %>{ "<%- type %>", LayerTypeInfo::SourceRequired };
|
||||
<% } -%>
|
||||
namespace {<%
|
||||
let layerCapabilities = {};
|
||||
let defaults = { caps: { 'Source': 'NotRequired',
|
||||
'Pass3D': 'NotRequired',
|
||||
'Layout': 'NotRequired',
|
||||
'Clipping': 'NotRequired'
|
||||
},
|
||||
require: function(cap) {
|
||||
let copy = Object.assign({}, this);
|
||||
copy.caps = Object.assign({}, this.caps);
|
||||
copy.caps[cap] = 'Required';
|
||||
return copy;
|
||||
},
|
||||
finalize: function() {
|
||||
return Object.keys(this.caps).reduce((acc, key) => {
|
||||
acc.push(`${key}::${this.caps[key]}`);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
};
|
||||
|
||||
layerCapabilities['background'] = defaults.finalize();
|
||||
layerCapabilities['fill'] = defaults.require('Source')
|
||||
.require('Layout')
|
||||
.require('Clipping')
|
||||
.finalize();
|
||||
layerCapabilities['fill-extrusion'] = defaults.require('Source')
|
||||
.require('Pass3D')
|
||||
.require('Layout')
|
||||
.finalize();
|
||||
layerCapabilities['hillshade'] = defaults.require('Source')
|
||||
.require('Pass3D')
|
||||
.finalize();
|
||||
layerCapabilities['symbol'] = defaults.require('Source')
|
||||
.require('Layout')
|
||||
.finalize();
|
||||
layerCapabilities['circle'] = defaults.require('Source').finalize();
|
||||
layerCapabilities['line'] = layerCapabilities['fill'];
|
||||
layerCapabilities['heatmap'] = layerCapabilities['hillshade'];
|
||||
layerCapabilities['raster'] = layerCapabilities['circle'];
|
||||
%>
|
||||
const LayerTypeInfo typeInfo<%- `${camelize(type)}`%>
|
||||
{"<%- type %>",
|
||||
<%-`${layerCapabilities[type].map(cap => `LayerTypeInfo::${cap}`).join(',\n ')}` %>
|
||||
};
|
||||
} // namespace
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoLine{ "line", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoLine
|
||||
{"line",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::Required,
|
||||
LayerTypeInfo::Clipping::Required
|
||||
};
|
||||
} // namespace
|
||||
|
||||
LineLayer::LineLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoRaster{ "raster", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoRaster
|
||||
{"raster",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
RasterLayer::RasterLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
@@ -15,7 +15,13 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoSymbol{ "symbol", LayerTypeInfo::SourceRequired };
|
||||
const LayerTypeInfo typeInfoSymbol
|
||||
{"symbol",
|
||||
LayerTypeInfo::Source::Required,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::Required,
|
||||
LayerTypeInfo::Clipping::NotRequired
|
||||
};
|
||||
} // namespace
|
||||
|
||||
SymbolLayer::SymbolLayer(const std::string& layerID, const std::string& sourceID)
|
||||
|
||||
Reference in New Issue
Block a user