multithread.js icon indicating copy to clipboard operation
multithread.js copied to clipboard

Help processing data

Open SacrilegeTx opened this issue 8 years ago • 0 comments

Hi, first off Ima newbie in this topic of multithreading with javascript.

Problem:

I need evaluate coords from array, so when I'm doing it the thread only takes first value of each array and dunno why.

Click here to view the image

There is a way to evaluate each value from each array?

Am I doing wrong something?

Hope help me, many thanks.

(Sorry for my english)

Code:

$.each(json, MT.process( function (i, row) { // Coordenadas X var xcoor = row.xcoor;

                if (xcoor.indexOf('=') !== -1)
                    xcoor = xcoor.split("=")[1];

                xcoor = xcoor.replace("{", "").replace("}", "");
                var xcoor_array = xcoor.split(',');

                // Coordenadas Y
                var ycoor = row.ycoor;

                if (ycoor.indexOf('=') !== -1)
                    ycoor = ycoor.split("=")[1];

                ycoor = ycoor.replace("{", "").replace("}", "");
                var ycoor_array = ycoor.split(',');

                // Coordenadas Z
                var zcoor = row.zcoor;

                if (zcoor.indexOf('=') !== -1)
                    zcoor = zcoor.split("=")[1];

                zcoor = zcoor.replace("{", "").replace("}", "");
                var zcoor_array = zcoor.split(',');

                // LANTA - A
                console.log('Length:', xcoor_array.length, 'Array X:', xcoor_array);
                for (var i = 0; i < xcoor_array.length; i++) {
                    if (xcoor_array[i] != "NULL" || xcoor_array[i] != 0) {
                        if (ycoor_array[i] != "NULL" || ycoor_array[i] != 0) {
                            error = 0;
                            ispolygon = true;

                            point = {
                                x: parseFloat(xcoor_array[i] / 100),
                                y: parseFloat(ycoor_array[i] / 100),
                                z: parseFloat(zcoor_array[i] / 100),
                                equipo: row.equipo
                            };

                            return point;
                        }
                    }
                }
            },
            function (r) {
                console.log("x: ", r.x, "y: ", r.y, "inside: ", isPointInPolygon(polygon, point = {x: r.x, y: r.y}));
            }
        )
    );

SacrilegeTx avatar Feb 28 '17 22:02 SacrilegeTx