GeometryOps
Documentation for GeometryOps.
GeometryOps.AbstractBarycentricCoordinateMethod
GeometryOps.DouglasPeucker
GeometryOps.MeanValue
GeometryOps.RadialDistance
GeometryOps.SimplifyAlg
GeometryOps.VisvalingamWhyatt
GeometryOps._det
GeometryOps._distance
GeometryOps.apply
GeometryOps.contains
GeometryOps.flatten
GeometryOps.flip
GeometryOps.get_contours
GeometryOps.intersection
GeometryOps.intersects
GeometryOps.isclockwise
GeometryOps.isconcave
GeometryOps.point_in_polygon
GeometryOps.point_on_line
GeometryOps.polygonize
GeometryOps.rebuild
GeometryOps.reconstruct
GeometryOps.reproject
GeometryOps.signed_area
GeometryOps.signed_distance
GeometryOps.simplify
GeometryOps.t_value
GeometryOps.unwrap
GeometryOps.weighted_mean
GeometryOps.AbstractBarycentricCoordinateMethod
— Typeabstract type AbstractBarycentricCoordinateMethod
Abstract supertype for barycentric coordinate methods. The subtypes may serve as dispatch types, or may cache some information about the target polygon.
API
The following methods must be implemented for all subtypes:
barycentric_coordinates!(λs::Vector{<: Real}, method::AbstractBarycentricCoordinateMethod, exterior::Vector{<: Point{2, T1}}, point::Point{2, T2})
barycentric_interpolate(method::AbstractBarycentricCoordinateMethod, exterior::Vector{<: Point{2, T1}}, values::Vector{V}, point::Point{2, T2})::V
barycentric_interpolate(method::AbstractBarycentricCoordinateMethod, exterior::Vector{<: Point{2, T1}}, interiors::Vector{<: Vector{<: Point{2, T1}}} values::Vector{V}, point::Point{2, T2})::V
The rest of the methods will be implemented in terms of these, and have efficient dispatches for broadcasting.
GeometryOps.DouglasPeucker
— TypeDouglasPeucker <: SimplifyAlg
+Home · GeometryOps.jl GeometryOps
Documentation for GeometryOps.
GeometryOps.AbstractBarycentricCoordinateMethod
GeometryOps.DouglasPeucker
GeometryOps.MeanValue
GeometryOps.RadialDistance
GeometryOps.SimplifyAlg
GeometryOps.VisvalingamWhyatt
GeometryOps._det
GeometryOps._distance
GeometryOps.apply
GeometryOps.contains
GeometryOps.crosses
GeometryOps.disjoint
GeometryOps.flatten
GeometryOps.flip
GeometryOps.get_contours
GeometryOps.isclockwise
GeometryOps.isconcave
GeometryOps.line_intersection
GeometryOps.line_intersects
GeometryOps.overlaps
GeometryOps.point_in_polygon
GeometryOps.point_on_line
GeometryOps.polygon_to_line
GeometryOps.polygonize
GeometryOps.rebuild
GeometryOps.reconstruct
GeometryOps.reproject
GeometryOps.signed_area
GeometryOps.signed_distance
GeometryOps.simplify
GeometryOps.t_value
GeometryOps.to_edges
GeometryOps.unwrap
GeometryOps.weighted_mean
GeometryOps.within
GeometryOps.AbstractBarycentricCoordinateMethod
— Typeabstract type AbstractBarycentricCoordinateMethod
Abstract supertype for barycentric coordinate methods. The subtypes may serve as dispatch types, or may cache some information about the target polygon.
API
The following methods must be implemented for all subtypes:
barycentric_coordinates!(λs::Vector{<: Real}, method::AbstractBarycentricCoordinateMethod, exterior::Vector{<: Point{2, T1}}, point::Point{2, T2})
barycentric_interpolate(method::AbstractBarycentricCoordinateMethod, exterior::Vector{<: Point{2, T1}}, values::Vector{V}, point::Point{2, T2})::V
barycentric_interpolate(method::AbstractBarycentricCoordinateMethod, exterior::Vector{<: Point{2, T1}}, interiors::Vector{<: Vector{<: Point{2, T1}}} values::Vector{V}, point::Point{2, T2})::V
The rest of the methods will be implemented in terms of these, and have efficient dispatches for broadcasting.
sourceGeometryOps.DouglasPeucker
— TypeDouglasPeucker <: SimplifyAlg
-DouglasPeucker(; number, ratio, tol)
Simplifies geometries by removing points below tol
distance from the line between its neighboring points.
Keywords
ratio
: the fraction of points that should remain after simplify
. Useful as it will generalise for large collections of objects.
number
: the number of points that should remain after simplify
. Less useful for large collections of mixed size objects.
tol
: the minimum distance a point will be from the line joining its neighboring points.
sourceGeometryOps.MeanValue
— TypeMeanValue() <: AbstractBarycentricCoordinateMethod
This method calculates barycentric coordinates using the mean value method.
References
sourceGeometryOps.RadialDistance
— TypeRadialDistance <: SimplifyAlg
Simplifies geometries by removing points less than tol
distance from the line between its neighboring points.
Keywords
ratio
: the fraction of points that should remain after simplify
. Useful as it will generalise for large collections of objects.
number
: the number of points that should remain after simplify
. Less useful for large collections of mixed size objects.
tol
: the minimum distance between points.
sourceGeometryOps.SimplifyAlg
— Typeabstract type SimplifyAlg
Abstract type for simplification algorithms.
API
For now, the algorithm must hold the number
, ratio
and tol
properties.
Simplification algorithm types can hook into the interface by implementing the _simplify(trait, alg, geom)
methods for whichever traits are necessary.
sourceGeometryOps.VisvalingamWhyatt
— TypeVisvalingamWhyatt <: SimplifyAlg
+DouglasPeucker(; number, ratio, tol)
Simplifies geometries by removing points below tol
distance from the line between its neighboring points.
Keywords
ratio
: the fraction of points that should remain after simplify
. Useful as it will generalise for large collections of objects.
number
: the number of points that should remain after simplify
. Less useful for large collections of mixed size objects.
tol
: the minimum distance a point will be from the line joining its neighboring points.
sourceGeometryOps.MeanValue
— TypeMeanValue() <: AbstractBarycentricCoordinateMethod
This method calculates barycentric coordinates using the mean value method.
References
sourceGeometryOps.RadialDistance
— TypeRadialDistance <: SimplifyAlg
Simplifies geometries by removing points less than tol
distance from the line between its neighboring points.
Keywords
ratio
: the fraction of points that should remain after simplify
. Useful as it will generalise for large collections of objects.
number
: the number of points that should remain after simplify
. Less useful for large collections of mixed size objects.
tol
: the minimum distance between points.
sourceGeometryOps.SimplifyAlg
— Typeabstract type SimplifyAlg
Abstract type for simplification algorithms.
API
For now, the algorithm must hold the number
, ratio
and tol
properties.
Simplification algorithm types can hook into the interface by implementing the _simplify(trait, alg, geom)
methods for whichever traits are necessary.
sourceGeometryOps.VisvalingamWhyatt
— TypeVisvalingamWhyatt <: SimplifyAlg
+
+VisvalingamWhyatt(; kw...)
Simplifies geometries by removing points below tol
distance from the line between its neighboring points.
Keywords
ratio
: the fraction of points that should remain after simplify
. Useful as it will generalise for large collections of objects.
number
: the number of points that should remain after simplify
. Less useful for large collections of mixed size objects.
tol
: the minimum area of a triangle made with a point and its neighboring points.
sourceGeometryOps._det
— Method_det(s1::Point2{T1}, s2::Point2{T2}) where {T1 <: Real, T2 <: Real}
Returns the determinant of the matrix formed by hcat
'ing two points s1
and s2
.
Specifically, this is:
s1[1] * s2[2] - s1[2] * s2[1]
sourceGeometryOps._distance
— MethodDistance from p0 to the line segment formed by p1 and p2. Implementation from Turf.jl.
sourceGeometryOps.apply
— Methodapply(f, target::Type{<:AbstractTrait}, obj; crs)
Reconstruct a geometry or feature using the function f
on the target
trait.
f(target_geom) => x
where x
also has the target
trait, or an equivalent.
The result is an functionally similar geometry with values depending on f
Flipped point the order in any feature or geometry, or iterables of either:
```juia import GeoInterface as GI import GeometryOps as GO geom = GI.Polygon([GI.LinearRing([(1, 2), (3, 4), (5, 6), (1, 2)]), GI.LinearRing([(3, 4), (5, 6), (6, 7), (3, 4)])])
flipped_geom = GO.apply(GI.PointTrait, geom) do p (GI.y(p), GI.x(p)) end
sourceGeometryOps.contains
— Methodcontains(ft1::AbstractGeometry, ft2::AbstractGeometry)::Bool
Return true if the second geometry is completely contained by the first geometry. The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) must not intersect the exterior of the primary (geometry a). contains
returns the exact opposite result of within
.
Examples
import GeometryOps as GO, GeoInterface as GI
+line = GI.LineString([(1, 1), (1, 2), (1, 3), (1, 4)])
+point = (1, 2)
+
+GO.contains(line, point)
+# output
+true
sourceGeometryOps.crosses
— Method crosses(geom1, geom2)::Bool
Return true
if the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries.
TODO: broken
Examples
import GeoInterface as GI, GeometryOps as GO
+
+line1 = GI.LineString([(1, 1), (1, 2), (1, 3), (1, 4)])
+line2 = GI.LineString([(-2, 2), (4, 2)])
+
+GO.crosses(line1, line2)
+# output
+true
sourceGeometryOps.disjoint
— Methoddisjoint(geom1, geom2)::Bool
Return true
if the intersection of the two geometries is an empty set.
Examples
import GeometryOps as GO, GeoInterface as GI
+
+poly = GI.Polygon([[(-1, 2), (3, 2), (3, 3), (-1, 3), (-1, 2)]])
+point = (1, 1)
+GO.disjoint(poly, point)
-VisvalingamWhyatt(; kw...)
Simplifies geometries by removing points below tol
distance from the line between its neighboring points.
Keywords
ratio
: the fraction of points that should remain after simplify
. Useful as it will generalise for large collections of objects.
number
: the number of points that should remain after simplify
. Less useful for large collections of mixed size objects.
tol
: the minimum area of a triangle made with a point and its neighboring points.
sourceGeometryOps._det
— Method_det(s1::Point2{T1}, s2::Point2{T2}) where {T1 <: Real, T2 <: Real}
Returns the determinant of the matrix formed by hcat
'ing two points s1
and s2
.
Specifically, this is:
s1[1] * s2[2] - s1[2] * s2[1]
sourceGeometryOps._distance
— MethodDistance from p0 to the line segment formed by p1 and p2. Implementation from Turf.jl.
sourceGeometryOps.apply
— Methodapply(f, target::Type{<:AbstractTrait}, obj; crs)
Reconstruct a geometry or feature using the function f
on the target
trait.
f(target_geom) => x
where x
also has the target
trait, or an equivalent.
The result is an functionally similar geometry with values depending on f
Flipped point the order in any feature or geometry, or iterables of either:
```juia import GeoInterface as GI import GeometryOps as GO geom = GI.Polygon([GI.LinearRing([(1, 2), (3, 4), (5, 6), (1, 2)]), GI.LinearRing([(3, 4), (5, 6), (6, 7), (3, 4)])])
flipped_geom = GO.apply(GI.PointTrait, geom) do p (GI.y(p), GI.x(p)) end
sourceGeometryOps.contains
— Methodcontains(pointlist, point)::Bool
Returns true
if point
is contained in pointlist
(geometrically, not as a set) ,and false
otherwise.
sourceGeometryOps.flatten
— Methodflatten(target::Type{<:GI.AbstractTrait}, geom)
Lazily flatten any geometry, feature or iterator of geometries or features so that objects with the specified trait are returned by the iterator.
sourceGeometryOps.flip
— Methodflip(obj)
Swap all of the x and y coordinates in obj, otherwise keeping the original structure (but not necessarily the original type).
sourceGeometryOps.get_contours
— Methodget_contours(A::AbstractMatrix)
Returns contours as vectors of CartesianIndex
.
sourceGeometryOps.intersection
— Methodintersection(line_a, line_b)
Find a point that intersects LineStrings with two coordinates each.
Returns nothing
if no point is found.
Examples
import GeoInterface as GI
-import GeometryOps as GO
-line1 = GI.Line([(124.584961,-12.768946), (126.738281,-17.224758)])
-line2 = GI.Line([(123.354492,-15.961329), (127.22168,-14.008696)])
-GO.intersection(line1, line2)
# output
-(125.58375366067547, -14.83572303404496)
sourceGeometryOps.intersects
— Methodintersects(line_a, line_b)
Check if line_a
intersects with line_b
.
These can be LineTrait
, LineStringTrait
or LinearRingTrait
sourceGeometryOps.isclockwise
— Methodisclockwise(line::Union{LineString, Vector{Position}})::Bool
Take a ring and return true or false whether or not the ring is clockwise or counter-clockwise.
Examples
import GeoInterface as GI, GeometryOps as GO
-line = GI.LineString([(0, 0), (1, 1), (1, 0), (0, 0)])
-GO.isclockwise(line)
+true
sourceGeometryOps.flatten
— Methodflatten(target::Type{<:GI.AbstractTrait}, geom)
Lazily flatten any geometry, feature or iterator of geometries or features so that objects with the specified trait are returned by the iterator.
sourceGeometryOps.flip
— Methodflip(obj)
Swap all of the x and y coordinates in obj, otherwise keeping the original structure (but not necessarily the original type).
sourceGeometryOps.get_contours
— Methodget_contours(A::AbstractMatrix)
Returns contours as vectors of CartesianIndex
.
sourceGeometryOps.isclockwise
— Methodisclockwise(line::Union{LineString, Vector{Position}})::Bool
Take a ring and return true or false whether or not the ring is clockwise or counter-clockwise.
Example
import GeoInterface as GI, GeometryOps as GO
+
+ring = GI.LinearRing([(0, 0), (1, 1), (1, 0), (0, 0)])
+GO.isclockwise(ring)
+
# output
-true
sourceGeometryOps.isconcave
— Methodisconcave(poly::Polygon)::Bool
Take a polygon and return true or false as to whether it is concave or not.
Examples
import GeoInterface as GI, GeometryOps as GO
+true
sourceGeometryOps.isconcave
— Methodisconcave(poly::Polygon)::Bool
Take a polygon and return true or false as to whether it is concave or not.
Examples
import GeoInterface as GI, GeometryOps as GO
+
poly = GI.Polygon([[(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]])
GO.isconcave(poly)
+
# output
-false
sourceGeometryOps.point_in_polygon
— Functionpoint_in_polygon(point::Point, polygon::Union{Polygon, MultiPolygon}, ignoreBoundary::Bool=false)::Bool
Take a Point and a Polygon and determine if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
Examples
import GeoInterface as GI, GeometryOps as GO
+false
sourceGeometryOps.line_intersection
— Methodline_intersection(line_a, line_b)
Find a point that intersects LineStrings with two coordinates each.
Returns nothing
if no point is found.
Example
import GeoInterface as GI, GeometryOps as GO
+
+line1 = GI.Line([(124.584961,-12.768946), (126.738281,-17.224758)])
+line2 = GI.Line([(123.354492,-15.961329), (127.22168,-14.008696)])
+GO.line_intersection(line1, line2)
+
+# output
+(125.58375366067547, -14.83572303404496)
sourceGeometryOps.line_intersects
— Methodline_intersects(line_a, line_b)
Check if line_a
intersects with line_b
.
These can be LineTrait
, LineStringTrait
or LinearRingTrait
Example
import GeoInterface as GI, GeometryOps as GO
+
+line1 = GI.Line([(124.584961,-12.768946), (126.738281,-17.224758)])
+line2 = GI.Line([(123.354492,-15.961329), (127.22168,-14.008696)])
+GO.line_intersects(line1, line2)
+
+# output
+true
sourceGeometryOps.overlaps
— Methodoverlaps(geom1, geom2)::Bool
Compare two Geometries of the same dimension and return true if their intersection set results in a geometry different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString, Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.
Examples
import GeometryOps as GO, GeoInterface as GI
+poly1 = GI.Polygon([[(0,0), (0,5), (5,5), (5,0), (0,0)]])
+poly2 = GI.Polygon([[(1,1), (1,6), (6,6), (6,1), (1,1)]])
+
+GO.overlaps(poly1, poly2)
+# output
+true
sourceGeometryOps.point_in_polygon
— Methodpoint_in_polygon(point::Point, polygon::Union{Polygon, MultiPolygon}, ignore_boundary::Bool=false)::Bool
Take a Point and a Polygon and determine if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
Examples
import GeoInterface as GI, GeometryOps as GO
+
point = (-77.0, 44.0)
-poly = GI.Polygon([[[-81, 41], [-81, 47], [-72, 47], [-72, 41], [-81, 41]]])
+poly = GI.Polygon([[(-81, 41), (-81, 47), (-72, 47), (-72, 41), (-81, 41)]])
GO.point_in_polygon(point, poly)
+
# output
-true
sourceGeometryOps.point_on_line
— Methodpoint_on_line(point::Point, line::LineString, ignoreEndVertices::Bool=false)::Bool
Return true if a point is on a line. Accept a optional parameter to ignore the start and end vertices of the linestring.
Examples
import GeoInterface as GI, GeometryOps as GO
-point = GI.Point(1, 1)
+true
sourceGeometryOps.point_on_line
— Methodpoint_on_line(point::Point, line::LineString; ignore_end_vertices::Bool=false)::Bool
Return true if a point is on a line. Accept a optional parameter to ignore the start and end vertices of the linestring.
Examples
import GeoInterface as GI, GeometryOps as GO
+
+point = (1, 1)
line = GI.LineString([(0, 0), (3, 3), (4, 4)])
GO.point_on_line(point, line)
+
+# output
+true
sourceGeometryOps.polygon_to_line
— Methodpolygon_to_line(poly::Polygon)
Converts a Polygon to LineString or MultiLineString
Examples
import GeometryOps as GO, GeoInterface as GI
+
+poly = GI.Polygon([[(-2.275543, 53.464547), (-2.275543, 53.489271), (-2.215118, 53.489271), (-2.215118, 53.464547), (-2.275543, 53.464547)]])
+GO.polygon_to_line(poly)
# output
-true
sourceGeometryOps.polygonize
— Methodpolygonize(A; minpoints=10)
-polygonize(xs, ys, A; minpoints=10)
Convert matrix A
to polygons.
If xs
and ys
are passed in they are used as the pixel center points.
Keywords
minpoints
: ignore polygons with less than minpoints
points.
sourceGeometryOps.rebuild
— Methodrebuild(geom, child_geoms)
Rebuild a geometry from child geometries.
By default geometries will be rebuilt as a GeoInterface.Wrappers geometry, but rebuild
can have methods added to it to dispatch on geometries from other packages and specify how to rebuild them.
(Maybe it should go into GeoInterface.jl)
sourceGeometryOps.reconstruct
— Methodreconstruct(geom, components)
Reconstruct geom
from an iterable of component objects that match its structure.
All objects in components
must have the same GeoInterface.trait
.
Ususally used in combination with flatten
.
sourceGeometryOps.reproject
— Methodreproject(geometry; source_crs, target_crs, transform, always_xy, time)
+GeoInterface.Wrappers.LineString{false, false, Vector{Tuple{Float64, Float64}}, Nothing, Nothing}([(-2.275543, 53.464547), (-2.275543, 53.489271), (-2.215118, 53.489271), (-2.215118, 53.464547), (-2.275543, 53.464547)], nothing, nothing)
sourceGeometryOps.polygonize
— Methodpolygonize(A; minpoints=10)
+polygonize(xs, ys, A; minpoints=10)
Convert matrix A
to polygons.
If xs
and ys
are passed in they are used as the pixel center points.
Keywords
minpoints
: ignore polygons with less than minpoints
points.
sourceGeometryOps.rebuild
— Methodrebuild(geom, child_geoms)
Rebuild a geometry from child geometries.
By default geometries will be rebuilt as a GeoInterface.Wrappers geometry, but rebuild
can have methods added to it to dispatch on geometries from other packages and specify how to rebuild them.
(Maybe it should go into GeoInterface.jl)
sourceGeometryOps.reconstruct
— Methodreconstruct(geom, components)
Reconstruct geom
from an iterable of component objects that match its structure.
All objects in components
must have the same GeoInterface.trait
.
Ususally used in combination with flatten
.
sourceGeometryOps.reproject
— Methodreproject(geometry; source_crs, target_crs, transform, always_xy, time)
reproject(geometry, source_crs, target_crs; always_xy, time)
-reproject(geometry, transform; always_xy, time)
Reproject any GeoInterface.jl compatible geometry
from source_crs
to target_crs
.
The returned object will be constructed from GeoInterface.WrapperGeometry
geometries, wrapping views of a Vector{Proj.Point{D}}
, where D
is the dimension.
Arguments
geometry
: Any GeoInterface.jl compatible geometries.source_crs
: the source coordinate referece system, as a GeoFormatTypes.jl object or a string.target_crs
: the target coordinate referece system, as a GeoFormatTypes.jl object or a string.
If these a passed as keywords, transform
will take priority. Without it target_crs
is always needed, and source_crs
is needed if it is not retreivable from the geometry with GeoInterface.crs(geometry)
.
Keywords
-always_xy
: force x, y coordinate order, true
by default. false
will expect and return points in the crs coordinate order. -time
: the time for the coordinates. Inf
by default.
sourceGeometryOps.signed_area
— Methodsigned_area(geom)::Real
Returns the signed area of the geometry, based on winding order.
sourceGeometryOps.signed_distance
— Methodsigned_distance(geom, x::Real, y::Real)::Float64
Calculates the signed distance from the geometry geom
to the point defined by (x, y)
. Points within geom
have a negative distance, and points outside of geom
have a positive distance.
If geom
is a MultiPolygon, then this function returns the maximum distance to any of the polygons in geom
.
sourceGeometryOps.simplify
— Methodsimplify(obj; kw...)
+reproject(geometry, transform; always_xy, time)
Reproject any GeoInterface.jl compatible geometry
from source_crs
to target_crs
.
The returned object will be constructed from GeoInterface.WrapperGeometry
geometries, wrapping views of a Vector{Proj.Point{D}}
, where D
is the dimension.
Arguments
geometry
: Any GeoInterface.jl compatible geometries.source_crs
: the source coordinate referece system, as a GeoFormatTypes.jl object or a string.target_crs
: the target coordinate referece system, as a GeoFormatTypes.jl object or a string.
If these a passed as keywords, transform
will take priority. Without it target_crs
is always needed, and source_crs
is needed if it is not retreivable from the geometry with GeoInterface.crs(geometry)
.
Keywords
-always_xy
: force x, y coordinate order, true
by default. false
will expect and return points in the crs coordinate order. -time
: the time for the coordinates. Inf
by default.
sourceGeometryOps.signed_area
— Methodsigned_area(geom)::Real
Returns the signed area of the geometry, based on winding order.
sourceGeometryOps.signed_distance
— Methodsigned_distance(geom, x::Real, y::Real)::Float64
Calculates the signed distance from the geometry geom
to the point defined by (x, y)
. Points within geom
have a negative distance, and points outside of geom
have a positive distance.
If geom
is a MultiPolygon, then this function returns the maximum distance to any of the polygons in geom
.
sourceGeometryOps.simplify
— Methodsimplify(obj; kw...)
simplify(::SimplifyAlg, obj)
Simplify a geometry, feature, feature collection, or nested vectors or a table of these.
RadialDistance
, DouglasPeucker
, or VisvalingamWhyatt
algorithms are available, listed in order of increasing quality but decreaseing performance.
PoinTrait
and MultiPointTrait
are returned unchanged.
The default behaviour is simplify(DouglasPeucker(; kw...), obj)
. Pass in other SimplifyAlg
to use other algorithms.
Example
Simplify a polygon to have six points:
import GeoInterface as GI
import GeometryOps as GO
@@ -60,5 +107,12 @@
GI.npoint(simple)
# output
-6
sourceGeometryOps.t_value
— Methodt_value(sᵢ, sᵢ₊₁, rᵢ, rᵢ₊₁)
Returns the "T-value" as described in Hormann's presentation [HormannPresentation] on how to calculate the mean-value coordinate.
Here, sᵢ
is the vector from vertex vᵢ
to the point, and rᵢ
is the norm (length) of sᵢ
. s
must be Point
and r
must be real numbers.
\[tᵢ = \frac{\mathrm{det}\left(sᵢ, sᵢ₊₁\right)}{rᵢ * rᵢ₊₁ + sᵢ ⋅ sᵢ₊₁}\]
```
sourceGeometryOps.unwrap
— Functionunwrap(target::Type{<:AbstractTrait}, obj)
-unwrap(f, target::Type{<:AbstractTrait}, obj)
Unwrap the geometry to vectors, down to the target trait.
If f
is passed in it will be applied to the target geometries as they are found.
sourceGeometryOps.weighted_mean
— Methodweighted_mean(weight::Real, x1, x2)
Returns the weighted mean of x1
and x2
, where weight
is the weight of x1
.
Specifically, calculates x1 * weight + x2 * (1 - weight)
.
Note The idea for this method is that you can override this for custom types, like Color types, in extension modules.
source- HormannPresentationK. Hormann and N. Sukumar. Generalized Barycentric Coordinates in Computer Graphics and Computational Mechanics. Taylor & Fancis, CRC Press, 2017.
Settings
This document was generated with Documenter.jl version 0.27.24 on Tuesday 1 August 2023. Using Julia version 1.9.2.
+6
GeometryOps.t_value
— Methodt_value(sᵢ, sᵢ₊₁, rᵢ, rᵢ₊₁)
Returns the "T-value" as described in Hormann's presentation [HormannPresentation] on how to calculate the mean-value coordinate.
Here, sᵢ
is the vector from vertex vᵢ
to the point, and rᵢ
is the norm (length) of sᵢ
. s
must be Point
and r
must be real numbers.
\[tᵢ = \frac{\mathrm{det}\left(sᵢ, sᵢ₊₁\right)}{rᵢ * rᵢ₊₁ + sᵢ ⋅ sᵢ₊₁}\]
```
GeometryOps.to_edges
— Methodto_edges()
Convert any geometry or collection of geometries into a flat vector of Tuple{Tuple{Float64,Float64},{Float64,Float64}}
edges.
GeometryOps.unwrap
— Functionunwrap(target::Type{<:AbstractTrait}, obj)
+unwrap(f, target::Type{<:AbstractTrait}, obj)
Unwrap the geometry to vectors, down to the target trait.
If f
is passed in it will be applied to the target geometries as they are found.
GeometryOps.weighted_mean
— Methodweighted_mean(weight::Real, x1, x2)
Returns the weighted mean of x1
and x2
, where weight
is the weight of x1
.
Specifically, calculates x1 * weight + x2 * (1 - weight)
.
The idea for this method is that you can override this for custom types, like Color types, in extension modules.
GeometryOps.within
— Methodwithin(geom1, geom)::Bool
Return true
if the first geometry is completely within the second geometry. The interiors of both geometries must intersect and, the interior and boundary of the primary (geometry a) must not intersect the exterior of the secondary (geometry b). within
returns the exact opposite result of contains
.
Examples
import GeometryOps as GO, GeoInterface as GI
+
+line = GI.LineString([(1, 1), (1, 2), (1, 3), (1, 4)])
+point = (1, 2)
+GO.within(point, line)
+
+# output
+true
- HormannPresentationK. Hormann and N. Sukumar. Generalized Barycentric Coordinates in Computer Graphics and Computational Mechanics. Taylor & Fancis, CRC Press, 2017.