I see all these answers, and none of them really seem to answer the
original question.  If I understand the question correctly, you just
need to know which states border a given state.  You can't do this
with latitude and longitude, or picking the "before" and "after"
states, or zip codes, or any other calculation, since states can be
close to others without actually touching, or can be huge, meaning one
end of one state to another state may be pretty far away, and border
anywhere from zero to about ten other states.

The only way to reliably do this is manually.  If you're doing it in a
DB, I'd probably do something like:

ADJACENT_STATE table with two columns.  The table contains records for
each state, and each state that it borders.  For example:
AZ CA
AZ NV
AZ CO
AZ UT
AZ NM
CA OR
CA NV
CA AZ

Column 1 would be indexed.  When you need to look up a state, you'd
filter by column 1.

The way I figure, it would only take an hour or two to set up - look
at a map, do the states one at a time - there are only 50 states, and
it wouldn't take more than a minute or so each.  And the table would
only have maybe a few hundred records, so performance would be
ridiculously fast.

I would bet that there's a list of these already out there on the web,
so you may not even have to do the work yourself.

If you don't have a database in your small app, you could do all of
this in an XML file, or you could get it into the compiled code using
something like a Dictionary<string, List<string>> or something
similar.

On May 13, 6:30 pm, S <[email protected]> wrote:
> I am developing this small application in which I need to find states
> adjacent to the one I am looking up. Say for example, if  I am looking
> up Connecticut, adjacent ones are NY, MA. Now I could potentially
> store it but I would want to rather compute it and do it very
> efficiently.
>
> Any ideas anyone can throw on this ?
>
> Thanks
> S

Reply via email to