使用以下代码通过geoserver-manager api(http://code.google.com/p/geoserver-manager/wiki/Documentation)以编程方式创建新图层时:

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);


新图层创建成功,但是类型错误(指向非直线)。在创建图层之前或之后,是否可以更改此图层类型(以线为单位)?

版本:
地理服务器2.3.0
Postgres 1.14
Geoserver-manager 1.3.0

谢谢!

最佳答案

2种方式:
您必须使用图层编码器来配置默认图层:

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

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


您可以在发布后尝试配置图层:

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

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


干杯,
卡洛·坎克里里里(Carlo Cancellieri)

参考:


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

关于java - 地理服务器管理器,添加新层,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15573984/

10-11 23:28