Manual Push NMEA Position¶
In this guide you will learn how to set or push
one individual NMEA
position, or sentence
, at a time,
interactively / manually, to gain a good understanding
of how navigation and simulation work at a low level.
Please see the Positioning Example
for the
recommended way to feed positions to the engine.
NMEA text sentence position¶
First, get an API key token, see the Getting Started guide.
Qt should be installed to continue.The Maps SDK for Qt should be installed, see the Setup Maps SDK for Qt guide.
Overview¶
ManualPushPosition
demonstrates how easy it is to push one NMEA
sentence (position) at a time to the engine, to set the live position tracker there.
How it works
In Qt, go to the File menu and select Open File or Project…
then browse to the ManualPushPosition example folder and open ManualPushPosition.pro
You may want to have a look at Setting your API Key to see how to open and configure a project and set your API Key.
In main.qml, in the Component.onCompleted:
block, the datasource is
set to live, and the first NMEA sentence (a line of text in one of the NMEA protocols)
is pushed, so that the example starts at the first position in the NMEA set.
1ServicesManager.dataSource.type = DataSource.Type.Live;
2ServicesManager.dataSource.pushNMEASentence(myCycleCounter.nmeaSentence);
The NMEA sentences, or positions, one per line of text, used in this example
are in the cyclecounter.h
header file for simplicity.
They could also be in a text file on disk, or received from the network,
this makes no difference.
Also the content type that will be downloaded upon demand is specified:
let updater = ServicesManager.contentUpdater(ContentItem.Type.RoadMap);
The MapView
displaying the interactive map has 2 text lines at the top.
The top line shows the frames per second, and the second line shows the
longitude and latitude of the current position, in degrees.
The red button at the bottom shows the NMEA sentence
number (zero based index),
followed by the actual NMEA sentence itself (green button), corresponding to the
current position.
Click the blue button to push the next NMEA sentence.
1MapView {
2 id: mapView
3 anchors.fill: parent
4 viewAngle: 25
5 zoomLevel: 69
6 viewPerspective: MapView.ViewPerspective.View3D
7 buildingsVisibility: MapView.BuildingsVisibility.Show3D
8 detailsQualityLevel: MapView.DetailsQualityLevel.Medium
9 gestures: MapView.Gesture.Pan
10 | MapView.Gesture.PanEnableVelocity
11 | MapView.Gesture.Pinch
12 | MapView.Gesture.Rotate
13 | MapView.Gesture.Tilt
14 ColumnLayout {
15 anchors.left: parent.left
16 anchors.top: parent.top
17 Text {
18 text: "FPS: " + fpsCounter.fps
19 }
20 Text {
21 id: mycoord
22 }
23 }
24 RowLayout {
25 anchors.left: parent.left
26 anchors.bottom: parent.bottom
27 Button {
28 id: sequenceNumber
29 text: myCycleCounter.countCycle + " "
30 background: Rectangle {
31 opacity: parent.hovered ? 1 : 0.5
32 color: (parent.hovered ? "#ff0000" : "#ff0000")
33 }
34 palette { buttonText: "#ffffff"; }
35 }
36 Button {
37 id: nmeaSentence
38 text: myCycleCounter.nmeaSentence + " "
39 background: Rectangle {
40 opacity: parent.hovered ? 1 : 0.5
41 color: (parent.hovered ? "#008000" : "#008000")
42 }
43 palette { buttonText: "#ffffff"; }
44 }
45 Button {
46 id: cycleButton
47 text: "Click for next position"
48 background: Rectangle {
49 opacity: parent.hovered ? 1 : 0.5
50 color: enabled ? parent.down ? "#aa00aa" :
51 (parent.hovered ? "#0000ff" : "#2000ff") : "#aaaaaa"
52 }
53 palette { buttonText: "#ffffff"; }
54 onClicked: {
55 let coordinates = mapView.wgsForScreen((mapView.width / 2), (mapView.height / 2));
56 mycoord.text = "Lon, Lat: " + coordinates.longitude + ", " + coordinates.latitude;
57 myCycleCounter.countCycle += 1;
58 console.log("Push NMEA sentence " + myCycleCounter.countCycle + ", " + myCycleCounter.nmeaSentence);
59 ServicesManager.dataSource.pushNMEASentence(myCycleCounter.nmeaSentence);
60 }
61 }
62 }
63}