|
First of all, it is important to understand what a "token" is. A token is all the text in a string up to the next space. So, in the string "hello, how are you?" The first token is "hello," the second token is "how" etc.
These are the rules for the location to be parsed as type A:
| 1. | The first token must be number. If the first token contains a number attached to a unit of measurement, they will be parsed first. (i.e.100' will be parsed to 100 FT) |
| 2. | The second token must be a unit of measurement. Valid values are: F, F., FT, FT., ', FEET, M, M., MI, MI.,MILE, MILES, METERS, MT, KILOMETERS, KILOMETER, KM, KM., K., K. Note that M is assumed to be miles, not meters. |
| 3. | If the distance is indicated in Miles, it will be converted to feet. If the distance is indicated in Kilometers, it will be converted to meters. |
| 4. | The third token must be a direction indicator. Valid direction indicators are: N, S, E, W, NORTH, SOUTH, EAST, WEST, NE, SE, NW, SW, N-E, S-E, N-W, S-W, NORTHEAST, SOUTHEAST, NORTHWEST, SOUTHWEST. The bold values are the preferred values and will be returned when requesting returnType 2. |
| 5. | The fourth token MUST be the word 'OF'. If this is not the case, this function will fail . This is the only way of assuring that we are not parsing an interesting road name into a reference location. |
| 6. | The remainder of the text will be considered the street name. |
These are the rules for the location to be parsed as type B:
| 1. | The text must fail to be parsed as type A. This is important. If the text "300 FT E OF BROADWAY" is passed, you don't want it being converted to "300" and "FT E OF BROADWAY". Simply missing the units is good enough, and missing the word "OF" is a positive way to assure proper parsing. |
| 2. | The first token must be a whole number. A decimal point will invalidate this parser because addresses are generally whole numbers and decimals probably indicate miles. Unlike in type A, the number must be its own token, with not other text attached to it. |
| 3. | The second token will be assumed to be the street name. |
These are the rules for the location to be parsed as type C:
| 4. | The first token must be "AT". That's it. If the first token is "AT", it will be parsed as type C. |
|