Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

Update:

Actually the above did not work for more than one revolution around the world. I ended up doing THISTHIS.

enter image description here

Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

Update:

Actually the above did not work for more than one revolution around the world. I ended up doing THIS.

enter image description here

Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

Update:

Actually the above did not work for more than one revolution around the world. I ended up doing THIS.

enter image description here

added 255 characters in body
Source Link
CaptDragon
  • 13.4k
  • 7
  • 55
  • 96

Two years later, I kept having this issue with features on a vector layerTwo years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

Update:

Actually the above did not work for more than one revolution around the world. I foundended up doing this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:THIS.

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

enter image description here

Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}

Update:

Actually the above did not work for more than one revolution around the world. I ended up doing THIS.

enter image description here

Source Link
CaptDragon
  • 13.4k
  • 7
  • 55
  • 96

Two years later, I kept having this issue with features on a vector layer. I found this file containing a snippet of code that shows how to flip an endpoint if it crossed the dateline:

if(Math.abs(startPoint.x-endPoint.x) > 180) {
  if(startPoint.x < endPoint.x) {
    endPoint.x -= 360;
  } else {
    endPoint.x += 360;
  }
}