CityOfPhiladelphia / ais

Address Information System
19 stars 8 forks source link

Improve related address matching/tag assignment #104

Closed bertday closed 7 years ago

bertday commented 7 years ago

Currently the address_link table is only being used to 1) return the match_type in the API and 2) to do some merging of unit siblings in make_address_summary. Using it more robustly in both the engine and the API could resolve a few open issues around address matching and attribute assignment (see #2, #6, #7, #9, #74).

Objectives

Project Outline

bertday commented 7 years ago

Mocked up API response with path-like match_type:

https://gist.github.com/rbrtmrtn/88c07f22d4e46e3d68c08621efd0d172

bertday commented 7 years ago

For step 1, we should make sure:

bertday commented 7 years ago

Query to select in range address links missing children:

select * from 
    (select 
        a.street_address,
        a.address_low,
        a.address_high,

        (a.address_high - a.address_low) / 2 + 1 as expected,
        al.count as actual,
        (al.count = (ceil((a.address_high - a.address_low) / 2) + 1)) as enough,
        ((a.address_high - a.address_low) / 2 + 1) - al.count as missing
    from address a
    join (select address_2, count(*) from address_link where relationship = 'in range' group by address_2) al
    on a.street_address = al.address_2
    ) b
where b.enough = false
order by b.missing desc