Define the schema

This commit is contained in:
Alireza Adli 2024-10-10 11:48:53 -04:00
parent a2e8ac119a
commit 20798d2127

View File

@ -1,7 +1,37 @@
"""
schemas module
Defines the schemas to post on app.py
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2024 Concordia CERC group
Code contributors: Alireza Adli alireza.adli@mail.concordia.ca
"""
from marshmallow import Schema, fields
class LCAWorkflowSchema(Schema):
city_file_path = fields.Str(required=True)
archetypes_file_name = fields.Str(required=True)
constructions_file_name = fields.Str(required=True)
class GeometrySchema(Schema):
"""Schema for the geometry of a feature."""
type = fields.String(required=True)
coordinates = fields.List(fields.List(fields.List(fields.Float())), required=True)
class PropertiesSchema(Schema):
"""Schema for the properties of a feature."""
name = fields.String(required=True)
address = fields.String(required=True)
function = fields.String(required=True)
height = fields.Integer(required=True)
year_of_construction = fields.Integer(required=True)
class FeatureSchema(Schema):
"""Schema for a GeoJSON feature."""
type = fields.String(required=True)
geometry = fields.Nested(GeometrySchema, required=True)
id = fields.Integer(required=True)
properties = fields.Nested(PropertiesSchema, required=True)
class LCAInputData(Schema):
"""Define variables that come from user input."""
type = fields.String(required=True)
features = fields.List(fields.Nested(FeatureSchema), required=True)