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
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

C#: MapPoint 2004 - Check Regions

This is a discussion on C#: MapPoint 2004 - Check Regions within the MapPoint Desktop 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 ...

  1. #11
    kaborka is offline 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.

  2. #12
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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);
        }

  3. #13
    kaborka is offline 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.

  4. #14
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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).

  5. #15
    kaborka is offline 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?

  6. #16
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: C#: MapPoint 2004 - Check Regions

    Hi,

    and when StreetAddress is not null, then still both Region and Country are null ?

  7. #17
    kaborka is offline 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.

  8. #18
    kaborka is offline 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.

  9. #19
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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.

  10. #20
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: C#: MapPoint 2004 - Check Regions

    Hi,

    Maybe this thread is also interesting for you:
    MapPoint Functionality

Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

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

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 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 55 56 57 58 59 60 61 62 63 64 65 66