A quick one on GM_FindNearestFeatures

Osei
Osei Global Mapper UserTrusted User
edited August 2009 in SDK
I am using GM_FindNearestFeatures to get all features within a specified rectangle. If I just use aMaxDistPixels, the operation is very similar to drawing a circle with radius aMaxDistPixels then getting all features that lie in the circle. However, for a rectangle, this will not work as an encompassing circle may encompass other features that are in the circle but not in the rectangle.

I have been trying to use aPixelRect and a very large aMaxDisPixels hoping that the intersection between the rectangle and the large circle will be give me the desired result.

I have attached an image to explain further my predicament.

I would therefore be glad if you could spend a few seconds to show me how I can achieve the desired result with aWorldBounds and/or aPixelRect parameters as in ff function


GM_Error_t32 __stdcall GM_FindNearestFeatures
(
const GM_Point_t* aPixelSearchPt,
GM_LayerHandle_t32* aLayerList,
uint32 aLayerCount,
GM_FindFlags_t32 aFindFlags,
const GM_Rectangle_t* aWorldBounds,
const GM_PixelRect_t* aPixelRect,
GM_FoundFeature_t* aNearestFeatures,
uint32 aMaxFeatures,
uint32* aFoundFeatureCnt,
uint32 aMaxDistPixels
);

Thanks in advance for your time and effort.

Comments

  • global_mapper
    global_mapper Administrator
    edited August 2009
    If you pass in the flag GM_FindFlags_GetAllFeatures to the search along with a valid aWorldBounds parameter for your desired rectangle you should get back all features within that rectangle.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Osei
    Osei Global Mapper User Trusted User
    edited August 2009
    I have tried using the aWorldBounds. I initially used the Current Display World Bounds and now I convert the pixel rect to world rect and it still returns InValid_Param both with FindPoints and FindAll.
    It works perfectly if I set both WorldBounds and PixelRect to NULL. Howeve, this will return all features within a given distance from a point (like a circle), instead of getting those in a rectangle.
  • global_mapper
    global_mapper Administrator
    edited August 2009
    If you pass in NULL for the world and pixel bounds it should use the last drawn bounds. Are you passing in the additional flag described above to get all features?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Osei
    Osei Global Mapper User Trusted User
    edited August 2009
    After meditating on the GM_FindNearestFeatures function for some time, I found the solution to my problem. Instead of getting the selected pixel rect and putting it in the function, I rather convert to WorldBounds and use it but substitute NULL for pixelrect.

    Thanks for your time and effort