How to use stroke-script?

classic Classic list List threaded Threaded
5 messages Options
remoe remoe
Reply | Threaded
Open this post in threaded view
|

How to use stroke-script?

Hi

I try to use the stroke-script as follow:

        <styles>
            <script>
              <![CDATA[
 
               function makeColors() {
			var colors = ["#0c2c00","#2b9700","#83c700","#d4dd00"];
			return colors[2];
                }
              ]]>
            </script> 		
            <style type="text/css">s {
				stroke-script: makeColors();
				stroke-width: 2500m; 
				stroke-min-pixels: 5; 
				stroke-tessellation-segments: 200; 
			}</style>
        </styles>

But it doesn't get the "stroke" color.

Cheers
Remo Eichenberger, Switzerland
ago ago
Reply | Threaded
Open this post in threaded view
|

Re: How to use stroke-script?

This post was updated on .
I found that "extrusion-height" support expression, stroke and fill does not support expression.



This can be replaced by the following


<map name="Inline styling" type="geocentric" version="2">
   
    <options>
        <lighting>false</lighting>
        <overlay_blending>false</overlay_blending>
    </options>

    <image name="world" driver="gdal">
        <url>../data/world.tif</url>
    </image>
   
    <model name="countries" driver="feature_geom">
                         
        <features name="states" driver="ogr">
            <url>../data/world.shp</url>
            <filters>
                <buffer distance="-0.05"/>
            </filters>
        </features>
<styles>           
        <script language="javascript"> <![CDATA[ function makeColors() { var colors = ["{stroke:#0c2c00;}","{stroke:#2b9700;}","{stroke:#83c700;}","{stroke:#d4dd00;}"]; return colors[3]; } ]]> </script>       
        <selector style_expr="makeColors()"/>
</styles>       
    </model>
</map>



OsgEarth editor test screenshot





SXEarth,a free osgEarth GUI Editor and Flight Simulation.

Email: seegogo@126.com
SXEarth download: http://www.sxsim.com/en/

remoe remoe
Reply | Threaded
Open this post in threaded view
|

Re: How to use stroke-script?

ago, thanks for your hint. I know this way. I want to use only a script for stroke. Some support is in code:

https://github.com/gwaldron/osgearth/blob/f6bafe8cd24efe4c98e1072ff21d1309fc6fdca2/src/osgEarthSymbology/LineSymbol.cpp#L142

But i haven't found a way to use this.

btw: your editor looks great ;)
Remo Eichenberger, Switzerland
ago ago
Reply | Threaded
Open this post in threaded view
|

Re: How to use stroke-script?

For example,feature_population_cylinders.earth

<feature_model name="City Population" feature_source="cities-data">
        <styles>
            <script profile="full"> <![CDATA[ var maxRank = 2; function makePopCircles() { if (feature.properties.scalerank <= maxRank) { var radius = (maxRank-feature.properties.scalerank+1) * 75000; feature.geometry = feature.geometry.buffer(radius); feature.properties.height = radius*1.5; } else { feature.geometry = null; } feature.save(); } ]]> </script>            <style type="text/css"> default { fill: #ff80007f; stroke: #ffcf7f; stroke-width: 1px; altitude-script: makePopCircles(); extrusion-height: feature.properties.height; render-bin: DepthSortedBin; } </style>        </styles>       
    </feature_model>



altitude-script is used to execute the script, and then extrusion-height is used to get the result of the execution, extrusion-height support expression, but the stroke from the code does not support expression.



I think GUI is more user-friendly, so I have developed the editor SXEarth, welcome to use it.
SXEarth,a free osgEarth GUI Editor and Flight Simulation.

Email: seegogo@126.com
SXEarth download: http://www.sxsim.com/en/

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: How to use stroke-script?

In reply to this post by remoe
Remo,

"stroke-script" does not return a stroke color. It does not return anything at all. It simply runs a script before applying the line symbol.
Glenn Waldron / Pelican Mapping