Skip to content

Commit 567683b

Browse files
committed
Fix bug in x, y, z, m lookup in getcoord.
1 parent 1805746 commit 567683b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/defaults.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const default_coord_names = (:X, :Y, :Z, :M)
99
coordnames(::AbstractGeometryTrait, geom) = default_coord_names[1:ncoord(geom)]
1010

1111
# Maybe hardcode dimension order? At least for X and Y?
12-
x(::AbstractPointTrait, geom) = getcoord(geom, findfirst(coordnames(geom), :X))
13-
y(::AbstractPointTrait, geom) = getcoord(geom, findfirst(coordnames(geom), :Y))
14-
z(::AbstractPointTrait, geom) = getcoord(geom, findfirst(coordnames(geom), :Z))
15-
m(::AbstractPointTrait, geom) = getcoord(geom, findfirst(coordnames(geom), :M))
12+
x(::AbstractPointTrait, geom) = getcoord(geom, findfirst(x -> x === :X, coordnames(geom)))
13+
y(::AbstractPointTrait, geom) = getcoord(geom, findfirst(x -> x === :Y, coordnames(geom)))
14+
z(::AbstractPointTrait, geom) = getcoord(geom, findfirst(x -> x === :Z, coordnames(geom)))
15+
m(::AbstractPointTrait, geom) = getcoord(geom, findfirst(x -> x === :M, coordnames(geom)))
1616

1717
is3d(::AbstractPointTrait, geom) = :Z in coordnames(geom)
1818
ismeasured(::AbstractPointTrait, geom) = :M in coordnames(geom)

test/test_primitives.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ struct MyPoint end
2323
@test GeoInterface.npoint(geom) == 2 # defaults to ngeom
2424
@test GeoInterface.coordinates(geom) == [[1, 2], [1, 2]]
2525
@test_throws MethodError GeoInterface.area(geom)
26+
point = GeoInterface.getgeom(geom, 1)
27+
@test GeoInterface.y(point) == 2
28+
2629

2730
end

0 commit comments

Comments
 (0)