Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for retina (scaling) TMS token #982

Open
zdila opened this issue Nov 4, 2020 · 18 comments
Open

Add support for retina (scaling) TMS token #982

zdila opened this issue Nov 4, 2020 · 18 comments

Comments

@zdila
Copy link
Contributor

zdila commented Nov 4, 2020

On CONTRIBUTING page I found no retina tile parameter. Editor iD has it implemented as {r} or {@2x}. Please add support for it.

@rbuffat
Copy link
Collaborator

rbuffat commented Nov 4, 2020

@zdila Is this an optional tms parameter? E.g. a source can work with or without this parameter?
Is there cross-editor support for this parameter? If it is an optional parameter, is there a way to specify it without breaking the compatibility with an editor that does not support it?

CC @Klumbumbus @simonpoole @quincylvania @systemed @bryceco

@zdila
Copy link
Contributor Author

zdila commented Nov 4, 2020

It is an optional parameter. If omitted then it is the same as @1x.

In ideal world editors not understanding {r} or {@2x} should remove this placeholder.

I have only checked editor iD which supports it and JOSM which shows error that {@2x} is not valid TMS argument.

I am not sure how to add a support for it and keep the compatibility. Maybe compiling geojsons for different editors?

@zdila
Copy link
Contributor Author

zdila commented Nov 4, 2020

Just for the reference - JOSM: https://josm.openstreetmap.de/ticket/20030

@zdila
Copy link
Contributor Author

zdila commented Nov 4, 2020

BTW some tileservers support other scales and they can be also fractional. For example please see one particular tile:

@grischard
Copy link
Collaborator

Since it would be a new parameter, existing editors wouldn't just strip it, and would get 404s if they call 0.png{r} instead of 0.png or 0.png@2x

Maybe something like the srcset html attribute could work, or a second url source?

Editors can also use the category to decide if they want to overzoom by default, for example on aerial imagery.

In any case, this should be done together with the JOSM team.

@rbuffat
Copy link
Collaborator

rbuffat commented Nov 4, 2020

In any case, this should be done together with the JOSM team.

Ideally, there should be a consensus among all osm editors. Is there somebody else that should be included in the discussion?

@rbuffat
Copy link
Collaborator

rbuffat commented Nov 4, 2020

There seems to be a small number of sources that support @2x, but my test script could also be a bit buggy, so there could be more or less.

Source ids returning a 512x512 pixel image for @2x:

Freemap.sk-Outdoor
IBGE_Nomes_Ruas
IBGE_Salvador_Streets
mapbox_locator_overlay
wikimedia-map
Arenda_OAM
Maxar_19-20_Australian_Bushfires_PreEvent
ARA_Bushfires_2020
IBGE_Setores_Rurais
IBGE_Setores_Urbanos
IBGE_DF_Addresses
US-TIGER-Roads-2017
Mapbox
US-TIGER-Roads-2014
US-TIGER-Roads-2019
US-TIGER-Roads-2018
City_of_Melbourne_May_2018
City_of_Melbourne_Feb_2019

Source ids returning a 768x768 pixel image for @3x:

Freemap.sk-Outdoor
Arenda_OAM
wikimedia-map
Maxar_19-20_Australian_Bushfires_PreEvent
ARA_Bushfires_2020

@zdila
Copy link
Contributor Author

zdila commented Nov 4, 2020

Following sources certainly don't support it (I know, because I am from Freemap community):

  • Freemap.sk-Hiking
  • Freemap.sk-Ski
  • Freemap.sk-Car
  • Freemap.sk-Cyclo

@rbuffat
Copy link
Collaborator

rbuffat commented Nov 4, 2020

@zdila
Thanks, there was a bug. I updated the list above.

@simonpoole
Copy link
Contributor

Would someone be so kind and explain what the point of supporting this for aerial imagery is (contrary to maps with labels, where the reasoning is clear)?

@zdila
Copy link
Contributor Author

zdila commented Nov 5, 2020

