Skip to content

Commit

Permalink
add bl func
Browse files Browse the repository at this point in the history
  • Loading branch information
fvankrieken committed Dec 3, 2024
1 parent fbbb7f6 commit f47432b
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 13 deletions.
156 changes: 143 additions & 13 deletions dcpy/models/geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SbvpSanbornMapIdentifier(BaseModel):
page_number_suffix: str | None = FieldStrOrNone("Page Number Suffix")


class ListOfGeographicIdentifiers(BaseModel):
class GeographicIdentifier(BaseModel):
low_house_number: str | None = FieldStrOrNone("Low House Number")
high_house_number: str | None = FieldStrOrNone("High House Number")
borough_code: str | None = FieldStrOrNone("Borough Code")
Expand Down Expand Up @@ -178,7 +178,7 @@ class BlockFace(BaseModel): # 1, 1E
pass


class GeoSupportReturn(BaseModel):
class GeoSupportResult(BaseModel):
reason_code: str | None = FieldStrOrNone("Reason Code")
reason_code_qualifier: str | None = FieldStrOrNone("Reason Code Qualifier")
warning_code: str | None = FieldStrOrNone("Warning Code")
Expand All @@ -194,7 +194,7 @@ class GeoSupportReturn(BaseModel):


class Result1(
CityServiceInfo, CensusInfo, PoliticalInfo, GeoSupportReturn, extra="forbid"
CityServiceInfo, CensusInfo, PoliticalInfo, GeoSupportResult, extra="forbid"
):
first_borough_name: str | None = FieldStrOrNone("First Borough Name")
house_number_display_format: str | None = FieldStrOrNone(
Expand Down Expand Up @@ -304,7 +304,7 @@ class Result1(
curve_flag: str | None = FieldStrOrNone("Curve Flag")


class Result1A(GeoSupportReturn, extra="forbid"):
class Result1A(GeoSupportResult, extra="forbid"):
first_borough_name: str | None = FieldStrOrNone("First Borough Name")
house_number_display_format: str | None = FieldStrOrNone(
"House Number - Display Format"
Expand Down Expand Up @@ -457,13 +457,13 @@ class Result1A(GeoSupportReturn, extra="forbid"):
number_of_entries_in_list_of_geographic_identifiers: str | None = FieldStrOrNone(
"Number of Entries in List of Geographic Identifiers"
)
list_of_geographic_identifiers: list[ListOfGeographicIdentifiers] = Field(
list_of_geographic_identifiers: list[GeographicIdentifier] = Field(
alias="LIST OF GEOGRAPHIC IDENTIFIERS"
)


class Result1E(
CityServiceInfo, CensusInfo, PoliticalInfo, GeoSupportReturn, extra="forbid"
CityServiceInfo, CensusInfo, PoliticalInfo, GeoSupportResult, extra="forbid"
):
first_borough_name: str | None = FieldStrOrNone("First Borough Name")
house_number_display_format: str | None = FieldStrOrNone(
Expand Down Expand Up @@ -644,7 +644,7 @@ class StrollingKey(BaseModel, extra="forbid"):


class Result1B(
CityServiceInfo, CensusInfo, PoliticalInfo, GeoSupportReturn, extra="forbid"
CityServiceInfo, CensusInfo, PoliticalInfo, GeoSupportResult, extra="forbid"
):
first_borough_name: str | None = FieldStrOrNone("First Borough Name")
house_number_display_format: str | None = FieldStrOrNone(
Expand Down Expand Up @@ -875,7 +875,7 @@ class Result1B(
low_house_number_of_defining_address_range: str | None = FieldStrOrNone(
"Low House Number of Defining Address Range"
)
rpad_self_check_code_scc_for_bbl: str | None = FieldStrOrNone(
rpad_self_check_code_for_bbl: str | None = FieldStrOrNone(
"RPAD Self-Check Code (SCC) for BBL"
)
rpad_building_classification_code: str | None = FieldStrOrNone(
Expand Down Expand Up @@ -914,16 +914,16 @@ class Result1B(
filler_tax_lot_version_no_billing_bbl: str | None = FieldStrOrNone(
"Filler - Tax Lot Version No. Billing BBL"
)
self_check_code_scc_of_billing_bbl: str | None = FieldStrOrNone(
self_check_code_of_billing_bbl: str | None = FieldStrOrNone(
"Self-Check Code (SCC) of Billing BBL"
)
low_bbl_of_this_building_s_condominium_units: str | None = FieldStrOrNone(
low_bbl_of_this_buildings_condominium_units: str | None = FieldStrOrNone(
"Low BBL of this Building's Condominium Units"
)
filler_tax_lot_version_no_of_low_bbl: str | None = FieldStrOrNone(
"Filler - Tax Lot Version No. of Low BBL"
)
high_bbl_of_this_building_s_condominium_units: str | None = FieldStrOrNone(
high_bbl_of_this_buildings_condominium_units: str | None = FieldStrOrNone(
"High BBL of this Building's Condominium Units"
)
filler_tax_log_version_no_of_high_bbl: str | None = FieldStrOrNone(
Expand All @@ -943,7 +943,7 @@ class Result1B(
x_y_coordinates_of_lot_centroid: str | None = FieldStrOrNone(
"X-Y Coordinates of Lot Centroid"
)
business_improvement_district_bid: str | None = FieldStrOrNone(
business_improvement_district: str | None = FieldStrOrNone(
"Business Improvement District (BID)"
)
tpad_bin_status: str | None = FieldStrOrNone("TPAD BIN Status")
Expand All @@ -955,6 +955,136 @@ class Result1B(
number_of_entries_in_list_of_geographic_identifiers: str | None = FieldStrOrNone(
"Number of Entries in List of Geographic Identifiers"
)
list_of_geographic_identifiers: list[ListOfGeographicIdentifiers] = Field(
list_of_geographic_identifiers: list[GeographicIdentifier] = Field(
alias="LIST OF GEOGRAPHIC IDENTIFIERS"
)


class ResultBN(GeoSupportResult, BaseModel):
first_borough_name: str = Field(alias="First Borough Name")
house_number_display_format: str = Field(alias="House Number - Display Format")
house_number_sort_format: str = Field(alias="House Number - Sort Format")
b10_sc_first_borough_and_street_code: str = Field(
alias="B10SC - First Borough and Street Code"
)
first_street_name_normalized: str = Field(alias="First Street Name Normalized")
b10_sc_second_borough_and_street_code: str = Field(
alias="B10SC - Second Borough and Street Code"
)
second_street_name_normalized: str = Field(alias="Second Street Name Normalized")
b10_sc_third_borough_and_street_code: str = Field(
alias="B10SC - Third Borough and Street Code"
)
third_street_name_normalized: str = Field(alias="Third Street Name Normalized")
bbl: Bbl = Field(alias="BOROUGH BLOCK LOT (BBL)")
filler_for_tax_lot_version_number: str = Field(
alias="Filler for Tax Lot Version Number"
)
low_house_number_display_format: str = Field(
alias="Low House Number - Display Format"
)
low_house_number_sort_format: str = Field(alias="Low House Number - Sort Format")
bin: str = Field(alias="Building Identification Number (BIN)")
street_attribute_indicators: str = Field(alias="Street Attribute Indicators")
node_number: str = Field(alias="Node Number")
unit_sort_format: UnitSortFormat = Field(alias="UNIT - SORT FORMAT")
unit_display_format: str = Field(alias="Unit - Display Format")
nin: str = Field(alias="NIN")
street_attribute_indicator: str = Field(alias="Street Attribute Indicator")
number_of_street_codes_and_street_names_in_list: str = Field(
alias="Number of Street Codes and Street Names in List"
)
list_of_street_codes: list = Field(alias="List of Street Codes")
list_of_street_names: list = Field(alias="List of Street Names")
continuous_parity_indicator_duplicate_address_indicator: str = Field(
alias="Continuous Parity Indicator /Duplicate Address Indicator"
)
low_house_number_of_defining_address_range: str = Field(
alias="Low House Number of Defining Address Range"
)
rpad_self_check_code_for_bbl: str = Field(
alias="RPAD Self-Check Code (SCC) for BBL"
)
rpad_building_classification_code: str = Field(
alias="RPAD Building Classification Code"
)
corner_code: str = Field(alias="Corner Code")
number_of_existing_structures_on_lot: str = Field(
alias="Number of Existing Structures on Lot"
)
number_of_street_frontages_of_lot: str = Field(
alias="Number of Street Frontages of Lot"
)
interior_lot_flag: str = Field(alias="Interior Lot Flag")
vacant_lot_flag: str = Field(alias="Vacant Lot Flag")
irregularly_shaped_lot_flag: str = Field(alias="Irregularly-Shaped Lot Flag")
marble_hill_rikers_island_alternate_borough_flag: str = Field(
alias="Marble Hill/Rikers Island Alternate Borough Flag"
)
lgi_overflow_flag: str = Field(
alias="List of Geographic Identifiers (LGI) Overflow Flag"
)
strolling_key: str = Field(alias="STROLLING KEY")
borough: str = Field(alias="Borough")
five_digit_street_code_of_on_street: str = Field(
alias="5-Digit Street Code of 'On' Street"
)
side_of_street_indicator: str = Field(alias="Side of Street Indicator")
high_house_number_sort_format: str = Field(alias="High House Number - Sort Format")
reserved_for_internal_use: str = Field(alias="Reserved for Internal Use")
building_identification_number_bin_of_input_address_or_nap: str = Field(
alias="Building Identification Number (BIN) of Input Address or NAP"
)
condominium_flag: str = Field(alias="Condominium Flag")
dof_condominium_identification_number: str = Field(
alias="DOF Condominium Identification Number"
)
condominium_unit_id_number: str = Field(alias="Condominium Unit ID Number")
condominium_billing_bbl: str = Field(alias="Condominium Billing BBL")
filler_tax_lot_version_no_for_billing_bbl: str = Field(
alias="Filler - Tax Lot Version No. for Billing BBL"
)
self_check_code_of_billing_bbl: str = Field(
alias="Self-Check Code (SCC) of Billing BBL"
)
low_bbl_of_this_buildings_condominium_units: LowBblOfThisBuildingsCondominiumUnits = Field(
alias="LOW BBL OF THIS BUILDING'S CONDOMINIUM UNITS"
)
filler_for_tax_lot_version_no_of_low_bbl: str = Field(
alias="Filler for Tax Lot Version No. of Low BBL"
)
high_bbl_of_this_buildings_condominium_units: HighBblOfThisBuildingsCondominiumUnits = Field(
alias="HIGH BBL OF THIS BUILDING'S CONDOMINIUM UNITS"
)
filler_for_tax_lot_version_no_of_high_bbl: str = Field(
alias="Filler for Tax Lot Version No. of High BBL"
)
cooperative_id_number: str = Field(alias="Cooperative ID Number")
sbvp_sanborn_map_identifier: SbvpSanbornMapIdentifier = Field(
alias="SBVP (SANBORN MAP IDENTIFIER)"
)
dcp_commercial_study_area: str = Field(alias="DCP Commercial Study Area")
tax_map_number_section_volume: str = Field(alias="Tax Map Number Section & Volume")
reserved_for_tax_map_page_number: str = Field(
alias="Reserved for Tax Map Page Number"
)
latitude: str = Field(alias="Latitude")
longitude: str = Field(alias="Longitude")
x_y_coordinates_of_tax_lot_centroid_internal_to_lot: str = Field(
alias="X-Y Coordinates of Tax Lot Centroid (Internal to Lot)"
)
business_improvement_district: str = Field(
alias="Business Improvement District (BID)"
)
tpad_bin_status_for_dm_job: str = Field(alias="TPAD BIN Status (for DM job)")
tpad_new_bin: str = Field(alias="TPAD New BIN")
tpad_new_bin_status: str = Field(alias="TPAD New BIN Status")
tpad_conflict_flag: str = Field(alias="TPAD Conflict Flag")
dcp_zoning_map: str = Field(alias="DCP Zoning Map")
list_of_4_lg_cs: str = Field(alias="List of 4 LGCs")
number_of_entries_in_list_of_geographic_identifiers: str = Field(
alias="Number of Entries in List of Geographic Identifiers"
)
list_of_geographic_identifiers: list[GeographicIdentifier] = Field(
alias="LIST OF GEOGRAPHIC IDENTIFIERS"
)
4 changes: 4 additions & 0 deletions dcpy/utils/geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ def geocode_df(
street_name_normalization: bool = False,
browse_flag: bool = False,
) -> pd.DataFrame:
# todo - definitely need some sort of caching for individual functions
# unless we can improve inner workings of geosupport, there are cases where
# we need to go BBL -> geographic identifiers / 5-digit street code -> address -> 1a
# though performance test for sure - maybe minimal benefit
data_records = df.to_dict("records")

def func(dict):
Expand Down

0 comments on commit f47432b

Please sign in to comment.