Skip to content

Commit 2f4b190

Browse files
committed
switch to openstreetmap and implement teleport
1 parent 84f5d13 commit 2f4b190

File tree

10 files changed

+709
-73
lines changed

10 files changed

+709
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ program zips are uploaded [here](https://github.com/lian/msfs2020-go/releases)
1414

1515
## tools
1616

17-
* [vfrmap](vfrmap/) web server that shows your current MSFS2020 plane position in google maps inside the browser
17+
* [vfrmap](vfrmap/) local web-server that will allow you to view your location, and some information about your trajectory including airspeed and altitude.
1818

1919
## examples
2020

build-vfrmap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
go generate github.com/lian/msfs2020-go/simconnect
55
go generate github.com/lian/msfs2020-go/vfrmap
6+
go generate github.com/lian/msfs2020-go/vfrmap/html/leafletjs
67

78
build_time=$(date -u +'%Y-%m-%d_%T')
89
set +e

simconnect/defs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const E_FAIL uint32 = 0x80004005
99
type DWORD uint32
1010

1111
const UNUSED DWORD = 0xffffffff // special value to indicate unused event, ID
12+
const OBJECT_ID_USER DWORD = 0 // proxy value for User vehicle ObjectID
1213

1314
const (
1415
DATATYPE_INVALID DWORD = iota // invalid data type

simconnect/simconnect.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var proc_SimConnect_AddToDataDefinition *syscall.LazyProc
2121
var proc_SimConnect_SubscribeToSystemEvent *syscall.LazyProc
2222
var proc_SimConnect_GetNextDispatch *syscall.LazyProc
2323
var proc_SimConnect_RequestDataOnSimObjectType *syscall.LazyProc
24+
var proc_SimConnect_SetDataOnSimObject *syscall.LazyProc
2425

2526
type SimConnect struct {
2627
handle unsafe.Pointer
@@ -58,6 +59,7 @@ func New(name string) (*SimConnect, error) {
5859
proc_SimConnect_SubscribeToSystemEvent = mod.NewProc("SimConnect_SubscribeToSystemEvent")
5960
proc_SimConnect_GetNextDispatch = mod.NewProc("SimConnect_GetNextDispatch")
6061
proc_SimConnect_RequestDataOnSimObjectType = mod.NewProc("SimConnect_RequestDataOnSimObjectType")
62+
proc_SimConnect_SetDataOnSimObject = mod.NewProc("SimConnect_SetDataOnSimObject")
6163
}
6264

6365
// SimConnect_Open(
@@ -227,6 +229,39 @@ func (s *SimConnect) RequestDataOnSimObjectType(requestID, defineID, radius, sim
227229
return nil
228230
}
229231

232+
func (s *SimConnect) SetDataOnSimObject(defineID, simobjectType, flags, arrayCount, size DWORD, buf unsafe.Pointer) error {
233+
//s.SetDataOnSimObject(defineID, simconnect.OBJECT_ID_USER, 0, 0, size, buf)
234+
235+
// SimConnect_SetDataOnSimObject(
236+
// HANDLE hSimConnect,
237+
// SIMCONNECT_DATA_DEFINITION_ID DefineID,
238+
// SIMCONNECT_OBJECT_ID ObjectID,
239+
// SIMCONNECT_DATA_SET_FLAG Flags,
240+
// DWORD ArrayCount,
241+
// DWORD cbUnitSize,
242+
// void * pDataSet
243+
// );
244+
args := []uintptr{
245+
uintptr(s.handle),
246+
uintptr(defineID),
247+
uintptr(simobjectType),
248+
uintptr(flags),
249+
uintptr(arrayCount),
250+
uintptr(size),
251+
uintptr(buf),
252+
}
253+
254+
r1, _, err := proc_SimConnect_SetDataOnSimObject.Call(args...)
255+
if int32(r1) < 0 {
256+
return fmt.Errorf(
257+
"SimConnect_SetDataOnSimObject for defineID %d error: %d %s",
258+
defineID, r1, err,
259+
)
260+
}
261+
262+
return nil
263+
}
264+
230265
func (s *SimConnect) GetNextDispatch() (unsafe.Pointer, int32, error) {
231266
var ppData unsafe.Pointer
232267
var ppDataLength DWORD

vfrmap/README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# msfs2020-go/vfrmap
22

3-
web server that shows your current MSFS2020 plane position in google maps inside the browser
3+
local web-server using msfs2020-go/simconnect that will allow you to view your location, and some information about your trajectory including airspeed and altitude.
4+
5+
also allows you to quickly teleport your plane to any location.
46

57
## install
68

@@ -10,21 +12,33 @@ web server that shows your current MSFS2020 plane position in google maps inside
1012
## run
1113
* run `vfrmap.exe`
1214
* browse to http://localhost:9000
15+
* or to `http://<computer-ip>:9000`
1316

1417
## arguments
1518

1619
* `-v` show program version
17-
* `-api-key` use your own gmap api-key
1820
* `-verbose` verbose output
1921

22+
## usage
23+
24+
click on your plane to see gps coordinates, follow or don't follow the plane, or open the current location on google maps in a new tab.
25+
26+
if you click on the map itself a new marker appears. clicking on that marker allows you to teleport to this location or enter your own gps coordinates.
27+
28+
esc key switching between following the plane or freely moving around on the map.
29+
2030
## change visualisation
2131

2232
if you want to change how the webpage looks then copy and change [index.html](html/index.html) to the same folder as `vfrmap.exe` and relaunch the program.
2333

34+
## openstreetmap
35+
36+
earlier versions of this app used google maps directly, but this was to expensive. openstreetmap is free to use and very good as well.
37+
2438
## compile
2539

2640
`GOOS=windows GOARCH=amd64 go build github.com/lian/msfs2020-go/vfrmap` or see [build-vfrmap.sh](https://github.com/lian/msfs2020-go/blob/master/build-vfrmap.sh)
2741

2842
## screenshots
2943

30-
![screenshot](https://i.imgur.com/YllMEvG.png)
44+
![screenshot](https://i.imgur.com/5PZyKC8.png)

vfrmap/bindata.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)