【发布时间】:2015-08-07 11:08:57
【问题描述】:
我是使用 gwt-openlayers 的新手。我尝试修改 PostGIS DB 中的几何图形。我可以在 UI 中修改它,但我无法保存修改后的几何图形。 这是我要编辑和保存的代码:
private void saveFeature(WFSProtocol wfsProtocol, Vector wfsLayer, SaveStrategy saveStrategy) {
Callback callbackSave = new Callback()
{
public void computeResponse(Response response)
{
System.out.println("Saved: " + response.getRequestType());
}
};
saveStrategy.save();
WFSProtocolCRUDOptions saveOptions = new WFSProtocolCRUDOptions(callbackSave);
wfsProtocol.commit(wfsLayer.getFeatures(), saveOptions);
}
private void editableLayer(Vector wfsLayer, Map map, VectorOptions vectorOptions, SaveStrategy saveStrategy) {
//Create some styles for the wfs
final Style normalStyle = new Style(); //the normal style
normalStyle.setStrokeWidth(3);
normalStyle.setStrokeColor("#FF0000");
normalStyle.setFillColor("#FFFF00");
normalStyle.setFillOpacity(0.8);
normalStyle.setStrokeOpacity(0.8);
final Style selectedStyle = new Style(); //the style when a feature is selected, or temporaly selected
selectedStyle.setStrokeWidth(3);
selectedStyle.setStrokeColor("#FFFF00");
selectedStyle.setFillColor("#FF0000");
selectedStyle.setFillOpacity(0.8);
selectedStyle.setStrokeOpacity(0.8);
final StyleMap styleMap = new StyleMap(normalStyle, selectedStyle,
selectedStyle);
wfsLayer.setStyleMap(styleMap);
//Create a ModifyFeature control that enables WFS modification
final ModifyFeatureOptions modifyFeatureControlOptions = new ModifyFeatureOptions();
modifyFeatureControlOptions.setMode(ModifyFeature.RESHAPE); //options are RESHAPE, RESIZE, ROTATE and DRAG
final ModifyFeature modifyFeatureControl = new ModifyFeature(wfsLayer,
modifyFeatureControlOptions);
map.addControl(modifyFeatureControl);
modifyFeatureControl.activate();
saveStrategy.activate();
}
【问题讨论】:
-
对不起,问题是连接到几何名称。 postgis 的默认名称是“the-geom”,但在我的例子中,名称是“geom”。
标签: openlayers