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

Fix polygonize #141

Merged
merged 35 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
473a99d
start improving and testing bools
rafaqz Aug 2, 2023
c4244e9
add turf boolean tests
rafaqz Aug 2, 2023
e6e4db5
more fixes
rafaqz Aug 2, 2023
cc6c75e
fix polygonize
rafaqz Aug 3, 2023
d6b2cbb
fix polygonize and tweak performance
rafaqz May 13, 2024
5ac9466
optimise geometry processes with extent checks
rafaqz May 13, 2024
8cfbf05
cleanup
rafaqz May 13, 2024
1763da6
more cleanup
rafaqz May 13, 2024
894b3c9
handle over_allow and cross_allow
rafaqz May 13, 2024
655aca3
only simple optimisations for now
rafaqz May 13, 2024
42a20bd
clean up example
rafaqz May 13, 2024
3a3ca22
fix methods
rafaqz May 13, 2024
7dc8ff4
add multiple value handling
rafaqz May 13, 2024
c977777
dict
rafaqz May 13, 2024
36a7aaf
faster with dict
rafaqz May 14, 2024
dd3adf7
update disjoint optimisation logic
rafaqz May 14, 2024
2c12557
get size down to an 8 multiple
rafaqz May 14, 2024
01b644a
remove bools.jl
rafaqz May 14, 2024
29afe97
cleanup
rafaqz May 15, 2024
d785a70
test and allow multi value functions
rafaqz May 15, 2024
d5fedc6
more tests
rafaqz May 15, 2024
ea63c1f
fix extents for performance
rafaqz May 15, 2024
dc60abd
fix docs
rafaqz May 15, 2024
0be82ff
as/polygonize_docs (#142)
asinghvi17 May 15, 2024
27aee80
Try to fix Literate not detecting the text properly
asinghvi17 May 15, 2024
30a1f16
Add testing packages to extras
asinghvi17 May 15, 2024
910def6
Return edge vectors with the same axis semantics as `axes(A)`
asinghvi17 May 15, 2024
136ccfd
Propagate CRS
asinghvi17 May 15, 2024
2d0de0e
Propagate extend to returned MultiPolygon for the Bool case
asinghvi17 May 15, 2024
946e8ef
Add exotic array tests for polygonize
asinghvi17 May 15, 2024
8e33cd7
Remove unnecessary `crs` passthrough to temporary geometries
asinghvi17 May 16, 2024
5aff698
Use mapreduce instead of reduce for extent unioning
asinghvi17 May 16, 2024
64f2370
Add extent and CRS to features and featurecollections in polygonize
asinghvi17 May 16, 2024
d117b5b
dont add nodes in straight lines
rafaqz May 16, 2024
d584605
clean up and dict performance tweaks
rafaqz May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ julia = "1.9"
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FlexiJoins = "e37f2e79-19fa-4eb7-8510-b63b51fe0a37"
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
GeoJSON = "61d90e0f-e114-555e-ac52-39dfb47a3ef9"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LibGEOS = "a90b1aa1-3769-5649-ba7e-abc5a9d163eb"
Rasters = "a3a2b9e3-a471-40c9-b274-f788e487c689"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Proj = "c94c279d-25a6-4763-9509-64d165bea63e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ArchGDAL", "CoordinateTransformations", "DataFrames", "Distributions", "FlexiJoins", "GeoFormatTypes", "GeoJSON", "Proj", "JLD2", "LibGEOS", "Random", "Shapefile", "Test"]
test = ["ArchGDAL", "CoordinateTransformations", "DataFrames", "Distributions", "DimensionalData", "FlexiJoins", "GeoFormatTypes", "GeoJSON", "Proj", "JLD2", "LibGEOS", "Random", "Rasters", "OffsetArrays", "Shapefile", "Test"]
2 changes: 1 addition & 1 deletion src/methods/geom_relations/coveredby.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@ function _coveredby(
!coveredby(sub_g1, g2) && return false
end
return true
end
end
58 changes: 53 additions & 5 deletions src/methods/geom_relations/geom_geom_processors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,18 @@ Else, return false.
If closed_line is true, line is treated as a closed line where the first and
last point are connected by a segment. Same with closed_curve.
=#
function _line_curve_process(
@inline function _line_curve_process(line, curve;
over_allow, cross_allow, kw...
)
skip, returnval = _maybe_skip_disjoint_extents(line, curve;
in_allow=(over_allow | cross_allow), kw...
)
skip && return returnval

return _inner_line_curve_process(line, curve; over_allow, cross_allow, kw...)
end

function _inner_line_curve_process(
line, curve;
over_allow, cross_allow, on_allow, out_allow,
in_require, on_require, out_require,
Expand Down Expand Up @@ -246,11 +257,17 @@ Else, return false.
If closed_line is true, line is treated as a closed line where the first and
last point are connected by a segment.
=#
function _line_polygon_process(
@inline function _line_polygon_process(line, polygon; kw...)
skip, returnval = _maybe_skip_disjoint_extents(line, polygon; kw...)
skip && return returnval
return _inner_line_polygon_process(line, polygon; kw...)
end

function _inner_line_polygon_process(
line, polygon;
closed_line=false,
in_allow, on_allow, out_allow,
in_require, on_require, out_require,
closed_line = false,
)
in_req_met = !in_require
on_req_met = !on_require
Expand Down Expand Up @@ -315,7 +332,13 @@ If out_require is true, the first polygon must have at least one interior point
If the point is in an "allowed" location and meets all requirments, return true.
Else, return false.
=#
function _polygon_polygon_process(
@inline function _polygon_polygon_process(poly1, poly2; kw...)
skip, returnval = _maybe_skip_disjoint_extents(poly1, poly2; kw...)
skip && return returnval
return _inner_polygon_polygon_process(poly1, poly2; kw...)
end

function _inner_polygon_polygon_process(
poly1, poly2;
in_allow, on_allow, out_allow,
in_require, on_require, out_require,
Expand Down Expand Up @@ -641,6 +664,7 @@ function _line_polygon_interactions(
line, polygon;
closed_line = false,
)

in_poly, on_poly, out_poly = _line_filled_curve_interactions(
line, GI.getexterior(polygon);
closed_line = closed_line,
Expand Down Expand Up @@ -669,4 +693,28 @@ end
function _point_in_extent(p, extent::Extents.Extent)
(x1, x2), (y1, y2) = extent.X, extent.Y
return x1 ≤ GI.x(p) ≤ x2 && y1 ≤ GI.y(p) ≤ y2
end
end

# Disjoint extent optimisation: skip work based on geom extent intersection
# returns Tuple{Bool, Bool} for (skip, returnval)
@inline function _maybe_skip_disjoint_extents(a, b;
in_allow, on_allow, out_allow,
in_require, on_require, out_require,
kw...
rafaqz marked this conversation as resolved.
Show resolved Hide resolved
)
ext_disjoint = Extents.disjoint(GI.extent(a), GI.extent(b))
skip, returnval = if !ext_disjoint
# can't tell anything about this case
false, false
elseif out_allow # && ext_disjoint
if in_require || on_require
true, false
else
true, true
end
else # !out_allow && ext_disjoint
# points not allowed in exterior, but geoms are disjoint
true, false
end
return skip, returnval
end
Loading
Loading