ScottFree
ScottFree

Reputation: 632

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!

Upvotes: 3

Views: 2464

Answers (1)

ccancellieri
ccancellieri

Reputation: 71

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:

Upvotes: 1

Related Questions