tangrams / tangram-play

Text editor web app for Tangram scenes
https://tangram.city/play/
MIT License
96 stars 27 forks source link

Saving house styles to Mapzen breaks relative urls to resources (e.g. fonts, textures) #660

Open louh opened 7 years ago

louh commented 7 years ago

When a Mapzen house style (e.g. Walkabout, etc) is loaded from its original location, and then saved to Mapzen via the Scene API, the scene file is saved but none of the resources. When the scene is loaded later from the Mapzen Scene API, those resources are missing (and results in side effects from missing textures, icons, etc).

There are two categories of fixes:

  1. Use absolute URL references to resources.
  2. Save all the resources with the scene file.

Category number one appears to be relatively simple to implement and can be done in one of two ways. The first is to update house styles to use absolute URLs. However, this is not doable in practice: House styles use relative URLs for resources because this is necessary for Tangram-ES. We can fork the original house styles and replace them with absolute URLs, but then we must manually keep the forked versions up to date (and stop-gap solutions have a tendency to atrophy into permanent solutions). The second way is to use the house style itself as an import. This ensures that links to resources are preserved, but trades off being able to see the contents of the imported scene file. This means neither solution in category one is ideal.

Category number two is more ideal, since Tangram has introduced the concept of a scene "bundle" in which a "scene" consists of not just its YAML file but any number of other resources, including fonts, textures, images, spheremaps, and other YAML files. We can conceive of a bundle as the "zip" file all these things are in, but we can also think of it as a collection of files that have some relationship as defined by a manifest. As Tangram Play opens, saves, and moves scenes around, this contents of this "bundle" should remain intact and its implementation should get out of the way of the user. We want to create this system, but this will take time. It will not happen before beta launch.

A slightly different (but also long-term) approach is worth mentioning here, and it comes from the Tangram side. Inevitably, someone somewhere will reference a resource that will not exist. How this happens is not important - it could just be a typo. What matters is that the resource is not reachable. This connects with one of Tangram's other goals, which is to surface more useful errors, and Tangram Play can then be aware of it. (This already happens with imports.) This would help improve messaging for when a resource fails to load for any reason.

louh commented 7 years ago

Given the conversations I've had so far, it seems to the best course of action is to not let this affect launch. @souperneon @kkowalsky @nvkelso @bcamper

nvkelso commented 7 years ago

All Mapzen basemap styles are now provided (since last week) in the ZIP bundle format via mapzen.com/carto. Is there a problem with Tangram Play referencing those ZIP bundles instead of the YAML?

I'm more in favor of "importing" the Mapzen basemap styles versus "opening" the full source by default. I suspect more people will want to overlay their own data on top of our basemap styles, or do a tiny modification of a basemap style (e.g. change labels language, enable transit), than go thru 6,000 lines of basemap source code.

(I'm not clear on launch schedule, seems like this can change after release?)

louh commented 7 years ago

Yeah - we can definitely revisit this after release. I talk a little more about my rationale here: https://github.com/tangrams/tangram-play/issues/640#issuecomment-275501693