使用以下代码以编程方式使用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
谢谢!
答案 0 :(得分: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);
干杯, Carlo Cancellieri
价: