PHPackages                             kudm761/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. kudm761/martinez-rueda-php

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

kudm761/martinez-rueda-php
==========================

Martinez-Rueda algorithm for polygon boolean operations

0.1.2(5y ago)2136.4k↓44.6%[1 PRs](https://github.com/BardoQi/polygon_utils/pulls)PHPPHP &gt;=7.0

Since Jun 3Pushed 5y agoCompare

[ Source](https://github.com/BardoQi/polygon_utils)[ Packagist](https://packagist.org/packages/kudm761/martinez-rueda-php)[ RSS](/packages/kudm761-martinez-rueda-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (0)

Martinez-Rueda polygon boolean operations algorithm
---------------------------------------------------

[](#martinez-rueda-polygon-boolean-operations-algorithm)

PHP implementation of original algorithm [http://www4.ujaen.es/~fmartin/bool\_op.html](http://www4.ujaen.es/~fmartin/bool_op.html)

Algorithm is used for computing Boolean operations on polygons:

- union
- difference
- intersection
- xor

install
-------

[](#install)

```
$ composer require kudm761/martinez-rueda-php:dev

```

Usage
-----

[](#usage)

Input parameter is a multipolygon - an array of polygons. And each polygon is an array of points x,y.

```
    $data = [[[-1, 4], [-3, 4], [-3, 0], [-3, -1], [-1, -1], [-1, -2], [2, -2], [2, 1], [-1, 1], [-1, 4]]];
    $subject = new \MartinezRueda\Polygon($data);

    $data = [[[-2, 5], [-2, 0], [3, 0], [3, 3], [2, 3], [2, 2], [0, 2], [0, 5], [-2, 5]]];
    $clipping = new \MartinezRueda\Polygon($data);

    $result = (new \MartinezRueda\Algorithm())->getUnion($subject, $clipping);

    echo json_encode($result->toArray()), PHP_EOL;

    // Result is:
    // [[[2,3],[2,2],[0,2],[0,5],[-2,5],[-2,4],[-3,4],[-3,0],[-3,-1],[-1,-1],[-1,-2],[2,-2],[2,0],[3,0],[3,3],[2,3]]]

```

Some visual examples
--------------------

[](#some-visual-examples)

Let's consider two polygons: green multipolygon of two polygons and yellow polygon.

Snow-white polygon is result of Boolean operation on two polygons.

[![](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_original.png)](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_original.png)

###### Union

[](#union)

[![](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_union.png)](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_union.png)

###### Difference (green NOT yellow)

[](#difference-green-not-yellow)

[![](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_difference.png)](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_difference.png)

###### Intersection

[](#intersection)

[![](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_intersection.png)](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_intersection.png)

###### Xor

[](#xor)

[![](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_xor.png)](https://raw.githubusercontent.com/kudm761/kudm761.github.io/master/docs/aa_polygon_xor.png)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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 ~2 days

Total

4

Last Release

2167d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bfb2d0271845406a6b777d824993d97eec9f249b61ffa43b86994698b988e30?d=identicon)[bardoqi](/maintainers/bardoqi)

---

Top Contributors

[![kudm761](https://avatars.githubusercontent.com/u/1829681?v=4)](https://github.com/kudm761 "kudm761 (15 commits)")[![BardoQi](https://avatars.githubusercontent.com/u/409367?v=4)](https://github.com/BardoQi "BardoQi (1 commits)")

---

Tags

geographypolygon clippingpolygon boolean operationspolygon unionpolygon intersectionpolygon differencepolygon xormartinez polygon algorithmmartinez php

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[geokit/geokit

Geo-Toolkit for PHP

251924.7k6](/packages/geokit-geokit)[brick/geo

GIS geometry library

245862.1k15](/packages/brick-geo)[matthiasmullie/geo

Geography helper

6377.6k1](/packages/matthiasmullie-geo)

PHPackages © 2026

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