You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+119-3Lines changed: 119 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,127 @@ CurrentModule = TGGeometry
4
4
5
5
# TGGeometry
6
6
7
-
Documentation for [TGGeometry](https://github.com/JuliaGeo/TGGeometry.jl).
7
+
TGGeometry.jl is a Julia wrapper around the [`tg`](https://github.com/tidwall/tg) C library for planar geometric predicates. Specifically, it provides:
8
+
9
+
-[`intersects(geom1, geom2)`](@ref intersects)
10
+
-[`contains(geom1, geom2)`](@ref contains)
11
+
-[`touches(geom1, geom2)`](@ref touches)
12
+
-[`disjoint(geom1, geom2)`](@ref disjoint)
13
+
-[`equals(geom1, geom2)`](@ref equals)
14
+
-[`covers(geom1, geom2)`](@ref covers)
15
+
-[`coveredby(geom1, geom2)`](@ref coveredby)
16
+
-[`within(geom1, geom2)`](@ref within)
17
+
18
+
from the [DE-9IM](https://en.wikipedia.org/wiki/DE-9IM) model.
19
+
20
+
It is fully [GeoInterface.jl](https://github.com/JuliaGeo/GeoInterface.jl) compatible, and is able to accept any combination of GeoInterface-compatible geometries as input (from GeoDataFrames, GeoJSON, ArchGDAL, GeometryOps, and many more packages!).
8
21
9
22
```@index
10
23
```
11
24
12
-
```@autodocs
13
-
Modules = [TGGeometry]
25
+
## Quick start
26
+
27
+
### Installation
28
+
29
+
Install via `]add TGGeometry` in the REPL, or `Pkg.add("TGGeometry")`.
30
+
31
+
### Basic usage
32
+
33
+
Since TGGeometry allows any GeoInterface-compatible geometry as input, let's start with some geometries from NaturalEarth.jl:
f, a, p = poly(germany; label = "Germany", axis = (; aspect = DataAspect(),)) # hide
42
+
poly!(a, belgium; label = "Belgium") # hide
43
+
leg = axislegend(a) # hide
44
+
hidedecorations!(a) # hide
45
+
f # hide
46
+
```
47
+
48
+
```@example quickstart
49
+
TGGeometry.intersects(germany, belgium)
50
+
```
51
+
52
+
```@example quickstart
53
+
TGGeometry.contains(germany, belgium)
14
54
```
55
+
56
+
```@example quickstart
57
+
TGGeometry.touches(germany, belgium)
58
+
```
59
+
60
+
```@example quickstart
61
+
TGGeometry.disjoint(germany, belgium)
62
+
```
63
+
64
+
You can use any data loader, like GeoJSON, GeoDataFrames, ArchGDAL, etc. You can also construct your own geometries via GeometryBasics, GeoInterface wrapper geometries, or accepted basic types like 2-tuple points.
65
+
66
+
```@example quickstart
67
+
berlin = (13.4050, 52.5200) # berlin (longitude, latitude)
68
+
scatter!(a, [berlin], color = :red, label = "Berlin") # hide
69
+
delete!(leg) # hide
70
+
leg = axislegend(a) # hide
71
+
f # hide`
72
+
```
73
+
74
+
```@example quickstart
75
+
TGGeometry.contains(germany, berlin)
76
+
```
77
+
78
+
### "Preparing" using `TGGeom`
79
+
80
+
TGGeometry is fast naturally, but you can make it even faster by "preparing" your geometries by converting them to `TGGeom`s. This converts the geometries to opaque pointers to a `tg` geometry - still fully GeoInterface-compatible though, but they have the acceleration benefits and don't have to be continually converted every time you call a predicate.
81
+
82
+
The way to convert is to call `GeoInterface.convert(TGGeometry, geom)`. This will convert the geometry to a `TGGeom` and return the new `TGGeom` object.
83
+
84
+
Let's see the difference in speed, between using a `TGGeom` and a GeoJSON polygon:
Predicates from the DE-9IM model are available (but not a full `relate` function that would return the full DE-9IM matrix).
103
+
104
+
```@docs
105
+
intersects
106
+
contains
107
+
touches
108
+
disjoint
109
+
equals
110
+
covers
111
+
coveredby
112
+
within
113
+
```
114
+
115
+
## TGGeom
116
+
117
+
The `TGGeom` type is a wrapper around the `tg_geom` object returned by the `tg` library. It is fully [GeoInterface.jl](https://github.com/JuliaGeo/GeoInterface.jl) compatible, and is able to accept any combination of GeoInterface-compatible geometries as input (from GeoDataFrames, GeoJSON, ArchGDAL, GeometryOps, and many more packages!).
118
+
119
+
```@docs
120
+
TGGeom
121
+
```
122
+
123
+
## Installation
124
+
125
+
It's as simple as `]add TGGeometry`.
126
+
127
+
## License
128
+
129
+
This project is licensed under the MIT License - see the LICENSE file for details.
0 commit comments