Skip to content

Commit

Permalink
Format .jl files (#380)
Browse files Browse the repository at this point in the history
Co-authored-by: yeesian <[email protected]>
  • Loading branch information
github-actions[bot] and yeesian authored May 7, 2023
1 parent 9e751b2 commit 4ddd99b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
22 changes: 17 additions & 5 deletions src/geointerface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ let pointtypes = (wkbPoint, wkbPoint25D, wkbPointM, wkbPointZM),
::GeoInterface.AbstractPointTrait,
geom::AbstractGeometry,
)
geom isa _AbstractGeometry3d || throw(ArgumentError("Geometry does not have `Z` values"))
geom isa _AbstractGeometry3d ||
throw(ArgumentError("Geometry does not have `Z` values"))
return getz(geom, 0)
end
function GeoInterface.m(
::GeoInterface.AbstractPointTrait,
geom::AbstractGeometry,
)
geom isa _AbstractGeometryHasM || throw(ArgumentError("Geometry does not have `M` values"))
geom isa _AbstractGeometryHasM ||
throw(ArgumentError("Geometry does not have `M` values"))
return getm(geom, 0)
end

Expand All @@ -121,7 +123,11 @@ let pointtypes = (wkbPoint, wkbPoint25D, wkbPointM, wkbPointZM),
end

@noinline function _getcoord_error(i)
throw(ArgumentError("Invalid getcoord index $i, must be between 1 and 2/3/4."))
throw(
ArgumentError(
"Invalid getcoord index $i, must be between 1 and 2/3/4.",
),
)
end

function GeoInterface.isempty(::GeometryTraits, geom::AbstractGeometry)
Expand Down Expand Up @@ -161,9 +167,15 @@ let pointtypes = (wkbPoint, wkbPoint25D, wkbPointM, wkbPointZM),
# We need three refs, even for 2d points
refs = Ref{Float64}(), Ref{Float64}(), Ref{Float64}()
if is3d(geom)
return ((p = getpoint!(geom, i - 1, refs...); (p[1], p[2], p[3])) for i in 1:GeoInterface.npoint(geom))
return (
(p = getpoint!(geom, i - 1, refs...); (p[1], p[2], p[3])) for
i in 1:GeoInterface.npoint(geom)
)
else
return ((p = getpoint!(geom, i - 1, refs...); (p[1], p[2])) for i in 1:GeoInterface.npoint(geom))
return (
(p = getpoint!(geom, i - 1, refs...); (p[1], p[2])) for
i in 1:GeoInterface.npoint(geom)
)
end
end

Expand Down
8 changes: 6 additions & 2 deletions test/test_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ import GeoFormatTypes as GFT
)
@test GI.getgeom(geom, 1) == (1, 4)
# Round-trip via geointeface
@test AG.toWKT(AG.createlinestring(collect(GI.getgeom(geom)))) == "LINESTRING (1 4,2 5,3 6)"
@test AG.toWKT(
AG.createlinestring(collect(GI.getgeom(geom))),
) == "LINESTRING (1 4,2 5,3 6)"
@test AG.toWKT(geom) == "LINESTRING (1 4,2 5,3 6)"
AG.closerings!(geom)
@test AG.toWKT(geom) == "LINESTRING (1 4,2 5,3 6)"
Expand Down Expand Up @@ -360,7 +362,9 @@ import GeoFormatTypes as GFT
)
@test GI.getgeom(geom, 1) == (1, 4)
# Round-trip via geointeface
@test AG.toWKT(AG.createlinearring(collect(GI.getgeom(geom)))) == "LINEARRING (1 4,2 5,3 6)"
@test AG.toWKT(
AG.createlinearring(collect(GI.getgeom(geom))),
) == "LINEARRING (1 4,2 5,3 6)"
@test AG.toWKT(geom) == "LINEARRING (1 4,2 5,3 6)"
AG.setpointcount!(geom, 5)
@test AG.toWKT(geom) == "LINEARRING (1 4,2 5,3 6,0 0,0 0)"
Expand Down

0 comments on commit 4ddd99b

Please sign in to comment.