1

First: the above banner links this to How to use a sld file with Openlayers using OSM data? , but look update2.

I would like to add rail-road hatching to my OpenLayers map with a Symbolizer. Example how that is done in GeoServer is at [1] and there I could do that like this:

   <FeatureTypeStyle>
     <Rule>
       <LineSymbolizer>
         <Stroke>
           <CssParameter name="stroke">#333333</CssParameter>
           <CssParameter name="stroke-width">3</CssParameter>
         </Stroke>
       </LineSymbolizer>
       <LineSymbolizer>
         <Stroke>
           <GraphicStroke>
             <Graphic>
               <Mark>
                 <WellKnownName>shape://vertline</WellKnownName>
                 <Stroke>
                   <CssParameter name="stroke">#333333</CssParameter>
                   <CssParameter name="stroke-width">1</CssParameter>
                 </Stroke>
               </Mark>
               <Size>12</Size>
             </Graphic>
           </GraphicStroke>
         </Stroke>
       </LineSymbolizer>
     </Rule>
   </FeatureTypeStyle>

(This is only example directly from link, not exactly making the desired thing, but the shower of idea only)

Picture about what I get with that example code below.

enter image description here

Now, after that on screen, I can go further and get what I want, but the issue is the lines are a pure line VectorFeature coming to my code and I have to do the same thing with OpenLayers.

Question:

How I could come up with vertical lines, like done in GeoServer, now with OpenLayers Symbolizer? How to substitute lines with Z and get an electricity line styling?

My ideas so far:

I accomplished a two line road with black and white styles combined above each other and thought, that having a dash that is very long but has a little cap with white and very broad width and then equal black line with same width, there should come a vertical black line every certain period. My issue is to substitute though the lines with Z symbols and to that I run out of ideas. Playing with lines comes to end here.

My issue is to know how to get a symbol with certain cap to line. Then is everything cool.

Update 1:

Looking up for the docs [2] is not so promising, but maybe a custom style still is possible.

Update 2:

The question linked to here [3] answers only partially the addressed question. At least shape symbol on given code won't work with commands told in link [2].

Changes to OL renderer is needed, so that when parsing sld to svg it "handles" the new stuff properly. How to do that? Well, maybe I post answer later, if I don't get any hints before I invent it myself.

Links together:

[1] http://docs.geoserver.org/stable/en/user/styling/sld-cookbook/lines.html#railroad-hatching

[2] http://docs.openlayers.org/library/feature_styling.html

[3] How to use a sld file with Openlayers using OSM data?

  • another thing I should do is to make equal vertical line than in picture to appear in every turning point of the line. First though I like to get any symbol, then that. So, zeta is one thing and this is the next. – mico Sep 25 '14 at 9:01
  • Have you looked at this sample: dev.openlayers.org/examples/sld.html. It shows how you read a sld file and apply it to a vector layer. I have used similar code in the past with great success. – Devdatta Tengshe Sep 25 '14 at 9:33
  • possible duplicate of How to use a sld file with Openlayers using OSM data? – Devdatta Tengshe Sep 25 '14 at 9:38
  • Well, asking other expert it turned out that you cannot extend OL setup with SLD stuff (docs.openlayers.org/library/feature_styling.html defines the setup of things anyways) and this will still remain undone. It can be done in SLD but it won't come true when sent to OL. – mico Sep 25 '14 at 12:12
  • some pointing towards the solution is to manually render the "unknown" SLD stuff to SVG format and that actually is doable, although not maybe easy stuff. So editing openlayers renderer is needed. – mico Sep 25 '14 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.