zekefarwell / josm-strava-heatmap

A browser extension that simplifies getting the TMS imagery url for using the Strava Heatmap in JOSM
MIT License
62 stars 3 forks source link

Not working in Caltopo as a Custom Layer #6

Closed zimmertr closed 2 years ago

zimmertr commented 2 years ago

First of all I apologize for filing this as an issue as it is likely your extension is working properly. I am just unable to find a different method to contact you. And if I were to ask on /r/strava or something people probably wouldn't have any idea what I'm talking about. This is a last resort sorta thing ;).

I've successfully generated a heatmap URL using both your extension as well as retrieving the cookies from my browser after signing into Strava as per the instructions here.

The resultant URL looks like this: tms[3,15]:https://heatmap-external-{switch:a,b,c}.strava.com/tiles-auth/all/hot/{zoom}/{X}/{Y}.png?Key-Pair-Id=REDACTED&Policy=REDACTED&Signature=REDACTED

In Caltopo, if I Add -> Custom Source and set the following options:

Type: TMS
URL Template: tms[3,15]:https://heatmap-external-{switch:a,b,c}.strava.com/tiles-auth/all/hot/{zoom}/{X}/{Y}.png?Key-Pair-Id=REDACTED&Policy=REDACTED&Signature=REDACTED
Max Zoom: 18
Overlay?: Yes

It returns "Template URL is invalid" when I click save. If I then update the URL and replace {switch:a,b,c} with a, b, or c, it will successfully save. However, when I enable the Custom Layer, no data is shown.

It works perfectly with OpenStreetMap. For example, if I use your extension to generate a URL and click Open in iD, a new tab opens and I can successfully see OpenStreetMap showing Strava Heatmap data as a Custom Background.

Do you know why this is? Is Strava's API rejecting the request from Caltopo for the data or something?

dericke commented 2 years ago

I was able to get it to work by doing the following:

  1. When using the extension, select the "no prefix" option. The tms[3,15]: bit is specific to JOSM, so you don't want anything in your URL before https://
  2. As you had already done, replace the {switch:a,b,c} part with a, b, or c
  3. Replace {zoom} in the URL with {z}
zimmertr commented 2 years ago

My hero :)

You have no idea how life changing this is going to be for route planning.

Well, actually, if anyone does it's probably you and Zeke.

THANK YOU SO MUCH!!!!!!

zimmertr commented 2 years ago

Have ya'll had any luck using this with GaiaGPS? Looks like they have a 250 character limit for the URL field... My full heatmap URL with my authentication tokens is 708 characters.

zekefarwell commented 2 years ago

Can't say I have. I've only ever tried using it for JOSM and iD. Should work in any application that can deal with a TMS server (and that doesn't have a character limit), though.

jleedev commented 2 years ago

You could proxy it to omit the parameters from the URL.

~¶ cat Caddyfile 
http://:8080 {
    rewrite * /tiles-auth{uri}?Key-Pair-Id=…&Policy=…&Signature=…
    reverse_proxy https://heatmap-external-c.strava.com {
        header_up Host {upstream_hostport}
    }
}
~¶ caddy run

Then configure http://localhost:8080/all/hot/{z}/{x}/{y}.png

zimmertr commented 2 years ago

That is a good idea. I tried using a URL shortener but Gaia rejected it because it failed a regular expression looking for {z}/{x}/{y}. I'll try that next. In the interim, I've sent an email to their support team asking them about it. Maybe they'll boost the limit.

One last question and then I promise I'll stop bothering you people. Do you know why the resolution is so much lower when imported on Caltopo as opposed to being shown natively on Strava? I assume Caltopo is just not capable of displaying the data at the same resolution?

Screen Shot 2022-01-06 at 8 17 43 PM
martintvl commented 2 years ago

I found that I also had to set it to Type: Tile in the Custom Map Source dialog box.

zimmertr commented 1 year ago

Adding ?px=256& appears to solve the resolution issue.

zimmertr commented 1 year ago

Also here is a Python program to generate the URL for Caltopo using the StravaCookies package.

https://github.com/zimmertr/StravaHeatmapStringBuilder