【问题标题】:gwt-openlayers - save modified object in PostGISgwt-openlayers - 在 PostGIS 中保存修改后的对象
【发布时间】: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


【解决方案1】:

解决了!问题是连接到几何名称。在 postgis 中,默认名称是“the-geom”,在我的例子中,名称是“geom”。我忘记在 WfsProtocolOptions 中指定它: wfsProtocolOptions.setGeometryName("geom");

现在一切正常!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 1970-01-01
    • 2011-10-22
    • 1970-01-01
    • 2018-12-11
    • 2013-08-13
    相关资源
    最近更新 更多