MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




list of post codes arround a city.

This is a discussion on list of post codes arround a city. within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello, I'm new user of visual studio and mappoint, I need to get the list of all cities with the ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 03-09-2008
Junior Member
White Belt
 
Join Date: Mar 2008
Posts: 2
list of post codes arround a city.

Hello,

I'm new user of visual studio and mappoint, I need to get the list of all cities with the postcode and the distance from a city. Do you think I can do that ? I need to do it with mappoint because all of my parterns work with it.

Have you some samples ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 03-10-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Re: list of post codes arround a city.

Hi,

Yes you can do that. you have to scan the map at regular distance and make a list of the places with their location. after you have build the list, filtered out duplicates and so, then you can use DistanceTo method to find the distance from all of them to the other.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 03-10-2008
Junior Member
White Belt
 
Join Date: Mar 2008
Posts: 2
Re: list of post codes arround a city.

I am a very dummy, I never code in vb. Can you give some samples, please ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 03-10-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Re: list of post codes arround a city.

Hi,

this class written in C# find streets in a selected area. You can do the same with postcodes for you application. You have to translate it into the programming language of you choice.

Code:
    public partial class FindStreetsInArea : Form
    {
        private Timer timer;
        private const double ALTITUDE = .5;
        private const int INCREMENT_METER = 75; // we do a check every 75 meter
        private double startLat, startLon;
        private double currentLat, currentLon;
        private double lonInc;
        private const double latInc = (double)INCREMENT_METER / 1000 / 1.852 / 60;
        private int x, y, maxX, maxY;
        private StringBuilder street = new StringBuilder();

        public FindStreetsInArea(GeoMapRegion mapRegion, double centerLat, double centerLon, double width, double height)
        {
            InitializeComponent();

            MP.NewMap(mapRegion);

            timer = new Timer();
            timer.Tick += timer_Tick;
            timer.Interval = 1;
            timer.Enabled = true;

            double nauticalMilesHeight = height / 1.852;    // heigth and width are in km
            double nauticalMilesWidth = width / 1.852;      // so we convert to nautical miles
            startLat = centerLat + nauticalMilesHeight / 2 / 60;
            startLon = centerLon - nauticalMilesWidth / 2 / 60 / Math.Cos(centerLat);
            maxX = (int)(width * 1000 / INCREMENT_METER);
            if (maxX == 0)
                maxX++;
            maxY = (int)(height * 1000 / INCREMENT_METER);
            if (maxY == 0)
                maxY++;
            lonInc = INCREMENT_METER / Math.Cos(centerLat) / 1000 / 1.852 / 60;
            currentLat = startLat;
            progressBar.Maximum = maxX * maxY;
            x = 0;
            y = 0;

        }

        void timer_Tick(object sender, EventArgs e)
        {
            timer.Enabled = false;
            try {
                if (x == 0)
                    currentLon = startLon;
                currentLon += lonInc;
                findStreets();
                triggerPosition();
                progressBar.Increment(1);
                x++;
                if (x == maxX) {
                    x = 0;
                    y++;
                    if (y > maxY) {
                        // We are done
                        timer.Dispose();
                        progressBar.ForeColor = Color.Lime;
                        return;
                    }
                    currentLat -= latInc;
                }
                timer.Enabled = true;
            } catch {   // Application could have been terminated
            }
        }

        /// <summary>
        /// Remove leading and trailing numbers
        /// Filters out duplicate streets
        /// Filters out streetnames length <= 3 characters, eg: N, E, A, Tel, Fax
        /// </summary>
        public void findStreets()
        {
            Map map = MP.ActiveMap;
            map.Altitude = ALTITUDE;
            Location loc = map.GetLocation(currentLat, currentLon, ALTITUDE);
            loc.GoTo();
            FindResults streetResults = map.ObjectsFromPoint(map.LocationToX(loc), map.LocationToY(loc));
            foreach (object o in streetResults) {
                Location StreetLoc = o as Location;
                if (StreetLoc != null && StreetLoc.StreetAddress != null) {
                    street.Length = 0;
                    int n = 0;
                    while (n < StreetLoc.StreetAddress.Street.Length) {
                        if (StreetLoc.StreetAddress.Street[n] >= 'A')
                            break;
                        n++;
                    }
                    while (n < StreetLoc.StreetAddress.Street.Length) {
                        if (StreetLoc.StreetAddress.Street[n] >= '0' && StreetLoc.StreetAddress.Street[n] <= '9')
                            break;
                        street.Append(StreetLoc.StreetAddress.Street[n++]);
                    }
                    string streetTrimmed = street.ToString().TrimEnd(new char[] { ' ', ',', '.', ':' });
                    if (streetTrimmed.Length > 3 && listBox.FindString(streetTrimmed) < 0)
                        listBox.Items.Add(streetTrimmed);
                }
            }
        }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
arround, city, codes, list, post


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/list-post-codes-arround-city-7265.html

Posted By For Type Date
MapPoint: Blogs, Photos, Videos and more on Technorati This thread Refback 04-11-2008 12:40 AM
Calling MapPoint From C++ Without the MFC Safety Net - MapPoint Articles - MP2K Magazine This thread Refback 03-12-2008 07:23 PM
The Magazine for MapPoint - MP2K Magazine This thread Refback 03-10-2008 12:32 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Distance between post codes nick72blue MapPoint 2006/2009 Discussion 5 02-29-2008 11:48 AM
Generate list of zip codes by state mj_stev MapPoint 2006/2009 Discussion 2 12-14-2007 10:19 AM
Post codes with lat.-lon.-Data in Access markus_figge MapPoint 2006/2009 Discussion 2 11-20-2006 10:36 AM
BA post codes UK Anonymous MapPoint 2006/2009 Discussion 2 01-30-2004 01:12 PM
UK District Post codes Anonymous MapPoint 2006/2009 Discussion 1 01-24-2003 11:23 PM


All times are GMT -5. The time now is 10:51 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55