Skip to content

Commit

Permalink
Barycentric coordinates (#10)
Browse files Browse the repository at this point in the history
* Make `contains` more geointerfacey

* Mean value method for barycentric coordinates

On arbitrary polygons

* Clean up + improve documentation

* Fix chatgpt numbering bug (this is some pretty bad stuff)

* Add a method for true polys

* Update make.jl

* Hormann method works well

* Reorder some code and comments

* Add tests

* Reorder, remove cruft, get this working

* Include and export

* Add README and logo

* Fix tests

* Remove MakieThemes

* Fix the doctest setup


x

* Don't use GB and Rasters in the bary example

* Don't test on nightly

* Fix examples

* More doc fixes

* Display figure to reset limits in docs

* Move doctests to tests file

* Test on v1.6 too

* Fix syntax for v1.6 in simplify.jl

* Literateify

* Remove codecov files

* Fix the plotted barycentric example

* Set the default method to mean value
  • Loading branch information
asinghvi17 authored Jun 4, 2023
1 parent 2e99d8b commit 5e41a15
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1'
- 'nightly'
# - 'nightly'
os:
- ubuntu-latest
arch:
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ version = "0.0.1-DEV"
[deps]
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Proj = "c94c279d-25a6-4763-9509-64d165bea63e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
GeometryBasics = "0.4.7"
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## GeometryOps.jl


[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://asinghvi17.github.io/GeometryOps.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://asinghvi17.github.io/GeometryOps.jl/dev/)
[![Build Status](https://github.com/asinghvi17/GeometryOps.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/asinghvi17/GeometryOps.jl/actions/workflows/CI.yml?query=branch%3Amain)

<img src="docs/src/assets/logo.png" alt="GeometryOps logo" width="250">

GeometryOps.jl is a package for geometric calculations on (primarily 2D) geometries.

The driving idea behind this package is to unify all the disparate packages for geometric calculations in Julia, and make them GeoInterface.jl-compatible. We seem to be focusing primarily on 2/2.5D geometries for now.

Most of the usecases are driven by GIS and similar Earth data workflows, so this might be a bit specialized towards that, but methods should always be general to any coordinate space.

## Methods

- Signed area, centroid, distance, etc
- Iteration into geometries (`apply`)
- Line and polygon simplification
- Generalized barycentric coordinates in polygons

### Planned additions

- OGC methods (crosses, contains, intersects, etc)
- Polygon union, intersection and clipping
- Arclength interpolation (absolute and relative)
34 changes: 24 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@ using GeometryOps
using Documenter
using Literate
using Makie, CairoMakie
CairoMakie.activate!(px_per_unit = 2, type = "png") # TODO: make this svg
CairoMakie.activate!(px_per_unit = 2, type = "png", inline = true) # TODO: make this svg

DocMeta.setdocmeta!(GeometryOps, :DocTestSetup, :(using GeometryOps); recursive=true)
DocMeta.setdocmeta!(GeometryOps, :DocTestSetup, :(using GeometryOps; using GeometryOps.GeometryBasics); recursive=true)

# First, remove any codecov files that may have been generated by the CI run
for (root, dirs, files) in walkdir(dirname(@__DIR__)) # walk through `GeometryOps/*`
# Iterate through all files in the current directory
for file in files
# If the file is a codecov file, remove it
if splitext(file)[2] == ".cov"
rm(joinpath(root, file))
end
end
end

source_path = joinpath(dirname(@__DIR__), "src")
output_path = joinpath(@__DIR__, "src", "source")
mkpath(output_path)

literate_pages = String[]

for (root_path, dirs, files) in walkdir(source_path)
output_dir = joinpath(output_path, relpath(root_path, source_path))
for file in files
# convert the source file to Markdown
Literate.markdown(joinpath(root_path, file), output_dir; documenter = false)
# TODO: make this respect nesting somehow!
push!(literate_pages, joinpath("source", relpath(root_path, source_path), splitext(file)[1] * ".md"))
withenv("JULIA_DEBUG" => "Literate") do # allow Literate debug output to escape to the terminal!
for (root_path, dirs, files) in walkdir(source_path)
output_dir = joinpath(output_path, relpath(root_path, source_path))
for file in files
# convert the source file to Markdown
Literate.markdown(joinpath(root_path, file), output_dir; documenter = false)
# TODO: make this respect nesting somehow!
push!(literate_pages, joinpath("source", relpath(root_path, source_path), splitext(file)[1] * ".md"))
end
end
end

Expand All @@ -36,7 +49,8 @@ makedocs(;
pages=[
"Home" => "index.md",
"Source code" => literate_pages
]
],
strict=false,
)

deploydocs(;
Expand Down
Binary file added docs/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/GeometryOps.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# # GeometryOps.jl

module GeometryOps

using GeoInterface
using GeometryBasics
import Proj
using LinearAlgebra

const GI = GeoInterface
const GB = GeometryBasics

include("primitives.jl")
include("utils.jl")

include("methods/signed_distance.jl")
include("methods/signed_area.jl")
include("methods/centroid.jl")
include("methods/contains.jl")
include("methods/barycentric.jl")

include("transformations/flip.jl")
include("transformations/simplify.jl")
include("transformations/reproject.jl")
Expand Down
Loading

0 comments on commit 5e41a15

Please sign in to comment.