+ // only a simple check\r
+ var minx = 200;\r
+ var maxx = 0;\r
+ var miny = 200;\r
+ var maxy = 0;\r
+ var error = 0;\r
+ for(var i = 0; i < polygon.array.length; i++){\r
+ if(polygon.array[i].x < minx){\r
+ minx = polygon.array[i].x;\r
+ }\r
+ if(polygon.array[i].x > maxx){\r
+ maxx = polygon.array[i].x;\r
+ }\r
+ if(polygon.array[i].y < miny){\r
+ miny = polygon.array[i].y;\r
+ }\r
+ if(polygon.array[i].y > maxy){\r
+ maxy = polygon.array[i].y;\r
+ }\r
+ if(isNaN(polygon.array[i].x) || isNaN(polygon.array[i].y)){\r
+ error++;\r
+ }\r
+ }\r
+ if(error == 0 && minx != maxx && miny != maxy && polygon.array.length >= 3){\r
+ var newArray = new Array();\r
+ newArray.push(polygon.array.shift());\r
+ while(polygon.array.length != 0){\r
+ var temp = polygon.array.shift();\r
+ if(newArray[newArray.length - 1].x != temp.x ||\r
+ newArray[newArray.length - 1].y != temp.y){\r
+ newArray.push(temp);\r
+ }\r
+ }\r
+ if(newArray.length >= 3){\r
+ polygon.array = newArray;\r
+ this.array.push(polygon);\r
+ }\r
+ }\r