gcudm

The GeoComm Unified Data Model

This package (gcudm) contains the GeoComm Unified Data Model implemented as a GeoAlchemy2 object-relational model.

Each version of the package represents the corresponding version of the data model.

If you want to get started using the library, check out the tutorial.

gcudm

Tutorial

Installation

You can install the library using pip.

pip install gcudm

If you need a specific version of the data model, specify it when you install.

pip install gcudm==0.0.1

Build Your Database

gcudm is built on GeoAlchemy 2 (and SqlAlchey). We try not to come between you and the underlying platforms, so if you’re familiar with these frameworks everything should work as you expect.

One convenience that is provided is the gcudm.model.load() function which you can call to make sure that all the modules that define object-relational mappings are loaded. You should do this before you create your database tables from the model to make sure that all the classes that implement the declarative base are loaded.

from gcudm.base import Base
import gcudm.model
from sqlalchemy import create_engine

# Load the entire model.
gcudm.model.load()

# The rest is standard SQLAlchemy...
# ...just create an engine.
engine = create_engine(
    'postgresql://<user>:<password>@<host>/<your-database>',
    echo=True)

# Now create the tables in your database.
Base.metadata.create_all(engine)
gcudm

Data Model

img_tbl_RoadCenterline Road Centerlines

Road centerlines are the principal polyline features that represent road segments traversable by most emergency vehicles.

Table Name:road_centerlines
Geometry Type:LINESTRING

img_road_centerlines_addCodeL addCodeL

Additional Code Left - This field needs a description.

Search Display
Requested Required
NENA:AddCode_L

img_road_centerlines_addCodeR addCodeR

Additional Code Right - This field needs a description.

Search Display
Requested Required
NENA:AddCode_R

img_road_centerlines_addRngPreL addRngPreL

Left Address Number Prefix - This field needs a description.

Search Display
Requested Required
NENA:AdNumPre_L

img_road_centerlines_addRngPreR addRngPreR

Right Address Number Prefix - This field needs a description.

Search Display
Requested Required
NENA:AdNumPre_R

img_road_centerlines_countryL countryL

Country Left - This field needs a description.

Search Display
Requested Required
NENA:Country_L

img_road_centerlines_countryR countryR

Country Right - This field needs a description.

Search Display
Requested Required
NENA:Country_R

img_road_centerlines_effective effective

Effective Date - This field needs a description.

Search Display
Requested Required

img_road_centerlines_esnL esnL

ESN Left - This field needs a description.

Search Display
Requested Required
NENA:ESN_L

img_road_centerlines_esnR esnR

ESN Right - This field needs a description.

Search Display
Requested Required
NENA:ESN_R

img_road_centerlines_expire expire

Expiration Date - This field needs a description.

Search Display
Requested Required

img_road_centerlines_fromAddL fromAddL

Left ‘From’ Address - This field needs a description.

Search Display
Requested Required
NENA:FromAddr_L

img_road_centerlines_fromAddR fromAddR

Right ‘From’ Address - This field needs a description.

Search Display
Requested Required
NENA:FromAddr_R

img_road_centerlines_gcUnqId gcUnqId

GeoComm ID - This field needs a description.

Search Display
Requested Required

img_road_centerlines_incMuniL incMuniL

Incorporated Municipality Left - This field needs a description.

Search Display
Requested Required
NENA:IncMuni_L

img_road_centerlines_incMuniR incMuniR

Incorporated Municipality Right - This field needs a description.

Search Display
Requested Required
NENA:IncMuni_R

img_road_centerlines_lgcyName lgcyName

Legacy Street Name - This field needs a description.

Search Display
Requested Required
NENA:LSt_Name

img_road_centerlines_lgcyPrTySp lgcyPrTySp

Legacy Street Name Pre Type Separator - This field needs a description.

Search Display
Requested Required

img_road_centerlines_lgcyPrType lgcyPrType

Legacy Street Name Pre Type - This field needs a description.

Search Display
Requested Required
NENA:LSt_PreDir

img_road_centerlines_lgcyPreDir lgcyPreDir

Legacy Street Name Pre Directional - This field needs a description.

Search Display
Requested Required

img_road_centerlines_lgcyPreMod lgcyPreMod

Legacy Street Name Pre Modifier - This field needs a description.

Search Display
Requested Required

img_road_centerlines_lgcyPstDir lgcyPstDir

Legacy Street Name Post Directional - This field needs a description.

Search Display
Requested Required
NENA:LStPosDir

img_road_centerlines_lgcyPstMod lgcyPstMod

