https://github.com/bast/polygons-rs

Computes distances to polygon edges and vertices and can check whether points are inside/outside.

https://github.com/bast/polygons-rs

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.8%) to scientific vocabulary

Keywords

distance geometry polygon rust spacial
Last synced: 5 months ago · JSON representation

Repository

Computes distances to polygon edges and vertices and can check whether points are inside/outside.

Basic Info
  • Host: GitHub
  • Owner: bast
  • License: gpl-3.0
  • Language: Rust
  • Default Branch: master
  • Homepage:
  • Size: 798 KB
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • Open Issues: 5
  • Releases: 0
Topics
distance geometry polygon rust spacial
Created about 7 years ago · Last pushed 11 months ago
Metadata Files
Readme License

README.md

Build status License polygons crate

polygons-rs

Computes distances to polygon edges and vertices and can check whether points are inside/outside polygons.

Rewriting https://github.com/bast/polygons to Rust - work in progress.

So far not beautiful and not stable. Will improve while learning.

Running the benchmark

$ cargo test --release -- --ignored --nocapture

Python interface

Inspired by https://github.com/dev-cafe/rustafarian.

$ cargo build --release --features pyo3 $ maturin develop --release --cargo-extra-args="--features pyo3"

Example

```python import polygons

polygon_points is a list of lists

the library has been developed to perform

with very many polygons - this is just to have a simple example

polygon_points = [ [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0), (0.0, 0.0)], [(0.0, 2.0), (1.0, 2.0), (1.0, 3.0), (0.0, 3.0), (0.0, 2.0)], ]

the more points you compute in one go, the better

this is just to make a simple example but if you have many points

then compute a thousand or a million in one go

so that the library can parallelize over the points

points = [(0.5, 0.5), (0.5, -0.5)]

parameters for the tree construction:

- each tree node has 4 children nodes

- each leaf collects 4 edges

you can try different parameters and check the timing

they (should) have no effect on the results apart from timing

numedgeschildren = 4 numnodeschildren = 4 tree = polygons.buildtree(polygonpoints, numedgeschildren, numnodeschildren)

inside = polygons.pointsareinside(tree, points) print(inside) # [True, False]

distances = polygons.distancesnearestvertices(tree, points) print(distances) # [0.7071067811865476, 0.7071067811865476]

distances = polygons.distancesnearestedges(tree, points) print(distances) # [0.5, 0.5]

distances = polygons.distancesnearestvertices(tree, [(0.6, 0.6), (0.5, -0.5)]) print(distances) # [0.5656854249492381, 0.7071067811865476] ```

Owner

  • Name: Radovan Bast
  • Login: bast
  • Kind: user
  • Location: Tromsø, Norway
  • Company: @uit-no @neicnordic

Theoretical chemist turned research software engineer. Leads @coderefinery.

GitHub Events

Total
  • Pull request event: 1
Last Year
  • Pull request event: 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 0
  • Total pull requests: 5
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 5
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
Pull Request Authors
  • dependabot[bot] (6)
Top Labels
Issue Labels
Pull Request Labels
dependencies (6) rust (2)