diff --git a/docs/src/api/isin.md b/docs/src/api/isin.md index 3ebccd7f..85d53629 100644 --- a/docs/src/api/isin.md +++ b/docs/src/api/isin.md @@ -1,22 +1,28 @@ -# API for Is it in a GeoRegion? +# API for Is it in/on a GeoRegion? ```@docs in( - Point :: Point2{<:Real}, - geo :: GeoRegion; - tlon :: Real = 0, - tlat :: Real = 0, - throw :: Bool = false -) -in( - cgeo :: GeoRegion, - geo :: RectRegion; + Point :: Point{<:Real}, + geo :: GeoRegion; throw :: Bool = false ) in( - cgeo :: GeoRegion, - geo :: Union{TiltRegion,PolyRegion}; - n :: Int = 100, + cgeo :: GeoRegion, + geo :: GeoRegion; + n :: Int = 100, + throw :: Bool = false, + verbose :: Bool = false +) +on( + Point :: Point{<:Real}, + geo :: GeoRegion; throw :: Bool = false ) +on( + cgeo :: GeoRegion, + geo :: GeoRegion; + n :: Int = 100, + throw :: Bool = false, + verbose :: Bool = false +) ``` \ No newline at end of file diff --git a/docs/src/basics/properties/isequal.md b/docs/src/basics/properties/isequal.md index c55b2207..5fe99e37 100644 --- a/docs/src/basics/properties/isequal.md +++ b/docs/src/basics/properties/isequal.md @@ -1 +1,7 @@ -# Are the GeoRegions Equivalent? \ No newline at end of file +# Comparing GeoRegions + +Now, suppose we have two different GeoRegions, we have constructed several different ways of defining equivalence: + +## 1. Are two GeoRegions Equivalent + +If you want to check that two GeoRegions are exactly the same, we can use the `==` or `isequal()` functions \ No newline at end of file diff --git a/src/georegions/define.jl b/src/georegions/define.jl index e257c56d..d0d4fb04 100644 --- a/src/georegions/define.jl +++ b/src/georegions/define.jl @@ -117,7 +117,7 @@ function RectRegion( lon,lat = rect2shape(N,S,E,W) geo = RectRegion{ST,FT}( ID, pID, name, joinpath(path,"rectlist.txt"), - [N, S, E, W], Point2.(lon,lat), Polygon(Point2.(lon,lat)), + [N, S, E, W], Point.(lon,lat), Polygon(Point.(lon,lat)), is180, is360 ) @@ -227,7 +227,7 @@ function TiltRegion( lon,lat = tilt2shape(X,Y,ΔX,ΔY,θ) geo = TiltRegion{ST,FT}( ID, pID, name, joinpath(path,"tiltlist.txt"), - [N, S, E, W], Point2.(lon,lat), Polygon(Point2.(lon,lat)), [X, Y, ΔX, ΔY, θ], + [N, S, E, W], Point.(lon,lat), Polygon(Point.(lon,lat)), [X, Y, ΔX, ΔY, θ], is180, is360 ) @@ -342,7 +342,7 @@ function PolyRegion( is180,is360 = checkbounds(N,S,E,W) geo = PolyRegion{ST,FT}( ID, pID, name, joinpath(path,"polylist.txt"), - [N, S, E, W], Point2.(lon,lat), Polygon(Point2.(lon,lat)), + [N, S, E, W], Point.(lon,lat), Polygon(Point.(lon,lat)), is180, is360 ) diff --git a/src/georegions/get.jl b/src/georegions/get.jl index ee194a2e..f2ae0abc 100644 --- a/src/georegions/get.jl +++ b/src/georegions/get.jl @@ -37,7 +37,7 @@ function getrectregion( return RectRegion{ST,FT}( ID, pID, name, fID, - [N, S, E, W], Point2.(lon,lat), Polygon(Point2.(lon,lat)), + [N, S, E, W], Point.(lon,lat), Polygon(Point.(lon,lat)), is180, is360 ) @@ -65,7 +65,7 @@ function gettiltregion( return TiltRegion{ST,FT}( ID, pID, name, fID, - [N, S, E, W], Point2.(lon,lat), Polygon(Point2.(lon,lat)), [X, Y, ΔX, ΔY, θ], + [N, S, E, W], Point.(lon,lat), Polygon(Point.(lon,lat)), [X, Y, ΔX, ΔY, θ], is180, is360 ) @@ -93,7 +93,7 @@ function getpolyregion( return PolyRegion{ST,FT}( ID, pID, name, fID, - [N, S, E, W], Point2.(lon,lat), Polygon(Point2.(lon,lat)), + [N, S, E, W], Point.(lon,lat), Polygon(Point.(lon,lat)), is180, is360 ) diff --git a/src/isin/isin.jl b/src/isin/isin.jl index 3360a35b..b8fb43d0 100644 --- a/src/isin/isin.jl +++ b/src/isin/isin.jl @@ -1,6 +1,6 @@ """ in( - point :: Point2{<:Real}, + point :: Point{<:Real}, geo :: GeoRegion; throw :: Bool = false ) -> Bool @@ -9,7 +9,7 @@ Check if a geographical point `point` is within a GeoRegion defined by `geo`. Arguments ========= -- `point` : A geographical point of Type `Point2`. Pass `Point2(plon,plat)`, where `plon` and `plat` are the longitude and latitudes of the point. +- `point` : A geographical point of Type `Point`. Pass `Point(plon,plat)`, where `plon` and `plat` are the longitude and latitudes of the point. - `geo` : The GeoRegion struct container Keyword Arguments @@ -17,7 +17,7 @@ Keyword Arguments - `throw` : If `true`, then if `point` is not within `geo`, an error is thrown and the program stops running. """ function Base.in( - point :: Point2{<:Real}, + point :: Point{<:Real}, geo :: GeoRegion; throw :: Bool = false ) @@ -33,20 +33,20 @@ function Base.in( while plon < -180; plon += 360 end isin = !iszero(sum([ - within(Point2(plon ,plat),geo.geometry), - within(Point2(plon+360,plat),geo.geometry), - within(Point2(plon-360,plat),geo.geometry) + within(Point(plon ,plat),geo.geometry), + within(Point(plon+360,plat),geo.geometry), + within(Point(plon-360,plat),geo.geometry) ])) if !isin if throw - error("$(modulelog()) - The requested coordinates $(Point2(plon,plat)) are not within the specified region boundaries.") + error("$(modulelog()) - The requested coordinates $(Point(plon,plat)) are not within the specified region boundaries.") else return false end else if throw - @info "$(modulelog()) - The requested coordinates $(Point2(plon,plat)) are within the specified region boundaries." + @info "$(modulelog()) - The requested coordinates $(Point(plon,plat)) are within the specified region boundaries." end return true end @@ -84,7 +84,7 @@ function Base.in( if verbose; @info "$(modulelog()) - Performing a check to determine if the $(cgeo.name) GeoRegion ($(cgeo.ID)) is inside the $(geo.name) GeoRegion ($(geo.ID))" end lon,lat = coordinates(cgeo,n=n) - isin = sum(.!in.(Point2.(lon,lat),[geo],n=n)); + isin = sum(.!in.(Point.(lon,lat),[geo],n=n)); if iszero(isin) diff --git a/src/isin/ison.jl b/src/isin/ison.jl index 498fa935..2b627342 100644 --- a/src/isin/ison.jl +++ b/src/isin/ison.jl @@ -1,6 +1,6 @@ """ on( - point :: Point2{<:Real}, + point :: Point{<:Real}, geo :: GeoRegion; throw :: Bool = false ) -> Bool @@ -9,7 +9,7 @@ Check if a geographical point `point` is on the boundary of a shape of a GeoRegi Arguments ========= -- `point` : A geographical point of Type `Point2`. Pass `Point2(plon,plat)`, where `plon` and `plat` are the longitude and latitudes of the point. +- `point` : A geographical point of Type `Point`. Pass `Point(plon,plat)`, where `plon` and `plat` are the longitude and latitudes of the point. - `geo` : The GeoRegion struct container Keyword Arguments @@ -17,7 +17,7 @@ Keyword Arguments - `throw` : If `true`, then if `point` is not within `geo`, an error is thrown and the program stops running. """ function on( - point :: Point2{<:Real}, + point :: Point{<:Real}, geo :: GeoRegion; throw :: Bool = false ) @@ -33,20 +33,20 @@ function on( while plon < -180; plon += 360 end isin = !iszero(sum([ - touches(Point2(plon ,plat),geo.geometry), - touches(Point2(plon+360,plat),geo.geometry), - touches(Point2(plon-360,plat),geo.geometry) + touches(Point(plon ,plat),geo.geometry), + touches(Point(plon+360,plat),geo.geometry), + touches(Point(plon-360,plat),geo.geometry) ])) if !isin if throw - error("$(modulelog()) - The requested coordinates $(Point2(plon,plat)) are not on the region perimeter.") + error("$(modulelog()) - The requested coordinates $(Point(plon,plat)) are not on the region perimeter.") else return false end else if throw - @info "$(modulelog()) - The requested coordinates $(Point2(plon,plat)) are on the region perimeter." + @info "$(modulelog()) - The requested coordinates $(Point(plon,plat)) are on the region perimeter." end return true end @@ -85,9 +85,9 @@ function on( lon1,lat1 = coordinates(geo1,n=n) lon2,lat2 = coordinates(geo2,n=n) - isin = sum(.!on.(Point2.(lon1,lat1),[geo2])) + sum(.!on.(Point2.(lon2,lat2),[geo1])) + isin = sum(.!on.(Point.(lon1,lat1),[geo2])) + sum(.!on.(Point.(lon2,lat2),[geo1])) - # @info lon1,lat1,Point2.(lon1,lat1) + # @info lon1,lat1,Point.(lon1,lat1) if iszero(isin)