[Geoserver-users] Converting CSS to SLD without web interface

Hi all,

I'm still experimenting with the great CSS Module and already managed to reproduce major parts of my former SLD styling information with much less code. Many thanks to David Winslow for developing this (also thx for updating the docs on the GeoServer website!)

In order to establish CSS styling in the automated workflow of the company I'm working for, I'm looking for a way to programmatically execute the CSS -> SLD conversion. So far I only managed to do this via the "CSS Demo" web interface by clicking on "Submit".

Is there any other way to access this conversion logic going on behind the scenes?

Thanks in advance and best regards,
Matthias

Yes, but it has been developed mostly for testing use and so isn’t packaged individually. If you have a working GeoServer installation, you should be able to run it after first including the GeoServer WEB-INF/lib directory on your CLASSPATH:

$ java -cp ‘webapps/geoserver/WEB-INF/lib/*’ org.geoscript.geocss.Converter foo.css

For each file argument, the converter will attempt to parse the file as CSS and write the resultant SLD to a file with the same name, but with the file extension replaced with SLD. So it is possible to convert many CSS files in one go and save yourself some JVM startup time.

There is also a Java API which is adapted for use in most (all?) variants of GeoScript (http://geoscript.org/).

···

On Tue, Jan 15, 2013 at 7:38 AM, Matthias Uden <matthias.uden@anonymised.com> wrote:

Hi all,

I’m still experimenting with the great CSS Module and already managed to
reproduce major parts of my former SLD styling information with much
less code. Many thanks to David Winslow for developing this (also thx
for updating the docs on the GeoServer website!)

In order to establish CSS styling in the automated workflow of the
company I’m working for, I’m looking for a way to programmatically
execute the CSS → SLD conversion. So far I only managed to do this via
the “CSS Demo” web interface by clicking on “Submit”.

Is there any other way to access this conversion logic going on behind
the scenes?

Thanks in advance and best regards,
Matthias


Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hi,

My web application uses Struts Framework, and the enviroments are JDK 6,Tomcat 6, GeoServer 2.2.2.

I configured GeoServer to secure WMS, a basic authencitation window pops up for WMS request. For example, user name and password
are required to input to access
http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers
In my web application, I don’t want to pass username and password in the URL string, instead, I want to access the secured WMS without authentication window.
I used ol4jsf proxy but it doesn’t work, the autentication window still pops up.

Please see below for my set up. Is there something wrong?

In my JSP page, I do the WMS request such as these:
untiled = new OpenLayers.Layer.WMS(
“topp:states - Untiled”, “http://localhost:8080/geoserver/topp/wms”,
{
LAYERS: ‘topp:states’,
STYLES: ‘’,
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: true,
yx : {‘EPSG:4326’ : true}
}
);

I put ol4jsf-core-2.5.0.jar in my application WEB-INF/lib floder and create ol4jsf-proxy.xml in WEB-INF/classes:

<?xml version="1.0" encoding="UTF-8"?> Development Environment. http://http:localhost:8080/geoserver/wms admin geoserver

In my web application web.xml page, I added these:

OL4JSFProxy org.ol4jsf.proxy.servlet.OL4JSFProxy 0 OL4JSFProxy /OL4JSFProxy/*

Any suggestions are highly appreciated.
Thanks!
Maggie

To avoid the popup (challenge) you have to send the Http Header

Authorization

which each request.

Look here for an example

http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html

Christian

Zitat von Meichun Li <pcloudy2005@anonymised.com>:

Hi,

My web application uses Struts Framework, and the enviroments are JDK 6,Tomcat 6, GeoServer 2.2.2.

I configured GeoServer to secure WMS, a basic authencitation window pops up for WMS request. For example, user name and password
are required to input to access
http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers
In my web application, I don't want to pass username and password in the URL string, instead, I want to access the secured WMS without authentication window.
I used ol4jsf proxy but it doesn't work, the autentication window still pops up.

Please see below for my set up. Is there something wrong?

In my JSP page, I do the WMS request such as these:
untiled = new OpenLayers.Layer.WMS(
"topp:states - Untiled", "http://localhost:8080/geoserver/topp/wms&quot;,
{
LAYERS: 'topp:states',
STYLES: '',
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: true,
yx : {'EPSG:4326' : true}
}
);

I put ol4jsf-core-2.5.0.jar in my application WEB-INF/lib floder and create ol4jsf-proxy.xml in WEB-INF/classes:

<?xml version="1.0" encoding="UTF-8"?>
<ol4jsf-proxy>
<use-environment id="desenv" />
<environment id="desenv">
<description>Development Environment.</description>
<resources>
<resource name="wms">
<url>http://http:localhost:8080/geoserver/wms</url>
<authentication>
<username>admin</username>
<password>geoserver</password>
</authentication>
</resource>
</resources>
</environment>
</ol4jsf-proxy>

In my web application web.xml page, I added these:

<!-- Proxy for GeoServer WMS-->

<servlet>
<servlet-name>OL4JSFProxy</servlet-name>
<servlet-class>org.ol4jsf.proxy.servlet.OL4JSFProxy</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>OL4JSFProxy</servlet-name>
<url-pattern>/OL4JSFProxy/*</url-pattern>
</servlet-mapping>

Any suggestions are highly appreciated.
Thanks!
Maggie

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Thanks a lot, that works nicely and is very convenient for my purposes!

Cheers,
Matthias

Am 15.01.2013 15:42, schrieb David Winslow:

Yes, but it has been developed mostly for testing use and so isn't packaged individually. If you have a working GeoServer installation, you should be able to run it after first including the GeoServer WEB-INF/lib directory on your CLASSPATH:

$ java -cp 'webapps/geoserver/WEB-INF/lib/*' org.geoscript.geocss.Converter foo.css

For each file argument, the converter will attempt to parse the file as CSS and write the resultant SLD to a file with the same name, but with the file extension replaced with SLD. So it is possible to convert many CSS files in one go and save yourself some JVM startup time.

There is also a Java API which is adapted for use in most (all?) variants of GeoScript (http://geoscript.org/).

--
David Winslow
OpenGeo - http://opengeo.org/

On Tue, Jan 15, 2013 at 7:38 AM, Matthias Uden <matthias.uden@anonymised.com <mailto:matthias.uden@anonymised.com>> wrote:

    Hi all,

    I'm still experimenting with the great CSS Module and already
    managed to
    reproduce major parts of my former SLD styling information with much
    less code. Many thanks to David Winslow for developing this (also thx
    for updating the docs on the GeoServer website!)

    In order to establish CSS styling in the automated workflow of the
    company I'm working for, I'm looking for a way to programmatically
    execute the CSS -> SLD conversion. So far I only managed to do
    this via
    the "CSS Demo" web interface by clicking on "Submit".

    Is there any other way to access this conversion logic going on behind
    the scenes?

    Thanks in advance and best regards,
    Matthias

    ------------------------------------------------------------------------------
    Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
    and more. Get SQL Server skills now (including 2012) with
    LearnDevNow -
    200+ hours of step-by-step video tutorials by Microsoft MVPs and
    experts.
    SALE $99.99 this month only - learn more at:
    http://p.sf.net/sfu/learnmore_122512
    _______________________________________________
    Geoserver-users mailing list
    Geoserver-users@lists.sourceforge.net
    <mailto:Geoserver-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hi Christian,

Thanks so much for you response. I looked at your example and understood basic authentication, but I don’t know to how to use it with openLayers. Can you please give me an example or guidelines?

I use openLayers to do WMS request as below. How to use basic authentication for this?

// setup tiled layer

tiled = new OpenLayers.Layer.WMS(

“Geoserver layers - Tiled”, “http://localhost:8080/geoserver/nc/wms”,

{

LAYERS: ‘NC_Map’,

STYLES: ‘’,

format: format,

tiled: true,

tilesOrigin : map.maxExtent.left + ‘,’ + map.maxExtent.bottom

},

{

buffer: 0,

displayOutsideMaxExtent: true,

isBaseLayer: true,

yx : {‘EPSG:4326’ : true}

}

);

// setup single tiled layer

untiled = new OpenLayers.Layer.WMS(

“Geoserver layers - Untiled”, “http://localhost:8080/geoserver/nc/wms”,

{

LAYERS: ‘NC_Map’,

STYLES: ‘’,

format: format

},

{

singleTile: true,

ratio: 1,

isBaseLayer: true,

yx : {‘EPSG:4326’ : true}

}

);

map.addLayers([untiled, tiled]);


From:christian.mueller@anonymised.com” <christian.mueller@anonymised.com.>
To: Meichun Li pcloudy2005@anonymised.com
Cc:geoserver-users@lists.sourceforge.netgeoserver-users@anonymised.comrge.net
Sent: Wednesday, January 16, 2013 1:01 AM
Subject: Re: [Geoserver-users] How to access secured WMS in web application

To avoid the popup (challenge) you have to send the Http Header

Authorization

which each request.

Look here for an example

http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html

Christian

Zitat von Meichun Li <pcloudy2005@anonymised.com>:

Hi,

My web application uses Struts Framework, and the enviroments are JDK 6,Tomcat 6, GeoServer 2.2.2.

I configured GeoServer to secure WMS, a basic authencitation window pops up for WMS request. For example, user name and password
are required to input to access
http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers
In my web application, I don’t want to pass username and password in the URL string, instead, I want to access the secured WMS without authentication window.
I used ol4jsf proxy but it doesn’t work, the autentication window still pops up.

Please see below for my set up. Is there something wrong?

In my JSP page, I do the WMS request such as these:
untiled = new OpenLayers.Layer.WMS(
“topp:states - Untiled”, “http://localhost:8080/geoserver/topp/wms”,
{
LAYERS: ‘topp:states’,
STYLES: ‘’,
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: true,
yx : {‘EPSG:4326’ : true}
}
);

I put ol4jsf-core-2.5.0.jar in my application WEB-INF/lib floder and create ol4jsf-proxy.xml in WEB-INF/classes:

<?xml version="1.0" encoding="UTF-8"?> Development Environment. [http://http:localhost:8080/geoserver/wms](http://http:localhost:8080/geoserver/wms) admin geoserver

In my web application web.xml page, I added these:

OL4JSFProxy org.ol4jsf.proxy.servlet.OL4JSFProxy 0 OL4JSFProxy /OL4JSFProxy/*

Any suggestions are highly appreciated.
Thanks!
Maggie


This message was sent using IMP, the Internet Messaging Program.

I am no Openlayers expert but look here

http://osgeo-org.1560.n6.nabble.com/Load-GeoServer-WMS-secured-layers-with-OpenLayers-td3919938.html

The answer from Andreas Hocevar should help.

Christian

Zitat von Meichun Li <pcloudy2005@anonymised.com>:

Hi Christian,

Thanks so much for you response. I looked at your example and understood basic authentication, but I don't know to how to use it with openLayers. Can you please give me an example or guidelines?

I use openLayers to do WMS request as below. How to use basic authentication for this?

.....

// setup tiled layer

tiled = new OpenLayers.Layer.WMS(

"Geoserver layers - Tiled", "http://localhost:8080/geoserver/nc/wms&quot;,

{

LAYERS: 'NC_Map',

STYLES: '',

format: format,

tiled: true,

tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom

},

{

buffer: 0,

displayOutsideMaxExtent: true,

isBaseLayer: true,

yx : {'EPSG:4326' : true}

}

);

// setup single tiled layer

untiled = new OpenLayers.Layer.WMS(

"Geoserver layers - Untiled", "http://localhost:8080/geoserver/nc/wms&quot;,

{

LAYERS: 'NC_Map',

STYLES: '',

format: format

},

{

singleTile: true,

ratio: 1,

isBaseLayer: true,

yx : {'EPSG:4326' : true}

}

);

map.addLayers([untiled, tiled]);

________________________________
From: "christian.mueller@anonymised.com" <christian.mueller@anonymised.com>
To: Meichun Li <pcloudy2005@anonymised.com>
Cc: "geoserver-users@lists.sourceforge.net" <geoserver-users@lists.sourceforge.net>
Sent: Wednesday, January 16, 2013 1:01 AM
Subject: Re: [Geoserver-users] How to access secured WMS in web application

To avoid the popup (challenge) you have to send the Http Header

Authorization

which each request.

Look here for an example

http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html

Christian

Zitat von Meichun Li <pcloudy2005@anonymised.com>:

Hi,

My web application uses Struts Framework, and the enviroments are JDK 6,Tomcat 6, GeoServer 2.2.2.

I configured GeoServer to secure WMS, a basic authencitation window pops up for WMS request. For example, user name and password
are required to input to access
http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers
In my web application, I don't want to pass username and password in the URL string, instead, I want to access the secured WMS without authentication window.
I used ol4jsf proxy but it doesn't work, the autentication window still pops up.

Please see below for my set up. Is there something wrong?

In my JSP page, I do the WMS request such as these:
untiled = new OpenLayers.Layer.WMS(
"topp:states - Untiled", "http://localhost:8080/geoserver/topp/wms&quot;,
{
LAYERS: 'topp:states',
STYLES: '',
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: true,
yx : {'EPSG:4326' : true}
}
);

I put ol4jsf-core-2.5.0.jar in my application WEB-INF/lib floder and create ol4jsf-proxy.xml in WEB-INF/classes:

<?xml version="1.0" encoding="UTF-8"?>
<ol4jsf-proxy>
<use-environment id="desenv" />
<environment id="desenv">
<description>Development Environment.</description>
<resources>
<resource name="wms">
<url>http://http:localhost:8080/geoserver/wms</url>
<authentication>
<username>admin</username>
<password>geoserver</password>
</authentication>
</resource>
</resources>
</environment>
</ol4jsf-proxy>

In my web application web.xml page, I added these:

<!-- Proxy for GeoServer WMS-->

<servlet>
<servlet-name>OL4JSFProxy</servlet-name>
<servlet-class>org.ol4jsf.proxy.servlet.OL4JSFProxy</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>OL4JSFProxy</servlet-name>
<url-pattern>/OL4JSFProxy/*</url-pattern>
</servlet-mapping>

Any suggestions are highly appreciated.
Thanks!
Maggie

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Thanks Christian for the link! It’s helpful!

I figured out how to use OL4JSFProxy to do geoserver WMS authorization with OpenLayers. It worked!

Thanks so much!

Maggie


From:christian.mueller@anonymised.comchristian.mueller@anonymised.com
To: Meichun Li pcloudy2005@anonymised.com
Cc:geoserver-users@anonymised.come.netgeoserver-users@lists.sourceforge.net
Sent: Thursday, January 17, 2013 10:53 AM
Subject: Re: [Geoserver-users] How to access secured WMS in web application

I am no Openlayers expert but look here

http://osgeo-org.1560.n6.nabble.com/Load-GeoServer-WMS-secured-layers-with-OpenLayers-td3919938.html

The answer from Andreas Hocevar should help.

Christian

Zitat von Meichun Li <pcloudy2005@anonymised.com>:

Hi Christian,

Thanks so much for you response. I looked at your example and
understood basic authentication, but I don’t know to how to use it
with openLayers. Can you please give me an example or guidelines?

I use openLayers to do WMS request as below. How to use basic
authentication for this?

// setup tiled layer

tiled = new OpenLayers.Layer.WMS(

“Geoserver layers - Tiled”, “http://localhost:8080/geoserver/nc/wms”,

{

LAYERS: ‘NC_Map’,

STYLES: ‘’,

format: format,

tiled: true,

tilesOrigin : map.maxExtent.left + ‘,’ + map.maxExtent.bottom

},

{

buffer: 0,

displayOutsideMaxExtent: true,

isBaseLayer: true,

yx : {‘EPSG:4326’ : true}

}

);

// setup single tiled layer

untiled = new OpenLayers.Layer.WMS(

“Geoserver layers - Untiled”, “http://localhost:8080/geoserver/nc/wms”,

{

LAYERS: ‘NC_Map’,

STYLES: ‘’,

format: format

},

{

singleTile: true,

ratio: 1,

isBaseLayer: true,

yx : {‘EPSG:4326’ : true}

}

);

map.addLayers([untiled, tiled]);


From: “christian.mueller@anonymised.com” <christian.mueller@anonymised.com…>
To: Meichun Li <pcloudy2005@anonymised.com>
Cc: “geoserver-users@anonymised.comrceforge.net
<geoserver-users@anonymised.coms.sourceforge.net>
Sent: Wednesday, January 16, 2013 1:01 AM
Subject: Re: [Geoserver-users] How to access secured WMS in web application

To avoid the popup (challenge) you have to send the Http Header

Authorization

which each request.

Look here for an example

http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html

Christian

Zitat von Meichun Li <pcloudy2005@anonymised.com>:

Hi,

My web application uses Struts Framework, and the enviroments are
JDK 6,Tomcat 6, GeoServer 2.2.2.

I configured GeoServer to secure WMS, a basic authencitation
window pops up for WMS request. For example, user name and password
are required to input to access
http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers
In my web application, I don’t want to pass username and password
in the URL string, instead, I want to access the secured WMS
without authentication window.
I used ol4jsf proxy but it doesn’t work, the autentication window
still pops up.

Please see below for my set up. Is there something wrong?

In my JSP page, I do the WMS request such as these:
untiled = new OpenLayers.Layer.WMS(
“topp:states - Untiled”,
http://localhost:8080/geoserver/topp/wms”,
{
LAYERS: ‘topp:states’,
STYLES: ‘’,
format: format
},
{
singleTile: true,
ratio: 1,
isBaseLayer: true,
yx : {‘EPSG:4326’ : true}
}
);

I put ol4jsf-core-2.5.0.jar in my application WEB-INF/lib floder
and create ol4jsf-proxy.xml in WEB-INF/classes:

<?xml version="1.0" encoding="UTF-8"?> Development Environment. [http://http:localhost:8080/geoserver/wms](http://http:localhost:8080/geoserver/wms) admin geoserver

In my web application web.xml page, I added these:

OL4JSFProxy org.ol4jsf.proxy.servlet.OL4JSFProxy 0 OL4JSFProxy /OL4JSFProxy/*

Any suggestions are highly appreciated.
Thanks!
Maggie


This message was sent using IMP, the Internet Messaging Program.


This message was sent using IMP, the Internet Messaging Program.