Why GM_FindFeaturesInArea Is of the result mistake the value?.

gugupogugupo Global Mapper UserPosts: 24Trusted User
edited November 2012 in SDK
Hi Mike.

GM_FindFeaturesInArea to use.

1. GlobalMapper Test.

Image10.jpg

Load to las file and dxf file.

Menu is 'Select All Point Features within the Selected Area(s)' to use.

Image11.jpg

GlobalMapper is Result.

2. GlobalMapper SDK Test.

Image16.jpg

Load to las file and dxf file.

Mouse RButton Click. GM_FindFeaturesInArea to use get, point infomation.

But, get point result is mistake?

Image12.jpg

Comments

  • gugupogugupo Global Mapper User Posts: 24Trusted User
    edited November 2012
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited November 2012
    How are you determining which points are selected in the SDK? I'm wondering if there is just an indexing problem or something and different points are being found than you think are being found.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • gugupogugupo Global Mapper User Posts: 24Trusted User
    edited November 2012
    Thanks, Mike.

    Use the GlobalMapperSDK version14, Search to result.

    Image13.jpgImage14.jpgImage15.jpg

    GlobalMapperSDK source code add.
    //===================================================================
    //
    // METHOD:
    // CGMDLL_TesterDlg::OnRButtonUp
    //
    // DESCRIPTION:
    // Called when the right mouse button is released. If the button
    // was clicked in the map area, a nearest search is performed to
    // find the nearest vector feature to the click location and
    // information about that feature is displayed.
    //
    //===================================================================
    void
    CGMDLL_TesterDlg::OnRButtonUp
    (
    UINT nFlags,
    CPoint point
    )
    {
    // If the point was in the map window, recenter on the point
    if ( ::PtInRect( &mMapWindow.GetDrawWndRect(), point ) )
    {
    // Find the nearest feature
    GM_MapWindow::FoundFeatureList_t theFindResults =
    mMapWindow.FindNearestFeatures( point, 20 );
    // Display the results
    if ( !theFindResults.empty() )
    {
    // Display information about the feature based on what type
    // it is.
    if ( GM_FeatureClass_Area == theFindResults.front().mFeatureClassType )
    {
    // Get the area feature
    GM_AreaFeature_t* theArea = GM_GetAreaFeature
    (
    theFindResults.front().mLayer, theFindResults.front().mFeatureIndex
    );
    if ( NULL == theArea )
    {
    ::AfxMessageBox( _T("Unable to get info for nearest area.") );
    }
    else
    {
    // Display an info dialog
    DisplayVectorFeatureInfo
    (
    theFindResults.front().mFeatureClassType, theArea->mFeatureInfo
    );
    // Test finding all points that are in the area
    GM_MapWindow::FoundFeatureList_t thePointsInArea = mMapWindow.FindFeaturesInArea
    (
    *theArea, theFindResults.front().mLayer, GM_FindFlags_FindPoints
    );
    if ( !thePointsInArea.empty() )
    {
    // Report how many points are in the area
    CString theStr;
    theStr.Format( _T("Found %u points in the area feature."), thePointsInArea.size() );
    ::AfxMessageBox( theStr );
    //add by code
    for ( int i = 0; i < thePointsInArea.size(); i++ )
    {
    GM_PointFeature_t* thePointFeature = GM_GetPointFeature
    (
    thePointsInArea.mLayer, i
    );

    double XX = thePointFeature->mPos.mX;
    double YY = thePointFeature->mPos.mY;

    for ( int j = 0; j < thePointFeature->mFeatureInfo.mNumAttrs; j++ )
    {
    CString Name = thePointFeature->mFeatureInfo.mAttrList[j].mName;
    CString Val = thePointFeature->mFeatureInfo.mAttrList[j].mVal;

    if ( Name.Compare( "ELEVATION" ) == 0 )
    {
    CString Temp = _T("X = ") + ToString( XX ) + _T(", Y = ") + ToString( YY ) + _T(", ELEVATION = ") + Val;
    AfxMessageBox( Temp );
    break;
    }


    }

    }
    //]
    }
    // Free the area feature
    GM_FreeAreaFeature( theArea );
    theArea = NULL;
    }
    }
    else if ( GM_FeatureClass_Line == theFindResults.front().mFeatureClassType )
    {
    // Get the line feature
    GM_LineFeature_t* theLine = GM_GetLineFeature
    (
    theFindResults.front().mLayer, theFindResults.front().mFeatureIndex
    );
    if ( NULL == theLine )
    {
    ::AfxMessageBox( _T("Unable to get info for nearest line.") );
    }
    else
    {
    // Display an info dialog
    DisplayVectorFeatureInfo
    (
    theFindResults.front().mFeatureClassType, theLine->mFeatureInfo
    );
    // Free the line feature
    GM_FreeLineFeature( theLine );
    theLine = NULL;
    }
    }
    else if ( GM_FeatureClass_Point == theFindResults.front().mFeatureClassType )
    {
    // Get the point feature
    GM_PointFeature_t* thePoint = GM_GetPointFeature
    (
    theFindResults.front().mLayer, theFindResults.front().mFeatureIndex
    );
    if ( NULL == thePoint )
    {
    ::AfxMessageBox( _T("Unable to get info for nearest point.") );
    }
    else
    {
    // Display an info dialog
    DisplayVectorFeatureInfo
    (
    theFindResults.front().mFeatureClassType, thePoint->mFeatureInfo
    );
    // Free the point feature
    GM_FreePointFeature( thePoint );
    thePoint = NULL;
    }
    }
    }
    else
    {
    ::AfxMessageBox( _T("No features found near the click location.") );
    }
    }
    // Call the base class implementation
    CDialog::OnRButtonUp( nFlags, point );
    } // end of function CGMDLL_TesterDlg::OnRButtonUp


    /////////////////////////////////////////////////
    I'm want to result.

    193593.904, 339166.502, 168.86
    193593.554, 339166.972, 168.88
    193594.147, 339167.392, 169.24
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited November 2012
    Your code is incorrect. Your call to GM_GetPointFeature should be as follows:

    GM_PointFeature_t* thePointFeature = GM_GetPointFeature
    (
    thePointsInArea.mLayer, thePointsInArea.mFeatureIndex
    );

    Before you just had 'i' for the second parameter which was your loop index and not the feature index in the layer.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • gugupogugupo Global Mapper User Posts: 24Trusted User
    edited November 2012
    Thanks,

    Mike.
Sign In or Register to comment.