3

使用以下代码以编程方式使用 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);

新图层已成功创建,但类型错误(点而不是线)。有没有办法在创建图层之前或之后更改此图层类型(线)?

版本: Geoserver 2.3.0 Postgres 1.14 Geoserver-manager 1.3.0

谢谢!

4

1 回答 1

1

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

干杯,卡洛·坎切列里

参考:

于 2013-12-11T14:28:41.750 回答