-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Implement a mechanism to define a schema for GeoOFF
, GeoPLY
and GeoOBJ
metadata.
This mechanism should allow defining the structure of required and optional meta information on file and/or object level.
A schema should consist of a key that references the meta-information key within the geometric file and with one or multiple values. Each value should correspond to the associated data type, and should also allow to define range constraints for numeric as well as string values.
The attributed grammar of such a metadataschema would somehow look like:
File = "File:\n" + Metadefinitions + "Object:\n" + Metadefinitions
Metadefinitions = Metadefinition | Metadefinitions + Metadefinition
Metadefinition = Key Required Typedefinition '\n'
Key = string
Required = 'r' | 'o'
Typedefinition = TypeChain | TypeChain Multitype
TypeChain = Type | Type TypeChain | LimitedMultiType | LimitedMultiType TypeChain
LimitedMultiType = Integer '*' Type
Multitype = Type + '*'
Type = TupleType | NumberType | StringType | 'datetime' | 'bool'
TupleType = '(' TypeChain ')'
NumberType = 'int' | 'int[' IntRange ']' | 'float' | 'float[' FloatRange ']'
IntRange = integer [IntRange] | [integer]:intger [IntRange]
FloatRange = float [IntRange] | [float]:float [IntRange]
StringType = 'str' | 'str[' StringRange ']'
StringRange = string [StringRange]
Leading to one example, meta information schema file like:
File:
tu r string
ru r string
axis_ordering o 3*string
Object:
special_type r string[building street bridge]
infos o string*
buildingyear o int[1990:2022]
Based on such a meta information schema implement:
- a parser
- a validator
Where the validator is used to validate a GeoObjectFile
or can be injected to a GeoObjReader
, GeoOffReader
or GeoPlyReader
.
Such a validator could have the following signature:
class SchemaValidator:
def __init__(file_schema: Dict[str, Any], object_schema: Dict[str, Any]):
# Todo
def validate(file: GeoObjectFile):
# Todo
def validate_file(key: str, values: List[Any]):
# Todo
def validate_object(key: str, values: List[Any]):
# Todo