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
Results 1 to 3 of 3

how to calculate Lat/Longs for the corners of a rectangle?

This is a discussion on how to calculate Lat/Longs for the corners of a rectangle? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I am a newbie of MapPoint development. Here is what I want to do: After I create a rectangle ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    how to calculate Lat/Longs for the corners of a rectangle?

    Hi,

    I am a newbie of MapPoint development. Here is what I want to do:

    After I create a rectangle by using the drawing toolbar(geoAutoShape/geoShapeRectangle), I need to know the latitude/longitudes for its four corner. Is it possible to do it?

    I already have a method to get a pair of Lat/Long from a location object. Is it possible to calculate those four locations based on center location and width/length?

    I am using Microsoft C# to write my code.

    Thanks a lot.

    Linda Chen

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    How about if you just select an area with you mouse by holding the left button and draging (you know how it makes a box on the screen so you can zoom in)

    Here is a post I made long ago on how to get the four corners of that selected area.

    http://www.mp2kmag.com/mappoint/disc...pic.asp?t=3327

    Problem is a "geoShapeRectangle" does not have a Vertices property. There might be a way to do it but I'm drawing a blank right now? Sorry but I do not have a sample in C# I'm sure you are used to converting VB samples in C# right?

    Hope this helps you...

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

    I just needed something similar So I first experimented with your code in C# and drop it as whell here

    Code:
                MapPoint.SelectedArea sa = MP.ActiveMap.SelectedArea;
                Location[] loc = new Location[5];
    
                loc[0] = MP.ActiveMap.XYToLocation(sa.Left, sa.Top);
                loc[1] = MP.ActiveMap.XYToLocation(sa.Left + sa.Width, sa.Top);
                loc[2] = MP.ActiveMap.XYToLocation(sa.Left + sa.Width, sa.Top + sa.Height);
                loc[3] = MP.ActiveMap.XYToLocation(sa.Left, sa.Top + sa.Height);
                loc[4] = loc[0];
    
                //MP.ActiveMap.Shapes.AddPolyline(loc);
    
                int PPCount = 0;
                foreach (MapPoint.DataSet ds in MP.ActiveMap.DataSets) {
                    MapPoint.Recordset rs = ds.QueryPolygon(loc);
                    rs.MoveFirst();
                    while (!rs.EOF) {
                        PPCount++;
                        rs.MoveNext();
                    }
                }
                Console.WriteLine("Record count " + Convert.ToString(PPCount));

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Draw a route between two LONGS LATS
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-16-2005, 10:08 AM
  2. Finding Longs and Lats on mouse Move
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-22-2004, 04:12 AM
  3. Get all pushpins in a shape (Radius, Rectangle ...)
    By kobkob in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 04-18-2004, 05:44 AM
  4. Values of area in rectangle
    By Matrices in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-13-2003, 01:16 PM
  5. How do I draw a circle, rectangle, ellipse or free....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-26-2000, 01:35 PM

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