All Projects → w8r → Martinez

w8r / Martinez

Licence: mit
Martinez-Rueda polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Martinez

Earcut
The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
Stars: ✭ 1,359 (+247.57%)
Mutual labels:  polygon, computational-geometry
Polysnap
A work in progress polygon operations library with integer snap-rounding
Stars: ✭ 14 (-96.42%)
Mutual labels:  polygon, computational-geometry
Cgal
The public CGAL repository, see the README below
Stars: ✭ 2,825 (+622.51%)
Mutual labels:  polygon, computational-geometry
Visibility
Simple sweep line visibility polygon algorithm implementation
Stars: ✭ 62 (-84.14%)
Mutual labels:  polygon, computational-geometry
polygon-splitter
A small (<10kb minified) javascript library for splitting polygons by a polyline.
Stars: ✭ 20 (-94.88%)
Mutual labels:  polygon, computational-geometry
vaportrade
a p2p trading app on Ethereum & Polygon :)
Stars: ✭ 52 (-86.7%)
Mutual labels:  polygon
Webpack Virtual Modules
Webpack Virtual Modules is a webpack plugin that lets you create, modify, and delete in-memory files in a way that webpack treats them as if they were physically presented in the file system.
Stars: ✭ 286 (-26.85%)
Mutual labels:  overlay
window-overlay-hijacker
This is a basic window hijacker written in c++ which will allow you to draw what ever you want over it!
Stars: ✭ 32 (-91.82%)
Mutual labels:  overlay
plain-overlay
The simple library for customizable overlay which covers a page, elements or iframe-windows.
Stars: ✭ 28 (-92.84%)
Mutual labels:  overlay
Popupdialog
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.
Stars: ✭ 3,709 (+848.59%)
Mutual labels:  overlay
Wordsandbuttons
A growing collection of interactive tutorials, demos, and quizzes about maths, algorithms, and programming.
Stars: ✭ 328 (-16.11%)
Mutual labels:  computational-geometry
Geopython
Notebooks and libraries for spatial/geo Python explorations
Stars: ✭ 268 (-31.46%)
Mutual labels:  computational-geometry
scanner-overlay
📹 AVCaptureVideoPreviewLayer with a masked overlay
Stars: ✭ 21 (-94.63%)
Mutual labels:  overlay
Grassmann.jl
⟨Leibniz-Grassmann-Clifford⟩ differential geometric algebra / multivector simplicial complex
Stars: ✭ 289 (-26.09%)
Mutual labels:  computational-geometry
react-native-tcharts
基于React Native ART的图表组件库
Stars: ✭ 25 (-93.61%)
Mutual labels:  polygon
Docker Freepbx
Dockerized FreePBX 15 w/Asterisk 17, Seperate MySQL Database support, and Data Persistence and UCP
Stars: ✭ 331 (-15.35%)
Mutual labels:  overlay
MillionHeros
Android直播答题助手,支持全部答题APP,百万英雄/百万赢家/冲顶大会/芝士超人
Stars: ✭ 23 (-94.12%)
Mutual labels:  overlay
Hootenanny
Hootenanny conflates multiple maps into a single seamless map.
Stars: ✭ 264 (-32.48%)
Mutual labels:  computational-geometry
Computational Geometry
Computational Geometry Unity library with implementations of intersection algorithms, triangulations like delaunay, voronoi diagrams, polygon clipping, bezier curves, ear clipping, convex hulls, mesh simplification, etc
Stars: ✭ 325 (-16.88%)
Mutual labels:  computational-geometry
Mapillary Js
Interactive, customizable street imagery viewer in the browser, powered by WebGL
Stars: ✭ 261 (-33.25%)
Mutual labels:  computational-geometry

Martinez-Rueda polygon clipping algorithm npm version TravisCI

screenshot 2016-07-26 10 54 01 screenshot 2016-07-25 18 53 44

Details

The algorithm is specifically fast and capable of working with polygons of all types: multipolygons (without cascading), polygons with holes, self-intersecting polygons and degenerate polygons with overlapping edges.

Example

Play with it by forking this Codepen

import * as martinez from 'martinez-polygon-clipping';
const gj1 = { "type": "Feature", ..., "geometry": { "type": "Polygon", "coordinates": [ [ [x, y], ... ] ]};
const gj2 = { "type": "Feature", ..., "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [x, y], ...] ] ]};

const intersection = {
  "type": "Feature",
  "properties": { ... },
  "geometry": {
    "type": "Polygon",
    "coordinates": martinez.intersection(gj1.geometry.coordinates, gj2.geometry.coordinates)
  }
};

API

  • .intersection(<Geometry>, <Geometry>) => <Geometry>
  • .union(<Geometry>, <Geometry>) => <Geometry>
  • .diff(<Geometry>, <Geometry>) => <Geometry>
  • .xor(<Geometry>, <Geometry>) => <Geometry>

<Geometry> is GeoJSON 'Polygon' or 'MultiPolygon' coordinates structure. <Operation> is an enum of { INTERSECTION: 0, UNION: 1, DIFFERENCE: 2, XOR: 3 } in case you have to decide programmatically which operation do you need

Benchmarks

Hole_Hole
Martinez x 29,530 ops/sec ±1.65% (85 runs sampled)
JSTS x 2,051 ops/sec ±2.62% (85 runs sampled)
- Fastest is Martinez

Asia union
Martinez x 9.19 ops/sec ±3.30% (26 runs sampled)
JSTS x 7.60 ops/sec ±4.24% (23 runs sampled)
- Fastest is Martinez

States clip
Martinez x 227 ops/sec ±1.10% (82 runs sampled)
JSTS x 100 ops/sec ±2.54% (73 runs sampled)
- Fastest is Martinez

Features

The algorithm of Martinez et al. was extended to work with multipolygons without cascading.

Authors

Based on

License

The MIT License (MIT)

Copyright (c) 2018 Alexander Milevski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].