![Yoctopuce Yocto-GPS User Manual Download Page 87](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557087.webp)
get_latitude
The
get_latitude()
method of the object returned by
YGps.FindGps
provides the latitude
currently measured by the Yocto-GPS. The value returned is a string, the format will vary according
to the Yocto-GPS configuration. To get a floating point value, no matter the configuartion, use the
YLatitude Class.
A real example
Launch Microsoft Visual C# and open the corresponding sample project provided in the directory
Examples/Doc-GettingStarted-Yocto-GPS
of the Yoctopuce library.
In this example, you will recognize the functions explained above, but this time used with all side
materials needed to make it work nicely as a small demo.
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
ConsoleApplication1
{
class
Program
{
static
void
usage
()
{
string
execname =
System
.
AppDomain
.
CurrentDomain
.
FriendlyName
;
Console
.
WriteLine
(
"Usage:"
)
;
Console
.
WriteLine
(
ex
" <serial_number>"
)
;
Console
.
WriteLine
(
ex
" <logical_name>"
)
;
Console
.
WriteLine
(
ex
" any "
)
;
System.
Threading
.
Thread
.
Sleep
(
2500
)
;
Environment
.
Exit
(
0
)
;
}
static
void
Main
(
string
[]
args
)
{
string
errmsg =
""
;
string
target;
YGps gps;
if
(
args.
Length
<
1
)
usage
()
;
target = args
[
0
]
.
ToUpper
()
;
// Setup the API to use local USB devices
if
(
YAPI.
RegisterHub
(
"usb"
,
ref
errmsg
)
!= YAPI.
SUCCESS
)
{
Console
.
WriteLine
(
"RegisterHub error: "
+ errmsg
)
;
Environment
.
Exit
(
0
)
;
}
if
(
target ==
"ANY"
)
{
gps = YGps.
FirstGps
()
;
if
(
gps ==
null
)
{
Console
.
WriteLine
(
"No module connected (check USB cable) "
)
;
Environment
.
Exit
(
0
)
;
}
}
else
{
gps = YGps.
FindGps
(
".temperature"
)
;
}
if
(
!gps.
isOnline
())
{
Console
.
WriteLine
(
"Module not connected (check identification and USB cable)"
)
;
Environment
.
Exit
(
0
)
;
}
while
(
gps.
isOnline
())
{
if
(
gps.
get_isFixed
()
!= YGps.
ISFIXED_TRUE
)
Console
.
WriteLine
(
"fixing... "
)
;
else
Console
.
WriteLine
(
gps.
get_latitude
()
+
" "
+ gps.
get_longitude
())
;
Console
.
WriteLine
(
" (press Ctrl-C to exit)"
)
;
YAPI.
Sleep
(
1000
,
ref
errmsg
)
;
}
12. Using Yocto-GPS with C#
www.yoctopuce.com
81
Summary of Contents for Yocto-GPS
Page 1: ...Yocto GPS User s guide...
Page 2: ......
Page 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Page 10: ...4 www yoctopuce com...
Page 14: ...8 www yoctopuce com...
Page 18: ...12 www yoctopuce com...
Page 22: ...16 www yoctopuce com...
Page 38: ...32 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 54: ...48 www yoctopuce com...
Page 72: ...66 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 122: ...116 www yoctopuce com...
Page 132: ...126 www yoctopuce com...
Page 564: ...22 Characteristics 558 www yoctopuce com...
Page 565: ......
Page 566: ......