MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




C#: MapPoint 2004 - Check Regions

This is a discussion on C#: MapPoint 2004 - Check Regions within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I too have the same problem. I need to have a C# program determine in which US State contains a ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (3) Thread Tools Display Modes
  #11 (permalink)  
Old 12-20-2006
Junior Member
White Belt
 
Join Date: Dec 2006
Posts: 11
Re: C#: MapPoint 2004 - Check Regions

I too have the same problem. I need to have a C# program determine in which US State contains a specific location specified in latitude,longitude. Can this be determined from the results supplied by GetLocation?

This is my very first attempt to use MapPoint from a program, so I'm a total newbie. I have MP2006 however, not MP2004.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12 (permalink)  
Old 12-21-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C#: MapPoint 2004 - Check Regions

Hi,

This can easy be done, this is example:

Code:
    Location loc = MP.ActiveMap.GetLocation(lat, lon, alt);
    FindResults StreetResults = MP.ActiveMap.ObjectsFromPoint(MP.ActiveMap.LocationToX(loc), MP.ActiveMap.LocationToY(loc));
    foreach (object o in StreetResults) {
	loc = o as Location;
	if (loc != null && loc.StreetAddress != null)
	    Console.WriteLine("country: " + loc.StreetAddress.Country);
    }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13 (permalink)  
Old 12-21-2006
Junior Member
White Belt
 
Join Date: Dec 2006
Posts: 11
Re: C#: MapPoint 2004 - Check Regions

Thank you, Wilfried. I will try this ASAP. Actually it is the region name (State, for US) I am seeking, not the country name, but I will pursue this approach. Ideally, it would be great to be able to request a specific Location Type, eg. geoShowByRegion1 to get the US State name.

Would this work if the lat,long. is not near any street? I will be performing these calls using computed lat,long coordinates as part of a search to find the nearest region (State) boundary along a given path, by stepping along the path until the State name changes. (Unless there is an easier way to locate the distance to the border in a given direction.)

Last edited by kaborka; 12-21-2006 at 02:14 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14 (permalink)  
Old 12-21-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C#: MapPoint 2004 - Check Regions

Hi,

There is a Region property too. So if a US State is the same as a Region (in my language a State is not a region but more like a Country) then you probably can yous that property. Please feedback about this

As for you other question you go high altitude. 10 Miles or so even a little higher then you will have always StreetAddresses (with a larger delusion of precision) (you should always check for null value, if it is null ho higher).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15 (permalink)  
Old 12-21-2006
Junior Member
White Belt
 
Join Date: Dec 2006
Posts: 11
Re: C#: MapPoint 2004 - Check Regions

Alas, I could not get this solution to work. I set MP.Units = 0 (miles) and called GetLocation(33, -118, 10) to obtain a point over Los Angeles, CA. None of the objects returned by FindResults had a nonempty Region value. It found a couple of highways (I-5 and US-395) and an object with Name = North America. It also returned an object with Name "San Diego", but its StreetAdress was null. I tried a lower altitude (1 mi), but that did not help.

Any suggestions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16 (permalink)  
Old 12-22-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C#: MapPoint 2004 - Check Regions

Hi,

and when StreetAddress is not null, then still both Region and Country are null ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17 (permalink)  
Old 12-22-2006
Junior Member
White Belt
 
Join Date: Dec 2006
Posts: 11
Re: C#: MapPoint 2004 - Check Regions

When StreeetAddress was not null, the Region property contained an empty string. I did not check the Country property. I'll do so when I get to work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18 (permalink)  
Old 12-22-2006
Junior Member
White Belt
 
Join Date: Dec 2006
Posts: 11
Re: C#: MapPoint 2004 - Check Regions

I found the problem. The approach does work. It turns out that my choice of coordinates was wrong. I rounded the coordinates of Los Angeles incorrectly. 33N,118W is in fact over the ocean! MP was unable to find any useful objects. When I used 34N,118W and confirmed by loc.Goto() this was in fact over the city, the algorithm worked perfectly.

I also checked to see what it returned when the loc was not in a city. I tried 34N,110W and saw this was over the desert in Arizona. Although MP found no location object with a nonnull StreetAddress, it did return a Location of Type geoShowByRegion1, whose Name property was "Arizona". It would seem I can alternatively determine the State by looking for a geoShowByRegion1 Location with a valid US State name.

I will now investigate the possibility of finding a more efficient means of locating the State boundary crossings along a great circle route, which is the actual problem at hand. At least it seems this iterative solution will work if I choose test locations along the route.

Thank you very much for your help with this!

Last edited by kaborka; 12-22-2006 at 02:24 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19 (permalink)  
Old 12-23-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C#: MapPoint 2004 - Check Regions

Hi,

Thank you for feedback. To check out I did some experiments, and it seems that the Location objects in the collection are included geoShowByRegion1, geoShowByRegion2, geoShowByCountry, geoShowByDefault ever, if I'm on a street, city, or not.

So I think in your case it is enough to check the type on geoShowByRegion1 and check the Name property.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #20 (permalink)  
Old 12-23-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C#: MapPoint 2004 - Check Regions

Hi,

Maybe this thread is also interesting for you:
MapPoint Functionality
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
check, mappoint 2004, regions


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/c-mappoint-2004-check-regions-5467.html

Posted By For Type Date
MapPoint Articles - MP2K Magazine This thread Refback 12-16-2006 02:16 AM
Wisconsin Map and Map of Wisconsin - MapPoint State Map Gallery - MP2K Magazine This thread Refback 12-14-2006 07:59 AM
The Magazine for MapPoint - MP2K Magazine This thread Refback 12-12-2006 05:37 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Check out if GPS pos is on a Route kristijan MapPoint 2006/2009 Discussion 11 04-19-2006 11:46 AM
How do I check to see if there is mappoint installed on a sy dew1969 MapPoint 2006/2009 Discussion 3 02-18-2004 11:05 AM
Territories, regions help please norty303 MapPoint 2006/2009 Discussion 0 11-14-2003 10:56 AM
Territories - Regions - Reps and other great ideas. Anonymous Wish List 0 03-21-2003 01:43 PM
MapPoint 2002 Retrieve all regions of a country VB6 Wim MapPoint 2006/2009 Discussion 0 11-15-2002 10:45 AM


All times are GMT -5. The time now is 08:15 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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