Skip to content

Commit

Permalink
Improve isless definition (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm authored Nov 22, 2024
1 parent 54c872f commit 9a7e160
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 56 deletions.
7 changes: 3 additions & 4 deletions src/Meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ using Random

using Bessels: gamma
using Unitful: AbstractQuantity, numtype
using StatsBase: AbstractWeights, Weights, quantile
using CoordRefSystems: Basic, Geographic, Projected
using Distances: PreMetric, Euclidean, Mahalanobis
using Distances: Haversine, SphericalAngle
using Distances: evaluate, result_type
using Rotations: Rotation, QuatRotation, Angle2d
using Rotations: rotation_between
using TiledIteration: TileIterator
using CoordRefSystems: Basic, Projected, Geographic
using NearestNeighbors: KDTree, BallTree
using NearestNeighbors: knn, inrange
using DelaunayTriangulation: triangulate, voronoi
using DelaunayTriangulation: each_solid_triangle
using DelaunayTriangulation: get_polygons
using DelaunayTriangulation: get_polygon_points
using StatsBase: AbstractWeights, Weights, quantile
using TiledIteration: TileIterator
using ScopedValues: ScopedValue
using Base.Cartesian: @nloops, @nref, @ntuple
using Base: @propagate_inbounds
Expand All @@ -36,7 +36,6 @@ import Random
import Base: sort
import Base: ==, !
import Base: +, -, *
import Base: <, >, ,
import StatsBase: sample
import Distances: evaluate
import NearestNeighbors: MinkowskiMetric
Expand Down
5 changes: 5 additions & 0 deletions src/geometries/primitives/point.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ function ==(A::Point{🌐,<:LatLon}, B::Point{🌐,<:LatLon})
lat₁ == lat₂ && lon₁ == lon₂ || (abs(lon₁) == 180u"°" && lon₁ == -lon₂)
end

function Base.isless(A::Point, B::Point)
A′, B′ = promote(A, B)
isless(to(A′), to(B′))
end

function Base.isapprox(A::Point, B::Point; atol=atol(lentype(A)), kwargs...)
A′, B′ = promote(A, B)
isapprox(to(A′), to(B′); atol, kwargs...)
Expand Down
52 changes: 0 additions & 52 deletions src/predicates/ordering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,6 @@
# Licensed under the MIT License. See LICENSE in the project root.
# ------------------------------------------------------------------

# ----------------------
# LEXICOGRAPHICAL ORDER
# ----------------------

"""
<(A::Point, B::Point)
The lexicographical order of points `A` and `B` (`<`).
`A < B` if the tuples of coordinates satisfy `(a₁, a₂, ...) < (b₁, b₂, ...)`.
See <https://en.wikipedia.org/wiki/Partially_ordered_set#Orders_on_the_Cartesian_product_of_partially_ordered_sets>
"""
<(A::Point, B::Point) = CoordRefSystems.values(coords(A)) < CoordRefSystems.values(coords(B))

"""
>(A::Point, B::Point)
The lexicographical order of points `A` and `B` (`>`).
`A > B` if the tuples of coordinates satisfy `(a₁, a₂, ...) > (b₁, b₂, ...)`.
See <https://en.wikipedia.org/wiki/Partially_ordered_set#Orders_on_the_Cartesian_product_of_partially_ordered_sets>
"""
>(A::Point, B::Point) = CoordRefSystems.values(coords(A)) > CoordRefSystems.values(coords(B))

"""
≤(A::Point, B::Point)
The lexicographical order of points `A` and `B` (`\\le`).
`A ≤ B` if the tuples of coordinates satisfy `(a₁, a₂, ...) ≤ (b₁, b₂, ...)`.
See <https://en.wikipedia.org/wiki/Partially_ordered_set#Orders_on_the_Cartesian_product_of_partially_ordered_sets>
"""
(A::Point, B::Point) = CoordRefSystems.values(coords(A)) CoordRefSystems.values(coords(B))

"""
≥(A::Point, B::Point)
The lexicographical order of points `A` and `B` (`\\ge`).
`A ≥ B` if the tuples of coordinates satisfy `(a₁, a₂, ...) ≥ (b₁, b₂, ...)`.
See <https://en.wikipedia.org/wiki/Partially_ordered_set#Orders_on_the_Cartesian_product_of_partially_ordered_sets>
"""
(A::Point, B::Point) = CoordRefSystems.values(coords(A)) CoordRefSystems.values(coords(B))

# --------------
# PRODUCT ORDER
# --------------

"""
≺(A::Point, B::Point)
Expand Down

0 comments on commit 9a7e160

Please sign in to comment.