Skip to content
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

[WIP] Use GeometryOpsCore for real #223

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

[WIP] Use GeometryOpsCore for real #223

wants to merge 24 commits into from

Conversation

asinghvi17
Copy link
Member

This PR switches GeometryOps to actually import the released version of GeometryOpsCore.

It turns out that this works on 1.10, but fails on nightly because it imports anonymous functions as well, and gensym doesn't know that so generates identical symbols for different anonymous functions in GeometryOps and GeometryOpsCore. I fix that by creating a static import list of things that GeometryOpsCore defines, are unexported, but must be defined in GeometryOps.

Additionally, the PR will deprecate the GeodesicSegments and LinearSegments methods for Geodesic and Linear manifolds. This is in preparation for the next breaking release where we'll introduce perimeter calculations, arclength interpolation, and basic spherical geometry utilities.

@asinghvi17 asinghvi17 self-assigned this Oct 6, 2024
import .GeometryOpsCore
for name in setdiff(names(GeometryOpsCore, all = true), (:eval, :var"#eval", :include, :var"#include"))
import GeometryOpsCore
for name in Base.setdiff(
Copy link
Member

@rafaqz rafaqz Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty obscure, is there a less scary way to do this so regular contributors don't run away straight away?

Personally I would just make a single tuple with everything you want to import and skip the union/setdiff part.

We should also export everything explicitly so people can read it

(to me this file is mostly about communicating an overview of the package clearly to other devs)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah that's a good point. I can probably just explicitly import stuff.

@tiemvanderdeure
Copy link
Contributor

What is the status on this? I thought about getting started with adding some basic spherical geometry operations like distance and centroid, but maybe I should wait for these imports to be resolved?

@asinghvi17
Copy link
Member Author

I'm hoping to get this resolved next week feiw, pretty sure it's just a bad kwarg I have to track down

@asinghvi17
Copy link
Member Author

Phew! Things are finally working.

@@ -51,6 +51,8 @@ end

A spherical manifold means that the geometry is on the 3-sphere (but is represented by 2-D longitude and latitude).

By default, the radius is defined as the mean radius of the Earth, `6371008.8 m`.
Copy link
Member

@rafaqz rafaqz Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make global named constants for all the numbers in these files, and both insert them in docs and use them for keywords?

Maybe in a different PR, just commenting because this text is added here

@@ -3,7 +3,7 @@ module GeometryOpsLibGEOSExt
import GeometryOps as GO, LibGEOS as LG
import GeoInterface as GI

import GeometryOps: GEOS, enforce
import GeometryOps: GEOS, enforce, _True, _False, _booltype
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should remove the underscores if we are importing these?

import GeometryOpsCore:
TraitTarget,
Manifold, Planar, Spherical, Geodesic,
BoolsAsTypes, _True, _False, _booltype,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again the underscores on imported objects...

Comment on lines +180 to +183
function segmentize(method::Manifold, geom; max_distance, threaded::Union{Bool, BoolsAsTypes} = _False())
@assert max_distance > 0 "`max_distance` should be positive and nonzero! Found $(method.max_distance)."
_segmentize_function(geom) = _segmentize(method, geom, GI.trait(geom); max_distance)
return apply(_segmentize_function, TraitTarget(GI.LinearRingTrait(), GI.LineStringTrait()), geom; threaded)
Copy link
Member

@rafaqz rafaqz Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like code duplication with the function below, are both needed?

Are these asserts not checked twice when called from the other method?

(Also throwing an error is better than asserts as it's guaranteed to actually run)

function segmentize(method::SegmentizeMethod, geom; threaded::Union{Bool, BoolsAsTypes} = _False())
@warn "`segmentize(method::$(typeof(method)), geom) is deprecated; use `segmentize($(method isa LinearSegments ? "Planar()" : "Geodesic()"), geom; max_distance, threaded) instead!" maxlog=3
@assert method.max_distance > 0 "`max_distance` should be positive and nonzero! Found $(method.max_distance)."
Copy link
Member

@rafaqz rafaqz Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same assert is applied again above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants