Skip to content

Commit 2ec03ec

Browse files
authored
Metadata Improvements + bug fixes (#320)
2 parents 7d43bb2 + e4fc1dd commit 2ec03ec

File tree

20 files changed

+319
-353
lines changed

20 files changed

+319
-353
lines changed

backend/api-gateway/Controllers/APIGatewayController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public APIGatewayController(HttpClient httpClient, ILogger<APIGatewayController>
3333
/// </summary>
3434
/// <returns>A list of available datasets</returns>
3535
[HttpGet("getDatasetList")]
36-
[ProducesResponseType(typeof(List<DatasetBasicData>), 200)]
36+
[ProducesResponseType(typeof(List<MetadataObject.BasicData>), 200)]
3737
[ProducesResponseType(400)]
3838
public async Task<IActionResult> GetDataSetList()
3939
{
@@ -44,7 +44,7 @@ public async Task<IActionResult> GetDataSetList()
4444

4545
var collection = _mongoDBService.GetDatasetsCollection();
4646
var datasets = await collection.Find(_ => true).ToListAsync();
47-
var datasetBasicDataList = datasets.Select(d => d.BasicData).ToList();
47+
var datasetBasicDataList = datasets.Select(d => d.basicData).ToList();
4848

4949
return Ok(datasetBasicDataList);
5050
}
@@ -55,7 +55,7 @@ public async Task<IActionResult> GetDataSetList()
5555
/// <param name="datasetID">The ID of the dataset</param>
5656
/// <returns>Metadata for the specified dataset</returns>
5757
[HttpGet("getDatasetMetadata")]
58-
[ProducesResponseType(typeof(DatasetMetadata), 200)]
58+
[ProducesResponseType(typeof(MetadataObject), 200)]
5959
[ProducesResponseType(400)]
6060
[ProducesResponseType(404)]
6161
public async Task<IActionResult> GetDatasetMetadata([FromQuery, Required] string datasetID)
@@ -66,14 +66,14 @@ public async Task<IActionResult> GetDatasetMetadata([FromQuery, Required] string
6666
}
6767

6868
var collection = _mongoDBService.GetDatasetsCollection();
69-
var dataset = await collection.Find(d => d.BasicData.DatasetId == datasetID).FirstOrDefaultAsync();
69+
var dataset = await collection.Find(d => d.basicData.DatasetId == datasetID).FirstOrDefaultAsync();
7070

7171
if (dataset == null)
7272
{
7373
return NotFound($"Dataset with ID {datasetID} not found.");
7474
}
7575

76-
return Ok(dataset.MetaData);
76+
return Ok(dataset.additionalData);
7777
}
7878

7979
/// <summary>

backend/api-gateway/Models/DatasetBasicData.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

backend/api-gateway/Models/DatasetData.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

backend/api-gateway/Models/DatasetMetadata.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

backend/api-gateway/Models/GeoJsonResponse.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ namespace APIGateway.Models
55

66
public class GeoJsonResponse
77
{
8-
public string type { get; set; }
9-
public List<Feature> features { get; set; }
8+
public string type { get; set; } = string.Empty;
9+
public List<Feature> features { get; set; } = new List<Feature>();
1010
}
1111

1212
public class Feature
1313
{
14-
public string type { get; set; }
15-
public Geometry geometry { get; set; }
16-
public Properties properties { get; set; }
14+
public string type { get; set; } = string.Empty;
15+
public Geometry geometry { get; set; } = new Geometry();
16+
public Properties properties { get; set; } = new Properties();
1717
}
1818

1919
public class Geometry
2020
{
21-
public string type { get; set; }
22-
public List<float> coordinates { get; set; }
21+
public string type { get; set; } = string.Empty;
22+
public List<float> coordinates { get; set; } = new List<float>();
2323
}
2424

2525
public class Properties
2626
{
27-
public string name { get; set; }
27+
public string name { get; set; } = string.Empty;
2828
}
2929
}

