Skip to content

Commit

Permalink
Merge branch 'sprint-release' into Ingest_air_pollutants_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahsankkhan committed Jul 13, 2024
2 parents 1755678 + 205fcf7 commit aebcd57
Show file tree
Hide file tree
Showing 70 changed files with 2,036 additions and 1,078 deletions.
21 changes: 0 additions & 21 deletions backend/api-gateway/Controllers/APIGatewayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,6 @@ public async Task<IActionResult> LoadLocationData([FromBody, Required] LocationD

}

// Helper method to generate mock data
private List<DatasetItem> GenerateMockData(string mapId, int count)
{
var random = new Random();
var data = new List<DatasetItem>();

for (int i = 0; i < count; i++)
{
var item = new DatasetItem
{
Id = Guid.NewGuid().ToString(), // Generate a unique ID
Key = $"{mapId} Item {i + 1} (distance)",
Value = $"{random.Next(50, 1000)} m",
MapId = mapId
};
data.Add(item);
}

return data;
}

/// <summary>
/// Gets the dataset viewport data based on the provided parameters.
/// </summary>
Expand Down
19 changes: 15 additions & 4 deletions backend/api-gateway/Models/LocationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,28 @@ public class Coordinate

public class LocationDataResponse
{
public List<DatasetItem> IndividualData { get; set; } = new List<DatasetItem>();
public List<DatasetItem> GeneralData { get; set; } = new List<DatasetItem>();
public List<DatasetItem> IndividualData { get; set; } = [];
public List<DatasetItem> SelectionData { get; set; } = [];
}

public class DatasetItem
{
public string Id { get; set; } = string.Empty;
public string DisplayName { get; set; } = string.Empty;
public string DatasetId { get; set; } = string.Empty;

public double[] Coordinate { get; set; } = [];
public List<double[]> PolygonCoordinates { get; set; } = [];
public List<SubdataItem> Subdata { get; set; } = [];
public string Value { get; set; } = string.Empty; // some items may not have subdata and should instead be directly displayed with a value

}

public class SubdataItem
{
public string Key { get; set; } = string.Empty;

public string Value { get; set; } = string.Empty;
public string MapId { get; set; } = string.Empty; // Optional -> for "open in map" functionality

}


Expand Down
45 changes: 21 additions & 24 deletions backend/lib/BieMetadata/MetadataDbHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class MetadataDbHelper
private string mMetaDataDbUrl;

private IMongoDatabase mDatabase;

public bool Connected { get; private set; }

public MetadataDbHelper()
Expand Down Expand Up @@ -58,7 +58,7 @@ public bool CreateConnection()
return metadataObject;
}

public bool UpdateMetadata(string dataset, string tableName, int numberOfLines, BoundingBox boundingBox)
public bool UpdateMetadata(string dataset, MetadataObject.TableData tableData)
{
// Load the collection
var collection = mDatabase.GetCollection<MetadataObject>("datasets");
Expand All @@ -74,31 +74,28 @@ public bool UpdateMetadata(string dataset, string tableName, int numberOfLines,
return false;
}

// Load the existing table
var existingTable = metadataObject.additionalData.Tables.Find(t => t.Name == tableName);
if (existingTable == null)
// Load and remove any existing table
var existingTable = metadataObject.additionalData.Tables.Find(t => t.Name == tableData.Name);
if (existingTable != null)
{
// Create a new table object if not present
var newTable = new MetadataObject.TableData()
{
Name = tableName,
NumberOfLines = numberOfLines,
BoundingBox = boundingBox
};
metadataObject.additionalData.Tables.Add(newTable);
collection.ReplaceOne(g => g.basicData.DatasetId == dataset, metadataObject);
return true;
metadataObject.additionalData.Tables.Remove(existingTable);
}

// Table info already exists, for now just choose the larger number of lines number.
existingTable.NumberOfLines = existingTable.NumberOfLines < numberOfLines
? numberOfLines
: existingTable.NumberOfLines;

// always write the current Bounding box
existingTable.BoundingBox = boundingBox;

// Insert the new Table object.
metadataObject.additionalData.Tables.Add(tableData);
collection.ReplaceOne(g => g.basicData.DatasetId == dataset, metadataObject);
return true;
}
}

public bool UpdateMetadata(string dataset, string tableName, int numberOfLines, BoundingBox boundingBox)
{
return UpdateMetadata(dataset,
new MetadataObject.TableData()
{
Name = tableName,
NumberOfLines = numberOfLines,
BoundingBox = new BoundingBox(),
RowHeaders = new List<string>()
});
}
}
54 changes: 49 additions & 5 deletions backend/lib/BieMetadata/MetadataObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
// ReSharper disable InconsistentNaming

namespace BieMetadata;

Expand Down Expand Up @@ -67,26 +66,71 @@ public class AdditionalData
public int MarkersThreshold { get; set; } = 0;

/// <summary>
/// The display property is the property that should be shown in a popup.
/// A list of display properties that should be shown in a marker popup.
/// </summary>
public string DisplayProperty { get; set; } = string.Empty;
public List<DisplayProperty> DisplayProperty { get; set; } = new List<DisplayProperty>();

/// <summary>
/// Table data populated by the data pipeline. Contains the name and the size of the all .yaml files correlated to that specific dataset.
/// </summary>
public List<TableData> Tables { get; set; } = new List<TableData>();

/// <summary>
/// A polygon coloring rule for different values.
/// </summary>
[BsonIgnoreIfNull] // Add this attribute to ignore null values
public PolygonColoring? PolygonColoring { get; set; }
}