Legacy Street Name Post Modifier - This field needs a description.

Search Display
Requested Required

img_road_centerlines_lgcyType lgcyType

Legacy Street Name Post Type - This field needs a description.

Search Display
Requested Required
NENA:LSt_Type

img_road_centerlines_msagCommL msagCommL

MSAG Community Name Left - This field needs a description.

Search Display
Requested Required
NENA:MSAGComm_L

img_road_centerlines_msagCommR msagCommR

MSAG Community Name Right - This field needs a description.

Search Display
Requested Required
NENA:MSAGComm_R

img_road_centerlines_parityL parityL

Parity Left - This field needs a description.

Search Display
Requested Required
NENA:Parity_L

img_road_centerlines_parityR parityR

Parity Right - This field needs a description.

Search Display
Requested Required
NENA:Parity_R

img_road_centerlines_postDir postDir

Street Name Post Directional - This field needs a description.

Search Display
Requested Required
NENA:St_PosDir

img_road_centerlines_postMod postMod

Street Name Post Modifier - This field needs a description.

Search Display
Requested Required
NENA:St_PosMod

img_road_centerlines_postType postType

Street Name Post Type - This field needs a description.

Search Display
Requested Required
NENA:St_PosTyp

img_road_centerlines_preDir preDir

Street Name Pre Directional - This field needs a description.

Search Display
Requested Required
NENA:St_PreDir

img_road_centerlines_preMod preMod

Street Name Pre Modifier - This field needs a description.

Search Display
Requested Required
NENA:St_PreMod

img_road_centerlines_preType preType

Street Name Pre Type - This field needs a description.

Search Display
Requested Required
NENA:St_PreTyp

img_road_centerlines_preTypeSep preTypeSep

Street Name Pre Type Separator - This field needs a description.

Search Display
Requested Required
NENA:St_PreSep

img_road_centerlines_rngType rngType

Ranging Type - This field needs a description.

Search Display
Requested Required

img_road_centerlines_srcFullNam srcFullNam

Source Full Name - This field needs a description.

Search Display
Requested Required

img_road_centerlines_srcLastEd srcLastEd

Source of Last Update - This field needs a description.

Search Display
Requested Required

img_road_centerlines_srcOfData srcOfData

Data Source - This field needs a description.

Search Display
Requested Required

img_road_centerlines_srcUnqId srcUnqId

NENA ID - This field needs a description.

Search Display
Requested Required
NENA:RCL_NGUID

img_road_centerlines_stateL stateL

State Left - This field needs a description.

Search Display
Requested Required
NENA:State_L

img_road_centerlines_stateR stateR

State Right - This field needs a description.

Search Display
Requested Required
NENA:State_R

img_road_centerlines_strName strName

Street Name - This field needs a description.

Search Display
Requested Required
NENA:StreetName

img_road_centerlines_toAddL toAddL

Left ‘To’ Address - This field needs a description.

Search Display
Requested Required
NENA:ToAddr_L

img_road_centerlines_toAddR toAddR

Right ‘To’ Address - This field needs a description.

Search Display
Requested Required
NENA:ToAddr_R

img_road_centerlines_unincCommL unincCommL

Unincorporated Community Left - This field needs a description.

Search Display
Requested Required
NENA:UnincCom_L

img_road_centerlines_unincCommR unincCommR

Unincorporated Community Right - This field needs a description.

Search Display
Requested Required
NENA:UnincCom_R

img_road_centerlines_updateDate updateDate

Last Update - This field needs a description.

Search Display
Requested Required

img_road_centerlines_uploadAuth uploadAuth

Upload Authority - This field needs a description.

Search Display
Requested Required

Say something descriptive about the ‘esbems’ module.

img_tbl_EsbEms Emergency Services Boundary (EMS)

This table needs a description.

Table Name:esbems
Geometry Type:LINESTRING

img_esbems_agencyID agencyID

Agency ID - This field needs a description.

Search Display
Requested Required
NENA:Agency_ID

img_esbems_country country

Country - This field needs a description.

Search Display
Requested Required

img_esbems_county county

County - This field needs a description.

Search Display
Requested Required

img_esbems_displayName displayName

Display Name - This field needs a description.

Search Display
Requested Required
NENA:DisplayName

img_esbems_effective effective

Effective Date - This field needs a description.

Search Display
Requested Required

img_esbems_expire expire

Expiration Date - This field needs a description.

Search Display
Requested Required

img_esbems_gcUnqId gcUnqId

