Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geoserver manager, adding a new layer

While programatically creating a new layer with the geoserver-manager api (http://code.google.com/p/geoserver-manager/wiki/Documentation) using the following code:

GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSER, RESTPW);

GSFeatureTypeEncoder featureTypeEncoder = new GSFeatureTypeEncoder();
featureTypeEncoder.setSRS("EPSG:41001");
featureTypeEncoder.setName("view1");
featureTypeEncoder.setNativeBoundingBox(10,10,100,100, "EPSG:41001");

GSLayerEncoder layerEncoder = new GSLayerEncoder();
layerEncoder.setEnabled(true);

boolean ok = publisher.publishDBLayer(WORKSPACE, "user1", featureTypeEncoder, layerEncoder);

The new layer is created successfully but it's the wrong type (point not line). Is there a way of changing this layer type (to line) either before or after creating the layer?

Versions: Geoserver 2.3.0 Postgres 1.14 Geoserver-manager 1.3.0

Thanks!

like image 924
ScottFree Avatar asked Jun 02 '26 08:06

ScottFree


1 Answers

2 ways: you have to use the layer encoder to configure the default layer:

        GSLayerEncoder layerEncoder = new GSLayerEncoder();
        layerEncoder.setEnabled(true);
        layerEncoder.setQueryable(true);
        layerEncoder.setDefaultStyle("polygon");

        boolean published = publisher.publishDBLayer(WORKSPACE, STORENAME, FTENCODER, layerEncoder);

you could try the configure the layer after the publish:

    String layerName = ...;
    String newStyleName = ...;
    GeoServerRESTPublisher publisher = ...;

    GSLayerEncoder le = new GSLayerEncoder();
    le.setDefaultStyle(newStyleName);
    publisher.configureLayer(le, layerName);

Cheers, Carlo Cancellieri

Ref:

  • https://github.com/geosolutions-it/geoserver-manager/wiki/Publishing-Layers-Advanced
  • https://github.com/geosolutions-it/geoserver-manager/blob/1.3.x/src/main/java/it/geosolutions/geoserver/rest/encoder/GSLayerEncoder.java#L126
like image 131
ccancellieri Avatar answered Jun 03 '26 21:06

ccancellieri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!