/// <summary>
/// Table data populated by the data pipeline. Contains the name and the size of the all .yaml files correlated to that specific dataset.
/// </summary>
public class TableData
{
// The name of the .yaml file
/// <summary>
/// the name of the table
/// </summary>
public string Name { get; set; } = string.Empty;
// The number of lines of data in that file.

/// <summary>
/// the number of lines in the table
/// </summary>
public int NumberOfLines { get; set; } = 0;

/// <summary>
/// the bounding box of the geomtry data in the table
/// </summary>
public BoundingBox? BoundingBox { get; set; }

/// <summary>
/// the headers of the dataset. Should NOT include the special Location header.
/// </summary>
public List<string> RowHeaders { get; set; }
}

/// <summary>
/// A list of display values to show for the markers on the map
/// </summary>
public class DisplayProperty
{
// The display name to show
public string displayName { get; set; } = string.Empty;
// The value to show
public string value { get; set; } = string.Empty;
}

/// <summary>
/// Polygon coloring rules
/// </summary>
public class PolygonColoring
{
public string attributeName { get; set; } = string.Empty;
public List<PolygonColor> colors { get; set; } = new List<PolygonColor>();
}

public class PolygonColor
{
public string color { get; set; } = string.Empty;
public List<string> values { get; set; } = new List<string>();
}
}
68 changes: 60 additions & 8 deletions backend/metadata-database/init-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const datasets = [
LongDescription: `An empty, default map of Germany, with no data loaded. Useful for exploring the map.`,
MinZoomLevel: -1,
MarkersThreshold: -1,
DisplayProperty: "",
DisplayProperty: [],
PolygonColoring: null,
Tables: [],
},
},
Expand All @@ -46,7 +47,8 @@ const datasets = [
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.`,
MinZoomLevel: 11,
MarkersThreshold: -1,
DisplayProperty: "name",
DisplayProperty: [{ displayName: "Operator", value: "operator" }],
PolygonColoring: null,
Tables: [],
},
},
Expand All @@ -64,7 +66,8 @@ const datasets = [
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.`,
MinZoomLevel: 11,
MarkersThreshold: 17,
DisplayProperty: "",
DisplayProperty: [],
PolygonColoring: null,
Tables: [],
},
},
Expand All @@ -81,8 +84,55 @@ const datasets = [
DataType: "SHAPE",
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.`,
MinZoomLevel: 11,
MarkersThreshold: 17,
DisplayProperty: "",
MarkersThreshold: 15,
DisplayProperty: [],
PolygonColoring: {
attributeName: "nutzart",
colors: [
{
color: "DarkOrchid",
values: [
"Wohnbaufläche",
"Industrie- und Gewerbefläche",
"Halde",
"Bergbaubetrieb",
"Tagebau, Grube Steinbruch",
"Fläche gemischter Nutzung",
"Fläche besonderer funktionaler Prägung",
"Sport-, Freizeit- und Erholungsfläche",
"Friedhof",
],
},
{
color: "green",
values: ["Wald", "Gehölz", "Sumpf"],
},
{
color: "yellow",
values: [
"Landwirtschaft",
"Heide",
"Moor",
"Unland/Vegetationslose Fläche",
],
},
{
color: "RosyBrown",
values: [
"Straßenverkehr",
"Weg",
"Platz",
"Bahnverkehr",
"Flugverkehr",
"Schiffsverkehr",
],
},
{
color: "Cyan",
values: ["Fließgewässer", "Hafenbecken", "Stehendes Gewässer"],
},
],
},
Tables: [],
},
},
Expand All @@ -91,15 +141,17 @@ const datasets = [
DatasetId: "building_models",
Name: "Building Models",
ShortDescription: `Simplified 3D building models.`,
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>',
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M232,228H204V28h12a4,4,0,0,0,0-8H40a4,4,0,0,0,0,8H52V228H24a4,4,0,0,0,0,8H232a4,4,0,0,0,0-8ZM60,28H196V228H156V184a4,4,0,0,0-4-4H104a4,4,0,0,0-4,4v44H60Zm88,200H108V188h40ZM92,64a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H96A4,4,0,0,1,92,64Zm48,0a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H144A4,4,0,0,1,140,64ZM92,104a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H96A4,4,0,0,1,92,104Zm48,0a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H144A4,4,0,0,1,140,104ZM96,148a4,4,0,0,1,0-8h16a4,4,0,0,1,0,8Zm44-4a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H144A4,4,0,0,1,140,144Z"></path></svg>',
},
additionalData: {
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>',
Icon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M232,228H204V28h12a4,4,0,0,0,0-8H40a4,4,0,0,0,0,8H52V228H24a4,4,0,0,0,0,8H232a4,4,0,0,0,0-8ZM60,28H196V228H156V184a4,4,0,0,0-4-4H104a4,4,0,0,0-4,4v44H60Zm88,200H108V188h40ZM92,64a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H96A4,4,0,0,1,92,64Zm48,0a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H144A4,4,0,0,1,140,64ZM92,104a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H96A4,4,0,0,1,92,104Zm48,0a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H144A4,4,0,0,1,140,104ZM96,148a4,4,0,0,1,0-8h16a4,4,0,0,1,0,8Zm44-4a4,4,0,0,1,4-4h16a4,4,0,0,1,0,8H144A4,4,0,0,1,140,144Z"></path></svg>',
Type: "areas",
DataType: "CITYGML",
LongDescription: `The building models have a 3D object of each building plus additional information on its dimentions.`,
MinZoomLevel: 11,
MarkersThreshold: 17,
DisplayProperty: "",
DisplayProperty: [],
PolygonColoring: null,
Tables: [],
},
},
Expand Down
Loading

0 comments on commit aebcd57

Please sign in to comment.