MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




GeoCountry -> enum to CString conversion VC++ 7

This is a discussion on GeoCountry -> enum to CString conversion VC++ 7 within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; GeoCountry -> enum to CString conversion VC++ 7 Sample : Code: <..snip> BSTR m_bstrRegion; locHotSprings->StreetAddress->get_Region(&m_bstrRegion); CString csRegion=Bstr2Cstr(m_bstrRegion); BSTR m_bstrCountry; //GeoCountry ...


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 Thread Tools Display Modes
  #1 (permalink)  
Old 03-23-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
GeoCountry -> enum to CString conversion VC++ 7

GeoCountry -> enum to CString conversion VC++ 7

Sample :

Code:
<..snip>

BSTR m_bstrRegion;
locHotSprings->StreetAddress->get_Region(&m_bstrRegion);
CString csRegion=Bstr2Cstr(m_bstrRegion);

BSTR m_bstrCountry;
//GeoCountry
MapPoint::GeoCountry MyGeoCountry;
CString csCountry;
locHotSprings->StreetAddress->get_Country(&MyGeoCountry );

str.Format(_T("%.3f km: %s, %s, %s %s %s %s"),adist, csStreet,csCity,csOtherCity,csRegion,csCountry,csPostal);
		
</snip>
Hi, could you help me on Howto convert the above MyGeoCountry
into String as Value or another way to get the actual
CountryCode by name out of the "simple" enum.. as CString.

(My first week in Visual C++ )


Thx in Advance
elec29a
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-23-2005
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 918
Blog Entries: 11
It doesn't look like MapPoint has a method to convert the enum into a string.

I would be tempted to create a lookup table and use that. The main problem with this is that there are some large gaps in the enum values.
So you could write a function/method that had lots of IFs (tedious).
Or, I'd create a lookup table using a map. MFC probably has an equivalent, but this could be a good time to learn about the STL (Standard Template Library). It handles a lot of the data structure things that MFC can do, but generally better/more flexible/faster.

You would need to manually create the map lookup table in an initialisation method. Then when you need the string, you would lookup the enum in the map, to get the string.

Something like this: (I haven't tested it: I prefer the STL string rather than the MFC CString, but I think they can be substituted in this case)

Code:
map< MapPoint::GeoCountry, CString >  Country_LUT;

Country_LUT[ 61 ] = CString("Denmark");
Country_LUT[109] = CString("Hungary");
// etc

// Use:

CString myCountryString = Country_LUT[ myCountryCode ];

That should get you on your way. I think the map<> can be replaced with an MFC collection, and I may have mis-translated my strings for CStrings.
If you're a beginner with C++, you might not immediately appreciate that STL is better - but it is worth learning in the long term.


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
See the Geoweb Guru for online mapping
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-23-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Map to get enum

Yes, but main Problem in your Solution is that i need to manually translate each Mappoint and we have already a German,Italian,English and more Versions.

i was pondering prior about the same :

char const fruitNames[] = { "State", "Orange", "Banana" }
std::string name = fruitNames[orange];

this would be a simple map, but i KNOW that it MUST be possible

Thx if someone could help me with a "real" inline solution.

Or maybe it is possible to get the name from the "Location and Scale" Toolbar or even if you try the save as function the predefined filename ends with the state..
so a map would be the worst solution in my mind..

Thx in advance
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
>, conversion, cstring, enum, geocountry


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
Lat/Long conversion klomp63 MapPoint 2006/2009 Discussion 1 03-14-2006 03:29 PM
OLEVariant conversion phoque MapPoint 2006/2009 Discussion 1 10-10-2005 01:44 PM
Help Re Conversion please Ticker MapPoint 2006/2009 Discussion 2 11-09-2004 11:25 AM
vb6 to vb.net conversion woes starbuck MapPoint 2006/2009 Discussion 5 07-23-2004 09:07 AM
Coordinate conversion Matrices MapPoint 2006/2009 Discussion 3 10-03-2003 08:13 AM


All times are GMT -5. The time now is 07:15 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, 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