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 6 of 6

Getting the coordinates from a freeform shape

This is a discussion on Getting the coordinates from a freeform shape within the MapPoint Desktop Discussion forums, part of the Map Forums category; Is it possible to extract the coordinates of a users drawn freeform shape? Today I'm cheating, saving the map, and ...

  1. #1
    pst
    pst is offline Junior Member White Belt
    Join Date
    Jul 2005
    Posts
    5

    Getting the coordinates from a freeform shape

    Is it possible to extract the coordinates of a users drawn freeform shape?

    Today I'm cheating, saving the map, and using a modified version of st2gpx to read back the coordinates.

    There must be a "cleaner" solution.

    (Using MFC/C++)

    /Patrik

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Check out this code sample --

    http://www.mp2kmag.com/importersub01.asp

    This loops around all the vertices of a freeform and exports to a mif/mid. You should be able to make this work for you.

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    pst
    pst is offline Junior Member White Belt
    Join Date
    Jul 2005
    Posts
    5
    I've been looking into that sample, but I have some problems translating the code to c++.

    The real problem is that I can't seem to retreive the "Location objects" from the Shapes Vertices.

    I use something like this:
    Code:
    	CMap0 m=m_Map.get_ActiveMap();
    	CShapes myShapes=m.get_Shapes();
    	long ns=myShapes.get_Count();
    	if(ns>0)
    	{
    		VARIANT a; a.vt=VT_I4; a.lVal=1;
    
     		CShape myShape=myShapes.get_Item(&a);
    		VARIANT v_coords=myShape.get_Vertices();
    
    		??? HOWTO extract the CLocation objects from the Vertices array ???
    	}
    Any code samples available?

    /Patrik

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    I'm not sure if it helps or not, but I have done the opposite (putting coords in shapes) in C++ in the following article:

    http://www.mp2kmag.com/a113--plottin....mappoint.html

    Note that I don't use MFC.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    pst
    pst is offline Junior Member White Belt
    Join Date
    Jul 2005
    Posts
    5
    After some trial & error coding with MFC variants and arrays, I finally got it working.

    See below for a code sample.

    /Patrik

    Code:
    void dlgZoneEdit::OnBnClickedShape()
    {
    	CMap0 m=m_Map.get_ActiveMap();
    	CShapes myShapes=m.get_Shapes();
    	long ns=myShapes.get_Count();
    	if(ns>0)
    	{
    		VARIANT a; a.vt=VT_I4; a.lVal=1;
    
     		CShape myShape=myShapes.get_Item(&a);
    		VARIANT v_coords=myShape.get_Vertices();
    		COleSafeArray saRet(&v_coords);
    
        long iPoints;
        saRet.GetUBound(1, &iPoints);
    
    		long index[1];
    		for&#40;int i=0;i<=iPoints;i++&#41;
    		&#123;
    			index&#91;0&#93;=i;
    			COleVariant vData;
    			saRet.GetElement&#40;index,vData&#41;;
    			
    			double lat,lon;
    			CLocation cl&#40;vData.pdispVal&#41;;
    			GetPos&#40;m,cl,&lat,&lon&#41;;
    		&#125;
    	&#125;
    &#125;
    [/code]

  6. #6
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Thanks for sharing.
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Shape coordinates
    By MarkStanley in forum MapPoint Desktop Discussion
    Replies: 13
    Last Post: 03-04-2007, 04:57 AM
  2. Start Draw shape (freeform)
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-24-2006, 07:37 PM
  3. freeform shape exporting.. database maybe?
    By Yard in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 07-25-2003, 09:22 AM
  4. View bounds of a Freeform Shape
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-29-2003, 06:35 PM
  5. How can I locate the position of a freeform shape ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 07-31-2002, 02:45 PM

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