首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gwt-openlayers在PostGIS中保存修改过的对象

gwt-openlayers在PostGIS中保存修改过的对象
EN

Stack Overflow用户
提问于 2015-08-07 19:08:57
回答 1查看 117关注 0票数 1

我是使用gwt-openlayer的新手。我尝试在PostGIS DB中修改几何图形。我可以在UI中修改它,但我不能保存修改后的几何图形。下面是我要编辑和保存的代码:

代码语言:javascript
复制
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();
}
EN

回答 1

Stack Overflow用户

发布于 2015-08-28 13:36:45

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

现在一切都正常了!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31876277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档