GeoComm ID - This field needs a description.

Search Display
Requested Required

img_esbems_routeURI routeURI

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esbems_serviceNum serviceNum

Service Number - This field needs a description.

Search Display
Requested Required
NENA:ServiceNum

img_esbems_serviceURN serviceURN

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esbems_srcLastEd srcLastEd

Source of Last Update - This field needs a description.

Search Display
Requested Required

img_esbems_srcOfData srcOfData

Data Source - This field needs a description.

Search Display
Requested Required

img_esbems_srcUnqId srcUnqId

NENA ID - This field needs a description.

Search Display
Requested Required
NENA:RCL_NGUID

img_esbems_state state

State - This field needs a description.

Search Display
Requested Required

img_esbems_updateDate updateDate

Last Update - This field needs a description.

Search Display
Requested Required

img_esbems_uploadAuth uploadAuth

Upload Authority - This field needs a description.

Search Display
Requested Required

img_esbems_vCardURI vCardURI

Agency vCard URI - This field needs a description.

Search Display
Requested Required
NENA:AVcard_URI

Say something descriptive about the ‘esbfire’ module.

img_tbl_EsbFire Emergency Services Boundary (Fire)

This table needs a description.

Table Name:esbfire
Geometry Type:LINESTRING

img_esbfire_agencyID agencyID

Agency ID - This field needs a description.

Search Display
Requested Required
NENA:Agency_ID

img_esbfire_country country

Country - This field needs a description.

Search Display
Requested Required

img_esbfire_county county

County - This field needs a description.

Search Display
Requested Required

img_esbfire_displayName displayName

Display Name - This field needs a description.

Search Display
Requested Required
NENA:DisplayName

img_esbfire_effective effective

Effective Date - This field needs a description.

Search Display
Requested Required

img_esbfire_expire expire

Expiration Date - This field needs a description.

Search Display
Requested Required

img_esbfire_gcUnqId gcUnqId

GeoComm ID - This field needs a description.

Search Display
Requested Required

img_esbfire_routeURI routeURI

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esbfire_serviceNum serviceNum

Service Number - This field needs a description.

Search Display
Requested Required
NENA:ServiceNum

img_esbfire_serviceURN serviceURN

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esbfire_srcLastEd srcLastEd

Source of Last Update - This field needs a description.

Search Display
Requested Required

img_esbfire_srcOfData srcOfData

Data Source - This field needs a description.

Search Display
Requested Required

img_esbfire_srcUnqId srcUnqId

NENA ID - This field needs a description.

Search Display
Requested Required
NENA:RCL_NGUID

img_esbfire_state state

State - This field needs a description.

Search Display
Requested Required

img_esbfire_updateDate updateDate

Last Update - This field needs a description.

Search Display
Requested Required

img_esbfire_uploadAuth uploadAuth

Upload Authority - This field needs a description.

Search Display
Requested Required

img_esbfire_vCardURI vCardURI

Agency vCard URI - This field needs a description.

Search Display
Requested Required
NENA:AVcard_URI

Say something descriptive about the ‘esblaw’ module.

img_tbl_EsbLaw Emergency Services Boundary (Law)

Emergency service boundaries for law enforcement define the areas to which law enforcement responds.

Table Name:esblaw
Geometry Type:LINESTRING

img_esblaw_agencyID agencyID

Agency ID - This field needs a description.

Search Display
Requested Required
NENA:Agency_ID

img_esblaw_country country

Country - This field needs a description.

Search Display
Requested Required

img_esblaw_county county

County - This field needs a description.

Search Display
Requested Required

img_esblaw_displayName displayName

Display Name - This field needs a description.

Search Display
Requested Required
NENA:DisplayName

img_esblaw_effective effective

Effective Date - This field needs a description.

Search Display
Requested Required

img_esblaw_expire expire

Expiration Date - This field needs a description.

Search Display
Requested Required

img_esblaw_gcUnqId gcUnqId

GeoComm ID - This field needs a description.

Search Display
Requested Required

img_esblaw_routeURI routeURI

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esblaw_serviceNum serviceNum

Service Number - This field needs a description.

Search Display
Requested Required
NENA:ServiceNum

img_esblaw_serviceURN serviceURN

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esblaw_srcLastEd srcLastEd

Source of Last Update - This field needs a description.

Search Display
Requested Required

img_esblaw_srcOfData srcOfData

Data Source - This field needs a description.

Search Display
Requested Required

img_esblaw_srcUnqId srcUnqId

NENA ID - This field needs a description.

