Sources

This package offers access to the standard database structure. All defined sources are belonging directly to the so called “standard configuration”. Whenever you use a standard configuration for a topic (you configure this in your YAML see: Configuration)you can find further information here. All standard sources are sub classes of the core source classes (Sources) and the basic database source (BaseDatabaseSource).

All sources developed in this package are behaving the same. Besides the maybe implemented parameters for the read method of course. The main approach is to establish a session with the configured database and query it. If some error accrues it is closing the session correctly to be aware of hanging sessions.

Address

class pyramid_oereb.contrib.data_sources.standard.sources.address.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, AddressBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read(params, street_name, zip_code, street_number)[source]

The read method to access the standard database structure. It uses SQL-Alchemy for querying. It tries to find the items via passed arguments. If there was no result found it goes on with assigning an empty list as records instance attribute.

Parameters:
  • params (pyramid_oereb.views.webservice.Parameter) – The parameters of the extract request.

  • street_name (unicode) – The name of the street for the desired address.

  • zip_code (int) – The postal zipcode for the desired address.

  • street_number (str) – The house or so called street number of the desired address.

Availability

class pyramid_oereb.contrib.data_sources.standard.sources.availability.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, AvailabilityBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

The read method to access the standard database structure. It uses SQL-Alchemy for querying. It does not accept any parameters nor it applies any filter on the database query. It simply loads all content from the configured model.

Data_Integration

class pyramid_oereb.contrib.data_sources.standard.sources.data_integration.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, DataIntegrationRecord

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

The read method to access the standard database structure. It uses SQL-Alchemy for querying. It does not accept any parameters nor it applies any filter on the database query. It simply loads all content from the configured model.

Disclaimer

class pyramid_oereb.contrib.data_sources.standard.sources.disclaimer.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, DisclaimerBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

The read method to access the standard database structure. It uses SQL-Alchemy for querying. It does not accept any parameters nor it applies any filter on the database query. It simply loads all content from the configured model.

Document

class pyramid_oereb.contrib.data_sources.standard.sources.document.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, DocumentBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read(office_records)[source]

Central method to read all theme entries.

Parameters:

office_records (list of pyramid_oereb.core.records.office.OfficeRecord) – The office records of the exact request.

Document_Types

class pyramid_oereb.contrib.data_sources.standard.sources.document_types.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, DocumentTypesBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all document type values.

General_Information

class pyramid_oereb.contrib.data_sources.standard.sources.general_information.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, GeneralInformationBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all general information values.

Glossary

class pyramid_oereb.contrib.data_sources.standard.sources.glossary.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, GlossaryBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all glossary entries.

Law_Status

class pyramid_oereb.contrib.data_sources.standard.sources.law_status.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, LawStatusBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read(params=None)[source]

Central method to read all law status values. :param params: The parameters of the extract request. :type params: pyramid_oereb.views.webservice.Parameter or None

Legend

class pyramid_oereb.contrib.data_sources.standard.sources.legend.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, LegendBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read(params, **kwargs)[source]

Central method to read one legend entry.

Parameters:
  • params (pyramid_oereb.views.webservice.Parameter) – The parameters of the extract request.

  • (kwargs) – Arbitrary keyword arguments. It must contain the key ‘type_code’.

Map_Layering

class pyramid_oereb.contrib.data_sources.standard.sources.map_layering.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, MapLayeringBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all map layering entries.

Municipality

class pyramid_oereb.contrib.data_sources.standard.sources.municipality.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, MunicipalityBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

The read method to access the standard database structure. It uses SQL-Alchemy for querying. It does not accept any parameters nor it applies any filter on the database query. It simply loads all content from the configured model.

Office

class pyramid_oereb.contrib.data_sources.standard.sources.office.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, OfficeBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all office entries.

Plr

class pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, PlrBaseSource

__init__(**kwargs)[source]
Keyword Arguments:
  • name (str) – The name. You are free to choose one.

  • code (str) – The official code. Regarding to the federal specifications.

  • geometry_type (str) – The geometry type. Possible are: POINT, POLYGON, LINESTRING, GEOMETRYCOLLECTION

  • thresholds (dict) – The configuration of limits and units used for processing.

  • text (dict of str) – The speaking title. It must be a dictionary containing language (as configured) as key and text as value.

  • language (str) – The language this public law restriction is originally shipped with.

  • federal (bool) – Switch if it is a federal topic. This will be taken into account in processing steps.

  • source (dict) – The configuration dictionary of the public law restriction

  • hooks (dict of str) – The hook methods: get_symbol, get_symbol_ref. They have to be provided as dotted string for further use with dotted name resolver of pyramid package.

  • law_status (dict of str) – The configuration dictionary of the law status. It consists of the code and text which must be a dictionary containing language (as configured) as key and text as value.

collect_legend_entries_by_bbox(session, bbox, law_status)[source]

