diff --git a/README.md b/README.md index 5d67b15ef..8ae61093d 100644 --- a/README.md +++ b/README.md @@ -9,21 +9,31 @@ 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. +The driving idea behind this package is to unify all the disparate packages for geometric calculations in Julia, and make them [GeoInterface.jl](https://github.com/JuliaGeo/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. +We welcome contributions, either as pull requests or discussion on issues! + ## Methods -- Signed area, centroid, distance, etc +GeometryOps tries to offer most of the basic geometry operations you'd need, implemented in pure Julia and accepting any GeoInterface.jl compatible type. + +- General geometry methods (OGC methods): `equals`, `extent`, `distance`, `crosses`, `contains`, `intersects`, etc - Targeted function application over large nested geometries (`apply`) -- Line and polygon simplification -- Generalized barycentric coordinates in polygons -- OGC methods (crosses, contains, intersects, etc) -- Proection of geometries between coordinate reference systems +- `signed_area`, `centroid`, `distance`, etc for valid geometries +- Line and polygon simplification (`simplify`) +- Polygon clipping, `intersection`, `difference` and `union` +- Generalized barycentric coordinates in polygons (`barycentric_coordinates`) +- Projection of geometries between coordinate reference systems using [Proj.jl](https://github.com/JuliaGeo/Proj.jl) +- Polygonization of raster images by contour detection (`polygonize`) + +See the "API" page in the docs for a more complete list! ### Planned additions -- Polygon union, intersection and clipping - Arclength interpolation (absolute and relative) -- Buffering, hulls +- Buffering, hulls +- Some kind of `applyreduce` primitive ([#38](https://github.com/asinghvi17/GeometryOps.jl/issues/38)) +- Checks for valid geometries (empty linestrings, null points, etc) ([#14](https://github.com/asinghvi17/GeometryOps.jl/issues/14)) +- Operations on spherical (non-Euclidean) geometry ([#17](https://github.com/asinghvi17/GeometryOps.jl/issues/17)) \ No newline at end of file diff --git a/docs/Manifest.toml b/docs/Manifest.toml index 895acb6b0..3911254f0 100644 --- a/docs/Manifest.toml +++ b/docs/Manifest.toml @@ -1,8 +1,8 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.9.2" +julia_version = "1.10.0" manifest_format = "2.0" -project_hash = "5c6e0f991b7e6ef7bde730ae272d855da989b6f6" +project_hash = "cca6bd4b83d2b19bb3bffaf93b4bd17a8d77c688" [[deps.ANSIColoredPrinters]] git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c" @@ -96,6 +96,12 @@ version = "0.4.7" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +[[deps.BenchmarkTools]] +deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] +git-tree-sha1 = "f1f03a9fa24271160ed7e73051fba3c1a759b53f" +uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +version = "1.4.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "9e2a6b69137e6969bab0152632dcb3bc108c8bdd" @@ -110,12 +116,6 @@ version = "0.4.2" [[deps.CRC32c]] uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" -[[deps.CRlibm]] -deps = ["CRlibm_jll"] -git-tree-sha1 = "32abd86e3c2025db5172aa182b982debed519834" -uuid = "96374032-68de-5a5b-8d9e-752f78720389" -version = "1.0.1" - [[deps.CRlibm_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "e329286945d0cfc04456972ea732551869af1cfc" @@ -130,9 +130,9 @@ version = "1.0.5" [[deps.CairoMakie]] deps = ["CRC32c", "Cairo", "Colors", "FFTW", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "PrecompileTools"] -git-tree-sha1 = "ec7c21818710774e72195bda25c70fd6c56bc005" +git-tree-sha1 = "958739bc7f13916ac1a1b8707c2e8c987d2f124b" uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" -version = "0.11.5" +version = "0.11.7" [[deps.Cairo_jll]] deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] @@ -148,14 +148,26 @@ version = "0.5.1" [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra"] -git-tree-sha1 = "c1deebd76f7a443d527fc0430d5758b8b2112ed8" +git-tree-sha1 = "1287e3872d646eed95198457873249bd9f0caed2" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.19.1" +version = "1.20.1" weakdeps = ["SparseArrays"] [deps.ChainRulesCore.extensions] ChainRulesCoreSparseArraysExt = "SparseArrays" +[[deps.CodecBzip2]] +deps = ["Bzip2_jll", "Libdl", "TranscodingStreams"] +git-tree-sha1 = "9b1ca1aa6ce3f71b3d1840c538a8210a043625eb" +uuid = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd" +version = "0.8.2" + +[[deps.CodecZlib]] +deps = ["TranscodingStreams", "Zlib_jll"] +git-tree-sha1 = "59939d8a997469ee05c4b4944560a820f9ba0d73" +uuid = "944b1d66-785c-5afd-91f1-9de20f533193" +version = "0.7.4" + [[deps.ColorBrewer]] deps = ["Colors", "JSON", "Test"] git-tree-sha1 = "61c5334f33d91e570e1d0c3eb5465835242582c4" @@ -214,7 +226,7 @@ weakdeps = ["Dates", "LinearAlgebra"] [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.0.5+0" +version = "1.0.5+1" [[deps.ConstructionBase]] deps = ["LinearAlgebra"] @@ -489,9 +501,9 @@ version = "1.3.3" [[deps.GeometryBasics]] deps = ["EarCut_jll", "Extents", "GeoInterface", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"] -git-tree-sha1 = "424a5a6ce7c5d97cca7bcc4eac551b97294c54af" +git-tree-sha1 = "5694b56ccf9d15addedc35e9a4ba9c317721b788" uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326" -version = "0.4.9" +version = "0.4.10" [[deps.GeometryOps]] deps = ["ExactPredicates", "GeoInterface", "GeometryBasics", "LinearAlgebra", "Proj", "Statistics"] @@ -577,10 +589,10 @@ uuid = "c817782e-172a-44cc-b673-b171935fbb9e" version = "0.1.7" [[deps.ImageCore]] -deps = ["AbstractFFTs", "ColorVectorSpace", "Colors", "FixedPointNumbers", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "PrecompileTools", "Reexport"] -git-tree-sha1 = "fc5d1d3443a124fde6e92d0260cd9e064eba69f8" +deps = ["ColorVectorSpace", "Colors", "FixedPointNumbers", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "PrecompileTools", "Reexport"] +git-tree-sha1 = "b2a7eaa169c13f5bcae8131a83bc30eff8f71be0" uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534" -version = "0.10.1" +version = "0.10.2" [[deps.ImageIO]] deps = ["FileIO", "IndirectArrays", "JpegTurbo", "LazyModules", "Netpbm", "OpenEXR", "PNGFiles", "QOI", "Sixel", "TiffImages", "UUIDs"] @@ -638,10 +650,10 @@ version = "0.15.1" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [[deps.IntervalArithmetic]] -deps = ["CRlibm", "RoundingEmulator"] -git-tree-sha1 = "c274ec586ea58eb7b42afd0c5d67e50ff50229b5" +deps = ["CRlibm_jll", "RoundingEmulator"] +git-tree-sha1 = "c4e979fa7cf5c88ba3031a753fea9082f0a4e2ad" uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" -version = "0.22.5" +version = "0.22.6" weakdeps = ["DiffRules", "RecipesBase"] [deps.IntervalArithmetic.extensions] @@ -755,21 +767,26 @@ version = "0.3.1" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.3" +version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "7.84.0+0" +version = "8.4.0+0" [[deps.LibGit2]] -deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +[[deps.LibGit2_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] +uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" +version = "1.6.4+0" + [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.10.2+0" +version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -876,16 +893,16 @@ uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" version = "0.5.13" [[deps.Makie]] -deps = ["Animations", "Base64", "CRC32c", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "DelaunayTriangulation", "Distributions", "DocStringExtensions", "Downloads", "FFMPEG_jll", "FileIO", "FilePaths", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "InteractiveUtils", "IntervalSets", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MacroTools", "MakieCore", "Markdown", "MathTeXEngine", "Observables", "OffsetArrays", "Packing", "PlotUtils", "PolygonOps", "PrecompileTools", "Printf", "REPL", "Random", "RelocatableFolders", "Scratch", "Setfield", "ShaderAbstractions", "Showoff", "SignedDistanceFields", "SparseArrays", "StableHashTraits", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "TriplotBase", "UnicodeFun"] -git-tree-sha1 = "a37c6610dd20425b131caf65d52abdf859da5ab1" +deps = ["Animations", "Base64", "CRC32c", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "DelaunayTriangulation", "Distributions", "DocStringExtensions", "Downloads", "FFMPEG_jll", "FileIO", "FilePaths", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "InteractiveUtils", "IntervalSets", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MacroTools", "MakieCore", "Markdown", "MathTeXEngine", "Observables", "OffsetArrays", "Packing", "PlotUtils", "PolygonOps", "PrecompileTools", "Printf", "REPL", "Random", "RelocatableFolders", "Scratch", "ShaderAbstractions", "Showoff", "SignedDistanceFields", "SparseArrays", "StableHashTraits", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "TriplotBase", "UnicodeFun"] +git-tree-sha1 = "8765761cc62145802eb29ff2d923723496b5fe91" uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" -version = "0.20.4" +version = "0.20.6" [[deps.MakieCore]] deps = ["Observables", "REPL"] -git-tree-sha1 = "ec5db7bb2dc9b85072658dcb2d3ad09569b09ac9" +git-tree-sha1 = "248b7a4be0f92b497f7a331aed02c1e9a878f46b" uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b" -version = "0.7.2" +version = "0.7.3" [[deps.MappedArrays]] git-tree-sha1 = "2dab0221fe2b0f2cb6754eaa743cc266339f527e" @@ -902,6 +919,12 @@ git-tree-sha1 = "465a70f0fc7d443a00dcdc3267a497397b8a3899" uuid = "d0879d2d-cac2-40c8-9cee-1863dc0c7391" version = "0.1.2" +[[deps.MathOptInterface]] +deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "DataStructures", "ForwardDiff", "JSON", "LinearAlgebra", "MutableArithmetics", "NaNMath", "OrderedCollections", "PrecompileTools", "Printf", "SparseArrays", "SpecialFunctions", "Test", "Unicode"] +git-tree-sha1 = "8b40681684df46785a0012d352982e22ac3be59e" +uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" +version = "1.25.2" + [[deps.MathTeXEngine]] deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "UnicodeFun"] git-tree-sha1 = "96ca8a313eb6437db5ffe946c457a401bbb8ce1d" @@ -911,7 +934,7 @@ version = "0.5.7" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+0" +version = "2.28.2+1" [[deps.Missings]] deps = ["DataAPI"] @@ -935,13 +958,19 @@ version = "0.3.4" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2022.10.11" +version = "2023.1.10" [[deps.Multisets]] git-tree-sha1 = "8d852646862c96e226367ad10c8af56099b4047e" uuid = "3b2b4ff1-bcff-5658-a3ee-dbcf1ce5ac09" version = "0.4.4" +[[deps.MutableArithmetics]] +deps = ["LinearAlgebra", "SparseArrays", "Test"] +git-tree-sha1 = "806eea990fb41f9b36f1253e5697aa645bf6a9f8" +uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" +version = "1.4.0" + [[deps.NLSolversBase]] deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"] git-tree-sha1 = "a0b464d183da839699f4c79e7606d9d186ec172c" @@ -987,7 +1016,7 @@ version = "1.3.5+1" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.21+4" +version = "0.3.23+2" [[deps.OpenEXR]] deps = ["Colors", "FileIO", "OpenEXR_jll"] @@ -1004,13 +1033,13 @@ version = "3.1.4+0" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+0" +version = "0.8.1+2" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "cc6e1927ac521b659af340e0ca45828a3ffc748f" +git-tree-sha1 = "60e3045590bd104a16fefb12836c00c0ef8c7f8c" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.0.12+0" +version = "3.0.13+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -1019,10 +1048,10 @@ uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" version = "0.5.5+0" [[deps.Optim]] -deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] -git-tree-sha1 = "01f85d9269b13fedc61e63cc72ee2213565f7a72" +deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "MathOptInterface", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] +git-tree-sha1 = "47fea72de134f75b105a5d4a1abe5c6aec89d390" uuid = "429524aa-4258-5aef-a3af-852621145aeb" -version = "1.7.8" +version = "1.9.1" [[deps.Opus_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -1038,7 +1067,7 @@ version = "1.6.3" [[deps.PCRE2_jll]] deps = ["Artifacts", "Libdl"] uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" -version = "10.42.0+0" +version = "10.42.0+1" [[deps.PDMats]] deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"] @@ -1109,7 +1138,7 @@ version = "0.42.2+0" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.9.2" +version = "1.10.0" [[deps.PkgVersion]] deps = ["Pkg"] @@ -1133,6 +1162,7 @@ deps = ["LinearAlgebra", "RecipesBase", "Setfield", "SparseArrays"] git-tree-sha1 = "a9c7a523d5ed375be3983db190f6a5874ae9286d" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" version = "4.0.6" +weakdeps = ["ChainRulesCore", "FFTW", "MakieCore", "MutableArithmetics"] [deps.Polynomials.extensions] PolynomialsChainRulesCoreExt = "ChainRulesCore" @@ -1140,12 +1170,6 @@ version = "4.0.6" PolynomialsMakieCoreExt = "MakieCore" PolynomialsMutableArithmeticsExt = "MutableArithmetics" - [deps.Polynomials.weakdeps] - ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" - FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" - MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b" - MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" - [[deps.PositiveFactorizations]] deps = ["LinearAlgebra"] git-tree-sha1 = "17275485f373e6673f7e7f97051f703ed5b15b20" @@ -1174,6 +1198,10 @@ version = "0.5.5" deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +[[deps.Profile]] +deps = ["Printf"] +uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" + [[deps.ProgressMeter]] deps = ["Distributed", "Printf"] git-tree-sha1 = "00099623ffee15972c16111bcf84c58a0051257c" @@ -1203,7 +1231,7 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.Random]] -deps = ["SHA", "Serialization"] +deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[deps.RangeArrays]] @@ -1279,9 +1307,9 @@ version = "0.7.0" [[deps.SQLite_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Zlib_jll"] -git-tree-sha1 = "81f7d934b52b2441f7b44520bd982fdb3607b0da" +git-tree-sha1 = "75e28667a36b5650b5cc4baa266c5760c3672275" uuid = "76ed43ae-9a5d-5a62-8c75-30186b810ce8" -version = "3.43.0+0" +version = "3.45.0+0" [[deps.Scratch]] deps = ["Dates"] @@ -1300,9 +1328,9 @@ version = "1.1.1" [[deps.ShaderAbstractions]] deps = ["ColorTypes", "FixedPointNumbers", "GeometryBasics", "LinearAlgebra", "Observables", "StaticArrays", "StructArrays", "Tables"] -git-tree-sha1 = "db0219befe4507878b1a90e07820fed3e62c289d" +git-tree-sha1 = "79123bc60c5507f035e6d1d9e563bb2971954ec8" uuid = "65257c39-d410-5151-9873-9b3e5be5013e" -version = "0.4.0" +version = "0.4.1" [[deps.SharedArrays]] deps = ["Distributed", "Mmap", "Random", "Serialization"] @@ -1368,6 +1396,7 @@ version = "1.2.1" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +version = "1.10.0" [[deps.SpecialFunctions]] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] @@ -1393,9 +1422,9 @@ version = "0.1.1" [[deps.StaticArrays]] deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] -git-tree-sha1 = "f68dd04d131d9a8a8eb836173ee8f105c360b0c5" +git-tree-sha1 = "7b0e9c14c624e435076d19aea1e5cbdec2b9ca37" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.9.1" +version = "1.9.2" weakdeps = ["ChainRulesCore", "Statistics"] [deps.StaticArrays.extensions] @@ -1410,7 +1439,7 @@ version = "1.4.2" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.9.0" +version = "1.10.0" [[deps.StatsAPI]] deps = ["LinearAlgebra"] @@ -1449,9 +1478,9 @@ deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] +deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "5.10.1+6" +version = "7.2.1+1" [[deps.TOML]] deps = ["Dates"] @@ -1492,9 +1521,9 @@ uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69" version = "0.6.8" [[deps.TranscodingStreams]] -git-tree-sha1 = "1fbeaaca45801b4ba17c251dd8603ef24801dd84" +git-tree-sha1 = "54194d92959d8ebaa8e26227dbe3cdefcdcd594f" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.10.2" +version = "0.10.3" weakdeps = ["Random", "Test"] [deps.TranscodingStreams.extensions] @@ -1603,7 +1632,7 @@ version = "1.5.0+0" [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.13+0" +version = "1.2.13+1" [[deps.Zstd_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] @@ -1632,7 +1661,7 @@ version = "0.15.1+0" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.8.0+0" +version = "5.8.0+1" [[deps.libfdk_aac_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -1661,12 +1690,12 @@ version = "1.3.7+1" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.48.0+0" +version = "1.52.0+1" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.4.0+0" +version = "17.4.0+2" [[deps.x264_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] diff --git a/docs/Project.toml b/docs/Project.toml index 90b9399a0..e12e70ddc 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f" GeometryOps = "3251bfac-6a57-4b6d-aa61-ac1fef2975ab" diff --git a/docs/make.jl b/docs/make.jl index 5fea229c2..d13e74509 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,7 +2,7 @@ using GeometryOps using Documenter using Literate using Makie, CairoMakie -CairoMakie.activate!(px_per_unit = 2, type = "png", inline = true) # TODO: make this svg +CairoMakie.activate!(px_per_unit = 2, type = "svg", inline = true) # TODO: make this svg DocMeta.setdocmeta!(GeometryOps, :DocTestSetup, :(using GeometryOps; using GeometryOps.GeometryBasics); recursive=true) @@ -48,7 +48,8 @@ makedocs(; ), pages=[ "Home" => "index.md", - "Source code" => literate_pages + "API Reference" => "api.md", + "Source code" => literate_pages, ], warnonly = true, ) diff --git a/docs/src/api.md b/docs/src/api.md new file mode 100644 index 000000000..4eb8dce88 --- /dev/null +++ b/docs/src/api.md @@ -0,0 +1,61 @@ +```@meta +CurrentModule = GeometryOps +``` + +# Full GeometryOps API documentation + +!!! warning + This page is still very much WIP! + +Documentation for [GeometryOps](https://github.com/asinghvi17/GeometryOps.jl)'s full API (only for reference!). + +```@index +``` + +## `apply` and associated functions +```@docs +apply +apply_reduce +reproject +transform +``` + +## General geometry methods + +### OGC methods +```@docs +GeometryOps.contains +coveredby +covers +crosses +disjoint +intersects +overlaps +touches +within +``` + +### Other general methods +```@docs +equals +centroid +distance +signed_distance +area +signed_area +angles +embed_extent +``` + +## Barycentric coordinates + +```@docs +barycentric_coordinates +barycentric_coordinates! +barycentric_interpolate +``` + +## Other methods +```@autodocs +Modules = [GeometryOps] +``` diff --git a/docs/src/index.md b/docs/src/index.md index d3f600e1b..ea87aab9d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -2,13 +2,29 @@ CurrentModule = GeometryOps ``` -# GeometryOps +# GeometryOps.jl -Documentation for [GeometryOps](https://github.com/asinghvi17/GeometryOps.jl). +GeometryOps.jl is a package for geometric calculations on (primarily 2D) geometries. -```@index -``` +The driving idea behind this package is to unify all the disparate packages for geometric calculations in Julia, and make them [GeoInterface.jl](https://github.com/JuliaGeo/GeoInterface.jl)-compatible. We seem to be focusing primarily on 2/2.5D geometries for now. -```@autodocs -Modules = [GeometryOps] -``` +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. + +We welcome contributions, either as pull requests or discussion on issues! + +## Main concepts + +### The `apply` paradigm + +!!! note + See the [Primitive Functions](@ref) page for more information on this. + +The `apply` function allows you to decompose a given collection of geometries down to a certain level, and then operate on it. + +Functionally, it's similar to `map` in the way you apply it to geometries. + +### What's this `GeoInterface.Wrapper` thing? + +Write a comment about GeoInterface.Wrapper and why it helps in type stability to guarantee a particular return type. + +### \ No newline at end of file diff --git a/src/methods/barycentric.jl b/src/methods/barycentric.jl index 027fb0886..a3f86a419 100644 --- a/src/methods/barycentric.jl +++ b/src/methods/barycentric.jl @@ -26,7 +26,7 @@ export MeanValue # This example was taken from [this page of CGAL's documentation](https://doc.cgal.org/latest/Barycentric_coordinates_2/index.html). #= ```@example barycentric -import GeometryOps as GO +using GeometryOps using GeometryOps.GeometryBasics using Makie using CairoMakie @@ -55,9 +55,9 @@ f, a1, p1 = poly( polygon_points; color = last.(polygon_points), colormap = cgrad(:jet, 18; categorical = true), axis = (; - aspect = DataAspect(), title = "Makie mesh based polygon rendering", subtitle = "CairoMakie" + type = Axis, aspect = DataAspect(), title = "Makie mesh based polygon rendering", subtitle = "CairoMakie" ), - figure = (; resolution = (800, 400),) + figure = (; size = (800, 400),) ) Makie.update_state_before_display!(f) # We have to call this explicitly, to get the axis limits correct @@ -66,24 +66,26 @@ Makie.update_state_before_display!(f) # We have to call this explicitly, to get a1_bbox = a1.finallimits[] # First we get the extent of the axis ext = GeometryOps.GI.Extent(NamedTuple{(:X, :Y)}(zip(minimum(a1_bbox), maximum(a1_bbox)))) -a2, p2box = poly( # Now, we plot a cropping rectangle around the axis so we only show the polygon - f[1, 2], +a2 = Axis( + f[1, 2], + aspect = DataAspect(), + title = "Barycentric coordinate based polygon rendering", subtitle = "GeometryOps", + limits = (ext.X, ext.Y) + ) +p2box = poly!( # Now, we plot a cropping rectangle around the axis so we only show the polygon + a2, GeometryOps.GeometryBasics.Polygon( # This is a rectangle with an internal hole shaped like the polygon. Point2f[(ext.X[1], ext.Y[1]), (ext.X[2], ext.Y[1]), (ext.X[2], ext.Y[2]), (ext.X[1], ext.Y[2]), (ext.X[1], ext.Y[1])], [reverse(Point2f.(polygon_points))] ); - color = :white, xautolimits = false, yautolimits = false, - axis = (; - aspect = DataAspect(), title = "Barycentric coordinate based polygon rendering", subtitle = "GeometryOps", - limits = (ext.X, ext.Y), - ) + color = :white, xautolimits = false, yautolimits = false ) hidedecorations!(a1) hidedecorations!(a2) cb = Colorbar(f[2, :], p1.plots[1]; vertical = false, flipaxis = true) # Finally, we perform barycentric interpolation on a grid, -xrange = LinRange(ext.X..., widths(a2.scene.px_area[])[1] * 4) # 2 rendered pixels per "physical" pixel -yrange = LinRange(ext.Y..., widths(a2.scene.px_area[])[2] * 4) # 2 rendered pixels per "physical" pixel +xrange = LinRange(ext.X..., size(a2.scene)[1] * 4) # 2 rendered pixels per "physical" pixel +yrange = LinRange(ext.Y..., size(a2.scene)[2] * 4) # 2 rendered pixels per "physical" pixel @time mean_values = barycentric_interpolate.( (MeanValue(),), # The barycentric coordinate algorithm (MeanValue is the only one for now) (Point2f.(polygon_points),), # The polygon points as `Point2f` @@ -95,9 +97,9 @@ hm = heatmap!( a2, xrange, yrange, mean_values; colormap = p1.colormap, # Use the same colormap as the original polygon plot colorrange = p1.plots[1].colorrange[], # Access the rendered mesh plot's colorrange directly - transformation = (; translation = Vec3f(0,0,-1)), # This gets the heatmap to render "behind" the previously plotted polygon xautolimits = false, yautolimits = false ) +translate!(hm, 0, 0, -1) # translate the heatmap behind the cropping polygon! f ``` diff --git a/src/methods/clipping/clipping_processor.jl b/src/methods/clipping/clipping_processor.jl index 3e787880e..61c494346 100644 --- a/src/methods/clipping/clipping_processor.jl +++ b/src/methods/clipping/clipping_processor.jl @@ -1,4 +1,5 @@ -# # This file contains the shared helper functions forlyNode the polygon clipping functionalities. +# # Polygon clipping helpers +# This file contains the shared helper functions for the polygon clipping functionalities. #= This is the struct that makes up a_list and b_list. Many values are only used if point is an intersection point (ipt). =# diff --git a/src/methods/distance.jl b/src/methods/distance.jl index 3973b5cc6..9c7db79e8 100644 --- a/src/methods/distance.jl +++ b/src/methods/distance.jl @@ -30,12 +30,21 @@ scatter!(GI.x(point_out), GI.y(point_out); color = :orange) f ``` This is clearly a rectangle with one point inside and one point outside. The -points are both an equal distance to the polygon. The distance to point_in is -negative while the distance to point_out is positive. +points are both an equal distance to the polygon. The distance to `point_in` is +negative while the distance to `point_out` is positive. ```@example rect -GO.distance(point_in, rect) # == 0 -GO.signed_distance(point_in, rect) # < 0 +( +GO.distance(point_in, rect), # == 0 +GO.signed_distance(point_in, rect), # < 0 GO.signed_distance(point_out, rect) # > 0 +) +``` + +Consider also a heatmap of signed distances around this object: +```@example rect +xrange = yrange = LinRange(-0.5, 1.5, 300) +f, a, p = heatmap(xrange, yrange, GO.signed_distance.(Point2f.(xrange, yrange'), Ref(rect)); colormap = :RdBu, colorrange = (-0.75, 0.75)) +a.aspect = DataAspect(); Colorbar(f[1, 2], p, label = "Signed distance"); lines!(a, GI.convert(GO.GeometryBasics, rect)); f ``` ## Implementation diff --git a/src/methods/geom_relations/geom_geom_processors.jl b/src/methods/geom_relations/geom_geom_processors.jl index bc631be71..61f71b3f6 100644 --- a/src/methods/geom_relations/geom_geom_processors.jl +++ b/src/methods/geom_relations/geom_geom_processors.jl @@ -1,9 +1,23 @@ +# # Line-curve interaction + #= Code is based off of DE-9IM Standards (https://en.wikipedia.org/wiki/DE-9IM) and attempts a standardized solution for most of the functions. =# +""" + Enum PointOrientation + +Enum for the orientation of a point with respect to a curve. A point can be +`point_in` the curve, `point_on` the curve, or `point_out` of the curve. +""" @enum PointOrientation point_in=1 point_on=2 point_out=3 +""" + Enum LineOrientation +Enum for the orientation of a line with respect to a curve. A line can be +`line_cross` (crossing over the curve), `line_hinge` (crossing the endpoint of the curve), +`line_over` (colinear with the curve), or `line_out` (not interacting with the curve). +""" @enum LineOrientation line_cross=1 line_hinge=2 line_over=3 line_out=4 diff --git a/src/methods/polygonize.jl b/src/methods/polygonize.jl index a8a78208a..c78eae881 100644 --- a/src/methods/polygonize.jl +++ b/src/methods/polygonize.jl @@ -11,7 +11,7 @@ export polygonize # ## Example -# Here's a basic implementation, using the `Makie.peaks()` function. First, let's investigate the nature of the function: +# Here's a basic example, using the `Makie.peaks()` function. First, let's investigate the nature of the function: # ```@example polygonize # using Makie, GeometryOps # n = 49 diff --git a/src/primitives.jl b/src/primitives.jl index 4fba1a388..8481c81f2 100644 --- a/src/primitives.jl +++ b/src/primitives.jl @@ -54,6 +54,9 @@ will of course not have new `extent` or `crs` embedded. Threading is used at the outermost level possible - over an array, feature collection, or e.g. a MultiPolygonTrait where each `PolygonTrait` sub-geometry may be calculated on a different thread. + +Currently, threading defaults to `false` for all objects, but can be turned on +by passing the keyword argument `threaded=true` to `apply`. =# """ @@ -79,7 +82,7 @@ $APPLY_KEYWORDS Flipped point the order in any feature or geometry, or iterables of either: -```juia +```julia import GeoInterface as GI import GeometryOps as GO geom = GI.Polygon([GI.LinearRing([(1, 2), (3, 4), (5, 6), (1, 2)]), diff --git a/src/transformations/extent.jl b/src/transformations/extent.jl index 9055de135..90629af29 100644 --- a/src/transformations/extent.jl +++ b/src/transformations/extent.jl @@ -1,3 +1,5 @@ +# # Extent embedding + """ embed_extent(obj) diff --git a/src/transformations/simplify.jl b/src/transformations/simplify.jl index 417a1fa0c..a4bade1c4 100644 --- a/src/transformations/simplify.jl +++ b/src/transformations/simplify.jl @@ -4,6 +4,26 @@ This file holds implementations for the RadialDistance, Douglas-Peucker, and Visvalingam-Whyatt algorithms for simplifying geometries (specifically for polygons and lines). + +## Examples + +A quick and dirty example is: + +```@example polygon_simplification +using Makie, GeoInterfaceMakie +import GeoInterface as GI +import GeometryOps as GO + +original = GI.Polygon([[[-70.603637, -33.399918], [-70.614624, -33.395332], [-70.639343, -33.392466], [-70.659942, -33.394759], [-70.683975, -33.404504], [-70.697021, -33.419406], [-70.701141, -33.434306], [-70.700454, -33.446339], [-70.694274, -33.458369], [-70.682601, -33.465816], [-70.668869, -33.472117], [-70.646209, -33.473835], [-70.624923, -33.472117], [-70.609817, -33.468107], [-70.595397, -33.458369], [-70.587158, -33.442901], [-70.587158, -33.426283], [-70.590591, -33.414248], [-70.594711, -33.406224], [-70.603637, -33.399918]]]) + +simple = GO.simplify(original; number=6) + +f, a, p = poly(original; label = "Original") +poly!(simple; label = "Simplified") +axislegend(a) +f +``` + =# export simplify, VisvalingamWhyatt, DouglasPeucker, RadialDistance diff --git a/src/transformations/transform.jl b/src/transformations/transform.jl index ee1c3f671..5848a020e 100644 --- a/src/transformations/transform.jl +++ b/src/transformations/transform.jl @@ -1,3 +1,4 @@ +# # Pointwise transformation """ transform(f, obj)