Search Display
Requested Required
NENA:RCL_NGUID

img_esblaw_state state

State - This field needs a description.

Search Display
Requested Required

img_esblaw_updateDate updateDate

Last Update - This field needs a description.

Search Display
Requested Required

img_esblaw_uploadAuth uploadAuth

Upload Authority - This field needs a description.

Search Display
Requested Required

img_esblaw_vCardURI vCardURI

Agency vCard URI - This field needs a description.

Search Display
Requested Required
NENA:AVcard_URI

Say something descriptive about the ‘esbpsap’ module.

img_tbl_EsbPsap Emergency Services Boundary (PSAP)

This table needs a description.

Table Name:esbpsap
Geometry Type:LINESTRING

img_esbpsap_agencyID agencyID

Agency ID - This field needs a description.

Search Display
Requested Required
NENA:Agency_ID

img_esbpsap_country country

Country - This field needs a description.

Search Display
Requested Required

img_esbpsap_county county

County - This field needs a description.

Search Display
Requested Required

img_esbpsap_displayName displayName

Display Name - This field needs a description.

Search Display
Requested Required
NENA:DisplayName

img_esbpsap_effective effective

Effective Date - This field needs a description.

Search Display
Requested Required

img_esbpsap_expire expire

Expiration Date - This field needs a description.

Search Display
Requested Required

img_esbpsap_gcUnqId gcUnqId

GeoComm ID - This field needs a description.

Search Display
Requested Required

img_esbpsap_routeURI routeURI

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esbpsap_serviceNum serviceNum

Service Number - This field needs a description.

Search Display
Requested Required
NENA:ServiceNum

img_esbpsap_serviceURN serviceURN

Service URI - This field needs a description.

Search Display
Requested Required
NENA:ServiceURI

img_esbpsap_srcLastEd srcLastEd

Source of Last Update - This field needs a description.

Search Display
Requested Required

img_esbpsap_srcOfData srcOfData

Data Source - This field needs a description.

Search Display
Requested Required

img_esbpsap_srcUnqId srcUnqId

NENA ID - This field needs a description.

Search Display
Requested Required
NENA:RCL_NGUID

img_esbpsap_state state

State - This field needs a description.

Search Display
Requested Required

img_esbpsap_updateDate updateDate

Last Update - This field needs a description.

Search Display
Requested Required

img_esbpsap_uploadAuth uploadAuth

Upload Authority - This field needs a description.

Search Display
Requested Required

img_esbpsap_vCardURI vCardURI

Agency vCard URI - This field needs a description.

Search Display
Requested Required
NENA:AVcard_URI
gcudm

API Documentation

gcudm

GeoComm Unified Data Model

gcudm.base

The GeoAlchemy declarative base for the data model is defined in this module along with some other helpful classes.

class gcudm.base.Base[source]

Bases: object

This is the model’s declarative base.

class gcudm.base.ModelMixin[source]

Bases: object

This is the parent class for all entity classes in the model. It defines common fields.

effective = Column(None, DateTime(), table=None)
expire = Column(None, DateTime(), table=None)
gcUnqId = Column(None, GUID(), table=None, primary_key=True, nullable=False)
classmethod geometry_type()[source]
srcLastEd = Column(None, DateTime(), table=None)
srcOfData = Column(None, String(), table=None)
srcUnqId = Column(None, String(), table=None)
updateDate = Column(None, DateTime(), table=None)
uploadAuth = Column(None, String(), table=None)

gcudm.docstrings

This module contains utilities for setting up docstrings

class gcudm.docstrings.ModelRstFormatter[source]

Bases: object

This class supports a number of specialized methods for creating reStructuredText docstrings for classes in this project.

cls2rst(cls, heading: str, preamble: str = None)[source]

Create a docstring for a model class.

Parameters:
  • cls – the class
  • heading – the heading for the reStructuredText section
  • preamble – everything that should preceed the generated docstring
Returns:

a reStructuredText docstring

col2section(table_name: str, column_name: str, meta: gcudm.meta.ColumnMeta) → str[source]

Format a block of reStructuredText to represent a column.

Parameters:
  • table_name – the name of the table to which the column belongs
  • column_name – the name of the column
  • meta – the column’s meta data
Returns:

a block of reStructuredText

enum2tbl(enum_cls: Type[Union[gcudm.meta.Requirement, gcudm.meta.Usage]], meta: gcudm.meta.ColumnMeta, excluded: Set[Any], indent: int = 1)[source]
static format_line(indent: int = 1, wrap: bool = True)[source]

