2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2018-04-04 21:52:54 +08:00
|
|
|
const { Router: router } = require('express');
|
|
|
|
|
2018-04-09 22:18:30 +08:00
|
|
|
const AnalysisLayergroupController = require('./analysis-layergroup-controller');
|
|
|
|
const AttributesLayergroupController = require('./attributes-layergroup-controller');
|
|
|
|
const DataviewLayergroupController = require('./dataview-layergroup-controller');
|
|
|
|
const PreviewLayergroupController = require('./preview-layergroup-controller');
|
|
|
|
const TileLayergroupController = require('./tile-layergroup-controller');
|
|
|
|
const AnonymousMapController = require('./anonymous-map-controller');
|
|
|
|
const PreviewTemplateController = require('./preview-template-controller');
|
|
|
|
const AnalysesCatalogController = require('./analyses-catalog-controller');
|
2019-02-27 02:19:44 +08:00
|
|
|
const ClusteredFeaturesLayergroupController = require('./clustered-features-layergroup-controller');
|
2018-04-04 21:52:54 +08:00
|
|
|
|
|
|
|
module.exports = class MapRouter {
|
2018-05-09 20:59:21 +08:00
|
|
|
constructor ({ collaborators }) {
|
2018-04-04 21:52:54 +08:00
|
|
|
const {
|
2020-04-29 01:17:00 +08:00
|
|
|
config,
|
2018-04-04 21:52:54 +08:00
|
|
|
analysisStatusBackend,
|
|
|
|
attributesBackend,
|
|
|
|
dataviewBackend,
|
|
|
|
previewBackend,
|
|
|
|
tileBackend,
|
|
|
|
pgConnection,
|
|
|
|
mapStore,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
layergroupAffectedTablesCache,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
surrogateKeysCache,
|
|
|
|
templateMaps,
|
|
|
|
mapBackend,
|
|
|
|
metadataBackend,
|
|
|
|
mapConfigAdapter,
|
|
|
|
statsBackend,
|
|
|
|
layergroupMetadata,
|
|
|
|
namedMapProviderCache,
|
2019-02-27 02:19:44 +08:00
|
|
|
tablesExtentBackend,
|
2020-04-29 01:17:00 +08:00
|
|
|
clusterBackend,
|
|
|
|
metricsBackend
|
2018-04-04 21:52:54 +08:00
|
|
|
} = collaborators;
|
|
|
|
|
|
|
|
this.analysisLayergroupController = new AnalysisLayergroupController(
|
|
|
|
analysisStatusBackend,
|
|
|
|
pgConnection,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-12 00:51:44 +08:00
|
|
|
authBackend
|
2018-04-04 21:52:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
this.attributesLayergroupController = new AttributesLayergroupController(
|
|
|
|
attributesBackend,
|
|
|
|
pgConnection,
|
|
|
|
mapStore,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
layergroupAffectedTablesCache,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
surrogateKeysCache
|
|
|
|
);
|
|
|
|
|
|
|
|
this.dataviewLayergroupController = new DataviewLayergroupController(
|
|
|
|
dataviewBackend,
|
|
|
|
pgConnection,
|
|
|
|
mapStore,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
layergroupAffectedTablesCache,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
surrogateKeysCache
|
|
|
|
);
|
|
|
|
|
|
|
|
this.previewLayergroupController = new PreviewLayergroupController(
|
|
|
|
previewBackend,
|
|
|
|
pgConnection,
|
|
|
|
mapStore,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
layergroupAffectedTablesCache,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
surrogateKeysCache
|
|
|
|
);
|
|
|
|
|
|
|
|
this.tileLayergroupController = new TileLayergroupController(
|
|
|
|
tileBackend,
|
|
|
|
pgConnection,
|
|
|
|
mapStore,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
layergroupAffectedTablesCache,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
surrogateKeysCache
|
|
|
|
);
|
|
|
|
|
|
|
|
this.anonymousMapController = new AnonymousMapController(
|
2020-04-29 01:17:00 +08:00
|
|
|
config,
|
2018-04-04 21:52:54 +08:00
|
|
|
pgConnection,
|
|
|
|
templateMaps,
|
|
|
|
mapBackend,
|
|
|
|
metadataBackend,
|
|
|
|
surrogateKeysCache,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
layergroupAffectedTablesCache,
|
|
|
|
mapConfigAdapter,
|
|
|
|
statsBackend,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2020-04-29 01:17:00 +08:00
|
|
|
layergroupMetadata,
|
|
|
|
metricsBackend
|
2018-04-04 21:52:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
this.previewTemplateController = new PreviewTemplateController(
|
2020-04-29 01:17:00 +08:00
|
|
|
config,
|
2018-04-04 21:52:54 +08:00
|
|
|
namedMapProviderCache,
|
|
|
|
previewBackend,
|
|
|
|
surrogateKeysCache,
|
2018-04-10 15:40:09 +08:00
|
|
|
tablesExtentBackend,
|
2018-04-04 21:52:54 +08:00
|
|
|
metadataBackend,
|
|
|
|
pgConnection,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2020-04-29 01:17:00 +08:00
|
|
|
userLimitsBackend,
|
|
|
|
metricsBackend
|
2018-04-04 21:52:54 +08:00
|
|
|
);
|
|
|
|
|
2018-04-09 22:18:30 +08:00
|
|
|
this.analysesController = new AnalysesCatalogController(
|
2018-04-04 21:52:54 +08:00
|
|
|
pgConnection,
|
2018-04-10 00:08:56 +08:00
|
|
|
authBackend,
|
2018-04-10 16:16:07 +08:00
|
|
|
userLimitsBackend
|
2018-04-04 21:52:54 +08:00
|
|
|
);
|
2019-02-27 02:19:44 +08:00
|
|
|
|
|
|
|
this.clusteredFeaturesLayergroupController = new ClusteredFeaturesLayergroupController(
|
|
|
|
clusterBackend,
|
|
|
|
pgConnection,
|
|
|
|
mapStore,
|
|
|
|
userLimitsBackend,
|
|
|
|
layergroupAffectedTablesCache,
|
|
|
|
authBackend,
|
|
|
|
surrogateKeysCache
|
|
|
|
);
|
2018-04-04 21:52:54 +08:00
|
|
|
}
|
|
|
|
|
2019-10-04 18:22:23 +08:00
|
|
|
route (apiRouter, routes) {
|
2018-05-14 17:50:48 +08:00
|
|
|
const mapRouter = router({ mergeParams: true });
|
2018-04-04 21:52:54 +08:00
|
|
|
|
2019-10-04 18:07:58 +08:00
|
|
|
routes.forEach(route => {
|
|
|
|
const { paths, middlewares = [] } = route;
|
2019-10-01 01:18:24 +08:00
|
|
|
|
2019-10-04 18:07:58 +08:00
|
|
|
middlewares.forEach(middleware => mapRouter.use(middleware()));
|
2018-04-04 21:52:54 +08:00
|
|
|
|
2019-10-04 18:22:23 +08:00
|
|
|
this.analysisLayergroupController.route(mapRouter);
|
|
|
|
this.attributesLayergroupController.route(mapRouter);
|
|
|
|
this.dataviewLayergroupController.route(mapRouter);
|
|
|
|
this.previewLayergroupController.route(mapRouter);
|
|
|
|
this.tileLayergroupController.route(mapRouter);
|
|
|
|
this.anonymousMapController.route(mapRouter);
|
|
|
|
this.previewTemplateController.route(mapRouter);
|
|
|
|
this.analysesController.route(mapRouter);
|
|
|
|
this.clusteredFeaturesLayergroupController.route(mapRouter);
|
2019-10-04 18:07:58 +08:00
|
|
|
|
|
|
|
paths.forEach(path => apiRouter.use(path, mapRouter));
|
|
|
|
});
|
2018-04-04 21:52:54 +08:00
|
|
|
}
|
|
|
|
};
|