Re: A "How would you do this"-type of question. not Java-specific.




Eric Sosman wrote:
korto.wow@xxxxxxxxx wrote:

Imagine you are writing a program that will display a map of the United
States. Your program will ask a user to input their ZIP code. Once
they do, a dot will appear on the map to indicate where that ZIP code
is located.

My question is, how would you go about doing something like this?
Would you have a file of all ZIP codes and their longitude, latitude
coords and extrapolate those to x,y coords on your graphic map? Or, is
there an easier way?

I can't think of a better approach. The assignment of
ZIP codes (USA postal codes) to geographical location is an
arbitrary encoding -- some large-scale patterns are evident
but they're not regular enough that you could derive map
coordinates from numerical calculations on the codes.[*]
May as well treat them as arbitrary keys and look them up
in a table.

Extrapolation doesn't seem to enter the picture, though.

[*] Mathematically, of course, one could always build a
polynomial of degree 100000 or less that interpolates every
five-digit ZIP code to its latitude, and another polynomial
for longitude. You might, however, have some difficulty in
evaluating such high-degree polynomials with useful accuracy!
In fact, I rather suspect that simply storing the coefficients
(as pairs of BigIntegers representing rational numbers, say)
might take more memory than the average 32-bit JVM can supply.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx

Also, you probably don't need all 100,000 entries. For a map, you could
probably just look at the first 3 or at most 4 digits to get a dot of
reasonable size placed on the map.

.



Relevant Pages

  • Re: for nzl*, was Re: The RCTQ map in Frappr and Thank You Frank
    ... thanks, kathyl. ... done in july and i have that refund check i also cant bank cuz it shows mom ... san-fran at ihug dot co dot nz ... >> i'm off the map now. ...
    (rec.crafts.textiles.quilting)
  • Re: British Postal Codes
    ... In UK you know exactly where they end up if you have a map. ... rail takes a different line from the road but most places theres a ... My favouorite places are where theres neither road or ... usenet davidhorne (dot) co uk ...
    (rec.travel.europe)
  • Re: tomtom maps for £9.99
    ... Is that on TomTom mobile? ... e-mail messages to bill dot lord at uku dot co dot uk ... I've always found my way with a good map, ... particularly in new areas or when having to make lots of direction changes. ...
    (uk.rec.caravanning)
  • Re: tomtom maps for £9.99
    ... Is that on TomTom mobile? ... e-mail messages to bill dot lord at uku dot co dot uk ... I've always found my way with a good map, ... The TT is really handy when used in conjunction with a paper map ...
    (uk.rec.caravanning)
  • Re: tomtom maps for £9.99
    ... Is that on TomTom mobile? ... e-mail messages to bill dot lord at uku dot co dot uk ... I've always found my way with a good map, ... It is even handier if you subscribe to the traffic news and it warns you of ...
    (uk.rec.caravanning)