Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 3 of 3

GeoCountry -> enum to CString conversion VC++ 7

This is a discussion on GeoCountry -> enum to CString conversion VC++ 7 within the MapPoint Desktop 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&#40;&m_bstrRegion&#41;; CString csRegion=Bstr2Cstr&#40;m_bstrRegion&#41;; BSTR m_bstrCountry; //GeoCountry ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    GeoCountry -> enum to CString conversion VC++ 7

    GeoCountry -> enum to CString conversion VC++ 7

    Sample :

    Code:
    <..snip>
    
    BSTR m_bstrRegion;
    locHotSprings->StreetAddress->get_Region&#40;&m_bstrRegion&#41;;
    CString csRegion=Bstr2Cstr&#40;m_bstrRegion&#41;;
    
    BSTR m_bstrCountry;
    //GeoCountry
    MapPoint&#58;&#58;GeoCountry MyGeoCountry;
    CString csCountry;
    locHotSprings->StreetAddress->get_Country&#40;&MyGeoCountry &#41;;
    
    str.Format&#40;_T&#40;"%.3f km&#58; %s, %s, %s %s %s %s"&#41;,adist, csStreet,csCity,csOtherCity,csRegion,csCountry,csPostal&#41;;
    		
    </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

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,826
    Blog Entries
    55
    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&#58;&#58;GeoCountry, CString >  Country_LUT;
    
    Country_LUT&#91; 61 &#93; = CString&#40;"Denmark"&#41;;
    Country_LUT&#91;109&#93; = CString&#40;"Hungary"&#41;;
    // etc
    
    // Use&#58;
    
    CString myCountryString = Country_LUT&#91; myCountryCode &#93;;

    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

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Lat/Long conversion
    By klomp63 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-14-2006, 02:29 PM
  2. OLEVariant conversion
    By phoque in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 10-10-2005, 12:44 PM
  3. Help Re Conversion please
    By Ticker in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 11-09-2004, 10:25 AM
  4. vb6 to vb.net conversion woes
    By starbuck in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 07-23-2004, 08:07 AM
  5. Coordinate conversion
    By Matrices in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 10-03-2003, 07:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81