Skip to main content
`Ctrl`+`K`

# ng911ok.lib.legacy module

Script counterpart to `legacy.yml`.

class LegacyFieldInfo(next_gen: str, legacy: str, concatenation: bool, equal: bool, value_map=None)

  Bases: `object`

  Contains information and performs conversions relating to corresponding pairs of next-gen/legacy fields. This class should not typically be instantiated directly! Use `load()` or `for_field()` instead.

  classmethod for_field(field: NG911Field | None = None, *, role: str | None = None, name: str | None = None) → Self

    Given an argument denoting either a legacy field or a next-gen field with a corresponding legacy field, returns an instance of this class with data relevant to that field.

  classmethod get_legacy_street_fields() → FrozenList[NG911Field]

    Loads the legacy street fields in the order used to compute `
    LgcyFulSt`. This is the legacy equivalent of `config.street_fields`.

    Warning

    If the entries under the `fields` key in `legacy.yml` are not in the correct order, then the sequence returned by this function will also be out of order.

    Returns:

      Legacy street field objects.

    Return type:

      FrozenList[NG911Field]

  classmethod load() → FrozenList[Self]

    Loads the data from `legacy.yml` and returns a list of instances of this class corresponding to each entry under the `fields` key in that file.

  compare_columns(df: DataFrame) → Series

    Given a feature class data frame, evaluates whether the values in the column with the same name as `self.legacy.name` correspond as expected to the values in the column named `self.next_gen.name`. Returns a boolean `Series` (with the same index as df) indicating whether the value in the legacy column was indeed the expected value.

    Parameters:

      df (pandas.DataFrame) – Feature class data frame

    Returns:

      Boolean validity series

    Return type:

      pandas.Series

  get_legacy_value(next_gen_value: str) → str | None

    Given a next-gen value present in an instance’s `value_map`, returns the corresponding legacy value. If there is no match, `None` is returned.

  get_next_gen_value(legacy_value: str) → str | None

    Given a legacy value present in an instance’s `value_map`, returns a corresponding next-gen value. In cases where a legacy value matches multiple next-gen values, only one next-gen value will be returned. If there is no match, or if `value_map` is empty, this method returns `None`.

  get_next_gen_values(legacy_value: str) → Series

    Given a legacy value present in an instance’s `value_map`, returns a `pandas.Series` with any corresponding next-gen values. Most, but not all, legacy values correspond to only one next-gen value. If there is no match, an empty `pandas.Series` will be returned.

  _value_map: FrozenDict[str, str] | None

    Mapping from the next-gen to the corresponding legacy values.

  concatenation: bool

    Whether the fields in the legacy/next-gen field pair are intended to be a concatenation of other fields.

  equal: bool

    Whether the values of the legacy field should always equal those of the next-gen field.

  legacy: NG911Field

    Legacy field of a legacy/next-gen field pair.

  next_gen: NG911Field

    NG911 field of a legacy/next-gen field pair.

  property value_map: Series

    Returns a `pandas.Series` of the instance’s value map.

convert_legacy_fields(gdb: str, feature_classes: Sequence[NG911FeatureClass], legacy_fields: Sequence[NG911Field], convert_to: Literal['LEGACY', 'NEXTGEN'], update_nulls_only: bool = True) → int

  Performs field conversions related to legacy abbreviations.

  Parameters:

    - gdb – Geodatabase path

    - feature_classes – Feature classes containing the supplied legacy_fields to include in the conversion

    - legacy_fields – The legacy fields involved in the conversion (the corresponding next-gen fields will be determined automatically)

    - convert_to – Direction to convert to; use `"LEGACY"` to convert from next-gen to legacy, or use `"NEXTGEN"` to convert from legacy to next-gen

    - update_nulls_only – Whether to only overwrite values that are null, default True

  Returns:

    Number of feature attributes updated