0-180 Degree Radials to North, South, East, West - Node.js Geometry

Node.js examples for Geometry:Radian

Description

0-180 Degree Radials to North, South, East, West

Demo Code

/* 0-180 Degree Radials to North, South, East, West */
if (typeof(Number.prototype.heading_to_direction) === "undefined") {
  Number.prototype.heading_to_direction = function() {

  var direction = "";
  
  if (this < 0 && this > -90) {
    direction = "north-west";
  }/*from www. j  av a 2 s .c  o  m*/
  
  if (this <= 70 && this <= 110) {
    direction = "east"
  }
   
  
  if (this > -180 && this <= -90) {
    direction = "south-west";
  }
  
  if (this > 0 && this <= 90) {
    direction = "north-east";
  }
  
  if (this > 90 && this <= 180) {
    direction = "north-east";
  }

  if (this <= 20 && this >= -20) {
    direction = "north"
  }
  
  if (this <= 160 && this <= -160) {
    direction = "south"
  }
  
  if (this <= -70 && this >= -110) {
    direction = "west"
  }

    return direction;
  }
}

Related Tutorials