QueryPolygon Results Question

dfriebus
01-10-2008, 10:58 AM
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?

Thanks.

Eric Frost
01-10-2008, 01:04 PM
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?

Eric

Paul Larson
01-15-2008, 08:45 AM
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.

HTH
-Paul

 
Web mp2kmag.com
mapforums.com