gwt openlayers-在PostGIS中保存修改的对象
我刚刚使用gwt openlayers。我尝试在PostGIS DB中修改几何体。我可以在UI中修改它,但无法保存修改后的几何体。 以下是我要编辑和保存的代码:gwt openlayers-在PostGIS中保存修改的对象,openlayers,Openlayers,我刚刚使用gwt openlayers。我尝试在PostGIS DB中修改几何体。我可以在UI中修改它,但无法保存修改后的几何体。 以下是我要编辑和保存的代码: private void saveFeature(WFSProtocol wfsProtocol, Vector wfsLayer, SaveStrategy saveStrategy) { Callback callbackSave = new Callback() { public void comp
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中,默认名称是“geom”,在我的例子中,默认名称是“geom”。我忘了在WfsProtocolOptions中指定它: wfsProtocolOptions.setGeometryName(“geom”)
现在一切都好了 解决了!问题是连接到几何体名称。在postgis中,默认名称是“geom”,在我的例子中,默认名称是“geom”。我忘了在WfsProtocolOptions中指定它: wfsProtocolOptions.setGeometryName(“geom”)
现在一切都好了 很抱歉,问题是连接到几何体名称。postgis的默认名称是“geom”,但在我的例子中,名称是“geom”。很抱歉,问题是连接到几何体名称。postgis的默认名称是“geom”,但在我的例子中,名称是“geom”。