PDA

View Full Version : GetItem(&Variant) in c++ cli ?



kemanke
11-14-2008, 11:00 AM
Hi all!

I try to find a FindResults method wich is equal to GetItem() in c++.
I want to get the street name of geographic location.



VARIANT idx;
VariantInit( &idx );

V_VT(&idx) = VT_I4;
V_I4(&idx) = 1;
for(int j=0;j<1000;j++){
latlongPos = myMap->GetLocation(lat,lon,1);

MapPoint::FindResults ^resultsPtr = myMap->ObjectsFromPoint( myMap->LocationToX(latlongPos),myMap->LocationToY(latlongPos));

if(resultsPtr->Count>0)
{
MapPoint::Location ^res = //--> Normaly I have: resultsPtr->GetItem( &idx );
sap = res->StreetAddress;

//...


thank you in advance for your help

Kemanke

Wilfried
11-16-2008, 07:51 AM
Hi,

Do you have an error?

kemanke
11-16-2008, 08:37 AM
Yes, because GetItem method does not exist in intellisence!!

Do you understant why ?
I use to use GetItem in C++ but here I can not!!

Any idea?

Thanks

Kemanke

Wilfried
11-17-2008, 02:29 AM
Hi,

If I use the type library in Delphi it is: Get_Item(...)
Maybe try this one?

kemanke
11-17-2008, 02:44 AM
Nop!

It's not a memeber of Mappoint::FindResults!!

In methods Get, I have only GetEnumerator(), GetHasCode(), and GetType() with intellisence !

Is it another way to get street addresses from geographic coordinates?

Thanks

Kemanke

kemanke
11-17-2008, 05:12 AM
I found another method to get address from Geo-coordinates but I think I do not use this in a good way because the address wich the method returns for a point is far and it's not exactly an address but a road.

Any idea?



MapPoint::Location^ latlongPosInicial = myMap->GetLocation(lat,lon,1);
System::Collections::IEnumerator^pItem;

for(int j=0;j<1000;j++)
{
latlongPos = myMap->GetLocation(lat,lon,1);

MapPoint::FindResults ^resultsPtr = myMap->ObjectsFromPoint( myMap->LocationToX(latlongPos),myMap->LocationToY(latlongPos));

//Get an enumerator
if(resultsPtr->Count>0 && resultsPtr->ResultsQuality == MapPoint::GeoFindResultsQuality::geoAllResultsVali d)
{
pItem = resultsPtr->GetEnumerator();
pItem->Reset();
pItem->MoveNext();

MapPoint::Location ^loc = (MapPoint::Location^)pItem->Current;

if(loc->StreetAddress)
{
//process the location
double distancefromPoint = latlongPosInicial->DistanceTo(latlongPos);

if(latlongPosInicial->DistanceTo(latlongPos)>=0.010)
test = "Proche de"+ loc->StreetAddress->Street+"Avec une erreur de"+ Convert::ToString(latlongPosInicial->DistanceTo(latlongPos)) +"Km"; //loc->StreetAddress->default,latlongPosInicial->DistanceTo(latlongPos));
else test = loc->StreetAddress->Street;

goto found;
}

}


that never goes through this part of code :
if(latlongPosInicial->DistanceTo(latlongPos)>=0.010)

the distance from location initial is 0 although the found address is not the exact address but a road far away from the location.

thanks

Kemanke

kemanke
11-17-2008, 05:38 AM
Ok I found Why it did not give the right address, I forgot something in my code:



latlongPos = myMap->GetLocation(lat,lon,10);
latlongPos->GoTo(); //-> DO NOT FORGET THIS


Thanks again

Kemanke

kemanke
11-17-2008, 05:50 AM
Can someone explains me why I do have to use "GoTo()" method?

And is it possible to use this method without zoom in the location, because I use circles approximations to find correct addresses and the screen is blinking (map is mooving due to circle approximation) if the addresses is not the exact address.

Any Ideas ?

Thanks a lot in adavance.

Kemanke

Wilfried
11-25-2008, 04:54 AM
Hi,

The goto zooms in for a good view. the map needs a good view (not too much altitude) to have a good dilution of precision.

if you want to avoid that a user see a map view changing without that hi wants it, then you can do your calculations on a second hidden map.