Extracts all legend entries in the topic which have spatial relation with the passed bounding box of visible extent.

Parameters:
  • session (sqlalchemy.orm.Session) – The requested clean session instance ready for use

  • bbox (shapely.geometry.base.BaseGeometry) – The bbox to search the records.

  • law_status (str) – String of the law status for which the legend entries should be queried.

Returns:

The result of the related geometries unique by the public law restriction id and law status

Return type:

list

Extracts all geometries in the topic which have spatial relation with the passed real estate

Parameters:
  • session (sqlalchemy.orm.Session) – The requested clean session instance ready for use

  • real_estate (pyramid_oereb.lib.records.real_estate.RealEstateRecord) – The real estate in its record representation.

Returns:

The result of the related geometries unique by the public law restriction id

Return type:

list

create_geometry_records_(law_status, published_from, published_until, geom, geo_metadata)[source]

Produces an array of pyramid_oereb geometry records representing simple shapely geometries POINT, LINE, POLYGON out of a passed shapely (multi)point, (multi)line, (multi)polygon or collection geometry and assigns all attributes to them.

Parameters:
  • law_status (pyramid_oereb.core.records.law_status.LawStatusRecord)

  • published_from (datetime.datetime.date) – Date from/since when the PLR record is published.

  • published_until (datetime.datetime.date) – Date until the PLR record is published.

  • geom (shapely.geometry.GeometryCollection) – The geometry which will be unwrapped.

  • geo_metadata (str) – The metadata uri.

Returns:

The list of unwrapped basic geometry

records. Each record has the same attribute values as the original one.

Return type:

list of pyramid_oereb.core.records.geometry.GeometryRecord

static extract_geometry_collection_db(db_path, real_estate_geometry, tolerances=None)[source]

Decides the geometry collection cases of geometric filter operations when the database contains multi geometries but the passed geometry does not. The multi geometry will be extracted to it’s sub parts for operation.

Parameters:
  • db_path (str) – The point separated string of schema_name.table_name.column_name from which we can construct a correct SQL statement.

  • real_estate_geometry (shapely.geometry.base.BaseGeometry) – The shapely geometry representation which is used for comparison.

Returns:

The clause element.

Return type:

sqlalchemy.sql.elements.BooleanClauseList

Raises:

HTTPBadRequest

from_db_to_document_records(documents_from_db)[source]
Parameters:

documents_from_db – (pyramid_oereb.contrib.data_sources.standard.models.get_document.<locals>.Document): The element read out of the database.

Returns:

The document record utilizing all attributes

read from db entity.

Return type:

pyramid_oereb.core.records.document.DocumentRecord

from_db_to_geometry_records(geometries_from_db)[source]

Translates a geometry element read from database (SQLAlchemy) into the internal record format.

Parameters:

geometries_from_db

(list of pyramid_oereb.contrib.data_sources.standard.models.get_geometry.<locals>.Geometry):

The element read out of the database.

Returns:

The geometry record utilizing all attributes

read from db entity.

Return type:

pyramid_oereb.core.records.geometry.GeometryRecord

from_db_to_office_record(office_from_db)[source]

Translates an office element read from database (SQLAlchemy) into the internal record format.

Parameters:

office_from_db (pyramid_oereb.contrib.data_sources.standard.models.get_office.<locals>.Office) – The element read out of the database.

Returns:

The office record utilizing all attributes

read from db entity.

Return type:

pyramid_oereb.core.records.office.OfficeRecord

from_db_to_plr_record(params, public_law_restriction_from_db, legend_entries_from_db)[source]

Produces out of the passed DB elements a PublicLawRestriction record. It heavily utilizes the instance methods to extract the nested information.

Parameters:
  • params (pyramid_oereb.core.views.webservice.Parameter) – The parameters of the extract request.

  • public_law_restriction_from_db – (pyramid_oereb.contrib.data_sources.standard.models.get_public_law_restriction.<locals>.PublicLawRestriction): The element read out of the database.

  • legend_entries_from_db – (pyramid_oereb.contrib.data_sources.standard.models.get_legend_entry.<locals>.LegendEntry): The elements read out of the database.

Returns:

The public law restriction record utilizing all

attributes read from db entity and its relations.

Return type:

pyramid_oereb.core.records.plr.PlrRecord

get_document_records(params, public_law_restriction_from_db)[source]

Here the M:N relation between Document and PLR through the relation table pyramid_oereb.contrib.data_sources.standard.models.get_public_law_restriction_document.<locals>.PublicLawRestrictionDocument is resolved to real document records.

Parameters:
  • params (pyramid_oereb.core.views.webservice.Parameter) – The parameters of the extract request.

  • public_law_restriction_from_db – (pyramid_oereb.contrib.data_sources.standard.models.get_public_law_restriction.<locals>.PublicLawRestriction): The element read out of the database.

