Opened 10 years ago

Closed 6 years ago

#1476 closed task (wontfix)

Use css classes properly

Reported by: Knut Arne Bjørndal Owned by: Hugh Barnes
Priority: minor Milestone:
Component: osmarender Version:
Keywords: Cc:

Description

Something that could, if it's possible, help us simplify the stylesheets a bit:

<rule ...>

<set-class class="foo"/> <rule ...>

<area class="bar"/> <!-- this would be foo bar -->

</rule>

</rule>

Possible implementation: Have the rule engine picks up the <set-class> commands and trickle the classes down through the template calls.

I don't have time to do this now, but may do so in the future. If anybody else wants to, then feel free.

Change History (8)

comment:1 Changed 10 years ago by Hugh Barnes

Owner: changed from osm@… to Hugh Barnes
Status: newassigned

If we are talking about the same thing, I was just working at this last night. Have been stewing on it for ages!

I have, for example, in z17:

.gate {
  fill: none;
  stroke: red;
  stroke-width: 1px;
  stroke-opacity: 0;                        
}

.gate.locked {
  marker-mid: url(#marker-gate-locked);
}

and have changed its rule invocation to, e.g.:

<else>
  <rule e="node" k="status" v="locked">
    <wayMarker k="highway" class="gate locked"/>
  </rule>

Is this what you're talking about?

comment:2 in reply to:  1 Changed 10 years ago by Knut Arne Bjørndal

Replying to dev.osm@hughbris.com:

If we are talking about the same thing, I was just working at this last night. Have been stewing on it for ages!

I have, for example, in z17:

.gate {
  fill: none;
  stroke: red;
  stroke-width: 1px;
  stroke-opacity: 0;                        
}

.gate.locked {
  marker-mid: url(#marker-gate-locked);
}

and have changed its rule invocation to, e.g.:

<else>
  <rule e="node" k="status" v="locked">
    <wayMarker k="highway" class="gate locked"/>
  </rule>

Is this what you're talking about?

I'm not quite sure, but I have a feeling it's a different thing.

If you show me some of your implementation I could probably make a better guess...

comment:3 Changed 10 years ago by Hugh Barnes

I'm not quite sure, but I have a feeling it's a different thing.

I think so too now. I think we may be trying to solve the same problem in incompatible ways. We probably both grimaced at those hiphenated classnames.

If you show me some of your implementation I could probably make a better guess...

I thought I did that with the code snippets I provided. It's taking quite some time to come up with just one file for zoom17, but I'll put it in a branch when ready for you to see. About 2/3 through now. It's very tedious. It will need very careful testing (hence http://trac.openstreetmap.org/ticket/1481) before I'd be merging it into the main branch.

My edit began before your patch for TimBL, so it will need trivial merging.

Back to what I'm doing: I'm using classes like tags or properties, exploiting the possibilities of applying more than one (classes are defined in the DTD as NMTOKENS - a list of tokens). This is the way class combinations should be implemented.

I think your solution, if I follow it, may not scale as well (only two levels) and will (perhaps) be less readable. It's also a kind of new solution where well-planned multiple classes already do it fine.

Anyway, will let you know. If you think your idea is better, I'll start a new ticket.

comment:4 Changed 10 years ago by Hugh Barnes

I don't know what I was looking at by saying I was 2/3 through level 17. Not really.

It's going to take a long time to do what I was going to do. I think it has less structural effect than your implementation, though. So while I will put up something to demonstrate the idea, I am wondering whether to hand back this ticket and start my own, take it over, or mark it wontfix. I am pretty sure both implementations can't happen.

Here, while you think about it, is another example of style madness:

class="highway-casing highway-bridleway-casing highway-bridleway-area-casing no-bezier"

.. which could be expressed as class="highway bridleway area casing no-bezier" and the CSS would contain a lot less redundancy, too (e.g. styles that apply to all highways).

Can we go on expecting developers to work with this?

Sorry, I'm being obstinate. Would be keen to hear your thoughts. I am going to first distract myself by adding rendering for a few new features :~)

comment:5 in reply to:  4 Changed 10 years ago by Knut Arne Bjørndal

Replying to dev.osm@hughbris.com:

I don't know what I was looking at by saying I was 2/3 through level 17. Not really.

It's going to take a long time to do what I was going to do. I think it has less structural effect than your implementation, though. So while I will put up something to demonstrate the idea, I am wondering whether to hand back this ticket and start my own, take it over, or mark it wontfix. I am pretty sure both implementations can't happen.

This sounds like something that could very well be done a little bit at a time, that would help make sure you don't get into merging hell too.

I don't see anything to indicate both ideas couldn't co-exist.

Maybe you should just take over this ticket (since this is where we have discussed this) and my idea can be moved to another.

Here, while you think about it, is another example of style madness:

class="highway-casing highway-bridleway-casing highway-bridleway-area-casing no-bezier"

.. which could be expressed as class="highway bridleway area casing no-bezier" and the CSS would contain a lot less redundancy, too (e.g. styles that apply to all highways).

That would be a _lot_ better. I think my idea will coexist well with this though, since that would result in that line being only class="bridleway", since highway, area and casing are shared with many rules in the same area of the stylesheet.

comment:6 Changed 10 years ago by Knut Arne Bjørndal

Summary: Idea: Trickle classesUse css classes properly

I'm letting this ticket be about your idea, I'll open a new one about mine.

comment:7 in reply to:  6 Changed 10 years ago by Hugh Barnes

Replying to bob@cakebox.net:

I'm letting this ticket be about your idea, I'll open a new one about mine.

Thanks - just to provide a progress report on this one, I have a difference in the bitmaps converted from the renderings for the comprehensive.osm test data. It's not as trivial to track down as I hoped. Probably a copy-paste error. :~)

On the positive side, I can see how I might be able to write a simple test script in bash or python, which will hopefully speed me up to more regular commits. ATM it's a series of hardcoded commands with filename arguments, but I should be able to change this to loop through the testdata directory.

comment:8 Changed 6 years ago by iandees

Resolution: wontfix
Status: assignedclosed

Cleaning aging tickets.

Note: See TracTickets for help on using tickets.