Получить ошибку в опциях GML - PullRequest
0 голосов
/ 24 апреля 2018

Я пытаюсь создать сервис wfs-t. Я использовал метод ol.format.WFS # writeTransaction и сериализовал WFS-t XML, но мой jslint всегда просматривал ошибку в опциях формата GML. Возможно ли, что я инициализирую объект ol.format.WFS неправильно?

Или, возможно, я передаю неправильные параметры методу writeTransaction? Или, может быть, это ошибка в OpenLayers4? эта деталь моего сервиса wfs-t, использующего угловой сервис http:

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;
}

сообщение ворса:

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

Ответы [ 2 ]

0 голосов
/ 26 апреля 2018

Я отказался от использования формата WFS для сборки запроса на транзакцию WFS, поэтому моя проблема была решена самостоятельно, я обнаружил этот lib geojson-to-wfs-t-2 . Эта библиотека очень легитимна для решения моей проблемы.

0 голосов
/ 26 апреля 2018

Из примера OpenLayers WFS-T :

        // 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.

...