get gps on iphone

Previous topic - Next topic

djtoon

did anyone do it?

Kitty Hello

#1
Code (glbasic) Select


INLINE
}extern "C" {

#ifdef IPHONE

void iPhoneLocation_Init();
int iPhoneLocation_Enable(int enable);
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading);
void iPhoneKeepAwake(int bKeepAwake);

#else

void iPhoneLocation_Init() {}
int iPhoneLocation_Enable(int enable) {return 1;}
int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading)
{
*latitude=48.717417; *longitude=11.49882;
*altitude=512; *speed=0; *heading=0;

// ok go about 100km/h north
static double t1=GETTIMERALL();
double t = (GETTIMERALL() - t1)/1000. / 60.0 / 60.0; // hours

*latitude=48.717417 - 0.1 * t;

return 1;

}
void iPhoneKeepAwake(int bKeepAwake){}
#endif

} namespace __GLBASIC__{
ENDINLINE



code
INLINE
iPhoneLocation_Init();
if(!iPhoneLocation_Enable(TRUE))
{
ConsolePrt(CGStr("Failed to init location"));
return FALSE;
}
ENDINLINE

LOCAL lat, lon
LOCAL bGotGPS%=FALSE
INLINE
float latitude=0.0f, longitude=0.0f, altitude, speed, heading;
if(iPhoneLocation_Poll(&latitude, &longitude, &altitude, &speed, &heading))
{
lat = latitude;
lon = longitude;
bGotGPS=TRUE;
}
ENDINLINE


Like this, sort of...


The "heading" value should be what the compass returns if available. Otherwise it's extrapolated from the moving direction.

djtoon

im getting this weird error

"gpc_temp0.cpp:151: error: expected unqualified-id before "if"

???


Kitty Hello

uh-huh.

Can you open the file %Temp%\glbasic\gpc_temp0.cpp and see what line 151 is?

djtoon


/* ---- ENDINLINE ---- */

                                    #undef __GLBNO__
                                    #define __GLBNO__ 31
//NDIF.

                                    #undef __GLBNO__
                                    #define __GLBNO__ 32
return 0;
} // end main
// ------------------------ //
DGInt __end_main__foo__()
{
   __PPRegisterFunction
return 0;
}
void __GLB_Defaults(){
__DG_RESX=640;
__DG_RESY=480;
__DG_FULLSCREEN=0;
__DG_MULTISAMPLE=0;
__DG_FRAMERATE=60;
__DG_DEBUG=0;
__DG_WANTMOUSE=GLB_WANTMOUSE_AT_START;
__DG_SCHOOLVER=0;
__g_AppName= "gps";
}

#include "glblicence.inc"
} // namespace

Kitty Hello

See the attached file.
Code (glbasic) Select


// -------------------------------------------------------
// distance between 2 GPS points in [m]
// -------------------------------------------------------
FUNCTION GPS_dist: lat1, lon1, lat2, lon2
CONSTANT R  = 6371000
CONSTANT PI = 3.14159265358979323846264338327950288

LOCAL dLat, dLon, a,c,d
dLat = (lat2 - lat1)
dLon = (lon2 - lon1)
a = SIN(dLat / 2) * SIN(dLat / 2) + COS(lat1) * COS(lat2) * SIN(dLon / 2) * SIN(dLon / 2)

c = 2.0 * ATAN(SQR(a), SQR(1.0 - a))*PI/180.0
d = R * c
RETURN d
ENDFUNCTION



This might be handy as well.

[attachment deleted by admin]

djtoon

i got this trying to compile:
glbasic\gpc_temp0.cpp:124: error: expected unqualified-id before "return"
*** FATAL ERROR - Please post this output in the forum

here is the c code from that line :
                                    #undef __GLBNO__
                                    #define __GLBNO__ 39

                                    #undef __GLBNO__
                                    #define __GLBNO__ 40
//Get GPS data. return TRUE/FALSE whether it got data or not..

                                    #undef __GLBNO__
                                    #define __GLBNO__ 41

                                    #undef __GLBNO__
                                    #define __GLBNO__ 42
