# How can I calculate the direction of a Google Maps polygon?

To create a hole in a polygon, you need to know if the inner polygon is in the opposite direction as the outer polygon (See here). How can I calculate this?

Here are some examples:

``````var triangleCoords1 = [
];
var triangleCoords2 = [

];
``````

or

``````var triangleCoords1 = [
];
var triangleCoords2 = [
];
``````

Note that these are just simple sample data. In reality, the polygons are much more complex. Like these:

``````var triangleCoords1 = [ [51.661322,6.509532600000057],[51.6618949,6.525535499999933],[51.6578484,6.590423500000043],[51.651778,6.6008948999999575],[51.6349357,6.600645200000031],[51.6345467,6.600138199999947],[51.629793,6.592814399999952],[51.6294074,6.592274699999962],[51.6268338,6.5895127],[51.6258968,6.588799300000005],[51.6234652,6.587523799999985],[51.6226498,6.587264199999936],[51.6193635,6.586994900000036],[51.6192657,6.584578100000044],[51.6182549,6.580674600000066],[51.6181604,6.580463499999951],[51.6176314,6.5793599999999515],[51.6175771,6.579162399999973],[51.6193684,6.578483600000027],[51.6194058,6.578383700000018],[51.6222868,6.577949799999942],[51.6226648,6.577693899999986],[51.6244503,6.575930200000016],[51.6246904,6.5757138999999825],[51.6191416,6.564902800000027],[51.617651,6.56278199999997],[51.617562,6.558956299999977],[51.6175854,6.558838899999955],[51.6189315,6.556704699999955],[51.6189811,6.556685799999968],[51.6191585,6.556225300000051],[51.6196586,6.554898999999978],[51.6179542,6.55393319999996],[51.6173398,6.55183599999998],[51.6165964,6.550559000000021],[51.6163669,6.549834199999964],[51.6141495,6.545811700000058],[51.6134925,6.54512479999994],[51.6114592,6.544230800000037],[51.6110868,6.5441946999999345],[51.6074407,6.5440607000000455],[51.6064844,6.544578300000012],[51.6054301,6.545319800000016],[51.6051288,6.546006000000034],[51.6032773,6.547108200000025],[51.6026895,6.547217100000012],[51.6016823,6.547769799999969],[51.6006062,6.548094799999944],[51.5999099,6.548602800000026],[51.5996305,6.548859399999969],[51.5990067,6.549258000000009],[51.598649,6.549597800000015],[51.596676,6.550768599999969],[51.5965885,6.550463100000002],[51.596523,6.550356400000055],[51.5960218,6.54985529999999],[51.5953549,6.549318099999937],[51.5947623,6.549142599999982],[51.5940037,6.548798099999999],[51.5935703,6.54843679999999],[51.5934588,6.548390299999937],[51.5930553,6.548123600000054],[51.5927726,6.548138699999981],[51.5925535,6.548083099999985],[51.5920583,6.548109699999941],[51.5918034,6.547992600000043],[51.5913186,6.547949700000004],[51.5906513,6.548035199999958],[51.5900026,6.5482511999999815],[51.5899033,6.548209700000029],[51.5871402,6.549558499999989],[51.5861133,6.550508000000036],[51.5858786,6.550786700000003],[51.5844951,6.551661500000023],[51.581237,6.555090000000064],[51.5802854,6.5564355000000205],[51.5797865,6.557418200000029],[51.5797701,6.5575244999999995],[51.5794238,6.559493999999972],[51.5790657,6.55935850000003],[51.5788895,6.559340900000052],[51.5786658,6.559269599999993],[51.5778078,6.561854100000005],[51.5773483,6.561344299999973],[51.5749365,6.5610781000000316],[51.5746673,6.560778099999993],[51.5749468,6.560056499999973],[51.5752343,6.559466199999974],[51.5716045,6.5505031000000145],[51.571875,6.550269699999944],[51.5715501,6.549397699999986],[51.5713659,6.549561799999992],[51.5689597,6.545628099999931],[51.5689756,6.54522929999996],[51.5663552,6.541035299999976],[51.565764,6.541925399999968],[51.5639695,6.539055500000018],[51.5639568,6.538888100000008],[51.5631655,6.536805299999969],[51.5627882,6.536939500000017],[51.5618604,6.537067500000035],[51.5608473,6.536908700000026],[51.5602288,6.536736399999995],[51.5596457,6.536166099999946],[51.5586129,6.535165000000006],[51.5579414,6.534663499999965],[51.5576385,6.534462800000028],[51.5573645,6.534199199999989],[51.5565067,6.533634099999972],[51.5559882,6.533587600000033],[51.5554003,6.533512100000053],[51.55502,6.533547799999951],[51.5549221,6.533522700000049],[51.5548234,6.5332281999999395],[51.5549331,6.532643900000039],[51.5550115,6.532387299999982],[51.5553028,6.53175269999997],[51.5553422,6.5311724000000595],[51.5564808,6.526574900000014],[51.5563015,6.525462500000003],[51.5558965,6.523728799999958],[51.5550913,6.521744799999965],[51.5550376,6.521677700000055],[51.5549829,6.521650700000009],[51.5559657,6.519948699999986],[51.5562833,6.519753100000003],[51.5566299,6.519610999999941],[51.5570046,6.5195865000000595],[51.5590707,6.519679900000028],[51.5597038,6.51978280000003],[51.5599593,6.519669300000032],[51.5613695,6.51855409999996],[51.5635614,6.516150700000026],[51.5648021,6.514666900000066],[51.5648283,6.51337030000002],[51.564876,6.512939700000061],[51.5651288,6.511698000000024],[51.564008,6.5094870000000356],[51.5626481,6.50419450000004],[51.5681317,6.497717400000056],[51.5508858,6.4646840999999995],[51.5473152,6.471200700000054],[51.5441068,6.476797799999986],[51.5384097,6.487065799999982],[51.5279216,6.478110900000047],[51.527688,6.477755600000023],[51.5276275,6.47738419999996],[51.5275824,6.476509999999962],[51.5272347,6.475534400000015],[51.5271734,6.474341900000013],[51.524853,6.476555400000052],[51.5243641,6.477133600000002],[51.5225486,6.479076200000009],[51.5218016,6.480385000000069],[51.5212424,6.4796020999999655],[51.5211054,6.479334800000061],[51.5214913,6.472383900000068],[51.5215445,6.472064899999964],[51.5215259,6.470843500000001],[51.5214275,6.469646399999988],[51.5215238,6.469612099999949],[51.5214906,6.46943060000001],[51.5215457,6.469381999999996],[51.5217918,6.469560199999933],[51.521915,6.469578100000035],[51.5220243,6.469491699999935],[51.5227252,6.468242400000008],[51.5230533,6.467461400000047],[51.5235254,6.466585399999985],[51.5237552,6.466348499999981],[51.5242212,6.46572470000001],[51.5244982,6.465238399999976],[51.5246263,6.464943299999959],[51.5246614,6.46467389999998],[51.5246347,6.46393779999994],[51.524255,6.462402300000008],[51.5250169,6.462094900000011],[51.5270782,6.461115199999995],[51.5271467,6.461122199999977],[51.5273807,6.457817299999988],[51.5277743,6.457945300000006],[51.5295191,6.455281900000045],[51.5295007,6.454982800000039],[51.529301,6.448412899999994],[51.5287294,6.448517100000004],[51.5286176,6.448596500000008],[51.5286115,6.448513600000069],[51.5285103,6.448533099999963],[51.5279312,6.448839799999973],[51.5278663,6.448904699999957],[51.5275975,6.449450999999954],[51.5273837,6.44976029999998],[51.5269218,6.4499038000000155],[51.526853,6.450105000000008],[51.5256932,6.452515400000038],[51.5255683,6.45269380000002],[51.5242874,6.453314299999988],[51.5229793,6.453346499999952],[51.5211932,6.4515444999999545],[51.5201394,6.449092899999982],[51.5128646,6.455479100000048],[51.5113287,6.45447809999996],[51.5110581,6.454364199999986],[51.5104023,6.454359699999941],[51.5100492,6.454385499999944],[51.5092252,6.454351699999961],[51.5087745,6.454508400000009],[51.5081592,6.454892299999983],[51.5079162,6.455113500000039],[51.5078156,6.455205100000057],[51.5077354,6.455318700000021],[51.5077158,6.455346500000019],[51.5076502,6.455506000000014],[51.5076281,6.455599600000028],[51.5075888,6.45576589999996],[51.5074444,6.4563772999999856],[51.5074263,6.456500199999937],[51.5073982,6.4566327],[51.5069188,6.4592817000000196],[51.5068183,6.4598369000000275],[51.5066152,6.460380200000031],[51.5063345,6.461131199999954],[51.5031169,6.464354800000024],[51.5029543,6.464207999999985],[51.5028828,6.464209100000062],[51.5025375,6.4643241999999645],[51.5022057,6.464401899999984],[51.5016865,6.464632400000028],[51.5006801,6.465535700000032],[51.4992925,6.466653599999972],[51.4982296,6.46768910000003],[51.4977761,6.468340399999988],[51.4971695,6.469109800000069],[51.4966844,6.469872699999996],[51.496275,6.470757300000059],[51.4961634,6.471145299999989],[51.495804,6.471982400000002],[51.4954732,6.472964300000058],[51.4952651,6.473362400000042],[51.4951484,6.473476600000026],[51.4948695,6.473576600000001],[51.4946087,6.473670200000015],[51.4927837,6.473782300000039],[51.4927557,6.474021499999935],[51.4913841,6.473849200000018],[51.4907417,6.473695099999986],[51.49074,6.473720899999989],[51.4906101,6.473752399999967],[51.4741379,6.4437041999999565],[51.4728892,6.443831100000011],[51.4726679,6.438197500000001],[51.4722253,6.438095999999973],[51.4722139,6.435641799999985],[51.4721937,6.431295099999943],[51.4700123,6.430838300000005],[51.4681539,6.430767699999933],[51.4681723,6.43056619999993],[51.4688095,6.423595699999964],[51.4679516,6.423608699999932],[51.4676197,6.420724299999961],[51.4665271,6.419503299999974],[51.4665524,6.418671000000018],[51.4677665,6.418366399999968],[51.4677665,6.417797999999948],[51.4817091,6.392397599999981],[51.4817522,6.392386600000009],[51.4816708,6.392279199999962],[51.4816638,6.392198900000039],[51.4817848,6.392313100000024],[51.481752,6.392214999999965],[51.4818288,6.391041800000039],[51.4820068,6.388327900000036],[51.4820092,6.387287199999946],[51.4827758,6.385434499999974],[51.483083,6.383815899999945],[51.483076,6.383594099999982],[51.484891,6.373807800000009],[51.484944,6.373763000000054],[51.484666,6.37361820000001],[51.4845328,6.373557500000061],[51.4845009,6.373390299999983],[51.4838834,6.371181100000058],[51.4839268,6.370099100000061],[51.4842344,6.369552300000009],[51.4878933,6.347755399999983],[51.487968,6.346222699999998],[51.4880188,6.3451069999999845],[51.488121,6.343555899999956],[51.4882198,6.343182299999967],[51.4899067,6.341225399999985],[51.4906133,6.340075599999977],[51.4908201,6.339559699999995],[51.4907588,6.339552499999968],[51.4905003,6.339842800000042],[51.4903811,6.339756299999976],[51.4899999,6.338832700000012],[51.4896198,6.3376402999999755],[51.4893269,6.335456300000033],[51.4893115,6.335237399999983],[51.489279,6.3352577000000565],[51.4892973,6.335151999999994],[51.4891456,6.3341245999999956],[51.489127,6.33361339999999],[51.4890938,6.333621600000015],[51.4890453,6.33210859999997],[51.4890683,6.332021499999996],[51.4873254,6.315289699999994],[51.4871451,6.314295500000071],[51.4837709,6.316027100000042],[51.4835182,6.316134299999931],[51.4829839,6.316162599999984],[51.4824604,6.31614060000004],[51.4817769,6.316103300000009],[51.4817933,6.3151940000000195],[51.4814432,6.31124299999999],[51.4809349,6.305565500000057],[51.4807235,6.30554010000003],[51.4805764,6.303845000000024],[51.4801053,6.303812300000004],[51.4801043,6.30377139999996],[51.4801289,6.303769699999975],[51.4805212,6.301567299999988],[51.481101,6.2990294999999605],[51.481171,6.298975499999983],[51.4716824,6.301354100000026],[51.4714096,6.301101099999983],[51.4712598,6.300854999999956],[51.4712296,6.300529800000049],[51.4709383,6.300215299999991],[51.4707859,6.299766399999953],[51.4707228,6.299672600000008],[51.4703238,6.2995167000000265],[51.4702752,6.299450200000024],[51.4701805,6.299072000000024],[51.4699618,6.298905999999988],[51.4699207,6.298591200000033],[51.4697567,6.296979299999975],[51.4697732,6.296967900000027],[51.4698773,6.296686200000067],[51.4697709,6.296186700000021],[51.4696456,6.295174900000006],[51.4694832,6.2932557000000315],[51.4694815,6.292258400000037],[51.4694623,6.292174199999977],[51.4691864,6.289648199999988],[51.4690115,6.2879394000000275],[51.4673117,6.287028200000009],[51.4671314,6.286930999999981],[51.4671504,6.28689159999999],[51.467601,6.2858870000000024],[51.4682733,6.284132600000021],[51.4683494,6.2838586000000305],[51.4845671,6.256817400000045],[51.4849637,6.255995100000064],[51.4857026,6.254321900000036],[51.4856794,6.254220099999998],[51.4857129,6.254150900000013],[51.4862761,6.253229499999975],[51.4866456,6.252576599999998],[51.486845,6.252318500000001],[51.4873644,6.251404900000011],[51.4874695,6.251248499999974],[51.4874959,6.2512819999999465],[51.4877957,6.250526100000002],[51.4879966,6.250173600000039],[51.4881033,6.249900499999967],[51.4883212,6.249155900000005],[51.4883877,6.248329099999978],[51.4880662,6.246559100000013],[51.4879984,6.246383000000037],[51.4879004,6.246241800000007],[51.487355,6.245810500000061],[51.4869006,6.24479759999997],[51.4870459,6.244608900000003],[51.4871618,6.244514600000002],[51.4870922,6.244179400000007],[51.4870041,6.244028000000071],[51.4864662,6.243588600000066],[51.4857273,6.242713299999991],[51.4849435,6.240284400000064],[51.4846559,6.239661299999966],[51.4846065,6.23950990000003],[51.4845709,6.2395371999999725],[51.4842184,6.238750200000027],[51.483863,6.238271199999986],[51.4836452,6.237588200000005],[51.4832487,6.235746899999981],[51.4834673,6.235736399999951],[51.4832814,6.232603100000006],[51.4834389,6.230979199999979],[51.4874061,6.215885100000037],[51.4878448,6.21554070000002],[51.487867,6.215523100000041],[51.4879548,6.215454200000067],[51.4879646,6.215446400000019],[51.4879938,6.215423500000043],[51.4880049,6.215414799999962],[51.4893923,6.214325099999996],[51.4906233,6.213321899999983],[51.4913082,6.212763699999982],[51.4915824,6.212791400000015],[51.4917466,6.2128079999999954],[51.4924475,6.212797599999931],[51.4932564,6.212786400000027],[51.4932775,6.212787400000025],[51.4933474,6.212790600000062],[51.4935017,6.212797799999976],[51.4951231,6.213096599999972],[51.4955765,6.213199300000042],[51.4963894,6.213338000000022],[51.4977774,6.21357409999996],[51.4985131,6.21370079999997],[51.4987774,6.213746300000025],[51.4990815,6.213798600000018],[51.4992191,6.213822299999947],[51.4993026,6.213702699999999],[51.5010338,6.2139386999999715],[51.5029126,6.214194899999939],[51.5032905,6.2141010999999935],[51.5044809,6.213804699999969],[51.504583,6.213791399999991],[51.5046459,6.21378279999999],[51.5055609,6.213661199999933],[51.5059817,6.213605199999961],[51.5061901,6.213577500000042],[51.5067655,6.2135008999999854],[51.5068736,6.2134865000000445],[51.5078177,6.213361299999974],[51.5088009,6.213219200000026],[51.5088288,6.21321510000007],[51.5097308,6.213081699999975],[51.509787,6.2130732000000535],[51.5203762,6.206512800000041],[51.5215935,6.205369099999984],[51.5223728,6.204638100000011],[51.5231995,6.203859599999987],[51.5238855,6.203221900000017],[51.5239576,6.203154400000017],[51.5245247,6.202620400000001],[51.525008,6.2021608000000015],[51.5252574,6.201924500000018],[51.5254494,6.2017468000000235],[51.5256302,6.201574700000037],[51.5256489,6.201557200000025],[51.526159,6.201082100000008],[51.5266508,6.200616699999955],[51.5266685,6.200601099999972],[51.5267092,6.2005633999999645],[51.5267605,6.200518099999954],[51.5268414,6.2004415999999765],[51.5273814,6.199928999999997],[51.5277446,6.199291899999935],[51.5279264,6.198971000000029],[51.5281745,6.198523499999965],[51.528443,6.198045699999966],[51.5286273,6.197716000000014],[51.5287946,6.197425399999929],[51.5288227,6.197374399999944],[51.5290119,6.197031299999935],[51.5292073,6.196686099999965],[51.5292149,6.19667179999999],[51.5292411,6.196620800000005],[51.5292728,6.1965629000000035],[51.5300916,6.194933200000037],[51.5301657,6.194784600000048],[51.5302916,6.194528900000023],[51.5303047,6.194510900000068],[51.5303663,6.194384200000059],[51.5311388,6.192943700000001],[51.5311778,6.192857000000004],[51.5391871,6.176454599999943],[51.5393578,6.176333800000066],[51.5398401,6.175992500000007],[51.5404955,6.175533200000018],[51.5405556,6.175483999999983],[51.5415992,6.174751900000047],[51.5427157,6.173956999999973],[51.5428193,6.173885799999994],[51.5449175,6.172396800000001],[51.5460139,6.171621899999991],[51.5480079,6.170206099999973],[51.5503276,6.168561899999986],[51.5503568,6.168532199999959],[51.5504318,6.168481799999995],[51.5504664,6.168466599999988],[51.5527693,6.16682650000007],[51.5554402,6.1649274000000105],[51.5554877,6.16488789999994],[51.5558814,6.164617599999929],[51.5564394,6.164224600000011],[51.5937911,6.1174588000000085],[51.5938475,6.117084699999964],[51.595259,6.114075800000023],[51.5963194,6.111807499999941],[51.5972951,6.109720899999957],[51.5984708,6.107201400000008],[51.6001095,6.103650000000016],[51.6006319,6.102643100000023],[51.6016204,6.100513999999976],[51.6026083,6.098381900000049],[51.6028143,6.09795639999993],[51.603073,6.097418199999993],[51.6030941,6.097368999999958],[51.6032461,6.097035399999982],[51.6036464,6.09617060000005],[51.6039341,6.09555869999997],[51.6041332,6.095132199999966],[51.6043069,6.094754400000056],[51.6045055,6.094324499999971],[51.604929,6.093418100000008],[51.6053218,6.09257290000005],[51.605686,6.091785999999956],[51.6058486,6.091423899999995],[51.6059361,6.091387499999996],[51.6059946,6.09139909999999],[51.6060444,6.09142010000005],[51.6061934,6.091475299999956],[51.6065141,6.091591600000015],[51.6067595,6.091680200000042],[51.6069351,6.091742699999941],[51.6070553,6.091778999999974],[51.6073006,6.09184730000004],[51.6076463,6.091943799999967],[51.6079044,6.092011200000002],[51.6195644,6.117839600000025],[51.618972,6.1191590999999335],[51.6363255,6.135785800000008],[51.634952,6.138445300000058],[51.6368665,6.140075400000001],[51.6377759,6.140785700000038],[51.6384548,6.14134839999997],[51.638291,6.142586800000004],[51.6413274,6.144759000000022],[51.6412761,6.14688000000001],[51.6412518,6.14788539999995],[51.6419951,6.147743300000002],[51.6432297,6.148291400000062],[51.6440864,6.149265900000046],[51.6445399,6.15111330000002],[51.646883,6.155559199999971],[51.6482939,6.157345699999951],[51.649818,6.1572442000000365],[51.6507879,6.1567569999999705],[51.6517452,6.155559199999971],[51.6524254,6.15196590000005],[51.6547807,6.152554699999996],[51.6546547,6.156939700000066],[51.6557253,6.156371300000046],[51.6557315,6.156425799999965],[51.6560401,6.159132199999931],[51.6780965,6.192413299999998],[51.6781875,6.194611699999996],[51.6782383,6.1948350999999775],[51.6777675,6.194937500000037],[51.6773112,6.195216599999981],[51.6776574,6.198794700000008],[51.6775813,6.199214600000005],[51.6765402,6.204961200000071],[51.6776102,6.205950900000062],[51.6760681,6.211178399999994],[51.6754628,6.211919800000032],[51.6756944,6.212082199999941],[51.6772749,6.211380299999973],[51.6777287,6.211578700000018],[51.6793199,6.21300789999998],[51.6817166,6.218221299999982],[51.6837205,6.220056500000055],[51.6852611,6.222833700000024],[51.6891375,6.225984499999981],[51.6913524,6.226780299999973],[51.6937183,6.22933009999997],[51.6948156,6.229135199999973],[51.696074,6.2263418],[51.6991341,6.225204899999994],[51.7011876,6.226780299999973],[51.7012436,6.227090900000007],[51.6955918,6.303976700000021],[51.6953893,6.306556900000032],[51.6975984,6.3087361999999985],[51.7014741,6.311116800000036],[51.7014284,6.311216800000011],[51.698226,6.3165434000000005],[51.6970772,6.314836199999945],[51.6954831,6.317568800000004],[51.6953679,6.317415100000062],[51.695113,6.317172300000038],[51.6948159,6.316992600000049],[51.694186,6.316959300000008],[51.6940859,6.316917800000056],[51.6933663,6.316992499999969],[51.6933016,6.317296299999953],[51.6924547,6.316883299999972],[51.6922677,6.316796199999999],[51.6921459,6.316742500000032],[51.6915857,6.316506000000004],[51.6911299,6.316188000000011],[51.6906682,6.315848200000005],[51.6905192,6.315740099999971],[51.6905051,6.319708399999968],[51.6889539,6.31960939999999],[51.688951,6.3197267000000465],[51.6889549,6.319872000000032],[51.6892017,6.324479399999973],[51.6893916,6.3245357000000695],[51.6895291,6.32599289999996],[51.6895183,6.326145799999949],[51.6895707,6.326166999999941],[51.6895585,6.326264900000069],[51.6895514,6.326264499999979],[51.6895151,6.326530100000014],[51.6894755,6.326877100000047],[51.6894113,6.327290700000049],[51.689372,6.327571199999966],[51.6892685,6.328447500000038],[51.6892504,6.328438699999992],[51.6891792,6.3289568000000145],[51.6892014,6.3289689000000635],[51.6890924,6.329593400000022],[51.6888174,6.331610500000011],[51.6879426,6.33881539999993],[51.6872332,6.343227500000012],[51.6873119,6.343327799999997],[51.6874117,6.343420000000037],[51.6877108,6.343936399999961],[51.688123,6.3445901999999705],[51.6882018,6.344652900000028],[51.6882393,6.3447651999999835],[51.6884812,6.345161500000017],[51.688591,6.345326399999976],[51.6892203,6.345710300000064],[51.690397,6.346222300000022],[51.6903062,6.346816900000022],[51.6903415,6.346921500000008],[51.6903649,6.346939900000052],[51.6930547,6.349568399999953],[51.6934529,6.349794800000041],[51.6962683,6.355557299999987],[51.6961397,6.355436700000041],[51.6959566,6.355339800000024],[51.6959186,6.355362600000035],[51.6958299,6.35556859999997],[51.6957235,6.3558898],[51.6956508,6.3560655],[51.6982975,6.357516000000032],[51.6985124,6.357294700000011],[51.698813,6.356819999999971],[51.6989665,6.356303799999978],[51.6993739,6.355334399999947],[51.6996225,6.354928100000052],[51.7020445,6.355907200000047],[51.7020515,6.3558448999999655],[51.702829,6.355979700000034],[51.7030378,6.35763929999996],[51.7090624,6.367364100000032],[51.7099323,6.370468500000015],[51.722329,6.387951899999962],[51.7244237,6.39077640000005],[51.7264345,6.387709900000004],[51.7266124,6.387313899999981],[51.7278345,6.3895506999999725],[51.7270972,6.391457500000001],[51.7291376,6.393276000000014],[51.7291863,6.393253700000059],[51.729232,6.393360099999995],[51.7318553,6.395699899999954],[51.7318997,6.395689899999979],[51.7319396,6.395723500000031],[51.7541804,6.409333100000026],[51.753682,6.41094129999999],[51.7531257,6.412393599999973],[51.7525533,6.413642999999979],[51.7520917,6.414516400000025],[51.7512894,6.415841999999998],[51.750456,6.4170163],[51.749832,6.417783999999983],[51.7490626,6.4186174000000165],[51.7479943,6.419594899999993],[51.7472835,6.420141999999942],[51.7462186,6.42082240000002],[51.7450185,6.421406299999944],[51.743952,6.421774000000028],[51.743099,6.422050899999931],[51.7416311,6.422114599999986],[51.7406501,6.422074299999963],[51.7397991,6.421950899999956],[51.7387082,6.4216696999999385],[51.737431,6.421157999999991],[51.713513,6.414343300000041],[51.7131593,6.415073799999959],[51.7128672,6.4157473999999866],[51.7123932,6.417020600000001],[51.7120501,6.418139099999962],[51.7117119,6.419498699999963],[51.7109712,6.422853000000032],[51.709902,6.4284333000000515],[51.7092628,6.432390800000007],[51.7092518,6.432458699999984],[51.7092193,6.432490899999948],[51.7092395,6.432544699999994],[51.7087057,6.436450000000036],[51.7083019,6.439972699999998],[51.707861,6.443838899999946],[51.7073648,6.446679099999983],[51.706813,6.449074699999983],[51.705981,6.451925599999981],[51.7050581,6.4544683000000305],[51.7039506,6.456979799999999],[51.7030696,6.458675299999982],[51.7020688,6.460313400000018],[51.7007765,6.4620552999999745],[51.6990807,6.463851699999964],[51.697653,6.4650281000000405],[51.6962991,6.466010900000015],[51.6947821,6.4670072999999775],[51.6928986,6.468098800000007],[51.6904993,6.469263899999987],[51.6875805,6.470360600000049],[51.6794719,6.472932799999967],[51.6766959,6.473978799999941],[51.6742027,6.475198099999943],[51.671076,6.477126699999985],[51.6612967,6.504024100000038],[51.6612646,6.50579689999995],[51.6612683,6.507582800000023],[51.661322,6.509532600000057]];

