MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

This is a discussion on Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC within the Development forums, part of the MapPoint 2006/2009 Discussion category; Hi there, Wondering if anyone can help me. Im using C++ MFC with MapPoint 2002. Im trying to calculate routes ...


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

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 01-05-2008
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Question Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Hi there,

Wondering if anyone can help me.
Im using C++ MFC with MapPoint 2002.
Im trying to calculate routes between lots of different sites and find the shortest drive time between the sites and certian buildings.
I have a fairly stable program working at the moment, however i've got to running through some test data and the program is stopping when a post code does not exist in MapPoint.
The AFX error message that comes up is:
'The requested member of the collection does not exist. Use a valid name or index number.'

I have no problem with there not being a post code match, however i need the program to keep running, and some way to tell the user which post code is not matched.

Any ideas with this would be a great help.

Cheers

PieEater3142
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 01-05-2008
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,487
Blog Entries: 1
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Can you post your code snippet? I assume at one point you have a FindResults collection and you normally just take the first item in the collection? Can you check the number of objects or count of objects in the collection first?

Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
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 01-05-2008
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Hi Eric,

Cheers for the quick response:

The function thats throwing the error is:
Quote:
bool Route_Calculator::calculate_route(CString patient_pc, CString site_pc)
{
//reset response value
routeOK = false;

//clear route information, ready for new route info
m_Route.Clear();
//clear distance and drivetime variables
dblDistance=(double)0;
dblDriveTime=(double)0;

//MapPoint requires a variant type for passing the country
//so Variant type created with value 242 - this is the UK
VARIANT vtGeoCountry;
vtGeoCountry.vt = VT_I4;
vtGeoCountry.intVal = 242;

//find postcodes on map
CFindResults patient_loc = m_Map.FindAddressResults("", "", "", "", patient_pc, vtGeoCountry);
CFindResults site_loc = m_Map.FindAddressResults("", "", "", "", site_pc, vtGeoCountry);

//bodge factor to get around crappy microsoft product
//create variant to pass with value 1 coz it cant handle an int
VARIANT v2;
v2.vt = VT_I4;
v2.intVal = 1;

//save the locations found to type CLocation for MapPoint to process
CLocation p_lc = patient_loc.GetItem(&v2);
CLocation s_lc = site_loc.GetItem(&v2);

//add points to map
m_WayPoints.Add(p_lc, "patient");
m_WayPoints.Add(s_lc, "site");

//calculate the best route
m_Route.Calculate();

//save distance and drive time to variables
dblDistance = m_Route.GetDistance();
dblDriveTime = m_Route.GetDrivingTime();

if(dblDriveTime==0){
routeOK = false;
}else{
routeOK = true;
}

return routeOK;
}
It uses the standard MapPoint classes built when you import the ActiveX control.

It creates the error message when it gets one of the two following commands (depending which has the bad post code in):

//save the locations found to type CLocation for MapPoint to process
CLocation p_lc = patient_loc.GetItem(&v2);
CLocation s_lc = site_loc.GetItem(&v2);

Cheers for your help

PieEater
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 01-05-2008
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,487
Blog Entries: 1
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Yes, I think it makes sense. You would be trying to get item 1 from a collection with no objects.

Check the FindResults collection object in the Help File. It has five properties

Properties
Application
Count
Item*
Parent
ResultsQuality

Before you use the GetItem, I think you want to check the Count property first to see if the collection has any items.

hope that helps.
Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2008
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Hi Eric,

Thanks for your help.
Works like a charm.

Where is this help file of which you speak.
Im currently using the object browser in VB6 or looking at the Class view in C++ for the different functions.

Thanks again.

PieEater
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2008
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,487
Blog Entries: 1
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Hello PieEater.

Of what pie do you like the most?

Under Start | Programs you may see MapPoint listed as a program, then go to Help and the Programming Information is at the bottom of the file.

If you don't see MapPoint in the Start menu, then you should be able to find it by going to your \Program Files\ directory and look for Microsoft MapPoint, the help file is a "MAPPOINT.chm" file you should be able to just double-click on to open. As a last resort you could search your hard drive for MapPoint.chm. If you still don't find it let me know and I can send you a copy - I don't think I have the MapPoint 2002 chm file, but the API / object model should be just about identical to the MapPoint 2004 object model.

Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 01-06-2008
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Hi Eric,

Thanks for help file info.

All pies are good - so many to choose from - but cant go wrong with chicken and mushroom or an apple pie

Another question for you if you dont mind.

I need to determine if a post code is on the isle of wight or not.

Now from the help file this would be the map.FindAddressResults function.
However the output is of type CFindResults for C++.
From the help file:
object.FindAddressResults([Street], [City], [OtherCity], [Region], [PostalCode], [Country])

So the value should come back in the OtherCity or Region field.
However how do i get the answer out in C++ - is there any way?

Cheers again

PieEater
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 01-06-2008
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Quote:
object.FindAddressResults([Street], [City], [OtherCity], [Region], [PostalCode], [Country])
Think i've got the wrong function there - was trying to get something together in vb just to see whats what (still needs to be done in c++) and it doesnt appear to give the output.

Any ideas what function can do what i need and how you can interpret the outputs?

Cheers

PieEater
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 01-06-2008
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,487
Blog Entries: 1
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Yes, you're right.

Honestly I think the easiest thing and the most reliable would be if you know the postcode range - is it consistent? for instance if all postcodes in the Isle of Wight began with

K3x xxxx through K8xx xxx or whatever

and you could just test through some string functions.

Eric
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 01-08-2008
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Re: Invalud PostCode issue with MapPoint 2002 with C++ ActiveX in the MFC

Damn, ok thanks for that.
Thought it might come to that but was looking for a neater way.
Oh well.

Cheers

Yet another question - bit random but here we go:

I have to use mappoint 2002 as its the only version that integrates with Visual C++ 6.
Unfortunately the post codes are out of date.
Is there any way to overwrite the data files on the mappoint 2002 version with the 2006 version for instance. I have tried - all file names are the same - sizes are obviously different but it doesnt work.
Is it possible (by giving it some other files) or am i stuck with it.

Thanks again for all your help with this, you've been a star.

Cheers

PieEater
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
activex, invalud, issue, mappoint 2002, mfc, postcode


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/invalud-postcode-issue-mappoint-2002-c-activex-mfc-6979.html

Posted By For Type Date
Automating MapPoint with Perl - MapPoint Articles - MP2K Magazine This thread Refback 01-13-2008 01:22 AM
Merging Multiple Routes - MapPoint Articles - MP2K Magazine This thread Refback 01-08-2008 04:05 PM
The Magazine for MapPoint - MP2K Magazine This thread Refback 01-07-2008 04:16 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
Mappoint Installation issue jacky3212 MP2K Magazine Articles 2 07-19-2008 01:08 AM
MapPoint 2002 ActiveX control and Visual Studio .NET 2003 chulaka MapPoint 2006/2009 Discussion 1 09-30-2003 11:35 AM
GetName() problem in 2002 ActiveX in VC++ jvirtue MapPoint 2006/2009 Discussion 0 09-26-2003 02:04 PM
Map Point 2002 Europe Postcode Sector Updates Anonymous MapPoint 2006/2009 Discussion 1 10-08-2002 11:13 AM
I am using Mappoint 2002 ActiveX control in a VB a.... Anonymous MapPoint 2006/2009 Discussion 2 06-14-2002 08:10 AM


All times are GMT -5. The time now is 05:24 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