openplans/openblock — pull request #4 by copelco (2012-01-11 18:47:08+00:00)
Title: Use primary feature name during block import

DISCLAIMER: AWAITING REVIEW - INCOMPLETE

I believe I've uncovered a small bug with the OpenBlock block importer. TLIDs (from the edges shapefile) can have more than one associated feature name (primary and alternates). For example, the TLID for a segment of W. Franklin (in Chapel Hill, NC) has two names: W. Franklin (primary) and 54 (alternate). Here's an example dump of feature names matching TLID 72390848:

https://gist.github.com/1560992/5e07f01ad2745411059886347db73879c44de7cc

Notice the PAFLAG attribute on each record: P(rimary) and A(lternate). The OpenBlock block importer ignores this flag and ends up storing the last feature name that it finds during importing. This means that depending on the order of the feature name data per each TLID, certain blocks may be labeled with different names along the same street. Like "100-200 Franklin St." and "201-300 54".

I updated the block importer to do the following:

1. Always use the primary feature name when naming a block
2. Log discovered alternates via Python logging

I attempted to create a new street alias (StreetMisspelling) for each alternate, but I discovered that it's not currently possible with the current data model. This is due the fact that an alternate name ("incorrect" column, which has a unique constraint) can point to many different streets. For example, State Rd. 54 runs through Chapel Hill, NC, so it's labeled as an alternate for different downtown streets. Here you'll see two different TLIDS referencing the same alternate "54":

https://gist.github.com/1560992/4e22f775bc024a6ead27982f4501337cedeb73b4

So we can't currently store alternates and maintain the proper block mapping. Let me know what you think!