Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:02:05+00:00 2026-06-11T17:02:05+00:00

Goal… Given a Zip code and a number of miles… get all zip codes

  • 0

Goal… Given a Zip code and a number of miles… get all zip codes within N miles.

Found one utility here in .NET: http://www.codeproject.com/Articles/9198/ZIP-Code-Utility
Found another utility in PHP.

Also found this: http://api.geonames.org/findNearbyPostalCodes?postalcode=53714&country=USA&radius=50&username=demo

Is there such a client in java?

UPDATE: I couldn’t find one and no one responded, so I went ahead and created one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:02:07+00:00Added an answer on June 11, 2026 at 5:02 pm

    I went ahead and wrote one.

    package ndd;
    
    public class RadiusBox {
        static final Double kEarthRadiusMiles = 3956.0;
        public static RadiusBox create(Double latitude, Double longitude, Double radiusInMiles)
        {
            /*
                A point {lat,lon} is a distance d out on the tc radial from point 1 if:
    
                lat = asin (sin (lat1) * cos (d) + cos (lat1) * sin (d) * cos (tc))
                dlon = atan2 (sin (tc) * sin (d) * cos (lat1), cos (d) - sin (lat1) * sin (lat))
                lon = mod (lon1 + dlon + pi, 2 * pi) - pi
    
                Where:
                    * d is the distance in radians (an arc), so the desired radius divided by
                        the radius of the Earth.
                    * tc = 0 is N, tc = pi is S, tc = pi/2 is E, tc = 3*pi/2 is W.
            */
            double lat;
            double dlon;
            double dLatInRads = latitude * (Math.PI / 180.0);
            double dLongInRads = longitude * (Math.PI / 180.0);
            double dDistInRad = radiusInMiles / kEarthRadiusMiles;
            RadiusBox box = new RadiusBox ();
            box.setRadius(radiusInMiles);
    
            //  N (tc == 0):
            //      lat = asin (sin(lat1)*cos(d) + cos(lat1)*sin(d))
            //          = asin (sin(lat1 + d))
            //          = lat1 + d
            //  Unused:
            //      lon = lon1, because north-south lines follow lines of longitude.
            box.setTopLine((dLatInRads + dDistInRad) * (180.0 / Math.PI));
    
            //  S (tc == pi):
            //      lat = asin (sin(lat1)*cos(d) - cos(lat1)*sin(d))
            //          = asin (sin(lat1 - d))
            //          = lat1 - d
            //  Unused:
            //      lon = lon1, because north-south lines follow lines of longitude.
            box.setBottomLine((dLatInRads - dDistInRad) * (180.0 / Math.PI));
    
            //  E (tc == pi/2):
            //      lat  = asin (sin(lat1)*cos(d))
            //      dlon = atan2 (sin(tc)*sin(d)*cos(lat1), cos(d) - sin(lat1)*sin(lat))
            //      lon  = mod (lon1 + dlon + pi, 2*pi) - pi
            lat = Math.asin (Math.sin(dLatInRads) * Math.cos (dDistInRad));
            dlon = Math.atan2 (Math.sin(Math.PI / 2.0) * Math.sin (dDistInRad) * Math.cos (dLatInRads), Math.cos (dDistInRad) - Math.sin (dLatInRads)* Math.sin (lat));
            box.setRightLine( (((dLongInRads + dlon + Math.PI) % (2.0 * Math.PI)) - Math.PI) * (180.0 / Math.PI));
    
            //  W (tc == 3*pi/2):
            //      lat  = asin (sin(lat1)*cos(d))
            //      dlon = atan2 (sin(tc)*sin(d)*cos(lat1), cos(d) - sin(lat1)*sin(lat))
            //      lon  = mod (lon1 + dlon + pi, 2*pi) - pi
            dlon = Math.atan2 (Math.sin (3.0 * Math.PI / 2.0) * Math.sin (dDistInRad) * Math.cos (dLatInRads), Math.cos (dDistInRad) - Math.sin (dLatInRads)* Math.sin (lat));
            box.setLeftLine((((dLongInRads + dlon + Math.PI) % (2.0 * Math.PI)) - Math.PI) * (180.0 / Math.PI));
    
            return box;
        }
    
        private double bottomLine;
        private double topLine;
        private double leftLine;
        private double rightLine;
        private double radius;
        public double getBottomLine() {
            return bottomLine;
        }
        public void setBottomLine(double bottomLine) {
            this.bottomLine = bottomLine;
        }
        public double getTopLine() {
            return topLine;
        }
        public void setTopLine(double topLine) {
            this.topLine = topLine;
        }
        public double getLeftLine() {
            return leftLine;
        }
        public void setLeftLine(double leftLine) {
            this.leftLine = leftLine;
        }
        public double getRightLine() {
            return rightLine;
        }
        public void setRightLine(double rightLine) {
            this.rightLine = rightLine;
        }
        public double getRadius() {
            return radius;
        }
        public void setRadius(double radius) {
            this.radius = radius;
        }
        @Override
        public String toString() {
            return "RadiusBox [bottomLine=" + bottomLine + ", leftLine=" + leftLine
                    + ", radius=" + radius + ", rightLine=" + rightLine
                    + ", topLine=" + topLine + "]";
        }
    
        public String getSqlQuery() {
            StringBuilder sb = new StringBuilder();
            sb.append ("SELECT * FROM ZIP_CODES WHERE ");
            sb.append ("LATITUDE >= ");
            sb.append(bottomLine);
            sb.append (" AND LATITUDE <= ");
            sb.append(topLine);
            sb.append (" AND LONGITUDE >= ");
            sb.append(leftLine);
            sb.append (" AND LONGITUDE <= ");
            sb.append(rightLine);
            sb.append (" ORDER BY CITY, STATE, ZIP");
            return sb.toString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: Rolling/Running total for all statements at the end of each month. Code: select
Goal: User only selects one , only one option at a given time for
Goal: Given a number (it may be very long and it is greater than
GOAL : To customize the background view of cell. Here is what I am
Goal: to create a percentage column based off the values of calculated columns. Here's
Goal My goal is to to get Twitter Bootstrap to worth with my Play
Goal: order records by 'start_date' select first record get the id of the record
Goal: Get values which are unique in $resultSecond So I have two objects. $result
Goal: Retrieve all instance of List<> from interface GameFactory Problem: I retrieve error message
Goal: Get the TEXT address and then display the street view and map view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.