var triangleCoords2 = [ [51.6374564,6.2919939],[51.6409527,6.293088],[51.6410591,6.2931822],[51.6423995,6.2951727],[51.6424951,6.2954172],[51.6424455,6.295446],[51.6370735,6.3221685],[51.6374211,6.3237341],[51.6361009,6.3244361],[51.6369858,6.329007],[51.6390467,6.3279031],[51.6411705,6.3368335],[51.6415389,6.3383826],[51.6411446,6.3386943],[51.6404944,6.3392081],[51.6406866,6.3399308],[51.6411452,6.339636],[51.6414868,6.3394618],[51.6415474,6.3394705],[51.6417841,6.3393849],[51.6454867,6.354829],[51.645729,6.3547852],[51.6461338,6.3548028],[51.6470803,6.3544764],[51.6473627,6.3544154],[51.6481115,6.35455],[51.6496542,6.3547274],[51.6503714,6.3548834],[51.6506048,6.3548481],[51.6510208,6.3546857],[51.6628731,6.3627299],[51.6631312,6.3629769],[51.6639263,6.3640273],[51.6641839,6.3646528],[51.6648136,6.3659468],[51.6657139,6.3671333],[51.6660381,6.3679235],[51.6661744,6.3683635],[51.6665699,6.370572],[51.6666021,6.3705017],[51.6666249,6.369979],[51.6666695,6.3699145],[51.667208,6.3704002],[51.6685914,6.3712257],[51.6685994,6.3718912],[51.6697245,6.3722902],[51.6703266,6.3724668],[51.6708544,6.3725129],[51.6709517,6.372562],[51.6711912,6.373203],[51.6714114,6.3728995],[51.6717377,6.3732507],[51.672286,6.3734576],[51.672984,6.3739507],[51.659193,6.3806025],[51.6590937,6.3805249],[51.658939,6.3806981],[51.6583944,6.3810911],[51.6578321,6.3813235],[51.6568774,6.3818502],[51.6562053,6.3819468],[51.6559175,6.3821154],[51.6547212,6.3832935],[51.6541343,6.3840321],[51.6538879,6.3844588],[51.6538194,6.3847285],[51.6536466,6.3851049],[51.6530047,6.3867834],[51.6524935,6.3891769],[51.6523484,6.3894585],[51.652274,6.3897499],[51.6516757,6.3913478],[51.6516259,6.3916159],[51.6514481,6.3921578],[51.6513595,6.392299],[51.6511733,6.3928593],[51.650897,6.393445],[51.6507175,6.3941213],[51.6506475,6.3941531],[51.650619,6.3942635],[51.6502748,6.3946549],[51.6501326,6.3947617],[51.649457,6.3954319],[51.6488446,6.3961747],[51.6309112,6.4394222],[51.6318061,6.4411756],[51.6315643,6.4421753],[51.6311483,6.441281],[51.6288142,6.4434011],[51.6283051,6.440655],[51.627612,6.4373738],[51.6261293,6.4317614],[51.625384,6.4280946],[51.623866,6.4214223],[51.6160649,6.417852],[51.6141602,6.4169739],[51.6137943,6.4168052],[51.6115319,6.4157622],[51.6118061,6.4139426],[51.6116865,6.4138594],[51.6084436,6.4137525],[51.6083358,6.414574],[51.605904,6.4148485],[51.6055045,6.4190014],[51.605453,6.4190635],[51.602746,6.4185115],[51.6000399,6.4179658],[51.5997121,6.4178966],[51.5995934,6.4178639],[51.599485,6.4177922],[51.5955003,6.4170597],[51.5614412,6.4073813],[51.5614312,6.4071187],[51.5613087,6.4063176],[51.5611822,6.4056343],[51.5611501,6.4054964],[51.5611366,6.4053673],[51.5611451,6.4052931],[51.5611863,6.4051812],[51.5611869,6.4051206],[51.5611454,6.4049595],[51.5611423,6.4048785],[51.5611593,6.4047548],[51.5611373,6.4044716],[51.5611011,6.4043863],[51.5610222,6.4042762],[51.5609875,6.404087],[51.560984,6.4039877],[51.5609776,6.4039363],[51.560947,6.4038438],[51.5609328,6.403661],[51.5609223,6.4036277],[51.5608557,6.4035469],[51.5607592,6.4032459],[51.5607457,6.4031791],[51.5610739,6.3993671],[51.5611186,6.3992888],[51.5611371,6.3992508],[51.5611399,6.3992022],[51.5611296,6.3991216],[51.5611402,6.3990828],[51.5611768,6.3990239],[51.561228,6.3987743],[51.5612526,6.3987073],[51.5612612,6.3986484],[51.5612603,6.3985904],[51.5612521,6.3984457],[51.5612501,6.3982946],[51.5612391,6.3981695],[51.5612451,6.3980314],[51.5612541,6.3978098],[51.5613063,6.3974087],[51.5614339,6.396631],[51.5614705,6.3961755],[51.5614911,6.3960003],[51.5614887,6.3958329],[51.5614699,6.3955779],[51.5615038,6.3947351],[51.5614866,6.3944796],[51.5662173,6.3767979],[51.5662904,6.3764906],[51.5664671,6.376018],[51.5663769,6.3759154],[51.56688,6.3746906],[51.5670677,6.3743278],[51.5672685,6.3737118],[51.5679001,6.372719],[51.5680534,6.3722814],[51.5681732,6.3718156],[51.5685236,6.3713451],[51.569115,6.3707208],[51.569637,6.3701375],[51.5699387,6.3699455],[51.5704138,6.3697091],[51.570736,6.3696602],[51.5720683,6.3694324],[51.5722125,6.369399],[51.5724347,6.3694077],[51.5725967,6.3694747],[51.5730717,6.3695157],[51.5733945,6.3695825],[51.573757,6.3694873],[51.574059,6.3691328],[51.6008761,6.3420999],[51.6000263,6.3395452],[51.5994454,6.3385449],[51.5994326,6.3385227],[51.5973016,6.334853],[51.5973287,6.3347787],[51.5972934,6.3347186],[51.5980961,6.3323416],[51.5982279,6.33187],[51.5984325,6.3313765],[51.5986929,6.3306283],[51.5990858,6.3296129],[51.599518,6.3282782],[51.6004088,6.3258522],[51.6004357,6.3251043],[51.6005379,6.3248075],[51.6013846,6.323372],[51.6018457,6.3228022],[51.6028227,6.3218791],[51.6030524,6.3217162],[51.6033023,6.3216989],[51.6036286,6.3217356],[51.6050448,6.3237751],[51.6075619,6.3274004],[51.6074676,6.3279842],[51.6074985,6.3280125],[51.6075469,6.3279676],[51.6075991,6.3280005],[51.6082134,6.329257],[51.6097505,6.3345441],[51.6189664,6.3150657],[51.6190724,6.3145315],[51.6190781,6.3144305],[51.6192046,6.314297],[51.6193416,6.3139645],[51.6193842,6.3137094],[51.6194076,6.3132404],[51.6196126,6.3118848],[51.6198033,6.3111133],[51.6200696,6.3093443],[51.6201649,6.3089954],[51.6204422,6.3077192],[51.6205635,6.306891],[51.6208648,6.3055356],[51.6211015,6.3040894],[51.6211227,6.3033757],[51.6212734,6.3021373],[51.6215973,6.30083],[51.6219318,6.3000397],[51.6222375,6.3005039],[51.6234065,6.3015526],[51.6254371,6.301622],[51.625814,6.3022414],[51.6263658,6.301669],[51.6264851,6.3014372],[51.6267533,6.3006951],[51.6268768,6.3007664],[51.6273685,6.3008863],[51.6276482,6.3020391],[51.627715,6.3021271],[51.6278228,6.3024971],[51.62826,6.3001723],[51.628914,6.2998259],[51.6366128,6.2939661],[51.6368861,6.293478],[51.6373414,6.2922249],[51.6374564,6.2919939]];
``````
• Rather than using Coordinates use the Array option stackoverflow.com/questions/45154737/… – Mapperz Mar 22 at 15:34
• You can calculate the area of a ring with the zipper algorithm, and use the sign of the value to determine if it is left-hand or right-hand rule – Vince Mar 23 at 3:20

``````function isClockwise(poly) {
var sum = 0
for (var i=0; i<poly.length-1; i++) {
var cur = poly[i],
next = poly[i+1]
sum += (next[0] - cur[0]) * (next[1] + cur[1])
}
if (sum > 0) {
return "clockwise";
} else if (sum < 0) {
return " counter-clockwise";
}
}
``````