backend/api-gateway/Models/LocationData.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22
{
33
public class LocationDataRequest
44
{
5-
public string DatasetId { get; set; }
6-
public List<Coordinate> Location { get; set; }
5+
public string DatasetId { get; set; } = string.Empty;
6+
public List<Coordinate> Location { get; set; } = new List<Coordinate>();
77
}
88

99
public class Coordinate
1010
{
11-
public double Latitude { get; set; }
12-
public double Longitude { get; set; }
11+
public double Latitude { get; set; } = 0;
12+
public double Longitude { get; set; } = 0;
1313
}
1414

1515
public class LocationDataResponse
1616
{
17-
public List<DatasetItem> CurrentDatasetData { get; set; }
18-
public List<DatasetItem> GeneralData { get; set; }
17+
public List<DatasetItem> CurrentDatasetData { get; set; } = new List<DatasetItem>();
18+
public List<DatasetItem> GeneralData { get; set; } = new List<DatasetItem>();
1919
}
2020

2121
public class DatasetItem
2222
{
23-
public string Id { get; set; }
23+
public string Id { get; set; } = string.Empty;
2424

25-
public string Key { get; set; }
26-
public string Value { get; set; }
27-
public string MapId { get; set; } // Optional -> for "open in map" functionality
25+
public string Key { get; set; } = string.Empty;
26+
public string Value { get; set; } = string.Empty;
27+
public string MapId { get; set; } = string.Empty; // Optional -> for "open in map" functionality
2828
}
2929

3030

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using MongoDB.Bson;
2+
using MongoDB.Bson.Serialization.Attributes;
3+
4+
namespace APIGateway.Models;
5+
6+
public class MetadataObject
7+
{
8+
[BsonRepresentation(BsonType.ObjectId)]
9+
public string _id { get; set; } = string.Empty;
10+
11+
[BsonElement("basicData")]
12+
public BasicData basicData { get; set; } = new BasicData();
13+
14+
[BsonElement("additionalData")]
15+
public AdditionalData additionalData { get; set; } = new AdditionalData();
16+
17+
// The general and most important data about a dataset.
18+
public class BasicData
19+
{
20+
public string DatasetId { get; set; } = string.Empty;
21+
public string Name { get; set; } = string.Empty;
22+
public string ShortDescription { get; set; } = string.Empty;
23+
public string Icon { get; set; } = string.Empty;
24+
}
25+
26+
// The additional data for each of the datasets, queried at a request.
27+
public class AdditionalData
28+
{
29+
public string Icon { get; set; } = string.Empty;
30+
public string Type { get; set; } = string.Empty;
31+
32+
public string LongDescription { get; set; } = string.Empty;
33+
34+
// Zoom level is higher the closer you look at something. If current zoom level is below this, it shouldn't display any value.
35+
public int MinZoomLevel { get; set; } = 0;
36+
37+
// The zoom threshold where areas start to turn into markers
38+
public int MarkersThreshold { get; set; } = 0;
39+
40+
// The display property is the property that should be shown in a popup.
41+
public string DisplayProperty { get; set; } = string.Empty;
42+
43+
// Table data populated by the data pipeline. Contains the name and the size of the all .yaml files correlated to that specific dataset.
44+
public List<TableData> Tables { get; set; } = new List<TableData>();
45+
}
46+
47+
// Table data populated by the data pipeline. Contains the name and the size of the all .yaml files correlated to that specific dataset.
48+
public class TableData
49+
{
50+
// The name of the .yaml file
51+
public string Name { get; set; } = string.Empty;
52+
// The number of lines of data in that file.
53+
public int NumberOfLines { get; set; } = 0;
54+
}
55+
}

backend/api-gateway/Services/MongoDBService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public MongoDBService(IConfiguration configuration)
1414
_database = client.GetDatabase("bci-metadata");
1515
}
1616

17-
public IMongoCollection<DatasetData> GetDatasetsCollection()
17+
public IMongoCollection<MetadataObject> GetDatasetsCollection()
1818
{
19-
return _database.GetCollection<DatasetData>("datasets");
19+
return _database.GetCollection<MetadataObject>("datasets");
2020
}
2121
}
2222
}

backend/metadata-database/init-db.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,85 @@ db.createUser({
1111
db.createUser({
1212
user: "datapipeline",
1313
pwd: "datapipeline",
14-
roles: [{role: "readWrite", db: "bci-metadata"}]
15-
})
14+
roles: [{ role: "readWrite", db: "bci-metadata" }],
15+
});
1616

