Assigning Numerical Value To Alpha Numeric Address Component
I am trying to figure out a method to assign a numerical value to the
street number component of an address. This is obviously very simple when
the street number component is just a plain ol' integer - for example 10
Main St (10 being the street number component). Where it gets difficult
(for me, anyways) is when letters come into play, for example 10 A Main
St, 10 B Main St.
I am working on an algorithm to determine to closest addresses above &
below an input address. For example, take the following addresses:
10 Main St
12 Main St
13 Main St
18 Main St
21 Main St
If I were to pass in 15 Main St, I would expect 13 Main St and 18 Main to
be returned. Easy enough in this example.
Now, for a more complicated example:
10 A Main St
10 C Main St
13 ABCDEFG Main St
13 BZ Main St
13 FG Main St
If I were to pass in 13 C Main St, I would expect 13 BZ Main St and 13 FG
Main St returned. I have yet to figure out a way to assign a numerical
value that works with this scheme. I know the function to assign value
needs to work like this:
Parse out number and character components ex (number: 13, character ABCDEFG)
?? Create a score for character component ??
Add character score to number
I need help scoring the character component. It needs to respect
alphabetical order, so 13 BZ trumps 13 ABCDEFG because B > A. And 13 ACC
would trump 13 ABCDEFG because ACC > ABC.
Hopefully I have clearly stated my problem. Any help would be greatly
appreciated.
No comments:
Post a Comment