Node-red-contrib-turf: simplify, tranformRotate function => options object returns error 'options is invalid'

Hi,

Once again I got stuck :roll_eyes:
My initial try is to simplify a lineString with the turf-node. For some reason it won't accept my options I am giving in the payload array.
It returns the error 'options is invalid' and I can't figure out how to fix it.

My function-node to pass everything into turf-node:

var geojson = {
    "type":"FeatureCollection",
    "features":[
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "LineString",
        "coordinates": msg.payload.line
            // [0.1, 0.02],
            // [0.2, 0.03],
            // [0.3, 0.04],
            // [0.4, 0.04],
            // [0.5, 0.04],
            // [0.6, 0.04],
            // [0.6, 0.05],
            // [0.7, 0.06],
            // [0.8, 0.06],
            // [0.9, 0.06],
            // [0.12, 0.07],
            // [0.15, 0.08],
            // [0.15, 0.09],
            // [0.14, 0.2],
            // [0.16, 0.3],
            // [0.16, 0.4],
            // [0.17, 0.5],
            // [0.18, 0.5],
            // [0.19, 0.6],
        //     [0.19, 0.6]
        // ]
      }
    }
    ]
};
// var geojson=turf.line([[msg.payload.line]]);
var options={tolerance:1};
msg.payload=[geojson, options];
// msg.payload=[geojson];
return msg; 

This are my findings so far:
I found in @turf/turf (line 50) that the error is thrown when checking if the options are an object. For some reason that function (line 765) returns 'false'.

I tried another function (transformRotate) where options need to be given as an object and it gave me the same error.

If I pass the function without options, the function works. As far as I can tell, when no options, an empty object is given and after the object-check, default values are applied to the function (see @turf/turf lines 47-53).

Here is the flow of the other function I tried:

[
    {
        "id": "f08a6c2679cbbad8",
        "type": "function",
        "z": "488c966fd330b21d",
        "name": "",
        "func": "var geojson = {\n    \"type\":\"FeatureCollection\",\n    \"features\":[\n    {\n      \"type\": \"Feature\",\n      \"properties\": {},\n      \"geometry\": {\n        \"type\": \"LineString\",\n        \"coordinates\": [\n          [0,29],\n          [3.5,29],\n          [2.5,32],\n          [0,29]\n        ]\n      }\n    }\n    ]\n};\n\nvar options = {pivot: [0, 25]};\nvar turfcontext=[geojson, 60, options];\n//var turfcontext=[geojson, 60];\nvar turffunction = \"transformRotate\";\n\nmsg.topic=turffunction;\nmsg.payload=turfcontext;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1720,
        "y": 1640,
        "wires": [
            [
                "bda6969dc2774169",
                "70199edc46546716"
            ]
        ]
    },
    {
        "id": "bda6969dc2774169",
        "type": "debug",
        "z": "488c966fd330b21d",
        "name": "simpifyfunction",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1880,
        "y": 1580,
        "wires": []
    },
    {
        "id": "70199edc46546716",
        "type": "turf",
        "z": "488c966fd330b21d",
        "fn": "",
        "name": "",
        "x": 1890,
        "y": 1640,
        "wires": [
            [
                "d2b1d18b5fc9d603"
            ]
        ]
    },
    {
        "id": "1175fe8e598c32f3",
        "type": "inject",
        "z": "488c966fd330b21d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 1540,
        "y": 1640,
        "wires": [
            [
                "f08a6c2679cbbad8"
            ]
        ]
    },
    {
        "id": "d2b1d18b5fc9d603",
        "type": "debug",
        "z": "488c966fd330b21d",
        "name": "simplify2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2040,
        "y": 1660,
        "wires": []
    }
]

If anyone could point me in the right direction to get this working... :blush:

Thanks in advance,

node-RED v2.2.2
nodejs v12.22.9

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.