Using SDK for non-display purpose

ExperimentorExperimentor Global Mapper UserPosts: 4
edited February 2012 in SDK
hi,

I'm interested in using the following query functions, but I do not need my data to be displayed


I managed to get GM_GetLocationElevation to work after my elevation data loaded but I'm not sure how to call GM_FindNearestFeatures without drawing anything. Would calling GM_DrawLayer before GM_FindNearestFeatures suffice? If so, do I need to specific a Device Context? Whats a Device Context (Apologies, not too familiar with windows GUI library)?

Please advise.

Thank you.
Exptor

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2012
    Exptor,

    You don't need to draw anything to get GM_FindNearestFeatures to work, just pass in actual bounding boxes of your area of interest and then just a fake "pixel" rectangle for the screen that your pixel search radius is referenced to. For example if you pass in a pixel rectangle of 100x100 pixels in size and a pixel search radius of 10, than amounts to finding anything within 1/10th of the size of your view bounds from the search point.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • ExperimentorExperimentor Global Mapper User Posts: 4
    edited February 2012
    Hi Mike,

    Sample data
    4 feature points(lat, lon):
    pt1 (1.000001, 100.000001)
    pt2 (1,100)
    bottomleft (0,95)
    topright (9,114)

    world bound
    minX = 99
    minY = 0
    maxX = 101
    maxY = 2

    "fake" pixel rect
    left = 0
    right = 2
    top = 0
    bottom = 2

    search point (1,1)

    GM_FindNearestFeatures (searchpt, shapelayer, 0, GM_FIndFlags_GetAllFeatures | GM_FindFlags_FindAll, world bound, pixel rect, results, 10, count, 1);

    Results:
    Found - pt1, pt2, bottomleft

    Thanks for your inputs, I tried the above but why does the function call return feature point "bottomleft" as well? Did I call the function wrongly?

    Thanks,
    Exptor
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2012
    Exptor,

    Hmmm with those values I would not expect the bottom left one to be coming in. Just to make sure we are looking at the same thing, can you first try getting the latest SDK build from http://www.globalmapper.com/GlobalMapperSDK_latest_beta.zip to see if you get the same results with that? If you do, can you provide your sample code that does this so I can take a look at that?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • ExperimentorExperimentor Global Mapper User Posts: 4
    edited February 2012
    Hi Mike,

    I have tried the version of SDK provided, the results were the same.
    Here's my test code.
    GM_LayerHandle_t32 theHandle = m_LayerLst[std::string(LayerName)];
    
    GM_Rectangle_t mCurrViewRect;
    mCurrViewRect.mMinX = 99;
    mCurrViewRect.mMinY = 0;
    mCurrViewRect.mMaxX = 101;
    mCurrViewRect.mMaxY = 2;
    
    GM_PixelRect_t theDrawRect;
    theDrawRect.mLeft = 0;
    theDrawRect.mRight = 1;
    theDrawRect.mTop = 0;
    theDrawRect.mBottom = 1;
    
    uint32 theMaxFeature = 10;
    GM_FoundFeature_t* theFoundFeature = new GM_FoundFeature_t [ theMaxFeature ];
    uint32 theFoundCnt = 0;
    
    GM_Point_t theSearchPt;
    theSearchPt.mx =0;
    theSearchPt.my =0;
    
    GM_Error_t32 theErr = GM_FindNearestFeatures (
    &theSearchPt, &theHandle, 1, GM_FindFlags_GetAllFeatures | GM_FindFlags_FindAll, 
    &mCurrViewRect, &theDrawRect, theFoundFeature, theMaxFeature, &theFoundCnt, 0);
    
    

    Thanks,
    Exptor
  • ExperimentorExperimentor Global Mapper User Posts: 4
    edited February 2012
    I noticed setting theDrawRect to 100 x 100 pixels works for this example.
    if the pixel size of theDrawRect affects the function results, what is the optimal value I should use to ensure that my solution will work for all scenarios?

    Thanks for the help,
    Exptor
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2012
    Exptor,

    Ah I think what might be happening is that when your pixel rectangle is so small the points are fetched even if their symbol would be in the specified bounds, so a symbol say just 10 pixels across on the screen becomes huge compared to your search rectangle and will cross into it for rendering even if several entire widths of the search box away. Try making your pixel size very large, like 10000x10000 or something, to minimize this effect. It would only affect points.

    Thanks,

    Mike
Sign In or Register to comment.