Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed the CCW function to do what its supposed to... with a much cleaner algorithm.
  • Loading branch information
Montago committed May 12, 2016
1 parent bace0c3 commit bc3633b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions GeoJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,15 @@ var GeoJSON = function( geojson, options ){
};

var _ccw = function( path ){
var isCCW;
var a = 0;
for (var i = 0; i < path.length-2; i++){
a += ((path[i+1].lat() - path[i].lat()) * (path[i+2].lng() - path[i].lng()) - (path[i+2].lat() - path[i].lat()) * (path[i+1].lng() - path[i].lng()));
var aux = 0.0;
var a = path[path.length-1];
for (var i = 0; i < path.length; i++)
{
var b = path[i];
aux += (b.lat() - a.lat()) * (b.lng() + a.lng());
a = b;
}
if(a > 0){
isCCW = true;
}
else{
isCCW = false;
}
return isCCW;
return aux > 0;
};

var _copy = function(obj){

This comment has been minimized.

Copy link
@amirmedina

amirmedina Jun 23, 2017

I'd all

This comment has been minimized.

Copy link
@amirmedina

amirmedina Jun 23, 2017

In

This comment has been minimized.

Copy link
@amirmedina

amirmedina Jun 23, 2017

Youthfulness

Expand Down

4 comments on commit bc3633b

@amirmedina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Live

@amirmedina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Income

@amirmedina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot

@amirmedina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transfer cc

Please sign in to comment.