-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getXMin et al. #95
getXMin et al. #95
Conversation
The regenerated API part will clash with the competing #94. |
The merge should not be problematic, since @visr and I did the same actions described in #93 (comment) |
…ypes for `flags` keyword argument
- Aligned XMin et al. naming in geos_operations.jl to GEOS naming - Removed `setPrecision` with 0 default value
- Exported getXMin et al.
In commit 4fae37b, I have:
Concerning the change from @visr if it suits you, I will make the change for the other functions in geos_operations.jl and add documentation |
I'd prefer to avoid generated functions if at all possible. I cannot properly explain because I don't fully understand, but in the Julia ecosystem I think most ofter their use is avoided if possible, because of other downsides they bring. Even for eval I'd argue the same thing, avoid using it unless it brings significant benefits. Even as a maintainer I get confused, when I cannot find a method, only to remember it is being created by eval. Adding a one line method |
It's a pity for me, I'm very fond of it :-) The issue I was trying to solve is to add documentation to geos operations functions. for (i, geom) in enumerate((:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :Polygon, :MultiPolygon, :GeometryCollection))
@eval begin
$i == 1 && @doc """
getXMin(geom, context=_context)
Finds the minimum X value in the geometry
"""
getXMin(obj::$geom, context::GEOSContext = _context) = getXMin(obj.ptr, context)
end
end or for (i, geom) in enumerate((:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :Polygon, :MultiPolygon, :GeometryCollection))
@eval getXMin(obj::$geom, context::GEOSContext = _context) = getXMin(obj.ptr, context)
@doc """
getXMin(geom, context=_context)
Finds the minimum X value in the geometry
""" getXMin
end I find them both more cluttered than: """
getXMin(geom, context=_context)
Finds the minimum X value in the geometry
"""
@generated function getXMin(geom::T, context::GEOSContext = _context) where {T<:UNION_ALL_GEOMTYPES}
return :(getXMin(geom.ptr, context))
end I understand you suggest to implement something unfactored like: """
getXMin(geom, context=_context)
Finds the minimum X value in the geometry
"""
getXMin(obj::Point, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::MultiPoint, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::LineString, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::MultiLineString, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::LinearRing, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::Polygon, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::MultiPolygon, context::GEOSContext = _context) = getXMin(obj.ptr, context)
getXMin(obj::GeometryCollection, context::GEOSContext = _context) = getXMin(obj.ptr, context) I have the feeling that it would be error prone and tedious to implement for all functions. Is it what you are aiming at or is it something different ? |
I don't understand why we need to automatically create docstrings? Docstrings are retrieved for functions, not specific methods. So we can add a single docstring to the manually written So for this PR, to avoid including too many changes at once, I'd suggest to go with the eval strategy like the rest of the code.
No that indeed looks tedious. But as you can see it is all the same code. So similarly like you did in #102, we can define Geometry = Union{
Point,
MultiPoint,
LineString,
MultiLineString,
LinearRing,
Polygon,
MultiPolygon,
GeometryCollection,
}
getXMin(obj::Geometry, context::GEOSContext = _context) = getXMin(obj.ptr, context) |
That's perfect ! I have checked the specialization with I will implement the Concerning my comment #95 (comment), shall I move the set Concerning my comment #95 (comment), shall I remove the destroying part of testing ? |
Moved related testing to test_geos_operations
Thanks, and sorry for the long wait! I created #105 as a reminder for replacing the evaled functions. |
Should fix #93
Includes:
setPrecision
methods and test to newCenum
type definitionGEOSPrecisionRules
GEOSGeom_getExtent_r
wrapping