Metadata-Version: 2.4
Name: shapely-mojo
Version: 0.1.0
Summary: Add your description here
License-File: LICENSE
Requires-Python: >=3.13
Requires-Dist: matplotlib
Requires-Dist: shapely>=2.1.2
Description-Content-Type: text/markdown

 # shapely-mojo
 
 Mojo-native, minimal Shapely-like geometry library and algorithms.
 
 ## Requirements
 
 - Mojo toolchain available on your PATH (`mojo`)
 - Python 3.13+
 - `uv`
 
 ## Setup
 
 Create / sync the virtualenv with dependencies:
 
```bash
uv sync
```
 
## Run the Mojo tests
 
```bash
uv run mojo run -I . tests/run_tests.mojo
```
 
## Run + compare benchmarks

Run both the Mojo and Python benchmarks, write the results to JSON, and print a per-benchmark speedup table:

```bash
uv run python bench/compare_benchmarks.py
```

This writes:

- `bench/results/mojo_results.json`
- `bench/results/python_results.json`

The printed `speedup(py/mojo)` value is `python_seconds / mojo_seconds`:

- values **> 1.0** mean Mojo is faster
- values **< 1.0** mean Python Shapely is faster

## Run the buffering + matplotlib example
 
This example:
 
- creates a couple of `LineString`s
- buffers them using **Mojo Shapely** (`shapely.constructive.buffer`)
- plots the input lines + buffer result using `matplotlib` via Mojo Python-interop
- writes the image to `outputs/line_buffer.png`
 
```bash
uv run mojo run -I . examples/plot_line_buffer.mojo
```
 
The output directory is created automatically.

## Images

Line buffer cap/join style comparison (generated by `examples/plot_line_buffer.mojo`):

![Line buffer styles](images/line_buffer_styles.png)

Polygon buffering with holes (shows `buffer` for `join_style` = round/bevel/mitre at distances `d=0.6` and `d=0.9`, including how interior holes shrink/round under each join style):

![Polygon buffer with holes](images/polygon_buffer_with_holes.png)

Regenerate:

```bash
uv run mojo run -I . examples/plot_polygon_buffer_with_holes.mojo
```

Tic-tac-toe board linework buffered + unioned into a single footprint (prints `area()` and `length()` and saves a plot):

![Tic-tac-toe buffer](images/tictactoe_buffer.png)

Regenerate:

```bash
uv run mojo run -I . examples/plot_tictactoe_buffer_metrics.mojo
```

Boolean operations (intersection / union / difference / symmetric difference) between two polygons:

![Boolean operations](images/boolean_operations.png)

Regenerate:

```bash
uv run mojo run -I . examples/plot_boolean_operations.mojo
```

STRtree spatial index example (predicate query + nearest / kNN):

![STRtree queries](images/strtree_queries.png)

Regenerate:

```bash
uv run mojo run -I . examples/plot_strtree_queries.mojo
```

## Project layout
 
- `shapely/`
  - Mojo implementation of geometry types and operations
- `tests/run_tests.mojo`
  - Small Mojo test runner
- `examples/`
  - Runnable examples (Mojo)
- `outputs/`
  - Generated images/artifacts (not tracked)