Format a line of reStructuredText.

Parameters:
  • line – the line to format
  • indent – the indentation level of the formatted line
  • wrap – Should a newline be placed at the end?
Returns:

the formatted line

static simplify_docstring()[source]

Simplify a docstring by removing leading and trailing spaces,

Parameters:s
Returns:
gcudm.docstrings.model(label: str)[source]

Use this decorator to provide meta-data for your model class.

Parameters:label – the friendly label for the class

gcudm.meta

This module contains metadata objects to help with inline documentation of the model.

gcudm.meta.COLUMN_META_ATTR = '__meta__'

the property that contains metadata

class gcudm.meta.ColumnMeta[source]

Bases: tuple

Metadata for table columns.

calculated

Alias for field number 6

description

Alias for field number 1

get_enum(enum_cls: Type[Union[gcudm.meta.Requirement, gcudm.meta.Usage]]) → gcudm.meta.Requirement[source]

Get the current value of an attribute defined by an enumeration.

Parameters:enum_cls – the enumeration class
Returns:the value of the attribute
guaranteed

Alias for field number 5

label

Alias for field number 0

nena

Alias for field number 2

requirement

Alias for field number 3

usage

Alias for field number 4

class gcudm.meta.Requirement[source]

Bases: enum.IntFlag

This enumeration describes contracts with source data providers.

NONE = 0

data for the column is neither requested nor required

REQUESTED = 1

data for the column is requested

REQUIRED = 3

data for the column is required

class gcudm.meta.Usage[source]

Bases: enum.IntFlag

This enumeration describes how data may be used.

DISPLAY = 2

The data is displayed to users.

NONE = 0

The data is not used.

SEARCH = 1

The data is used for searching.

gcudm.meta.column(dtype: Any, meta: gcudm.meta.ColumnMeta, *args, **kwargs) → sqlalchemy.sql.schema.Column[source]

Create a GeoAlchemy Column annotated with metadata.

Parameters:
  • dtype – the GeoAlchemy column type
  • meta – the meta data
Returns:

a GeoAlchemy Column

gcudm.model

Say something descriptive about the ‘model’ module.

gcudm.model.load()[source]

Load the data model.

gcudm.modes

This module can be used to describe the mode in which the library is running.

gcudm.types

This module contains custom GeoAlchemy/SQLAlchemy types.

class gcudm.types.GUID(*args, **kwargs)[source]

Bases: sqlalchemy.sql.type_api.TypeDecorator

This is a Platform-independent GUID type that uses PostgreSQL’s UUID type ( and otherwise uses CHAR(32), storing as stringified hex values.

impl

alias of sqlalchemy.sql.sqltypes.CHAR

load_dialect_impl(dialect)[source]

Return a TypeEngine object corresponding to a dialect.

This is an end-user override hook that can be used to provide differing types depending on the given dialect. It is used by the TypeDecorator implementation of type_engine() to help determine what type should ultimately be returned for a given TypeDecorator.

By default returns self.impl.

process_bind_param(value, dialect)[source]

Receive a bound parameter value to be converted.

Subclasses override this method to return the value that should be passed along to the underlying TypeEngine object, and from there to the DBAPI execute() method.

The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.

This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.

Parameters:
  • value – Data to operate upon, of any type expected by this method in the subclass. Can be None.
  • dialect – the Dialect in use.
process_result_value(value, dialect)[source]

Receive a result-row column value to be converted.

Subclasses should implement this method to operate on data fetched from the database.

Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying TypeEngine object, originally from the DBAPI cursor method fetchone() or similar.

The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.

Parameters:
  • value – Data to operate upon, of any type expected by this method in the subclass. Can be None.
  • dialect – the Dialect in use.

This operation should be designed to be reversible by the “process_bind_param” method of this class.

Python Module Dependencies

The requirements.txt file contains this project’s module dependencies. You can install these dependencies using pip.

pip install -r requirements.txt

requirements.txt

GeoAlchemy2>=0.4.2,<1
parameterized>=0.6.1,<1
psycopg2>=2.7.4,<3
psycopg2-binary>=2.7.4,<3
pytest>=3.4.0,<4
pytest-cov>=2.5.1,<3
pytest-pythonpath>=0.7.2,<1
setuptools>=38.4.0
Sphinx>=1.7.1,<2
sphinx-rtd-theme>=0.2.4,<1
SQLAlchemy>=1.2.6,<2
singleton-decorator>=1.0.0,<2
titlecase>=0.12.0,<1

Indices and tables