return 0;
} // end main
// ------------------------ //
DGNat iPhoneGPS(DGInt& lat, DGInt& lon, DGInt& alt, DGInt& spd, DGInt& head)
{
   __PPRegisterFunction

                                    #undef __GLBNO__
                                    #define __GLBNO__ 43

                                    #undef __GLBNO__
                                    #define __GLBNO__ 44

                                    #undef __GLBNO__
                                    #define __GLBNO__ 45

/* ---- INLINE ---- */

iPhoneLocation_Init();

if(!iPhoneLocation_Enable(TRUE))

djtoon

any progress on this kitty?\

Kitty Hello

what version are you using? The file I attached compiles fine for me.

djtoon


Marmor

#10
same error here   also 8.148 IDE

no explizit, iphone

/cygdrive/C/DOKUME~1/Besitzer/LOKALE~1/Temp/glbasic/gpc_temp0.cpp:124: error: expected unqualified-id before 'return'

Code (glbasic) Select

#include "gpc_temp.h"
void __GQuitNProfile()
{
   __PPExportProf("profile.csv", __DATE__, __TIME__);
}

namespace __GLBASIC__{
#define CODEFILE_Str() (DGStr("vfff.gbas.gbas"))
void __glb_init_globals();
int __MainGameSub_(void)
{   __PPRegisterFunction
    __glb_init_globals();
/* GBAS: Z:\glcode\GLBasic\vfff\vfff.gbas */

#undef __GLBNO__
#define __GLBNO__ 0
//--------------------------------- //.

#undef __GLBNO__
#define __GLBNO__ 1
//Project: SpyKit.

#undef __GLBNO__
#define __GLBNO__ 2
//Start: Wednesday, November 10, 2010.

#undef __GLBNO__
#define __GLBNO__ 3
//IDE Version: 8.148.

#undef __GLBNO__
#define __GLBNO__ 4

#undef __GLBNO__
#define __GLBNO__ 5

#undef __GLBNO__
#define __GLBNO__ 6

#undef __GLBNO__
#define __GLBNO__ 7

#undef __GLBNO__
#define __GLBNO__ 8

/* ---- INLINE ---- */

}extern "C" {



#ifdef IPHONE



void iPhoneLocation_Init();

int iPhoneLocation_Enable(int enable);

int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading);



#else



void iPhoneLocation_Init() {}

int iPhoneLocation_Enable(int enable) {return 1;}

int iPhoneLocation_Poll(float* latitude, float* longitude, float* altitude, float* speed, float* heading)

{

*latitude=48.717417;*longitude=11.49882;

*altitude=512;*speed=0;*heading=0;



//ok go about 100km/h north

static double t1=GETTIMERALL();

double t = (GETTIMERALL() - t1)/1000. / 60.0 / 60.0;//hours



*latitude=48.717417 - 0.1 * t;



return 1;



}

#endif



} namespace __GLBASIC__{


/* ---- ENDINLINE ---- */

#undef __GLBNO__
#define __GLBNO__ 38

#undef __GLBNO__
#define __GLBNO__ 39

#undef __GLBNO__
#define __GLBNO__ 40
//Get GPS data. return TRUE/FALSE whether it got data or not..

#undef __GLBNO__
#define __GLBNO__ 41

#undef __GLBNO__
#define __GLBNO__ 42
return 0;
} // end main
// ------------------------ //
DGNat iPhoneGPS(DGInt& lat, DGInt& lon, DGInt& alt, DGInt& spd, DGInt& head)
{
   __PPRegisterFunction

#undef __GLBNO__
#define __GLBNO__ 43

#undef __GLBNO__
#define __GLBNO__ 44

#undef __GLBNO__
#define __GLBNO__ 45

/* ---- INLINE ---- */

iPhoneLocation_Init();

if(!iPhoneLocation_Enable(TRUE))

{

return FALSE;

}


/* ---- ENDINLINE ---- */

#undef __GLBNO__
#define __GLBNO__ 51

#undef __GLBNO__
#define __GLBNO__ 52

#undef __GLBNO__
#define __GLBNO__ 53

/* ---- INLINE ---- */

float latitude=0.0f, longitude=0.0f, altitude, speed, heading;

if(iPhoneLocation_Poll(&latitude, &longitude, &altitude, &speed, &heading))

{

lat = latitude;

lon = longitude;

alt = altitude;

spd = speed;

head= heading;

return TRUE;

}


/* ---- ENDINLINE ---- */

#undef __GLBNO__
#define __GLBNO__ 64

#undef __GLBNO__
#define __GLBNO__ 65
return FALSE;

#undef __GLBNO__
#define __GLBNO__ 66
return 0;
}
// ------------------------ //
DGInt __end_main__foo__()
{
   __PPRegisterFunction

#undef __GLBNO__
#define __GLBNO__ 67
return 0;
}
void __GLB_Defaults(){
__DG_RESX=320;
__DG_RESY=480;
__DG_FULLSCREEN=1;
__DG_MULTISAMPLE=0;
__DG_FRAMERATE=60;
__DG_DEBUG=0;
__DG_WANTMOUSE=GLB_WANTMOUSE_AT_START;
__DG_SCHOOLVER=0;
__g_AppName= "vfff";
}

#include "glblicence.inc"
} // namespace


djtoon


Kitty Hello

DUUUUDE!! Make that the 2nd file of your project, no the main program.

Marmor

 :shit:  sry gernot

djtoon

ok it compiles but what now?


how do you use it?
i call iPhoneGPS();
what do i need for params ?
i seems like i need to give it my location isnt it the other way around?