sandermvanvliet / RoadCaptain

Build and ride custom routes in Zwift
Other
84 stars 4 forks source link

Creating python xyToLatLong using constants from MapCoordinate.cs #110

Closed stuartlynne closed 1 year ago

stuartlynne commented 2 years ago

I have created a small Python function to map the Zwift API x,y points to latitude, and longitude using the constants and algorithm from thMapCoordinate.cs.

I would like permission to release this as a GitHub archive and PyPI module.

Thanks! stuart.lynne@gmail.com

`
Worlds = { 1: ( -128809769.40541935, 9.040388931996475E-06, 1824587167.6433601, 9.15017561017031E-06), # Watopia 2: ( 416681564.4970093, 9.0099976736186E-06, -684350551.7311095, 1.1315458228533332E-05), # Richmond 3: ( 572999216.4279556, 8.988093472576876E-06, -1165514.8567129374, 1.4409163767062611E-05), # London 4: ( 451904755.49697876, 9.021199819576003E-06, -624888323.3413696, 1.1838382403428395E-05), # New York 5: ( 525815359.3559265, 8.990380293086398E-06, 85498815.16199112, 1.3328535060711476E-05), # Innsbruck 6: ( 494915327.2666931, 8.990380293086398E-06, 89998398.77214432, 1.2603824000201662E-05), # Bologna 7: ( 600543305.7785034, 8.990380293086398E-06, -10081972.491562366, 1.529215665285275E-05), # Yorkshire 8: ( -114866743.52011015, 9.040388931996475E-06, 1811999121.6374512, 9.15017561017031E-06), # Crit City 9: ( -118908671.79471876, 9.040388931996475E-06, 1812385336.6892092, 9.15017561017031E-06), # Makuri Islands 10: ( -240220877.27394104, 9.031302494445749E-06, 1719827819.2077637, 9.663609744784066E-06), # France 11: ( 543554648.5443115, 8.990380293086398E-06, 16931795.4672575, 1.366736370221548E-05), # Paris }

def xyToLatLong(courseId, x, y):
    world = ZwiftXY.Worlds[ZwiftXY.course2world[courseId]]
    latitude = (x + world[0]) * world[1] * 0.01
    longitude = (y + world[2]) * world[3] * 0.01
    return round(latitude, 7), round(longitude, 7)

`

sandermvanvliet commented 2 years ago

@stuartlynne I’ve gotten these from nebulous sources so you don’t need my permission to release this πŸ˜‰

appreciate the heads up though πŸ‘ Happy that my work is useful to someone πŸ™‚

stuartlynne commented 2 years ago

Thanks!

I'm hoping that it can get used in Sauce4Zwift as well. Which you might be able to get data from for RoadCaptain now that packet capture is not possible.

On Fri, Nov 18, 2022 at 10:27 AM Sander van Vliet @.***> wrote:

@stuartlynne https://github.com/stuartlynne I’ve gotten these from nebulous sources so you don’t need my permission to release this πŸ˜‰

appreciate the heads up though πŸ‘ Happy that my work is useful to someone πŸ™‚

β€” Reply to this email directly, view it on GitHub https://github.com/sandermvanvliet/RoadCaptain/issues/110#issuecomment-1320383948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIUWINS2F3LBE2DFFEAR3WI7DABANCNFSM6AAAAAASD5GC44 . You are receiving this because you were mentioned.Message ID: @.***>

-- __O____ -\<,____ ____()/()___


@.***>__604-518-1749(m)604-461-7532(h)

sandermvanvliet commented 2 years ago

Hm, maybe I could do something with a Zwift -> RoadCaptain -> old-style UDP bridge πŸ€”

stuartlynne commented 2 years ago

Sauce4Zwift uses a Zwift login (second free account usually). It then has full access to all the data we used to get through packet capture.

The primary use case is typically just putting up various gauges etc to show interesting things.

But it also has a built-in web server that you can use to create a WebSocket and get a feed of the event data. Which has a lot of interesting data and updates once per second.

In this case X, and Y points.

I'm writing a Windows dashboard (www.fitnesshrv.com) that captures as many ANT+ or BLE sensors as possible (Power, HRM, FEC, MO2, VO2) and records everything to a FIT file. Effectively solving the dual-recording issues. You get your power meter (plural if available) and your trainer.

If Sauce4Zwift is available I connect to it to get their view of power, cadence, speed and more interestingly location and world information, and laps. I can then merge that in and have a FIT file with everything you would get from Zwift, as well as the additional sensors, etc, etc.

On Fri, Nov 18, 2022 at 12:10 PM Sander van Vliet @.***> wrote:

Hm, maybe I could do something with a Zwift -> RoadCaptain -> old-style UDP bridge πŸ€”

β€” Reply to this email directly, view it on GitHub https://github.com/sandermvanvliet/RoadCaptain/issues/110#issuecomment-1320476314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIUWOKBMAUDWS2FZ4RXODWI7PEPANCNFSM6AAAAAASD5GC44 . You are receiving this because you were mentioned.Message ID: @.***>

-- __O____ -\<,____ ____()/()___


@.***>__604-518-1749(m)604-461-7532(h)