Returns:

The document records related to

the passed PLR.

Return type:

list of pyramid_oereb.core.records.documents.DocumentRecord

handle_collection(session, geometry_to_check)[source]

Handles geometry collection in the geometry query if needed.

Parameters:
  • session (sqlalchemy.orm.Session or sqlalchemy.orm.scoped_session) – The requested clean session instance ready for use

  • geometry_to_check (shapely.geometry.base.BaseGeometry) – geometry to be queried

Returns:

the query based on the geometry_to_check

Return type:

sqlalchemy.orm.Query

property info

Return the info dictionary.

Returns:

The info dictionary.

Return type:

dict

read(params, real_estate, bbox)[source]

The read point which creates an extract, depending on a passed real estate.

Parameters:
  • params (pyramid_oereb.core.views.webservice.Parameter) – The parameters of the extract request.

  • real_estate (pyramid_oereb.lib.records.real_estate.RealEstateRecord) – The real estate in its record representation.

  • bbox (shapely.geometry.base.BaseGeometry) – The bbox to search the records.

unwrap_geometry_collection_(law_status, published_from, published_until, collection, geo_metadata)[source]

Produces an array of geometry records representing simple shapely geometries POINT, LINE, POLYGON out of a passed shapely collection geometry and assigns all attributes to them.

Parameters:
  • law_status (pyramid_oereb.core.records.law_status.LawStatusRecord)

  • published_from (datetime.datetime.date) – Date from/since when the PLR record is published.

  • published_until (datetime.datetime.date) – Date until the PLR record is published.

  • collection (shapely.geometry.GeometryCollection) – The geometry which will be unwrapped.

  • geo_metadata (str) – The metadata uri.

Returns:

The list of unwrapped basic geometry

records. Each record has the same attribute values as the original one.

Return type:

list of pyramid_oereb.core.records.geometry.GeometryRecord

unwrap_multi_geometry_(law_status, published_from, published_until, multi_geom, geo_metadata)[source]

Produces an array of geometry records representing simple shapely geometries POINT, LINE, POLYGON out of a passed shapely multi geometry and assigns all attributes to them.

Parameters:
  • law_status (pyramid_oereb.core.records.law_status.LawStatusRecord) – The law status.

  • published_from (datetime.datetime.date) – Date from/since when the PLR record is published.

  • published_until (datetime.datetime.date) – Date until the PLR record is published.

  • ( (multi_geom) – shapely.geometry.MultiPoint or shapely.geometry.MultiLineString or shapely.geometry.MultiPolygon

  • ) – The geometry which will be unwrapped.

  • geo_metadata (str) – The metadata uri.

Returns:

The list of unwrapped basic geometry

records. Each record has the same attribute values as the original one.

Return type:

list of pyramid_oereb.core.records.geometry.GeometryRecord

Plr

class pyramid_oereb.contrib.data_sources.standard.sources.plr.StandardThemeConfigParser(**kwargs)[source]

Bases: object

__init__(**kwargs)[source]

Real_Estate

class pyramid_oereb.contrib.data_sources.standard.sources.real_estate.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, RealEstateBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read(params, nb_ident=None, number=None, egrid=None, geometry=None)[source]

Central method to read all plrs (geometry input) or explicitly one plr (nb_ident+number/egrid input).

Parameters:
  • params (pyramid_oereb.views.webservice.Parameter) – The parameters of the extract request.

  • nb_ident (int or None) – The identification number of the desired real estate. This parameter is directly related to the number parameter and both must be set! Combination will deliver only one result or crashes.

  • number (str or None) – The number of parcel or also known real estate. This parameter is directly related to the nb_ident parameter and both must be set! Combination will deliver only one result or crashes.

  • None) ((str or) – The unique identifier of the desired real estate. This will deliver only one result or crashes.

  • geometry (str or None) – A geometry as WKT string which is used to obtain intersected real estates. This may deliver several results.

Real_Estate_Type

class pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, RealEstateTypeBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read(params=None)[source]

Central method to read all real estate type values.

Parameters:

params (pyramid_oereb.views.webservice.Parameter) – The parameters of the extract request.

Theme

class pyramid_oereb.contrib.data_sources.standard.sources.theme.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, ThemeBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all theme entries.

Theme_Document

class pyramid_oereb.contrib.data_sources.standard.sources.theme_document.DatabaseSource(**kwargs)[source]

Bases: BaseDatabaseSource, ThemeDocumentBaseSource

__init__(**kwargs)
Keyword Arguments:
  • db_connection (str) – A rfc1738 conform database connection string in the form of: <driver_name>://<username>:<password>@<database_host>:<port>/<database_name>

  • model (str) – A valid dotted name string which leads to an importable representation of sqlalchemy.ext.declarative.DeclarativeMeta or the real class itself.

read()[source]

Central method to read all theme document entries.