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

QueryPolygon Results Question

This is a discussion on QueryPolygon Results Question within the Development forums, part of the MapPoint Desktop Discussion category; I am relatively new to MapPoint. I am coding a Windows Forms app (VB.NET 2005) using the OCX that ships ...

  1. #1
    dfriebus is offline Junior Member White Belt
    Join Date
    Dec 2007

    Question QueryPolygon Results Question

    I am relatively new to MapPoint. I am coding a Windows Forms app (VB.NET 2005) using the OCX that ships with MapPoint 2006. In this app, I am using the QueryPolygon method to select all the pushpins that are in the currently visible area of the map control. The code:

    locations(0) = objMap.XYToLocation(0, 0)
    locations(1) = objMap.XYToLocation(objMap.Width, 0)
    locations(2) = objMap.XYToLocation(objMap.Width, objMap.Height)
    locations(3) = objMap.XYToLocation(0, objMap.Height)
    locations(4) = objMap.XYToLocation(0, 0)
    Dim objDataSet As MapPoint.DataSet = objMap.DataSets(1)
    objSelectedPushpins = objDataSet.QueryPolygon(locations)

    I'm finding that when I have pushpins near the edges of the map, some of the pushpins at the top of the map are not always being selected while some pushpins just below the visible portion of the map are being selected. This seems to most prevalent when I'm zoomed out.

    My theory is that while I'm feeding the QueryPolygon method coordinates of a perfect rectangle, that rectangle needs to be applied to a spherical object in the background (i.e. the Earth) before the data can be queried. The rectangle is distorted by the curvature of the Earth. This causes a visual discrepancy between what you think should be selected and what actually gets selected.

    Am I making any sense at all? If so, does anyone know if my theory is correct? Does QueryPolygon take the curvature of the Earth into consideration and might that account for what I'm seeing? Or do I just have a bug?


  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Blog Entries

    Re: QueryPolygon Results Question

    I'm sure your theory is correct, but I don't have any recommendation. You must be looking at pretty large areas?

    Can you give an example of the exact coordinates?

    Have you drawn the polygon on the map to see what it looks like?

    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    Paul Larson is offline Senior Member Green Belt
    Join Date
    Sep 2005
    Battle Creek, Michigan

    Red face Re: QueryPolygon Results Question

    I've come across this issue as well. Your theory is correct.
    The rectangle is computed and rendered in flat-space, when it should be rendered as a trapezoid with curved east-west sides.

    The only solution I came up with at the time was to expand the rectangle into a hexagon with the east-west points expanded outward according to the current zoom level. I wound up breaking/expanding the east-west points at one-third north of the lesser absolute latitude. (south of the equator, you'd use one-third south)

    This does still incorporate some error, particularly at the east-west points, but it is far less than the flat-space rectangle.


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. QueryPolygon Error
    By dfriebus in forum Development
    Replies: 2
    Last Post: 12-31-2007, 07:51 AM
  2. Two results for one address :-(
    By alex_kuechler in forum MapPoint Desktop Discussion
    Replies: 8
    Last Post: 03-08-2007, 04:24 AM
  3. GPS Coordinates Results
    By tommyf in forum MapPoint Desktop Discussion
    Replies: 10
    Last Post: 02-14-2007, 03:02 AM
  4. FindAddress Results in c#
    By starbuck in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-21-2004, 05:00 PM
  5. help - new user, no results
    By Anonymous in forum Products: Pushpin Tool, Single State Mapper
    Replies: 1
    Last Post: 07-29-2003, 10:56 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 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96