How to get the Best Matched Address from FindAddressResults.

gvkreddy
01-09-2005, 03:34 AM
Hi,

I am using the method FindAddressResults of MapPoint object to find some address results in a map file.
When I use the same, it returns me some abiguous results.
I would like to get the best matched one out of the ambiguous results.

I am not sure how to get the best matched location from the results object.

Any pointer / information is much appreciated.

Wilfried
01-09-2005, 06:26 AM
Hi,

I dont know if this is what you looking for but the collection returned from FindAddressResults has a property named ResultsQuality. It can have following values:
public enum GeoFindResultsQuality
{
geoAllResultsValid = 0,
geoFirstResultGood = 1,
geoAmbiguousResults = 2,
geoNoGoodResult = 3,
geoNoResults = 4,
}
Another possible is that you look for a specific object type in the collection because it can contain different types. For example if you onle need to find the Location objects you can do something like this:
foreach (object o in Results) {
Location Loc = o as Location;

if (Loc != null) {
//here you go
}
}
or you can combine the 2 and first check if the ResultsQuality <= geoAmbiguousResults and then loop with the foreach();

Anonymous
01-10-2005, 02:38 AM
I would like to be more specific.

1> I get the matched addresses using findaddressresults method
2> This returns me the Results object having the ambiguous results.
Among these results I would like to get the closest match to my address.

Suppose if I pass

FindAddressResults("","New York", "", "NY", "", "US");

I must get the location which is center of New York.

I hope I am clear.

Vijay

Wilfried
01-10-2005, 03:10 AM
Hi Vijay,

FindAddressResults("","New York", "", "NY", "", "US");

I must get the location which is center of New York.

Note that country is not string but Geocountry type. I dont know about the short form "NY" if mappoint will recognize it, but this is probably not importand.

Anyway I just tryed that first with only a ZIP code, and then with only a city name, and it returns exact the center of the city as you wanted :)

Anonymous
01-10-2005, 03:17 AM
Thanks a lot.

Any idea how to convert given address string into a location object with out using the find, findresults , findaddressresults mehtods.

Actually, I have an address string,

I would like to get the all pushpins with in specified radius from this location.


Vijay

Wilfried
01-10-2005, 04:13 AM
Hi Vijay,

Maybe is FindPlaceResults the method you wnat ? It accepts a string like: "Washington, D.C." but I never tryed it. To find opjects near by you can try the FindNearBy method.

Anonymous
01-10-2005, 04:30 AM
oResults=oMap.FindAddressResults(@street,@city,"" ,@state, @zip, @country);
string resQuality=oResults.ResultsQuality.ToString();
if( resQuality== "geoFirstResultGood" || resQuality=="geoAmbiguousResults")
{
foreach (object o in oResults)
{
MapPoint.Location oLoc =o as MapPoint.Location;
if(oLoc!=null)
{
// oDataset is mappoint Dataset holding the Counsellors. oRs=oDataSet.QueryCircle(oLoc, radius);
if(oRs!=null)
{
oRs.MoveFirst();
while(!oRs.EOF )
{
oPin=oRs.Pushpin;
if(oPin !=null)
counselCount=counselCount+1;
oRs.MoveNext();
}
}
//break;
}
}
return counselCount;

I am using the above code to get the Pushpins from.

When i try to use my MapPoint application, chose the New York city and if I use the MapPoint Application on my system it gives me nearly 22 counsellors(Puspin) in 50 miles of radius,

But when I execute the above program, it gives me just 5 Counsellors(Puspin).

I am not able to understand where am going wrong. :(

Wilfried
01-10-2005, 04:58 AM
Hi,

ResultsQuality can also be: geoAllResultsValid. I suggest you do not use a string to compare (it is also slower) but like this:

if (Results.ResultsQuality <= GeoFindResultsQuality.geoAmbiguousResults) {

Anonymous
01-10-2005, 05:05 AM
Thank you very much..

I will make necessary changes and get back to you.

Vijay

 
Web mp2kmag.com
mapforums.com