@simonpoole Aerial imagery sources (non-hybrid, without labels, icons and other added symbology) should only be flagged that they are scaleable witout issues. Then rendering on HDPI (2x) can be easily done by taking 4 tiles from zoom+1 and rendering them in 2x2 grid in the place of the original "non-HDPI" tile.

@andrewharvey
Copy link
Collaborator

Another good reason here for versioning releases. Can auto-strip it for the current version, but add a breaking change not for the next major version.

Although some sources have a convention eg @2x other sources you might need a whole new URL entered.

Would someone be so kind and explain what the point of supporting this for aerial imagery is (contrary to maps with labels, where the reasoning is clear)?

I don't think it's needed in that case. But we should still support it for all the non-imagery maps in the index.

@rbuffat
Copy link
Collaborator

rbuffat commented Nov 15, 2020

Since it would be a new parameter, existing editors wouldn't just strip it, and would get 404s if they call 0.png{r} instead of 0.png or 0.png@2x
Maybe something like the srcset html attribute could work, or a second url source?

Probably, the most elegant solution is to encode it in the url, the question is what the best way would be.
E.g. for the freemap outdoor example, the following variants work:

https://outdoor.tiles.freemap.sk/12/2249/1460
https://outdoor.tiles.freemap.sk/12/2249/1460@1x
https://outdoor.tiles.freemap.sk/12/2249/1460@2x
https://outdoor.tiles.freemap.sk/12/2249/1460@3x

I don't know if there is a guarantee that, if e.g. a service offers @2x variant, also the @1x works.
Thus, probably it would be a good idea to encode the known working resolutions.

Maybe something like `https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}{r:1,2,3}?

Editors that do not wish to use higher resolutions could simply drop the {r} token. We could integrate this token in the URLs but drop it automatically in the imagery.* files until every editor supports it.

@rbuffat
Copy link
Collaborator

rbuffat commented Nov 15, 2020

More on a general note, is there a platform where such topics can be discussed and developers of all OSM editors listen to? E.g. a specific mailing list?

@andrewharvey
Copy link
Collaborator

More on a general note, is there a platform where such topics can be discussed and developers of all OSM editors listen to? E.g. a specific mailing list?

https://lists.openstreetmap.org/pipermail/dev is for all OSM development and developers building tools for OSM data, not specific to editors.

@simonpoole
Copy link
Contributor

Editors that do not wish to use higher resolutions could simply drop the {r} token. We could integrate this token in the URLs but drop it automatically in the imagery.* files until every editor supports it.

I suppose this could be solved the other way around, add a list of supported resolution tokens in the config. Assuming that ELI clients simply ignore json fields they don't recognize, for this to work there the client will need hardwired information on the semantics of @2x and @3x, but currently it would seem they need that anyway.

@zdila
Copy link
Contributor Author

zdila commented Nov 15, 2020

Other option could be extending properties with additional URLs for every supported scaling (even fractional). This would make it backward compatibile with old (current) software:

{
  "properties": {
    "url": "https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}",
    "scales": {
      "2": "https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}@2x",
      "3": "https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}@3x"
    }
    // ...
  }
  // ...
}

BTW @2x is a common standard identifying scale in URL but there are other. For example Strava heatmap uses tile dimenstion:

@simonpoole
Copy link
Contributor

Other option could be extending properties with additional URLs for every supported scaling (even fractional). This would make it backward compatibile with old (current) software:

If we do something like that, integrating alternative URLs (we currently can't model this, but JOSM has them) in general would make sense imho, so something like:

{
  "properties": {
    "url": "https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}",
    "scale": 1, // optional if 1
    "alternatives": [
      {
        "url": "https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}@2x",
        "scale": 2
      },
      {
        "url": "https://outdoor.tiles.freemap.sk/{zoom}/{x}/{y}@3x",
        "scale": 3
      },
      {
        "url": "https://somewhere.different.sk/{zoom}/{x}/{y}",
        "scale": 1
      }
    ]
    // ...
  }
  // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants