Model
model
Package containing models, the pythonic representation of feature classes.
They inherit from BaseFeature
, which extends the Pydantic BaseModel
with some utility, and are usually instantiated with the model_factory
method.
A feature collection is represented by the BaseCollection
class.
Example
Load the BP_Plan model for XPlanung v6.0 and instantiate it with some data:
model_factory(model_name, model_version, data_type='xplan')
Factory method for retrieving the corresponding pydantic model representation of a feature class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
name of the feature class |
required |
model_version
|
str | None
|
version of the specification release |
required |
data_type
|
Literal['xplan', 'xtrasse', 'plu', 'def']
|
Specification of either XPlanung, INSPIRE PLU, or general definitions used by both application schemas. |
'xplan'
|
Raises:
Type | Description |
---|---|
ValueError
|
raises error for invalid model name and/or incompatible data version. |
Returns:
Name | Type | Description |
---|---|---|
BaseFeature |
BaseFeature
|
The concrete feature class inheriting from BaseFeature. |
Source code in xplan_tools/model/__init__.py
BaseFeature
Bases: BaseModel
, GMLAdapter
, CoretableAdapter
, JsonFGAdapter
Base class for application schema classes.
It extends pydantic BaseModel with Feature-related helper methods as well as conversion capabilities from/to other formats via inheriting from respective adapter classes.
deserialization_hook(data, info)
classmethod
Provides deserialization for different formats/representations before validation.
Source code in xplan_tools/model/base.py
get_associations()
classmethod
Returns the classes association fields.
get_data_type()
classmethod
Return the data type.
Source code in xplan_tools/model/base.py
get_geom_field()
classmethod
Returns the classes geometry field name, if any.
Source code in xplan_tools/model/base.py
get_geom_srid()
Returns the object's geometry's SRID, if any.
get_geom_types()
classmethod
Returns the canonical name of the FeatureClass.
Source code in xplan_tools/model/base.py
get_geom_wkt()
Returns the object's eWKT geometry's WKT representation withouth SRID, if any.
get_name()
classmethod
get_properties()
classmethod
Returns a slimmed down model with just the properties, i.e. exluding id and geometry attributes as well as utility methods.
Source code in xplan_tools/model/base.py
get_property_info(name)
classmethod
Property information.
Returns a dict containing the following property information which might be useful e.g. for de-/serialization:
stereotype
: the property's stereotype, e.g. DataType or Associationtypename
: the concrete type(s) of the property; may be an array, especially for associationslist
: whether the property has a multiplicity > 1nullable
: whether the property is optionaluom
: unit of measure for measure typesenum_info
: names, aliases, description and, if available, tokens for codes from enumeration typesassoc_info
: reverse properties and whether it's a source or a target end for associations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The property's name. |
required |
Raises:
Type | Description |
---|---|
AttributeError
|
The name was not found in the model fields. |
Source code in xplan_tools/model/base.py
get_version()
classmethod
model_dump_coretable()
model_dump_gml(data_type='xplan', **kwargs)
Dumps the model data to a GML structure held in an etree.Element.
BaseCollection
Bases: BaseModel
Container for features that provides validation of references.
The features are stored in a dictionary with their ID as key and the feature instance as value.
add_style_properties(to_text=False, always_populate_schriftinhalt=False)
Add styling properties to presentational objects.
This method parses object (dientZurDarstellungVon) and property (art) references from presentational objects and derives styling information (stylesheetId, schriftinhalt) based on a set of defined rules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_text
|
bool
|
Whether to convert symbolic presentational objects to textual ones. Defaults to False. |
False
|
always_populate_schriftinhalt
|
bool
|
Populate |
False
|
Source code in xplan_tools/model/base.py
check_references_and_srs()
Checks if all objects referenced via UUID are part of the collection and if all features have the same SRS.
Source code in xplan_tools/model/base.py
get_features()
get_single_plans(with_name=False)
Yields BaseCollection objects for every plan in the original collection.
Source code in xplan_tools/model/base.py
list_to_dict(data)
classmethod
Takes a list of BaseFeatures and returns a BaseCollection dict.