Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Detect self-intersecting polygons in Javascript. An implementation of the Bentley–Ottmann sweep line algorithm for detecting crossings in a set of line segments.

NotificationsYou must be signed in to change notification settings

e-cloud/sweepline

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An implementation of the O((n + k) log n) Bentley–Ottmann sweep-line algorithm for detecting crossings in a set of line segments. The aim was to make something to speedily detect self-intersecting polygons for client side validation before serialisation and storage, but there's not much to stop it being used server-side (except it being more a statement of intent than actual production ready code).

Despite intending it for the browser, it probably still needs some fettling to make sure the CommonJS-style code I've written works in your target browser.

Reference Implementation

http://geomalgorithms.com/a09-_avl_code.html#SweepLineClassthe above is the implementation of Bentley–Ottmann sweep-line algorithm with the AVL tree.There is a cpp file of that code in thelib/

But in this repo, we use the redblack tree to replace the AVL tree. It has some adjustment.e.g. remove thelpP of ClassSweepLineSeg.

Develop Environment

  • node.js 4.2
  • mocha
  • chai

Tests

To run the tests, ensure you have node.js and the expresso npm installed:

$ npm test

Caution

Note that this implementation currently doesn't validate polygons that share the same start and end vertex. Look at the tests for workarounds to this issue.If last vertex in geoJson is equal to first vertex, you need to remove the last one when you use theisSimplePolygon.

Licence

MIT

About

Detect self-intersecting polygons in Javascript. An implementation of the Bentley–Ottmann sweep line algorithm for detecting crossings in a set of line segments.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++55.4%
  • JavaScript44.6%

[8]ページ先頭

©2009-2025 Movatter.jp