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

**URL:** <https://discourse.nodered.org/t/node-red-contrib-turf-simplify-tranformrotate-function-options-object-returns-error-options-is-invalid/58934>\
**Category:** General\
**Created:** [24 February 2022 15:00 UTC](https://discourse.nodered.org/t/node-red-contrib-turf-simplify-tranformrotate-function-options-object-returns-error-options-is-invalid/58934 "2022-02-24T15:00:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Razio](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/razio/32/52407_2.png) [@Razio](https://discourse.nodered.org/u/Razio)\
**Post date:** [24 February 2022 15:00 UTC](https://discourse.nodered.org/t/node-red-contrib-turf-simplify-tranformrotate-function-options-object-returns-error-options-is-invalid/58934/1 "2022-02-24T15:00:26Z")

</div>

Hi,

Once again I got stuck 🙄  
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:

```auto
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)](https://github.com/Turfjs/turf/blob/master/packages/turf-simplify/index.js) that the error is thrown when checking if the options are an object. For some reason that [function (line 765)](https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/index.ts) 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](https://github.com/Turfjs/turf/blob/master/packages/turf-simplify/index.js)).

Here is the flow of the other function I tried:

```auto
[
    {
        "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... 😊

Thanks in advance,

node-RED v2.2.2  
nodejs v12.22.9

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 April 2022 15:00 UTC](https://discourse.nodered.org/t/node-red-contrib-turf-simplify-tranformrotate-function-options-object-returns-error-options-is-invalid/58934/2 "2022-04-25T15:00:51Z")

</div>

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