Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Getting the coordinates from a freeform shape within the MapPoint 2006/2009 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 ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Getting the coordinates from a 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 |
| ||||
|
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
__________________ |
| |||
|
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 ???
}
/Patrik |
| ||||
|
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 See the Geoweb Guru for online mapping |
| |||
|
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(int i=0;i<=iPoints;i++)
{
index[0]=i;
COleVariant vData;
saRet.GetElement(index,vData);
double lat,lon;
CLocation cl(vData.pdispVal);
GetPos(m,cl,&lat,&lon);
}
}
}
|
![]() |
| Tags |
| coordinates, freeform, shape |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shape coordinates | MarkStanley | MapPoint 2006/2009 Discussion | 13 | 03-04-2007 03:57 AM |
| Start Draw shape (freeform) | Anonymous | MapPoint 2006/2009 Discussion | 2 | 10-24-2006 06:37 PM |
| freeform shape exporting.. database maybe? | Yard | MapPoint 2006/2009 Discussion | 3 | 07-25-2003 08:22 AM |
| View bounds of a Freeform Shape | Anonymous | MapPoint 2006/2009 Discussion | 0 | 04-29-2003 05:35 PM |
| How can I locate the position of a freeform shape .... | Anonymous | MapPoint 2006/2009 Discussion | 4 | 07-31-2002 01:45 PM |
Costa Brava Holiday
Beautiful kilometres of sandy beaches await you should you choose a Costa Brava holiday through UlookUbook!