I'm trying to create an automatic procedure for uploading shapefiles on a drupal portal website (see Create CMS system using Cartaro for my previous post that is related to this).
Today I've started to automate the styling of the layers. I've imported the Drupal color_field module and have modified it for my own needs. In here I create my SLD file with the color that has been selected.
Afterwards, I want to create a style based on this SLD. I do this with the following code: (refer to my previous post to make things more clear)
//Create a new style for this layer $createstyle=("curl -u admin:geoserver -X POST -H 'Content-type: text/xml' -d '<style> <name>$storename</name><filename>style.sld</filename></style>' localhost:8082/geoserver/rest/styles"); exec($createstyle); //Upload the style to geoserver $uploadstyle=("curl -u admin:geoserver -X PUT -H 'Content-type: application/vnd.ogc.sld+xml' -d style.sld localhost:8082/geoserver/rest/styles/$storename"); exec($uploadstyle); //Apply the style $applystyle=("curl -u admin:geoserver -X PUT -H 'Content-type: text/xml' -d '<layer><defaultStyle><name>$storename</name></defaultStyle></layer>' localhost:8082/geoserver/rest/layers/$storename"); exec($applystyle);
Now this works fine for just creating the style, but when the style gets applied to the layer with the curl commands, the layer isn't "enabled" anymore.
Another weird situation is that when I go to layer preview (after manually enabling the layer), the preview turns into a "vnd.ogc.sld+xml" file on my virtual machine, but when I implement it on another virtual machine with the same settings, it just shows the layer preview in OpenLayers. I think that's very strange.
So these are my two questions to you. Any solutions?
Furthermore I want to refer to my second post, just on a side note so you know what I plan to do with all this. SLD style definition from GeoServer to Drupal
Thanks in advance! Dieter