1717
// Define the datasets
1818
const datasets = [
1919
{
2020
basicData: {
2121
DatasetId: "empty_map",
2222
Name: "Empty Map",
23-
Description: "An empty, default map of Germany, with no data loaded.",
24-
Tables: [],
23+
ShortDescription: `An empty, default map of Germany, with no data loaded.`,
2524
},
26-
metaData: {
27-
Type: "marker",
25+
additionalData: {
26+
Type: "none",
27+
LongDescription: `An empty, default map of Germany, with no data loaded. Useful for exploring the map.`,
2828
MinZoomLevel: -1,
29+
MarkersThreshold: -1,
30+
DisplayProperty: "",
31+
Tables: [],
2932
},
3033
},
3134
{
3235
basicData: {
3336
DatasetId: "EV_charging_stations",
3437
Name: "Charging stations",
35-
Description: "Locations of all charging stations in Germany.",
38+
ShortDescription: `Locations of all charging stations in Germany.`,
3639
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="#000000" viewBox="0 0 256 256"><path d="M134.62,123.51a8,8,0,0,1,.81,7.46l-16,40A8,8,0,0,1,104.57,165l11.61-29H96a8,8,0,0,1-7.43-11l16-40A8,8,0,1,1,119.43,91l-11.61,29H128A8,8,0,0,1,134.62,123.51ZM248,86.63V168a24,24,0,0,1-48,0V128a8,8,0,0,0-8-8H176v88h16a8,8,0,0,1,0,16H32a8,8,0,0,1,0-16H48V56A24,24,0,0,1,72,32h80a24,24,0,0,1,24,24v48h16a24,24,0,0,1,24,24v40a8,8,0,0,0,16,0V86.63A8,8,0,0,0,229.66,81L210.34,61.66a8,8,0,0,1,11.32-11.32L241,69.66A23.85,23.85,0,0,1,248,86.63ZM160,208V56a8,8,0,0,0-8-8H72a8,8,0,0,0-8,8V208Z"></path></svg>',
37-
Tables: [],
3840
},
39-
metaData: {
41+
additionalData: {
4042
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="#000000" viewBox="0 0 256 256"><path d="M134.62,123.51a8,8,0,0,1,.81,7.46l-16,40A8,8,0,0,1,104.57,165l11.61-29H96a8,8,0,0,1-7.43-11l16-40A8,8,0,1,1,119.43,91l-11.61,29H128A8,8,0,0,1,134.62,123.51ZM248,86.63V168a24,24,0,0,1-48,0V128a8,8,0,0,0-8-8H176v88h16a8,8,0,0,1,0,16H32a8,8,0,0,1,0-16H48V56A24,24,0,0,1,72,32h80a24,24,0,0,1,24,24v48h16a24,24,0,0,1,24,24v40a8,8,0,0,0,16,0V86.63A8,8,0,0,0,229.66,81L210.34,61.66a8,8,0,0,1,11.32-11.32L241,69.66A23.85,23.85,0,0,1,248,86.63ZM160,208V56a8,8,0,0,0-8-8H72a8,8,0,0,0-8,8V208Z"></path></svg>',
4143
Type: "marker",
44+
LongDescription: `A map of EV charging stations displays the locations of electric vehicle charging points located in Germany, helping drivers plan routes and manage charging needs. It is essential for supporting the adoption and convenience of electric vehicles.`,
4245
MinZoomLevel: 10,
46+
MarkersThreshold: -1,
4347
DisplayProperty: "name",
48+
Tables: [],
4449
},
4550
},
4651
{
4752
basicData: {
4853
DatasetId: "house_footprints",
4954
Name: "House Footprints",
50-
Description: "Footprints for the houses.",
55+
ShortDescription: `Footprints for the houses.`,
5156
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="#000000" viewBox="0 0 256 256"><path d="M232,56H72V40a8,8,0,0,0-8-8H48A32,32,0,0,0,16,64V176a32,32,0,0,0,32,32H232a8,8,0,0,0,8-8V64A8,8,0,0,0,232,56ZM32,64A16,16,0,0,1,48,48h8v96H48a31.82,31.82,0,0,0-16,4.29ZM224,192H48a16,16,0,0,1,0-32H64a8,8,0,0,0,8-8V72H224ZM104,136a8,8,0,0,0,0,16h16v8a8,8,0,0,0,16,0v-8h24v8a8,8,0,0,0,16,0v-8h16a8,8,0,0,0,0-16H176V120h16a8,8,0,0,0,0-16H176V96a8,8,0,0,0-16,0v8H136V96a8,8,0,0,0-16,0v8H104a8,8,0,0,0,0,16h16v16Zm32-16h24v16H136Z"></path></svg>',
52-
Tables: [],
5357
},
54-
metaData: {
58+
additionalData: {
5559
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="#000000" viewBox="0 0 256 256"><path d="M232,56H72V40a8,8,0,0,0-8-8H48A32,32,0,0,0,16,64V176a32,32,0,0,0,32,32H232a8,8,0,0,0,8-8V64A8,8,0,0,0,232,56ZM32,64A16,16,0,0,1,48,48h8v96H48a31.82,31.82,0,0,0-16,4.29ZM224,192H48a16,16,0,0,1,0-32H64a8,8,0,0,0,8-8V72H224ZM104,136a8,8,0,0,0,0,16h16v8a8,8,0,0,0,16,0v-8h24v8a8,8,0,0,0,16,0v-8h16a8,8,0,0,0,0-16H176V120h16a8,8,0,0,0,0-16H176V96a8,8,0,0,0-16,0v8H136V96a8,8,0,0,0-16,0v8H104a8,8,0,0,0,0,16h16v16Zm32-16h24v16H136Z"></path></svg>',
5660
Type: "marker",
61+
LongDescription: `House footprints refer to the outline or ground area covered by a house, typically measured from the exterior walls of the structure. This footprint includes all parts of the house that are in contact with the ground, and is important for planning and zoning purposes, calculating property taxes, and designing land use.`,
5762
MinZoomLevel: 10,
63+
MarkersThreshold: 10,
64+
DisplayProperty: "",
65+
Tables: [],
5866
},
5967
},
6068
{
6169
basicData: {
6270
DatasetId: "actual_use",
6371
Name: "Actual Use",
64-
Description: "The Actual Use (?)",
65-
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="#000000" viewBox="0 0 256 256"><path d="M232,56H72V40a8,8,0,0,0-8-8H48A32,32,0,0,0,16,64V176a32,32,0,0,0,32,32H232a8,8,0,0,0,8-8V64A8,8,0,0,0,232,56ZM32,64A16,16,0,0,1,48,48h8v96H48a31.82,31.82,0,0,0-16,4.29ZM224,192H48a16,16,0,0,1,0-32H64a8,8,0,0,0,8-8V72H224ZM104,136a8,8,0,0,0,0,16h16v8a8,8,0,0,0,16,0v-8h24v8a8,8,0,0,0,16,0v-8h16a8,8,0,0,0,0-16H176V120h16a8,8,0,0,0,0-16H176V96a8,8,0,0,0-16,0v8H136V96a8,8,0,0,0-16,0v8H104a8,8,0,0,0,0,16h16v16Zm32-16h24v16H136Z"></path></svg>',
66-
Tables: [],
72+
ShortDescription: `The division of the land based on its utilization.`,
73+
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M136.83,220.43a8,8,0,0,1-11.09,2.23A183.15,183.15,0,0,0,24,192a8,8,0,0,1,0-16,199.11,199.11,0,0,1,110.6,33.34A8,8,0,0,1,136.83,220.43ZM24,144a8,8,0,0,0,0,16,214.81,214.81,0,0,1,151.17,61.71,8,8,0,1,0,11.2-11.42A230.69,230.69,0,0,0,24,144Zm208,16a216.51,216.51,0,0,0-48.59,5.49q8.24,6.25,16,13.16A201.53,201.53,0,0,1,232,176a8,8,0,0,1,0,16c-6,0-11.93.29-17.85.86q8.32,8.67,15.94,18.14a8,8,0,1,1-12.48,10A247,247,0,0,0,24,128a8,8,0,0,1,0-16,266.33,266.33,0,0,1,48,4.37V80a8,8,0,0,1,3.2-6.4l64-48a8,8,0,0,1,9.6,0l64,48A8,8,0,0,1,216,80v32.49c5.31-.31,10.64-.49,16-.49a8,8,0,0,1,0,16,246.3,246.3,0,0,0-84.26,14.69q9.44,5,18.46,10.78A232.2,232.2,0,0,1,232,144a8,8,0,0,1,0,16ZM120,88h48a8,8,0,0,1,8,8v21.94q11.88-2.56,24-4V84L144,42,88,84v35.81q12.19,3,24,7.18V96A8,8,0,0,1,120,88Zm8.07,45.27A262.48,262.48,0,0,1,160,121.94V104H128v29.24Z"></path></svg>',
6774
},
68-
metaData: {
69-
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="#000000" viewBox="0 0 256 256"><path d="M232,56H72V40a8,8,0,0,0-8-8H48A32,32,0,0,0,16,64V176a32,32,0,0,0,32,32H232a8,8,0,0,0,8-8V64A8,8,0,0,0,232,56ZM32,64A16,16,0,0,1,48,48h8v96H48a31.82,31.82,0,0,0-16,4.29ZM224,192H48a16,16,0,0,1,0-32H64a8,8,0,0,0,8-8V72H224ZM104,136a8,8,0,0,0,0,16h16v8a8,8,0,0,0,16,0v-8h24v8a8,8,0,0,0,16,0v-8h16a8,8,0,0,0,0-16H176V120h16a8,8,0,0,0,0-16H176V96a8,8,0,0,0-16,0v8H136V96a8,8,0,0,0-16,0v8H104a8,8,0,0,0,0,16h16v16Zm32-16h24v16H136Z"></path></svg>',
75+
additionalData: {
76+
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M136.83,220.43a8,8,0,0,1-11.09,2.23A183.15,183.15,0,0,0,24,192a8,8,0,0,1,0-16,199.11,199.11,0,0,1,110.6,33.34A8,8,0,0,1,136.83,220.43ZM24,144a8,8,0,0,0,0,16,214.81,214.81,0,0,1,151.17,61.71,8,8,0,1,0,11.2-11.42A230.69,230.69,0,0,0,24,144Zm208,16a216.51,216.51,0,0,0-48.59,5.49q8.24,6.25,16,13.16A201.53,201.53,0,0,1,232,176a8,8,0,0,1,0,16c-6,0-11.93.29-17.85.86q8.32,8.67,15.94,18.14a8,8,0,1,1-12.48,10A247,247,0,0,0,24,128a8,8,0,0,1,0-16,266.33,266.33,0,0,1,48,4.37V80a8,8,0,0,1,3.2-6.4l64-48a8,8,0,0,1,9.6,0l64,48A8,8,0,0,1,216,80v32.49c5.31-.31,10.64-.49,16-.49a8,8,0,0,1,0,16,246.3,246.3,0,0,0-84.26,14.69q9.44,5,18.46,10.78A232.2,232.2,0,0,1,232,144a8,8,0,0,1,0,16ZM120,88h48a8,8,0,0,1,8,8v21.94q11.88-2.56,24-4V84L144,42,88,84v35.81q12.19,3,24,7.18V96A8,8,0,0,1,120,88Zm8.07,45.27A262.48,262.48,0,0,1,160,121.94V104H128v29.24Z"></path></svg>',
7077
Type: "marker",
78+
LongDescription: `The Actual Use map describes the use of the earth's surface in four main groups (settlement, traffic, vegetation and water bodies). The division of these main groups into almost 140 different types of use, such as residential areas, road traffic, agriculture or flowing water, enables detailed evaluations and analyses of the use of the earth's surface.`,
7179
MinZoomLevel: 10,
80+
MarkersThreshold: 10,
81+
DisplayProperty: "",
82+
Tables: [],
7283
},
7384
},
7485
];
7586

7687
// Iterate over datasets and insert only if DatasetId does not exist
7788
datasets.forEach((dataset) => {
7889
if (
79-
!db.datasets.findOne({ "basicData.DatasetId": dataset.basicData.DatasetId })
90+
!db.datasets.findOne({
91+
"basicData.DatasetId": dataset.basicData.DatasetId,
92+
})
8093
) {
8194
db.datasets.insertOne(dataset);
8295
}

0 commit comments

Comments
 (0)