Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

99 tile layers #103

Merged
merged 5 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- added option to use tile layers in map with data provided by external url [#103](https://github.com/openkfw/Oscar/pull/103/files)
- new route for unique featureIds for one attributeId [#86](https://github.com/openkfw/Oscar/pull/86/files)
- option to store geographical data in database collection [#85](https://github.com/openkfw/Oscar/issues/85) [#94](https://github.com/openkfw/Oscar/pull/94)
- pdf button for exporting dashboard tab as pdf document
Expand Down
1 change: 1 addition & 0 deletions api/src/actions/mapLayersActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const getMapLayersWithGeoData = async () => {
$or: [
...filterOr,
{ layerType: 'points' }, // layers with all values stored in pointAttributes collection, like disaster response functionality
{ layerType: 'tile' }, // layers with tile data at external url
],
};

Expand Down
10 changes: 9 additions & 1 deletion doc/data-structures/config-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ _or with geodata file provided in folder './initial-data-load/data/{COUNTRY}/geo

## mapLayers.yml

This config file is one long array with settings for layers in map. As there are multiple types of layers (regions, points on map, any geometrical objects or even combination of them) and also multiple sources of data for one layer, the structure of items in array may vary greatly.
This config file is one long array with settings for layers in map. As there are multiple types of layers (regions, points on map, any geometrical objects or even combination of them and tile layers) and also multiple sources of data for one layer, the structure of items in array may vary greatly.

![mapLayersStructure](./mapLayersStructure.jpg)

Expand All @@ -140,6 +140,10 @@ This config file is one long array with settings for layers in map. As there are

**featureId**: property in Feature in geojson file under which the value for 'featureId' in attributes is stored,

**tileDataUrl**: url of map tile layer data source,

**tileAttributions**: attributions of the tile layer data source,

**metadata**: informations about data in layer, they are shown when you click on info button aside from map layer in layers menu

- **description**:,
Expand Down Expand Up @@ -202,6 +206,10 @@ As the name of it prompts, with this enabled, the stroke line is dashed.

Not always are data nicely structured in only one way. For this cases, combined layers style is able to show points and geometrical shapes in one layer.

##### tile layer

Tile layer provides an option to display data provided by external data source through url in form of map tiles.

#### Legend object

Legend values are closely intertwined with style. Basically for each color or colormap used in visualisation, there should be one item in legend array.
Expand Down
1 change: 1 addition & 0 deletions frontend/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const staticLayersTypes = {
GEOMETRY: 'geometry',
GROUP: 'group',
COMBINED: 'combined',
TILE: 'tile',
};
// static layer color types
export const staticLayerColorTypes = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ol/staticLayers/layerTypes/combined.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const combinedLayer = (layerData, handleIsLoading) => {
featureId: layerData.featureId,
type: layerData.layerType,
source: vectorSource,
zIndex: 1,
zIndex: 2,
style: combinedStyleFactory(layerData.attribute, layerData.style),
legend: layerData.legend,
minZoom: 11,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ol/staticLayers/layerTypes/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const geometryLayer = (layerData, handleIsLoading) => {
featureId: layerData.featureId,
type: layerData.layerType,
source: createVectorSource(layerData, handleIsLoading),
zIndex: 1,
zIndex: 2,
style: geometryStyleFactory(layerData.attribute, layerData.style),
legend: layerData.legend,
layerOptions: layerData.layerOptions,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ol/staticLayers/layerTypes/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const pointsLayer = (layerData, handleIsLoading) => {
}),
style: pointStyleFactory(layerData.attribute, layerData.style),
legend: layerData.legend,
zIndex: 2,
zIndex: 3,
layerOptions: layerData.layerOptions,
maxResolution: (layerData.layerOptions && layerData.layerOptions.maxResolution) || layerData.maxResolution,
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ol/staticLayers/layerTypes/regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const regionsLayer = (layerData, handleIsLoading) => {
source: vectorSource,
style: regionStyleFactory(layerData.attribute, layerData.style),
legend: layerData.legend,
zIndex: 0,
zIndex: 1,
layerOptions: layerData.layerOptions,
maxResolution: (layerData.layerOptions && layerData.layerOptions.maxResolution) || layerData.maxResolution,
});
Expand Down
28 changes: 28 additions & 0 deletions frontend/src/ol/staticLayers/layerTypes/tiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';

const tileLayer = (layerData) => {
const newLayer = new TileLayer({
title: layerData.title,
attribute: layerData.attribute,
attributeDescription: layerData.attributeDescription,
featureId: layerData.featureId,
type: layerData.layerType,
source: new XYZ({
url: layerData.tileDataUrl,
attributions: layerData.tileAttributions,
}),
zIndex: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this should be always below 'region' so I suggest bump the rest +1 (regions =1, geometry, combined = 2 and point=3)

layerOptions: layerData.layerOptions,
maxResolution: (layerData.layerOptions && layerData.layerOptions.maxResolution) || layerData.maxResolution,
});
newLayer.selectable = true;
if (layerData.visible) {
newLayer.setVisible(true);
} else {
newLayer.setVisible(false);
}
return newLayer;
};

export default tileLayer;
4 changes: 4 additions & 0 deletions frontend/src/ol/staticLayers/staticLayerGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import regionsLayer from './layerTypes/regions';
import pointsLayer from './layerTypes/points';
import geometryLayer from './layerTypes/geometry';
import combinedLayer from './layerTypes/combined';
import tileLayer from './layerTypes/tiles';
// eslint-disable-next-line import/no-cycle
import groupLayer from './layerTypes/group';

Expand All @@ -29,6 +30,9 @@ const staticLayerGenerator = (layerData, handleIsLoading) => {
case staticLayersTypes.COMBINED: {
return combinedLayer({ ...layerData, layerOptions }, handleIsLoading);
}
case staticLayersTypes.TILE: {
return tileLayer({ ...layerData, layerOptions }, handleIsLoading);
}
// eslint-disable-next-line no-empty
default: {
}
Expand Down
4 changes: 4 additions & 0 deletions initial-data-load/src/mapLayers/mapLayersSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const OneMapLayerData = new mongoose.Schema(
featureId: String,
style: StyleSchema,
legend: [LegendSchema],
tileDataUrl: String,
tileAttributions: String,
},
{ _id: false },
);
Expand All @@ -90,6 +92,8 @@ const MapLayerSchema = new mongoose.Schema({
metadata: MetadataSchema,
timeseries: Boolean,
layerOptions: LayerOptionsSchema,
tileDataUrl: String,
tileAttributions: String,
});

const MapLayer = mongoose.model('MapLayer', MapLayerSchema, 'mapLayers');
Expand Down
2 changes: 2 additions & 0 deletions initial-data-load/src/mapLayers/mapLayersUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const addMapLayer = async (data) => {
legend: data.legend,
timeseries: data.timeseries,
layerOptions: data.layerOptions,
tileDataUrl: data.tileDataUrl,
tileAttributions: data.tileAttributions,
};
};

Expand Down