获取 GML 选项错误

Get error on GML options

我正在尝试创建 wfs-t 服务我使用了 ol.format.WFS#writeTransaction 方法并序列化了 WFS-t XML 但我的 jslint 总是在 GML 格式选项中预览错误。有没有可能是我初始化 ol.format.WFS 对象不正确?

或者我向 writeTransaction 方法传递了错误的选项?或者这可能是 OpenLayers4 中的错误?使用 angular http 服务的我的 wfs-t 服务的详细信息:

private _transactWFS(feature: any, operation: any): any {

    let payload;

    try {
        const formatWFS = new ol.format.WFS({});
        const formatGML = new ol.format.GML({
            featureNS: operation.featureNS,
            featureType: operation.featureType,
            srsName: operation.srsName
        });
        const xs = new XMLSerializer();
        let node: any = null;
        switch (operation.mode) {
            case 'insert':
                node = formatWFS.writeTransaction([feature], null, null, formatGML);
                break;
            case 'update':
                node = formatWFS.writeTransaction(null, [feature], null, formatGML);
                break;
            case 'delete':
                node = formatWFS.writeTransaction(null, null, [feature], formatGML);
                break;
        }

        payload = xs.serializeToString(node);
    } catch (error) {}

    return payload;
}

lint 消息:

 [ts]
Argument of type 'GML' is not assignable to parameter of type 'WFSWriteTransactionOptions'.
Property 'featureNS' is missing in type 'GML'.

来自OpenLayers WFS-T example

        // Word to the Wise from an anonymous OpenLayers hacker:
        //             
        // The typename in the options list when adding/loading a wfs 
        // layer not should contain the namespace before, (as in the 
        // first typename parameter to the wfs consctructor).
        // 
        // Specifically, in the first parameter you write typename: 
        // 'topp:myLayerName', and in the following option list 
        // typeName: 'myLayerName'. 
        // 
        // If you have topp included in the second one you will get 
        // namespace 14 errors when trying to insert features.
        //
        wfs = new OpenLayers.Layer.WFS(
            "Cities",
            "http://sigma.openplans.org/geoserver/wfs",
            {typename: 'topp:tasmania_cities'},
            {
                typename: "tasmania_cities",
                featureNS: "http://www.openplans.org/topp",
                extractAttributes: false,
                commitReport: function(str) {
                    OpenLayers.Console.log(str);
                }
            }
        );

似乎表明您构建的 WFS 对象有误。

我放弃使用 WFS 格式来构建 WFS 事务请求,所以我的问题自己解决了,我找到了这个库 geojson-to-wfs-t-2。这个库非常适合解决我的问题。