Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| 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>
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 |
| ||||
|
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 |
| |||
| 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 |
![]() |
| Tags |
| >, conversion, cstring, enum, geocountry |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |