Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
korto.wow@gmail.com - 27 Sep 2006 20:40 GMT
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?

Not really a Java question, just something that I was thinking about
today and I have no idea what mechanism anyone would use to accomplish
it.

Right now, I'm thinking the easiest way is using the file set-up I
mentioned above.  Does anyone else have a different mechansim that
would be better?

Thanks,

Korto
Eric Sosman - 28 Sep 2006 02:37 GMT
> 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
[quoted text clipped - 5 lines]
> 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.

Signature

Eric Sosman
esosman@acm-dot-org.invalid

Jeff - 28 Sep 2006 04:03 GMT
> > 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
[quoted text clipped - 28 lines]
> Eric Sosman
> esosman@acm-dot-org.invalid

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.
korto.wow@gmail.com - 28 Sep 2006 16:22 GMT
> 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.

Thanks, all, for the advice.  I recently learned that there are some
places that sell a file with all US Zip codes and their GPS coords.  I
wonder if I could make use of that?  Hmmm...

Anyway, thanks, again, for your thoughts!

Korto
Josh Falter - 28 Sep 2006 20:51 GMT
Looks like the post office uses the Google Maps API to convert it for
them
http://www.zip-codes.com/

> 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
[quoted text clipped - 17 lines]
>
> Korto
korto.wow@gmail.com - 29 Sep 2006 04:22 GMT
> Looks like the post office uses the Google Maps API to convert it for
> them
> http://www.zip-codes.com/

Wow!  Incredible!  Thank you so much, Josh!

Korto


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.