Skip to content

Commit

Permalink
MORE UPDATES to Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
natgeo-wong committed Sep 25, 2024
1 parent e9757e5 commit 58b2376
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 26 deletions.
10 changes: 5 additions & 5 deletions docs/src/api/addreadrm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

```@docs
GeoRegion(
geoID :: AbstractString;
path :: AbstractString = homedir()
) -> geo :: GeoRegion
geoID :: AbstractString;
path :: AbstractString = homedir()
)
```

```@docs
add
overwrite
rm
```

You can also remove a GeoRegion associated with an `ID`.

```@docs
isID
rmID
```
20 changes: 16 additions & 4 deletions docs/src/basics/properties/isin.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,21 @@ And we see that this is indeed the case.

```@docs
in(
Point :: Point2{<:Real},
geo :: RectRegion;
:: Point2{<:Real},
:: GeoRegion;
:: Real = 0,
:: Real = 0,
:: Bool = false
)
in(
cgeo :: GeoRegion,
geo :: RectRegion;
throw :: Bool = false
)
in(
cgeo :: GeoRegion,
geo :: Union{TiltRegion,PolyRegion};
n :: Int = 100,
throw :: Bool = false
)
in(::GeoRegion,::RectRegion)
in(::GeoRegion,::PolyRegion)
```
11 changes: 7 additions & 4 deletions docs/src/basics/read/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tablePolyRegions(srex = true/false, ar6 = true/false, custom = true/false)

## Use Case Examples

:::tabs
::::tabs

== tableGeoRegions()

Expand All @@ -49,12 +49,15 @@ tablePolyRegions()

== tableTiltRegions()

!!! info "No predefined `TiltRegion`s"
There are no predefined `TiltRegion`s in GeoRegions.jl, so calling `tableTiltRegions()` will only return the `GLB` GeoRegion.
::: info "No predefined `TiltRegion`s"

There are no predefined `TiltRegion`s in GeoRegions.jl, so calling `tableTiltRegions()` will only return the `GLB` GeoRegion.

:::

```@example tablesimple
using GeoRegions
tableTiltRegions()
```

:::
::::
66 changes: 63 additions & 3 deletions docs/src/tutorials/addreadrm.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ tableGeoRegions(path=joinpath(pwd(),"test"),crop=true)

And we see that yes, we can confirm their addition to the files.

Alternatively, we can check if the `ID`s have been added using the function `isID`:

```@example addreadremove
isID("TSR",path=joinpath(pwd(),"test")),
isID("TSP",path=joinpath(pwd(),"test"))
```

## 3. Reading and Retrieving GeoRegions for your Project

So now that we have saved information on the abovementioned user-defined GeoRegions, let's see if we can retrieve the information on these GeoRegions:
Expand All @@ -66,7 +73,60 @@ Let's try retrieving the shape of this `PolyRegion`
lon,lat = coordinates(ply)
```

## 4. Removing a the custom GeoRegions list from your Project
## 4. Overwriting Information for a Previously Defined GeoRegion

Once a GeoRegion associated with an `ID` has been saved into the directory named `path`, this `ID` can no longer be used in association with another GeoRegion for this Project. Therefore, you cannot save another GeoRegion of this `ID` into the same project.

```@example addreadremove
geo = PolyRegion("TSP","GLB","Test Save PolyRegion 2",[10,90,-50,10],[20,10,0,20])
add(geo,path=joinpath(pwd(),"test"))
```

In order to replace the GeoRegion associated with this `ID` with another set of information, you need to _**overwrite**_ the preexisting information with `overwrite()`

```@example addreadremove
overwrite(geo,path=joinpath(pwd(),"test"))
```

And we reload the GeoRegion associated with the `ID = TSP`

```@example addreadremove
ply = GeoRegion("TSP",path=joinpath(pwd(),"test"))
```

## 5. Removing a custom GeoRegions from your Project

Now, we've realized that you don't really need a `GeoRegion` anymore, or for some reason you want to delete the information of a particular `GeoRegion` associate with a certain `ID` and replace it with a new information, there are two ways to do it:

### 5.1 Removing a GeoRegion that has been loaded

THe first method is to remove a GeoRegion `geo` that has already been loaded into the workspace. We use the function `rm()` to do this

```@example addreadremove
rm(ply,path=joinpath(pwd(),"test"))
```

And now we check if the `GeoRegion` `TSP` now exists:

```@example addreadremove
isID("TSP",path=joinpath(pwd(),"test"))
```

And we see that it does not.

### 5.2 Removing a GeoRegion based on its `ID`

The second method is to remove a `GeoRegion` based on an `ID`, or its `string` identifier. We do this with the function `rmID()`

```@example addreadremove
rmID("TSR",path=joinpath(pwd(),"test"))
```

```@example addreadremove
isID("TSR",path=joinpath(pwd(),"test"))
```

## 6. Removing a the custom GeoRegions lists from your Project

Say you want to completely clear your project of custom GeoRegions, replacing them with new lists. You can just delete the files directly, or you can do `deleteGeoRegions()`.

Expand All @@ -79,6 +139,6 @@ deleteGeoRegions(path=joinpath(pwd(),"test"))

Let's test and see if we can retrieve the user-defined GeoRegions now we have deleted their information from the project.

```@example addreadremove
GeoRegion("TSR",path=joinpath(pwd(),"test"))
```@repl
isID("TSR",path=joinpath(pwd(),"test"),throw=false)
```
2 changes: 1 addition & 1 deletion docs/src/tutorials/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tableGeoRegions(path=pwd(),predefined=false)

Note, we have no custom GeoRegions added, so there is nothing to list right now even though the files exist. If any of `rectlist.txt`, `polylist.txt` and `tiltlist.txt` are not present, a warning will be shown unless the keyword `warn = false` is set.

## 4. Removing a the custom GeoRegions list from your Project
## 3. Removing a the custom GeoRegions list from your Project

Say you want to completely clear your project of custom GeoRegions, replacing them with new lists. You can just delete the files directly, or you can do `deleteGeoRegions()`.

Expand Down
18 changes: 9 additions & 9 deletions src/isin/georegion.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
"""
in(
Child :: GeoRegion,
rectG :: RectRegion;
throw :: Bool = false
cgeo :: GeoRegion,
geo :: RectRegion;
throw :: Bool = false
) -> Bool
Check if a child GeoRegion defined by `Child` is within a RectRegion `rectG`.
Check if a child GeoRegion defined by `cgeo` is within a RectRegion `geo`.
Arguments
=========
- `Child` : A GeoRegion that we postulate to be a "child", or a subset of the GeoRegion defined by `polyG`
- `rectG` : A GeoRegion that we postulate to be a "parent", or containing the GeoRegion defined by `Child`
- `cgeo` : A GeoRegion that we postulate to be a "child", or a subset of the GeoRegion defined by `polyG`
- `geo` : A GeoRegion that we postulate to be a "parent", or containing the GeoRegion defined by `Child`
Keyword Arguments
=================
- `throw` : If `true`, then if `Child` is not within `polyG`, an error is thrown and the program stops running
"""
Base.in(
Child :: GeoRegion,
rectG :: RectRegion;
cgeo :: GeoRegion,
geo :: RectRegion;
throw :: Bool = false
) = isinGeoRegion(Child,rectG,throw=throw)
) = isinGeoRegion(cgeo,geo,throw=throw)

"""
in(
Expand Down

0 comments on commit 58b2376

Please sign in to comment.