Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Retrieve the sac_scale and mtb_scale tags #1317

ravenfeld started this conversation in General
Discussion options

I wanted to confirm that in order to have the sac_scale and mtb_scale data in the tiles I have to do like BikeRouteOverlay.java ?

The idea is to create a rendering for the outdoors.
hyperknot/openfreemap#31 (comment)

You must be logged in to vote

Replies: 2 comments 5 replies

Comment options

mtb:scale is already available as mtb_scale: https://openmaptiles.org/schema/#mtb_scale

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
Comment options

Comment options

Me neither and so not knowing anything I don't really know where to look.

Comment options

Planetiler-openmaptiles only uses sac_scale to determine min zoom, it doesn't put it onto the features: https://github.com/openmaptiles/planetiler-openmaptiles/blob/1ba1a5464ee732b8328cc35a481eefad91a708d7/src/main/java/org/openmaptiles/layers/Transportation.java#L551

So you could add it in openmaptiles/openmaptiles repo then planetiler-openmaptiles would eventually get it. Or if openfreemap is using a planetiler-openmaptiles fork you could add code to that to copy over sac_scale

Comment options

Sorry, I didn't quite understand what to do. Before indicating in the issue what to do, I'll try to do it on my side. I saw that we can make shema.yml but for the moment without success on my side

Comment options

I did this which seems to work. I don't know if it's very good but I have an additional outdoor layer that is added

public class CustomProfile extends OpenMapTilesProfile {
	public CustomProfile(Planetiler runner) {
 super(runner.translations(), runner.config(), runner.stats());
 }
 public CustomProfile(Translations translations, PlanetilerConfig config, Stats stats) {
 super(translations,config,stats);
 }
 
 @Override
 public void processFeature(SourceFeature sourceFeature, FeatureCollector features) {
 super.processFeature(sourceFeature, features);
 // Puis ajoute sac_scale à transportation
 if (sourceFeature.canBeLine() && sourceFeature.hasTag("highway") &&
 (
	 sourceFeature.hasTag("sac_scale") || 
	 sourceFeature.hasTag("surface") ||
	 sourceFeature.hasTag("trail_visibility") ||
	 sourceFeature.hasTag("tracktype")
	 )) {
 var line = features.line("outdoor")
 .inheritAttrFromSource("highway"); // récupère d'autres attributs utiles
 if (sourceFeature.hasTag("tracktype")) {
 line.setAttr("tracktype", sourceFeature.getTag("tracktype"));
 }
 
 if (sourceFeature.hasTag("sac_scale")) {
 line.setAttr("sac_scale", sourceFeature.getTag("sac_scale"));
 }
 if (sourceFeature.hasTag("surface")) {
 line.setAttr("surface", sourceFeature.getTag("surface"));
 }
 if (sourceFeature.hasTag("trail_visibility")) {
 line.setAttr("trail_visibility", sourceFeature.getTag("trail_visibility"));
 }
 
 int i = 0;
 for (var routeInfo : sourceFeature.relationInfo(RouteRelationInfo.class)) {
 // (routeInfo.role() also has the "role" of this relation member if needed)
 RouteRelationInfo relation = routeInfo.relation();
 
 line.setAttr("relation_"+i+"_name", relation.name);
 line.setAttr("relation_"+i+"_ref", relation.ref);
 line.setAttr("relation_"+i+"_route", relation.route);
 line.setAttr("relation_"+i+"_network", relation.network);
 line.setAttr("relation_"+i+"_symbol", relation.symbol);
 line.setAttr("relation_"+i+"_color", relation.color);
 i++;
 }
 }
 }
 private record RouteRelationInfo(
 // OSM ID of the relation (required):
 @Override long id,
 // Values for tags extracted from the OSM relation:
 String name, String ref, String route, String network,String symbol,String color
 ) implements OsmRelationInfo {}
 @Override
 public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation) {
 if (relation.hasTag("type", "route")) {
 if (relation.hasTag("route","hiking")) {
 return List.of(new RouteRelationInfo(
 relation.id(),
 relation.getString("name"),
 relation.getString("ref"),
 relation.getString("route"),
 relation.getString("network", ""),
 relation.getString("osmc:symbol", ""),
 relation.getString("colour", "")
 ));
 }
 }
 return null;
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /