Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| list of post codes arround a city. 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 ? |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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);
}
}
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| arround, city, codes, list, post |
| ||||
| 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 | |
| |
| ||||
| 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 |