《BREW進階與精通——3G移動增值業務的運營、定製與開發》連載之77——BREW中位置資訊的獲得(LBS應用)

abel_cao發表於2010-09-29

版權宣告:本文為半吊子子全棧工匠(wireless_com,同公眾號)原創文章,未經允許不得轉載。 https://blog.csdn.net/wireless_com/article/details/5914128

IPosDet介面可以直接獲得經緯度等相關資訊,應用將這些資訊傳遞給伺服器與GIS系統配合使用就可以開發出各種豐富多彩的應用了,IPosDet的使用示例如下:

// create the instance for PosDet

ISHELL_CreateInstance(pi->a.m_pIShell, AEECLSID_POSDET, (void **) &(pi->m_pPosDet));                                           

if(pi->m_pPosDet)        {

                // Initialize the Callback function

                CALLBACK_Init(&pi->SimpleGPSCB, simplegps_PosDetCB, pi);

                // You also can get seperate information through

                IPOSDET_GetGPSInfo(pi->m_pPosDet, AEEGPS_GETINFO_LOCATION|AEEGPS_GETINFO_VELOCITY|AEEGPS_GETINFO_ALTITUDE,AEEGPS_ACCURACY_LEVEL1, &pi->m_gpsInfo, &pi->SimpleGPSCB);

}

                return(TRUE);

Simplegps_PosDetCB函式將得到的位置資訊顯示的螢幕上以顯示緯度為例的程式碼如下

// wasFactor is the factor between AEEGPSInfo and real world data.

   STR_TO_WSTR(“186413.5111”,szNum,sizeof(szNum));

   wgsFactor= WSTR_TO_FLOAT(szNum);

   //Display Latitude on the screen

   val = IntegerToFloat(pMe->m_gpsInfo.dwLat);

   val = FDIV(val, wgsFactor);

   FLOATTOWSTR(val, szNum, TEXT_BUFFER_SIZE);

   STR_TO_WSTR(“Lat:”, szText, TEXT_BUFFER_SIZE);

   WSTRCAT(szText,szNum);

   // IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);

   IDISPLAY_DrawText(pMe->a.m_pIDisplay,    // Display instance

                  AEE_FONT_BOLD,       // Use BOLD font

                  szText,              // Text – Normally comes from resource

                  -1,                  // -1 = Use full string length

                  0,                   // Ignored – IDF_ALIGN_CENTER

                  32,                   // Ignored – IDF_ALIGN_MIDDLE

                  NULL,                // No clipping

                  IDF_ALIGN_CENTER);


相關文章