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, which inherits from Pydantic RootModel
.
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', '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)
classmethod
Provides deserialization for different formats/representations before validation.
Source code in xplan_tools/model/base.py
get_data_type()
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_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 types
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')
Dumps the model data to a GML structure held in an etree.Element.
BaseCollection
Bases: RootModel
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)
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
|
Source code in xplan_tools/model/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
check_references()
Checks if all objects referenced via UUID are part of the collection.
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.