From 36be8109ee20a8a76f0aa70ddf8567489cc3772f Mon Sep 17 00:00:00 2001 From: Raruto Date: Thu, 20 Jul 2023 10:49:09 +0200 Subject: [PATCH 01/14] refactor function `LayerFactory::get(config = {})` - simplify nested `switch-if` logic - convert `LayerFactory` to ES6 class --- src/app/core/layers/layerfactory.js | 163 +++++++++++++++------------- 1 file changed, 86 insertions(+), 77 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 235ea85bf..b34a24ddf 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -1,86 +1,95 @@ -const Layer = require('core/layers/layer'); -const TableLayer = require('core/layers/tablelayer'); -const VectorLayer = require('core/layers/vectorlayer'); -const ImageLayer = require('core/layers/imagelayer'); -const BaseLayers = require('core/layers/baselayers/baselayers'); +const Layer = require('core/layers/layer'); +const TableLayer = require('core/layers/tablelayer'); +const VectorLayer = require('core/layers/vectorlayer'); +const ImageLayer = require('core/layers/imagelayer'); +const BaseLayers = require('core/layers/baselayers/baselayers'); const GeojsonLayer = require('core/layers/geojson'); +const TABLE_LAYERS = [ + Layer.SourceTypes.VIRTUAL, + Layer.SourceTypes.POSTGIS, + Layer.SourceTypes.MSSQL, + Layer.SourceTypes.SPATIALITE, + Layer.SourceTypes.WFS, + Layer.SourceTypes.CSV, + Layer.SourceTypes.ORACLE, + Layer.SourceTypes.OGR, + Layer.SourceTypes.MDAL, +]; + +const IMAGE_LAYERS = [ + Layer.SourceTypes.WMST, + Layer.SourceTypes.WCS, + Layer.SourceTypes.WMS, + Layer.SourceTypes.GDAL, + Layer.SourceTypes.VECTORTILE, + Layer.SourceTypes["VECTOR-TILE"], + Layer.SourceTypes.MDAL, +]; + +const BASE_LAYERS = [ + Layer.ServerTypes.OSM, + Layer.ServerTypes.BING, + Layer.ServerTypes.TMS, + Layer.ServerTypes.WMS, + Layer.ServerTypes.WMTS, + Layer.ServerTypes.ARCGISMAPSERVER, +]; + // Class to build layer based on configuration -function LayerFactory() { - this.build = function(config, options) { - // return the layer instance +class LayerFactory { + + /** + * @returns layer instance + */ + build(config, options) { const layerClass = this.get(config); return layerClass ? new layerClass(config, options) : null - }; - - this.get = function(config={}) { - let LayerClass; - const serverType = config.servertype; - switch (serverType) { - case Layer.ServerTypes.QGIS: - if (config.source) { - if (config.geometrytype) { - if ([ - Layer.SourceTypes.VIRTUAL, - Layer.SourceTypes.POSTGIS, - Layer.SourceTypes.MSSQL, - Layer.SourceTypes.SPATIALITE, - Layer.SourceTypes.WFS, - Layer.SourceTypes.CSV, - Layer.SourceTypes.ORACLE, - Layer.SourceTypes.OGR, - Layer.SourceTypes.MDAL, - ].find(sourcetype => sourcetype === config.source.type)) { - if (config.geometrytype && config.geometrytype === 'NoGeometry') LayerClass = TableLayer; - else LayerClass = ImageLayer; - } - } else if ([ // here set new layer has to be threat as wms - Layer.SourceTypes.WMST, - Layer.SourceTypes.WCS, - Layer.SourceTypes.WMS, - Layer.SourceTypes.GDAL, - Layer.SourceTypes.VECTORTILE, - Layer.SourceTypes["VECTOR-TILE"], - Layer.SourceTypes.MDAL, - ].find(sourcetype => sourcetype === config.source.type)) LayerClass = ImageLayer; - } - break; - case Layer.ServerTypes.OGC: - if(config.source) { - const type = config.source.type; - switch (type) { - case Layer.SourceTypes.WMS: - LayerClass = ImageLayer; - break; - case Layer.SourceTypes.WFS: - LayerClass = VectorLayer; - } - } - break; - case Layer.ServerTypes.LOCAL: - LayerClass = VectorLayer; - break; - case Layer.ServerTypes.OSM: - case Layer.ServerTypes.BING: - case Layer.ServerTypes.TMS: - case Layer.ServerTypes.WMS: - case Layer.ServerTypes.WMTS: - case Layer.ServerTypes.ARCGISMAPSERVER: - LayerClass = BaseLayers[serverType]; - break; - case Layer.ServerTypes.G3WSUITE: - LayerClass = VectorLayer; - if (config.source) { - switch (config.source.type) { - case 'geojson': - LayerClass = GeojsonLayer; - break; - } - } - break; + } + + /** + * @returns layer class + */ + get(config = {}) { + + if (!config.servertype) { + console.warn('Undefined layer server type'); + return; } - return LayerClass; + + const is_qgis = Layer.ServerTypes.QGIS === config.servertype; + const is_ogc = Layer.ServerTypes.OGC === config.servertype; + const is_g3w = Layer.ServerTypes.G3WSUITE === config.servertype + const is_local = Layer.ServerTypes.LOCAL === config.servertype; + + const has_type = config.source && config.geometrytype; + const is_table = is_qgis && has_type && TABLE_LAYERS.includes(config.source.type); + const is_image = is_qgis && !has_type && IMAGE_LAYERS.includes(config.source.type); + const is_wms = is_ogc && config.source && Layer.SourceTypes.WMS === config.source.type; + const is_wfs = is_ogc && config.source && Layer.SourceTypes.WFS === config.source.type; + const is_geojson = is_g3w && config.source && Layer.SourceTypes.GEOJSON === config.source.type; + + const no_geom = config.geometrytype === 'NoGeometry'; + + const is_table_layer = is_table && no_geom; + const is_image_layer = (is_table && !no_geom) || is_image || is_wms + const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); + const is_base_layer = BASE_LAYERS.includes(config.servertype); + const is_geojson_layer = is_geojson; + + if (is_table_layer) return TableLayer; + if (is_image_layer) return ImageLayer; + if (is_vector_layer) return VectorLayer; + if (is_base_layer) return BaseLayers[config.servertype]; + if (is_geojson_layer) return GeojsonLayer; + + console.warn('Uknown layer server type', config); + + // return BaseLayers[config.source.type.toUpperCase()]; + // return ImageLayer; + } + } -module.exports = new LayerFactory(); +module.exports = new LayerFactory(); \ No newline at end of file From 3b6bce9b0ec11f2da10fafe0f191fd3e1c9cba12 Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 21 Jul 2023 11:36:55 +0200 Subject: [PATCH 02/14] delete folder `src/app/core/layers/baselayers/` --- .../core/layers/{baselayers => }/baselayer.js | 0 src/app/core/layers/baselayers/arcgislayer.js | 28 ----- src/app/core/layers/baselayers/baselayers.js | 10 -- src/app/core/layers/baselayers/binglayer.js | 47 ------- src/app/core/layers/baselayers/osmlayer.js | 23 ---- src/app/core/layers/baselayers/tmslayer.js | 29 ----- src/app/core/layers/baselayers/wmslayer.js | 29 ----- src/app/core/layers/baselayers/wmtslayer.js | 32 ----- src/app/core/layers/layerfactory.js | 119 ++++++++++++++++-- .../core/layers/map/baselayers/binglayer.js | 2 +- .../core/layers/map/baselayers/osmlayer.js | 2 +- 11 files changed, 110 insertions(+), 211 deletions(-) rename src/app/core/layers/{baselayers => }/baselayer.js (100%) delete mode 100644 src/app/core/layers/baselayers/arcgislayer.js delete mode 100644 src/app/core/layers/baselayers/baselayers.js delete mode 100644 src/app/core/layers/baselayers/binglayer.js delete mode 100644 src/app/core/layers/baselayers/osmlayer.js delete mode 100644 src/app/core/layers/baselayers/tmslayer.js delete mode 100644 src/app/core/layers/baselayers/wmslayer.js delete mode 100644 src/app/core/layers/baselayers/wmtslayer.js diff --git a/src/app/core/layers/baselayers/baselayer.js b/src/app/core/layers/baselayer.js similarity index 100% rename from src/app/core/layers/baselayers/baselayer.js rename to src/app/core/layers/baselayer.js diff --git a/src/app/core/layers/baselayers/arcgislayer.js b/src/app/core/layers/baselayers/arcgislayer.js deleted file mode 100644 index 1ee7a3c8e..000000000 --- a/src/app/core/layers/baselayers/arcgislayer.js +++ /dev/null @@ -1,28 +0,0 @@ -const { base, inherit } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); -const BasesLayers = require('g3w-ol/layers/bases'); - -function ARCGISMAPSERVERLayer(config={}, options={}) { - this.config = config; - base(this, config, options); -} - -inherit(ARCGISMAPSERVERLayer, BaseLayer); - -const proto = ARCGISMAPSERVERLayer.prototype; - -proto._makeOlLayer = function() { - // here configuration to create TMS - const {url, attributions, crs} = this.config; - const projection = this.getProjectionFromCrs(crs); - const olLayer = BasesLayers.TMS.get({ - url, - source_type: 'arcgismapserver', - projection, - attributions - }); - return olLayer -}; - - -module.exports = ARCGISMAPSERVERLayer; diff --git a/src/app/core/layers/baselayers/baselayers.js b/src/app/core/layers/baselayers/baselayers.js deleted file mode 100644 index 2cc887fc1..000000000 --- a/src/app/core/layers/baselayers/baselayers.js +++ /dev/null @@ -1,10 +0,0 @@ -const BaseLayers = { - 'OSM': require('./osmlayer'), - 'Bing': require('./binglayer'), - 'TMS': require('./tmslayer'), - 'ARCGISMAPSERVER': require('./arcgislayer'), - 'WMTS': require('./wmtslayer'), - 'WMS': require('./wmslayer') -}; - -module.exports = BaseLayers; diff --git a/src/app/core/layers/baselayers/binglayer.js b/src/app/core/layers/baselayers/binglayer.js deleted file mode 100644 index a7f776b5d..000000000 --- a/src/app/core/layers/baselayers/binglayer.js +++ /dev/null @@ -1,47 +0,0 @@ -import ApplicationState from 'store/application-state' - -const { base, inherit } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); -const BasesLayers = require('g3w-ol/layers/bases'); - -function BingLayer(config={}, options={}){ - base(this, config, options); -} - -inherit(BingLayer, BaseLayer); - -const proto = BingLayer.prototype; - -proto._makeOlLayer = function(){ - let olLayer; - const key = ApplicationState.keys.vendorkeys.bing; - const subtype = this.config.source ? this.config.source.subtype : null; - switch(subtype) { - case 'streets': - olLayer = BasesLayers.BING.get({ - imagerySet: 'Road', - key - }); - break; - case 'aerial': - olLayer = BasesLayers.BING.get({ - imagerySet: 'Aerial', - key - }); - break; - case 'aerialwithlabels': - olLayer = BasesLayers.BING.get({ - imagerySet: 'AerialWithLabels', - key - }); - break; - default: - olLayer = BasesLayers.BING.get({ - imagerySet: 'Aerial', - key - }); - } - return olLayer -}; - -module.exports = BingLayer; diff --git a/src/app/core/layers/baselayers/osmlayer.js b/src/app/core/layers/baselayers/osmlayer.js deleted file mode 100644 index eabd7397e..000000000 --- a/src/app/core/layers/baselayers/osmlayer.js +++ /dev/null @@ -1,23 +0,0 @@ -const { inherit, base } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); -const BasesLayers = require('g3w-ol/layers/bases'); - -function OSMLayer(config={}, options={}){ - base(this, config, options); -} - -inherit(OSMLayer, BaseLayer); - -const proto = OSMLayer.prototype; - -proto._makeOlLayer = function() { - const olLayer = BasesLayers.OSM.get({ - id: this.config.name, - title: this.config.title, - url: this.config.url - }); - return olLayer -}; - - -module.exports = OSMLayer; diff --git a/src/app/core/layers/baselayers/tmslayer.js b/src/app/core/layers/baselayers/tmslayer.js deleted file mode 100644 index 274d90f35..000000000 --- a/src/app/core/layers/baselayers/tmslayer.js +++ /dev/null @@ -1,29 +0,0 @@ -const { base, inherit } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); -const BasesLayers = require('g3w-ol/layers/bases'); - -function TMSLayer(config={}, options={}) { - this.config = config; - base(this, config, options); -} - -inherit(TMSLayer, BaseLayer); - -const proto = TMSLayer.prototype; - -proto._makeOlLayer = function() { - // here configuration to create TMS - const {url, attributions, minZoom, maxZoom, crs} = this.config; - const projection = this.getProjectionFromCrs(crs); - const olLayer = BasesLayers.TMS.get({ - url, - minZoom, - maxZoom, - attributions, - projection - }); - return olLayer -}; - - -module.exports = TMSLayer; diff --git a/src/app/core/layers/baselayers/wmslayer.js b/src/app/core/layers/baselayers/wmslayer.js deleted file mode 100644 index ba586354c..000000000 --- a/src/app/core/layers/baselayers/wmslayer.js +++ /dev/null @@ -1,29 +0,0 @@ -const { inherit, base } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); -const BasesLayers = require('g3w-ol/layers/bases'); - -function WMSLayer(config={}, options={}) { - this.config = config; - base(this, config, options); -} - -inherit(WMSLayer, BaseLayer); - -const proto = WMSLayer.prototype; - -proto._makeOlLayer = function() { - //use this config to get params - const {url, layers, singleTile, attributions, crs, opacity} = this.config; - const projection = this.getProjectionFromCrs(crs); - const olLayer = BasesLayers.WMS.get({ - url, - layers, - singleTile, - attributions, - projection, - opacity - }); - return olLayer -}; - -module.exports = WMSLayer; diff --git a/src/app/core/layers/baselayers/wmtslayer.js b/src/app/core/layers/baselayers/wmtslayer.js deleted file mode 100644 index da0195e81..000000000 --- a/src/app/core/layers/baselayers/wmtslayer.js +++ /dev/null @@ -1,32 +0,0 @@ -const { base, inherit } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); -const BasesLayers = require('g3w-ol/layers/bases'); - -function WMTSLayer(config={}, options={}) { - this.config = config; - base(this, config, options); -} - -inherit(WMTSLayer, BaseLayer); - -const proto = WMTSLayer.prototype; - -proto._makeOlLayer = function() { - //use this config to get params - const {url, layer, attributions, matrixSet, format, style, requestEncoding, crs} = this.config; - const projection = this.getProjectionFromCrs(crs); - const olLayer = BasesLayers.WMTS.get({ - url, - layer, - attributions, - format, - projection, - requestEncoding, - matrixSet, - style - }); - return olLayer -}; - - -module.exports = WMTSLayer; diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index b34a24ddf..47ec56d14 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -1,8 +1,11 @@ +import ApplicationState from 'store/application-state' + const Layer = require('core/layers/layer'); const TableLayer = require('core/layers/tablelayer'); const VectorLayer = require('core/layers/vectorlayer'); const ImageLayer = require('core/layers/imagelayer'); -const BaseLayers = require('core/layers/baselayers/baselayers'); +const BaseLayer = require('core/layers/baselayer'); +const BASE = require('g3w-ol/layers/bases'); const GeojsonLayer = require('core/layers/geojson'); const TABLE_LAYERS = [ @@ -27,14 +30,108 @@ const IMAGE_LAYERS = [ Layer.SourceTypes.MDAL, ]; -const BASE_LAYERS = [ - Layer.ServerTypes.OSM, - Layer.ServerTypes.BING, - Layer.ServerTypes.TMS, - Layer.ServerTypes.WMS, - Layer.ServerTypes.WMTS, - Layer.ServerTypes.ARCGISMAPSERVER, -]; +const BASE_LAYERS = { + + /** + * ORIGINAL SOURCE: src/core/layers/baselayers/osmlayer.js@3.8.6 + */ + [Layer.ServerTypes.OSM]: class OSMLayer extends BaseLayer { + _makeOlLayer() { + return BASE.OSM.get({ + id: this.config.name, + title: this.config.title, + url: this.config.url, + }); + } + }, + + /** + * ORIGINAL SOURCE: core/layers/baselayers/binglayer.js@3.8.6 + */ + [Layer.ServerTypes.BING]: class BingLayer extends BaseLayer { + _makeOlLayer() { + const key = ApplicationState.keys.vendorkeys.bing; + switch(this.config.source ? this.config.source.subtype : null) { + case 'streets': return BASE.BING.get({ key, imagerySet: 'Road' }); + case 'aerial': return BASE.BING.get({ key, imagerySet: 'Aerial' }); + case 'aerialwithlabels': return BASE.BING.get({ key, imagerySet: 'AerialWithLabels' }); + default: return BASE.BING.get({ key, imagerySet: 'Aerial' }); + } + } + }, + + /** + * ORIGINAL SOURCE: src/core/layers/baselayers/tmslayer.js@3.8.6 + */ + [Layer.ServerTypes.TMS]: class TMSLayer extends BaseLayer { + _makeOlLayer() { + // configuration to create TMS + const { url, attributions, minZoom, maxZoom, crs } = this.config; + return BASE.TMS.get({ + url, + minZoom, + maxZoom, + attributions, + projection: this.getProjectionFromCrs(crs), + }); + } + }, + + /** + * ORIGINAL SOURCE: src/require('core/layers/baselayers/arcgislayer.js@3.8.6 + */ + [Layer.ServerTypes.ARCGISMAPSERVER]: class ARCGISMAPSERVERLayer extends BaseLayer { + _makeOlLayer() { + // configuration to create TMS + const { url, attributions, crs } = this.config; + return BASE.TMS.get({ + url, + source_type: 'arcgismapserver', + projection: this.getProjectionFromCrs(crs), + attributions, + }); + } + }, + + /** + * ORIGINAL SOURCE: src/require('core/layers/baselayers/wmtslayer.js@3.8.6 + */ + [Layer.ServerTypes.WMTS]: class WMTSLayer extends BaseLayer { + _makeOlLayer() { + // use this config to get params + const { url, layer, attributions, matrixSet, format, style, requestEncoding, crs } = this.config; + return BASE.WMTS.get({ + url, + layer, + attributions, + format, + projection: this.getProjectionFromCrs(crs), + requestEncoding, + matrixSet, + style, + }); + } + }, + + /** + * ORIGINAL SOURCE: src/require('core/layers/baselayers/wmslayer.js@3.8.6 + */ + [Layer.ServerTypes.WMS]: class WMSLayer extends BaseLayer { + _makeOlLayer() { + // use this config to get params + const { url, layers, singleTile, attributions, crs, opacity } = this.config; + return BASE.WMS.get({ + url, + layers, + singleTile, + attributions, + projection: this.getProjectionFromCrs(crs), + opacity, + }); + } + }, + +}; // Class to build layer based on configuration class LayerFactory { @@ -74,13 +171,13 @@ class LayerFactory { const is_table_layer = is_table && no_geom; const is_image_layer = (is_table && !no_geom) || is_image || is_wms const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); - const is_base_layer = BASE_LAYERS.includes(config.servertype); + const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; if (is_table_layer) return TableLayer; if (is_image_layer) return ImageLayer; if (is_vector_layer) return VectorLayer; - if (is_base_layer) return BaseLayers[config.servertype]; + if (is_base_layer) return BASE_LAYERS[config.servertype]; if (is_geojson_layer) return GeojsonLayer; console.warn('Uknown layer server type', config); diff --git a/src/app/core/layers/map/baselayers/binglayer.js b/src/app/core/layers/map/baselayers/binglayer.js index 3a76bb43b..9c93c3b3c 100644 --- a/src/app/core/layers/map/baselayers/binglayer.js +++ b/src/app/core/layers/map/baselayers/binglayer.js @@ -1,5 +1,5 @@ const { base, inherit } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); +const BaseLayer = require('core/layers/baselayer'); const BasesLayers = require('g3w-ol/layers/bases'); function BingLayer(options){ diff --git a/src/app/core/layers/map/baselayers/osmlayer.js b/src/app/core/layers/map/baselayers/osmlayer.js index 4fd75f5b1..d4d31f012 100644 --- a/src/app/core/layers/map/baselayers/osmlayer.js +++ b/src/app/core/layers/map/baselayers/osmlayer.js @@ -1,5 +1,5 @@ const { inherit, base } = require('core/utils/utils'); -const BaseLayer = require('core/layers/baselayers/baselayer'); +const BaseLayer = require('core/layers/baselayer'); const BasesLayers = require('g3w-ol/layers/bases'); function OSMLayer(options={}){ From 6162e143f8e75baa1e2aa163e8a9e77215bc56cb Mon Sep 17 00:00:00 2001 From: volterra79 Date: Fri, 25 Aug 2023 14:26:36 +0200 Subject: [PATCH 03/14] Add comments and change variable names --- src/app/core/layers/layerfactory.js | 271 +++++++++++++++++++--------- 1 file changed, 190 insertions(+), 81 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 864cf363e..88d68461d 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -1,90 +1,199 @@ -const Layer = require('core/layers/layer'); -const TableLayer = require('core/layers/tablelayer'); -const VectorLayer = require('core/layers/vectorlayer'); -const ImageLayer = require('core/layers/imagelayer'); -const BaseLayers = require('core/layers/baselayers/baselayers'); +import ApplicationState from 'store/application-state' + +const Layer = require('core/layers/layer'); +const TableLayer = require('core/layers/tablelayer'); +const VectorLayer = require('core/layers/vectorlayer'); +const ImageLayer = require('core/layers/imagelayer'); +const BaseLayer = require('core/layers/baselayer'); +const BASE = require('g3w-ol/layers/bases'); const GeojsonLayer = require('core/layers/geojson'); +const SOURCE_WITH_GEOMETRY_TYPE = [ + Layer.SourceTypes.VIRTUAL, + Layer.SourceTypes.POSTGIS, + Layer.SourceTypes.MSSQL, + Layer.SourceTypes.SPATIALITE, + Layer.SourceTypes.WFS, + Layer.SourceTypes.CSV, + Layer.SourceTypes.ORACLE, + Layer.SourceTypes.OGR, + Layer.SourceTypes.MDAL, +]; + +const SOURCE_NO_GEOMETRY_TYPE = [ + Layer.SourceTypes.WMST, + Layer.SourceTypes.WCS, + Layer.SourceTypes.WMS, + Layer.SourceTypes.GDAL, + Layer.SourceTypes.VECTORTILE, + Layer.SourceTypes["VECTOR-TILE"], + Layer.SourceTypes.MDAL, + /** @since 3.8.7 */ + Layer.SourceTypes.ARCGISMAPSERVER, +]; + +const BASE_LAYERS = { + + /** + * ORIGINAL SOURCE: src/core/layers/baselayers/osmlayer.js@3.8.6 + */ + [Layer.ServerTypes.OSM]: class OSMLayer extends BaseLayer { + _makeOlLayer() { + return BASE.OSM.get({ + id: this.config.name, + title: this.config.title, + url: this.config.url, + }); + } + }, + + /** + * ORIGINAL SOURCE: core/layers/baselayers/binglayer.js@3.8.6 + */ + [Layer.ServerTypes.BING]: class BingLayer extends BaseLayer { + _makeOlLayer() { + const key = ApplicationState.keys.vendorkeys.bing; + switch(this.config.source ? this.config.source.subtype : null) { + case 'streets': return BASE.BING.get({ key, imagerySet: 'Road' }); + case 'aerial': return BASE.BING.get({ key, imagerySet: 'Aerial' }); + case 'aerialwithlabels': return BASE.BING.get({ key, imagerySet: 'AerialWithLabels' }); + default: return BASE.BING.get({ key, imagerySet: 'Aerial' }); + } + } + }, + + /** + * ORIGINAL SOURCE: src/core/layers/baselayers/tmslayer.js@3.8.6 + */ + [Layer.ServerTypes.TMS]: class TMSLayer extends BaseLayer { + _makeOlLayer() { + // configuration to create TMS + const { url, attributions, minZoom, maxZoom, crs } = this.config; + return BASE.TMS.get({ + url, + minZoom, + maxZoom, + attributions, + projection: this.getProjectionFromCrs(crs), + }); + } + }, + + /** + * ORIGINAL SOURCE: src/require('core/layers/baselayers/arcgislayer.js@3.8.6 + */ + [Layer.ServerTypes.ARCGISMAPSERVER]: class ARCGISMAPSERVERLayer extends BaseLayer { + _makeOlLayer() { + // configuration to create TMS + const { url, attributions, crs } = this.config; + return BASE.TMS.get({ + url, + source_type: 'arcgismapserver', + projection: this.getProjectionFromCrs(crs), + attributions, + }); + } + }, + + /** + * ORIGINAL SOURCE: src/require('core/layers/baselayers/wmtslayer.js@3.8.6 + */ + [Layer.ServerTypes.WMTS]: class WMTSLayer extends BaseLayer { + _makeOlLayer() { + // use this config to get params + const { url, layer, attributions, matrixSet, format, style, requestEncoding, crs } = this.config; + return BASE.WMTS.get({ + url, + layer, + attributions, + format, + projection: this.getProjectionFromCrs(crs), + requestEncoding, + matrixSet, + style, + }); + } + }, + + /** + * ORIGINAL SOURCE: src/require('core/layers/baselayers/wmslayer.js@3.8.6 + */ + [Layer.ServerTypes.WMS]: class WMSLayer extends BaseLayer { + _makeOlLayer() { + // use this config to get params + const { url, layers, singleTile, attributions, crs, opacity } = this.config; + return BASE.WMS.get({ + url, + layers, + singleTile, + attributions, + projection: this.getProjectionFromCrs(crs), + opacity, + }); + } + }, + +}; + // Class to build layer based on configuration -function LayerFactory() { - this.build = function(config, options) { - // return the layer instance +class LayerFactory { + + /** + * @returns layer instance + */ + build(config, options) { const layerClass = this.get(config); return layerClass ? new layerClass(config, options) : null - }; - - this.get = function(config={}) { - let LayerClass; - const serverType = config.servertype; - switch (serverType) { - case Layer.ServerTypes.QGIS: - if (config.source) { - if (config.geometrytype) { - if ([ - Layer.SourceTypes.VIRTUAL, - Layer.SourceTypes.POSTGIS, - Layer.SourceTypes.MSSQL, - Layer.SourceTypes.SPATIALITE, - Layer.SourceTypes.WFS, - Layer.SourceTypes.CSV, - Layer.SourceTypes.ORACLE, - Layer.SourceTypes.OGR, - Layer.SourceTypes.MDAL, - ].find(sourcetype => sourcetype === config.source.type)) { - if (config.geometrytype && config.geometrytype === 'NoGeometry') LayerClass = TableLayer; - else LayerClass = ImageLayer; - } - } else if ([ // here set new layer has to be threat as wms - Layer.SourceTypes.WMST, - Layer.SourceTypes.WCS, - Layer.SourceTypes.WMS, - Layer.SourceTypes.GDAL, - Layer.SourceTypes.VECTORTILE, - Layer.SourceTypes["VECTOR-TILE"], - Layer.SourceTypes.MDAL, - /** - * @since 3.8.7 - */ - Layer.SourceTypes.ARCGISMAPSERVER, - ].find(sourcetype => sourcetype === config.source.type)) LayerClass = ImageLayer; - } - break; - case Layer.ServerTypes.OGC: - if(config.source) { - const type = config.source.type; - switch (type) { - case Layer.SourceTypes.WMS: - LayerClass = ImageLayer; - break; - case Layer.SourceTypes.WFS: - LayerClass = VectorLayer; - } - } - break; - case Layer.ServerTypes.LOCAL: - LayerClass = VectorLayer; - break; - case Layer.ServerTypes.OSM: - case Layer.ServerTypes.BING: - case Layer.ServerTypes.TMS: - case Layer.ServerTypes.WMS: - case Layer.ServerTypes.WMTS: - case Layer.ServerTypes.ARCGISMAPSERVER: - LayerClass = BaseLayers[serverType]; - break; - case Layer.ServerTypes.G3WSUITE: - LayerClass = VectorLayer; - if (config.source) { - switch (config.source.type) { - case 'geojson': - LayerClass = GeojsonLayer; - break; - } - } - break; + } + + /** + * @returns layer class + */ + get(config = {}) { + + if (!config.servertype) { + console.warn('Undefined layer server type'); + return; } - return LayerClass; + + //Check ServerTypes + const is_qgis = Layer.ServerTypes.QGIS === config.servertype; + const is_ogc = Layer.ServerTypes.OGC === config.servertype; + const is_g3w = Layer.ServerTypes.G3WSUITE === config.servertype + const is_local = Layer.ServerTypes.LOCAL === config.servertype; + + const is_wms = is_ogc && config.source && Layer.SourceTypes.WMS === config.source.type; + const is_wfs = is_ogc && config.source && Layer.SourceTypes.WFS === config.source.type ; + const is_geojson = is_g3w && config.source && Layer.SourceTypes.GEOJSON === config.source.type ; + + //Check geometrytype + const has_geometrytype = config.geometrytype; + const no_geom = config.geometrytype === 'NoGeometry'; + + const is_qgis_with_geometrytype = is_qgis && has_geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); + const is_qgis_no_geometrytype = is_qgis && !has_geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); + + //Check layer type + const is_table_layer = is_qgis_with_geometrytype && no_geom; + const is_image_layer = is_wms || (is_qgis_with_geometrytype && false === no_geom) || is_qgis_no_geometrytype; + const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); + const is_base_layer = config.servertype in BASE_LAYERS; + const is_geojson_layer = is_geojson; + + //Return Class + if (is_table_layer) return TableLayer; + if (is_image_layer) return ImageLayer; + if (is_vector_layer) return VectorLayer; + if (is_base_layer) return BASE_LAYERS[config.servertype]; + if (is_geojson_layer) return GeojsonLayer; + + console.warn('Uknown layer server type', config); + + // return BaseLayers[config.source.type.toUpperCase()]; + // return ImageLayer; + } + } -module.exports = new LayerFactory(); +module.exports = new LayerFactory(); \ No newline at end of file From c1389cc7d26d75d15903c8e1b2df111a7ca34a7d Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 14:41:26 +0200 Subject: [PATCH 04/14] start simplifying geomtype --- src/app/core/layers/layerfactory.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 88d68461d..ba8b0413d 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -167,15 +167,13 @@ class LayerFactory { const is_geojson = is_g3w && config.source && Layer.SourceTypes.GEOJSON === config.source.type ; //Check geometrytype - const has_geometrytype = config.geometrytype; - const no_geom = config.geometrytype === 'NoGeometry'; - - const is_qgis_with_geometrytype = is_qgis && has_geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); - const is_qgis_no_geometrytype = is_qgis && !has_geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); + const has_geom = config.geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); + const no_geom = config.geometrytype === 'NoGeometry'; + const no_geometrytype = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); //Check layer type - const is_table_layer = is_qgis_with_geometrytype && no_geom; - const is_image_layer = is_wms || (is_qgis_with_geometrytype && false === no_geom) || is_qgis_no_geometrytype; + const is_table_layer = is_qgis && with_geometrytype && no_geom; + const is_image_layer = is_wms || (is_qgis && has_geom && false === no_geom) || no_geometrytype; const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; From 3686d630371733f392aebbc1c0fe4f8f7cd274df Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 14:42:51 +0200 Subject: [PATCH 05/14] missing var --- src/app/core/layers/layerfactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index ba8b0413d..f97d8998a 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -172,7 +172,7 @@ class LayerFactory { const no_geometrytype = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); //Check layer type - const is_table_layer = is_qgis && with_geometrytype && no_geom; + const is_table_layer = is_qgis && has_geom && no_geom; const is_image_layer = is_wms || (is_qgis && has_geom && false === no_geom) || no_geometrytype; const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; From 1eedddf4c8910e6deb31d44e1a8ba1f3ecfc2018 Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 14:58:13 +0200 Subject: [PATCH 06/14] add `is_empty` --- src/app/core/layers/layerfactory.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index f97d8998a..100cf981d 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -167,13 +167,13 @@ class LayerFactory { const is_geojson = is_g3w && config.source && Layer.SourceTypes.GEOJSON === config.source.type ; //Check geometrytype - const has_geom = config.geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); - const no_geom = config.geometrytype === 'NoGeometry'; - const no_geometrytype = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); + const is_empty = config.geometrytype === 'NoGeometry'; + const has_geom = config.geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); + const no_geom = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); //Check layer type - const is_table_layer = is_qgis && has_geom && no_geom; - const is_image_layer = is_wms || (is_qgis && has_geom && false === no_geom) || no_geometrytype; + const is_table_layer = is_qgis && has_geom && is_empty; + const is_image_layer = is_wms || no_geom || (is_qgis && has_geom); const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; From 5c604581dc652f172b9dc939c7bf3939a8b0df75 Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 15:05:35 +0200 Subject: [PATCH 07/14] shorten variable names --- src/app/core/layers/layerfactory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 100cf981d..453f115fb 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -8,7 +8,7 @@ const BaseLayer = require('core/layers/baselayer'); const BASE = require('g3w-ol/layers/bases'); const GeojsonLayer = require('core/layers/geojson'); -const SOURCE_WITH_GEOMETRY_TYPE = [ +const WITH_GEOMETRY = [ Layer.SourceTypes.VIRTUAL, Layer.SourceTypes.POSTGIS, Layer.SourceTypes.MSSQL, @@ -20,7 +20,7 @@ const SOURCE_WITH_GEOMETRY_TYPE = [ Layer.SourceTypes.MDAL, ]; -const SOURCE_NO_GEOMETRY_TYPE = [ +const NO_GEOMETRY = [ Layer.SourceTypes.WMST, Layer.SourceTypes.WCS, Layer.SourceTypes.WMS, @@ -168,8 +168,8 @@ class LayerFactory { //Check geometrytype const is_empty = config.geometrytype === 'NoGeometry'; - const has_geom = config.geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); - const no_geom = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); + const has_geom = config.geometrytype && WITH_GEOMETRY.includes(config.source && config.source.type); + const no_geom = !config.geometrytype && NO_GEOMETRY.includes(config.source && config.source.type); //Check layer type const is_table_layer = is_qgis && has_geom && is_empty; From 6d1b500b1f6e9f46b29f0b21f9479d1f0df85ff3 Mon Sep 17 00:00:00 2001 From: volterra79 Date: Fri, 25 Aug 2023 15:08:37 +0200 Subject: [PATCH 08/14] Add source variable and handle no and has geom --- src/app/core/layers/layerfactory.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 100cf981d..741521028 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -162,18 +162,20 @@ class LayerFactory { const is_g3w = Layer.ServerTypes.G3WSUITE === config.servertype const is_local = Layer.ServerTypes.LOCAL === config.servertype; - const is_wms = is_ogc && config.source && Layer.SourceTypes.WMS === config.source.type; - const is_wfs = is_ogc && config.source && Layer.SourceTypes.WFS === config.source.type ; - const is_geojson = is_g3w && config.source && Layer.SourceTypes.GEOJSON === config.source.type ; + //get source + const source = config.source || {}; + + const is_wms = is_ogc && Layer.SourceTypes.WMS === source.type; + const is_wfs = is_ogc && Layer.SourceTypes.WFS === source.type ; + const is_geojson = is_g3w && Layer.SourceTypes.GEOJSON === source.type ; //Check geometrytype - const is_empty = config.geometrytype === 'NoGeometry'; - const has_geom = config.geometrytype && SOURCE_WITH_GEOMETRY_TYPE.includes(config.source.type); - const no_geom = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(config.source.type); + const has_geom = config.geometrytype && config.geometrytype !== 'NoGeometry' && SOURCE_WITH_GEOMETRY_TYPE.includes(source.type); + const no_geom = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(source.type); //Check layer type - const is_table_layer = is_qgis && has_geom && is_empty; - const is_image_layer = is_wms || no_geom || (is_qgis && has_geom); + const is_table_layer = is_qgis && has_geom && config.geometrytype === 'NoGeometry'; + const is_image_layer = is_wms || is_qgis && (no_geom || has_geom); const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; From dc7395c640606cc51a44e98c313a08ae4e38a9a5 Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 15:09:21 +0200 Subject: [PATCH 09/14] comments --- src/app/core/layers/layerfactory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 453f115fb..f4c6f17a4 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -156,7 +156,7 @@ class LayerFactory { return; } - //Check ServerTypes + // Check Server Type const is_qgis = Layer.ServerTypes.QGIS === config.servertype; const is_ogc = Layer.ServerTypes.OGC === config.servertype; const is_g3w = Layer.ServerTypes.G3WSUITE === config.servertype @@ -166,19 +166,19 @@ class LayerFactory { const is_wfs = is_ogc && config.source && Layer.SourceTypes.WFS === config.source.type ; const is_geojson = is_g3w && config.source && Layer.SourceTypes.GEOJSON === config.source.type ; - //Check geometrytype + // Check Geometry Type const is_empty = config.geometrytype === 'NoGeometry'; const has_geom = config.geometrytype && WITH_GEOMETRY.includes(config.source && config.source.type); const no_geom = !config.geometrytype && NO_GEOMETRY.includes(config.source && config.source.type); - //Check layer type + // Check Layer type const is_table_layer = is_qgis && has_geom && is_empty; const is_image_layer = is_wms || no_geom || (is_qgis && has_geom); const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; - //Return Class + // Return Layer Class if (is_table_layer) return TableLayer; if (is_image_layer) return ImageLayer; if (is_vector_layer) return VectorLayer; From 1cbcf34411cbed7abe438563955bedbe41ac9810 Mon Sep 17 00:00:00 2001 From: volterra79 Date: Fri, 25 Aug 2023 15:14:56 +0200 Subject: [PATCH 10/14] refactor is_table_layer is_image_layer --- src/app/core/layers/layerfactory.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index b6a201ae0..09cfba38b 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -170,12 +170,12 @@ class LayerFactory { const is_geojson = is_g3w && Layer.SourceTypes.GEOJSON === source.type ; //Check geometrytype - const has_geom = config.geometrytype && config.geometrytype !== 'NoGeometry' && SOURCE_WITH_GEOMETRY_TYPE.includes(source.type); - const no_geom = !config.geometrytype && SOURCE_NO_GEOMETRY_TYPE.includes(source.type); + const has_geom = config.geometrytype && WITH_GEOMETRY.includes(source.type); + const no_geom = !config.geometrytype && NO_GEOMETRY.includes(source.type); //Check layer type const is_table_layer = is_qgis && has_geom && config.geometrytype === 'NoGeometry'; - const is_image_layer = is_wms || is_qgis && (no_geom || has_geom); + const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && config.geometrytype !== 'NoGeometry')); const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; From ba378e88a55d197113fd3ede3f8b19997c92da0b Mon Sep 17 00:00:00 2001 From: volterra79 Date: Fri, 25 Aug 2023 15:26:57 +0200 Subject: [PATCH 11/14] explicit boolean condition --- src/app/core/layers/layerfactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 9b304e1e5..8ab8aa0f4 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -176,7 +176,7 @@ class LayerFactory { //Check layer type const is_table_layer = is_qgis && has_geom && config.geometrytype === 'NoGeometry'; const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && config.geometrytype !== 'NoGeometry')); - const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); + const is_vector_layer = is_local || is_wfs || (is_g3w && false === is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; From 0fe4120a455974a93d5fa737bc29f1e21d92fcd7 Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 15:33:28 +0200 Subject: [PATCH 12/14] simplify please --- src/app/core/layers/layerfactory.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 8ab8aa0f4..f89fb6779 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -156,27 +156,28 @@ class LayerFactory { return; } + // Get Source + const source = config.source || {}; + // Check Server Type const is_qgis = Layer.ServerTypes.QGIS === config.servertype; const is_ogc = Layer.ServerTypes.OGC === config.servertype; const is_g3w = Layer.ServerTypes.G3WSUITE === config.servertype const is_local = Layer.ServerTypes.LOCAL === config.servertype; - //get source - const source = config.source || {}; - const is_wms = is_ogc && Layer.SourceTypes.WMS === source.type; const is_wfs = is_ogc && Layer.SourceTypes.WFS === source.type ; const is_geojson = is_g3w && Layer.SourceTypes.GEOJSON === source.type ; - //Check geometrytype + // Check Geometry Type + const is_tabular = config.geometrytype === 'NoGeometry'; const has_geom = config.geometrytype && WITH_GEOMETRY.includes(source.type); const no_geom = !config.geometrytype && NO_GEOMETRY.includes(source.type); - //Check layer type - const is_table_layer = is_qgis && has_geom && config.geometrytype === 'NoGeometry'; - const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && config.geometrytype !== 'NoGeometry')); - const is_vector_layer = is_local || is_wfs || (is_g3w && false === is_geojson); + // Check Layer Type + const is_table_layer = is_qgis && has_geom && is_tabular; + const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && !is_tabular); + const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; const is_geojson_layer = is_geojson; From 2c33d7db48ebfe08e3d006ebb0256ddd2b8aff7f Mon Sep 17 00:00:00 2001 From: volterra79 Date: Fri, 25 Aug 2023 15:42:13 +0200 Subject: [PATCH 13/14] Fix missing bracket and explicit boolean condition --- src/app/core/layers/layerfactory.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index f89fb6779..56c7bdbcd 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -175,10 +175,10 @@ class LayerFactory { const no_geom = !config.geometrytype && NO_GEOMETRY.includes(source.type); // Check Layer Type - const is_table_layer = is_qgis && has_geom && is_tabular; - const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && !is_tabular); - const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_base_layer = config.servertype in BASE_LAYERS; + const is_table_layer = is_qgis && has_geom && is_tabular; + const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && !is_tabular)); + const is_vector_layer = is_local || is_wfs || (is_g3w && false === is_geojson); const is_geojson_layer = is_geojson; // Return Layer Class From ed3883fed491178b774bf96902ea03e7d8d763de Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 25 Aug 2023 15:44:38 +0200 Subject: [PATCH 14/14] remove yoda --- src/app/core/layers/layerfactory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/core/layers/layerfactory.js b/src/app/core/layers/layerfactory.js index 56c7bdbcd..9ebbfb4e3 100644 --- a/src/app/core/layers/layerfactory.js +++ b/src/app/core/layers/layerfactory.js @@ -165,9 +165,9 @@ class LayerFactory { const is_g3w = Layer.ServerTypes.G3WSUITE === config.servertype const is_local = Layer.ServerTypes.LOCAL === config.servertype; - const is_wms = is_ogc && Layer.SourceTypes.WMS === source.type; - const is_wfs = is_ogc && Layer.SourceTypes.WFS === source.type ; - const is_geojson = is_g3w && Layer.SourceTypes.GEOJSON === source.type ; + const is_wms = is_ogc && Layer.SourceTypes.WMS === source.type; + const is_wfs = is_ogc && Layer.SourceTypes.WFS === source.type; + const is_geojson = is_g3w && Layer.SourceTypes.GEOJSON === source.type; // Check Geometry Type const is_tabular = config.geometrytype === 'NoGeometry'; @@ -178,7 +178,7 @@ class LayerFactory { const is_base_layer = config.servertype in BASE_LAYERS; const is_table_layer = is_qgis && has_geom && is_tabular; const is_image_layer = is_wms || is_qgis && (no_geom || (has_geom && !is_tabular)); - const is_vector_layer = is_local || is_wfs || (is_g3w && false === is_geojson); + const is_vector_layer = is_local || is_wfs || (is_g3w && !is_geojson); const is_geojson_layer = is_geojson; // Return Layer Class