From 58b237698f17d65baae72215c804dd9c5b92fc7a Mon Sep 17 00:00:00 2001 From: Nathanael Wong Date: Tue, 24 Sep 2024 22:25:56 -0400 Subject: [PATCH] MORE UPDATES to Documentation --- docs/src/api/addreadrm.md | 10 ++--- docs/src/basics/properties/isin.md | 20 +++++++-- docs/src/basics/read/tables.md | 11 +++-- docs/src/tutorials/addreadrm.md | 66 ++++++++++++++++++++++++++++-- docs/src/tutorials/projects.md | 2 +- src/isin/georegion.jl | 18 ++++---- 6 files changed, 101 insertions(+), 26 deletions(-) diff --git a/docs/src/api/addreadrm.md b/docs/src/api/addreadrm.md index 18c11805..01cb433a 100644 --- a/docs/src/api/addreadrm.md +++ b/docs/src/api/addreadrm.md @@ -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 ``` \ No newline at end of file diff --git a/docs/src/basics/properties/isin.md b/docs/src/basics/properties/isin.md index a9e1eeaa..a549367b 100644 --- a/docs/src/basics/properties/isin.md +++ b/docs/src/basics/properties/isin.md @@ -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) ``` \ No newline at end of file diff --git a/docs/src/basics/read/tables.md b/docs/src/basics/read/tables.md index d842dc4b..7f7a821c 100644 --- a/docs/src/basics/read/tables.md +++ b/docs/src/basics/read/tables.md @@ -24,7 +24,7 @@ tablePolyRegions(srex = true/false, ar6 = true/false, custom = true/false) ## Use Case Examples -:::tabs +::::tabs == tableGeoRegions() @@ -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() ``` -::: \ No newline at end of file +:::: \ No newline at end of file diff --git a/docs/src/tutorials/addreadrm.md b/docs/src/tutorials/addreadrm.md index 4d8ca477..1266c5c4 100644 --- a/docs/src/tutorials/addreadrm.md +++ b/docs/src/tutorials/addreadrm.md @@ -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: @@ -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()`. @@ -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) ``` \ No newline at end of file diff --git a/docs/src/tutorials/projects.md b/docs/src/tutorials/projects.md index ba7051a6..f7554b23 100644 --- a/docs/src/tutorials/projects.md +++ b/docs/src/tutorials/projects.md @@ -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()`. diff --git a/src/isin/georegion.jl b/src/isin/georegion.jl index 721f0bc8..506c1364 100644 --- a/src/isin/georegion.jl +++ b/src/isin/georegion.jl @@ -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(