PHPackages                             ifsnop/martinez-rueda-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ifsnop/martinez-rueda-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ifsnop/martinez-rueda-php
=========================

Robust and tested library for boolean operations on polygons (union, intersection, difference, xor)

1.0.1(1mo ago)32GPL-3.0-or-laterPHP

Since Oct 23Pushed yesterday1 watchersCompare

[ Source](https://github.com/ifsnop/martinez-rueda-php)[ Packagist](https://packagist.org/packages/ifsnop/martinez-rueda-php)[ RSS](/packages/ifsnop-martinez-rueda-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Martinez Rueda PHP
==================

[](#martinez-rueda-php)

Robust and tested library for boolean operations on polygons (union, intersection, difference, xor) in PHP.

Some improvements over other libraries: This one is tested (see end-to-end directory) and optimized to use polygons with large amount of vertex (ie, binary search when doing intersections between segments).

This library can use arrays with polygons, geojson strings or geojson files directly.

Resources
=========

[](#resources)

- To understand the algorithm, you can go [here](https://unpkg.com/polybooljs@1.2.0/dist/demo.html)
- Based somewhat on the F. Martinez (2008) algorithm:
    - [Website](https://www4.ujaen.es/~fmartin/bool_op.html)
    - A new algorithm for computing Boolean operations on polygons 2009 [Research Gate](https://www.researchgate.net/publication/220163820_A_new_algorithm_for_computing_Boolean_operations_on_polygons)[Science Direct](https://www.sciencedirect.com/science/article/abs/pii/S0965997813000379)
    - [A simple algorithm for Boolean operations on polygons 2013](https://investigacion.ujaen.es/documentos/5f1cdfbd29995265e44d906f?lang=en)

Examples
========

[](#examples)

Some tests and demo implementation inside tests.php, extended coverage with PHPUnit:

- php tests.php
- ./vendor/bin/phpunit tests/
- ./vendor/phpstan/phpstan/phpstan --error-format=raw

For profiling:

- check that xdebug module is available and loaded: php -m | grep xdebug
- launch php with xdebug enabled: php
    -dxdebug.mode=profile
    -dxdebug.start\_with\_request=yes
    -dxdebug.output\_dir=xdebug-profiler/
    tests.php

Tutorials and notes
===================

[](#tutorials-and-notes)

- [Interactive tutorial Polygon Clipping (Part 1)](https://sean.fun/a/polygon-clipping-pt1/)
- [Interactive tutorial Polygon Clipping (Part 2)](https://sean.fun/a/polygon-clipping-pt2/)
- [Notes on the Martinez-Rueda Polygon Clipping algorithm](https://liorsinai.github.io/mathematics/2025/01/11/bentley-ottman.html)
- Let's build! Boolean operations of polygons[Part 1 - Introduction](https://wellquite.org/posts/lets_build/polygons_intro/)[Part 2 - Intersections](https://wellquite.org/posts/lets_build/polygons_intersections/)

Improvements
============

[](#improvements)

- [Speed improvement with inserts by bisection](https://github.com/velipso/polybooljs/issues/23) [Pull](https://github.com/velipso/polybooljs/pull/28)

History
=======

[](#history)

- This library is a port for PHP of [pypolybool](https://github.com/KaivnD/pypolybool)
- Previoulsy, was a port for JS of [polybooljs](https://github.com/velipso/polybooljs)
- Help from a .NET [port](https://github.com/idormenco/PolyBool.Net)

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance97

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~122 days

Total

2

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ba441d3c7e04f0b168f7e0ffb4048175434e44b2efa42e02df331a60e238dab?d=identicon)[ifsnop](/maintainers/ifsnop)

---

Top Contributors

[![ifsnop](https://avatars.githubusercontent.com/u/967656?v=4)](https://github.com/ifsnop "ifsnop (71 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ifsnop-martinez-rueda-php/health.svg)

```
[![Health](https://phpackages.com/badges/ifsnop-martinez-rueda-php/health.svg)](https://phpackages.com/packages/ifsnop-martinez-rueda-php)
```

###  Alternatives

[jakewhiteley/php-sets

An implementation of a Java-like Set data structure for PHP. A Set is an iterable data structure which allows strict-type storage of unique values.

1828.2k](/packages/jakewhiteley-php-sets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
