Skip to content

Commit

Permalink
Fix deprecations (#11)
Browse files Browse the repository at this point in the history
* Fix deprecations

* Remove Compat from REQUIRE

- Allow failures on nightly
- Stop testing on 0.5
  • Loading branch information
femtocleaner[bot] authored and yeesian committed Nov 12, 2017
1 parent a5dfb75 commit 6d901cd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 58 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ os:
- linux
- osx
julia:
- 0.5
- 0.6
- nightly
matrix:
allow_failures:
- julia: nightly
notifications:
email: false
# uncomment the following lines to override the default test script
Expand Down
1 change: 0 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
julia 0.6
Compat 0.17
26 changes: 12 additions & 14 deletions src/GeoInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ __precompile__()

module GeoInterface

using Compat

export AbstractPosition, Position,
AbstractGeometry, AbstractGeometryCollection, GeometryCollection,
AbstractPoint, Point,
Expand All @@ -22,7 +20,7 @@ module GeoInterface
geometry, bbox, crs, properties,
features

@compat abstract type AbstractPosition{T <: Real} <: AbstractVector{T} end
abstract type AbstractPosition{T <: Real} <: AbstractVector{T} end
geotype(::AbstractPosition) = :Position
xcoord(::AbstractPosition) = error("xcoord(::AbstractPosition) not defined.")
ycoord(::AbstractPosition) = error("ycoord(::AbstractPosition) not defined.")
Expand All @@ -31,7 +29,7 @@ module GeoInterface
hasz(::AbstractPosition) = false
coordinates(p::AbstractPosition) = hasz(p) ? Float64[xcoord(p),ycoord(p),zcoord(p)] : Float64[xcoord(p),ycoord(p)]
# (Array-like indexing # http://julia.readthedocs.org/en/latest/manual/arrays/#arrays)
Base.eltype{T <: Real}(p::AbstractPosition{T}) = T
Base.eltype(p::AbstractPosition{T}) where {T <: Real} = T
Base.ndims(AbstractPosition) = 1
Base.length(p::AbstractPosition) = hasz(p) ? 3 : 2
Base.size(p::AbstractPosition) = (length(p),)
Expand All @@ -40,40 +38,40 @@ module GeoInterface
Base.convert(::Type{Vector{Float64}}, p::AbstractPosition) = coordinates(p)
# Base.linearindexing{T <: AbstractPosition}(::Type{T}) = LinearFast()

@compat abstract type AbstractGeometry end
abstract type AbstractGeometry end
coordinates(obj::AbstractGeometry) = error("coordinates(::AbstractGeometry) not defined.")

@compat abstract type AbstractPoint <: AbstractGeometry end
abstract type AbstractPoint <: AbstractGeometry end
geotype(::AbstractPoint) = :Point

@compat abstract type AbstractMultiPoint <: AbstractGeometry end
abstract type AbstractMultiPoint <: AbstractGeometry end
geotype(::AbstractMultiPoint) = :MultiPoint

@compat abstract type AbstractLineString <: AbstractGeometry end
abstract type AbstractLineString <: AbstractGeometry end
geotype(::AbstractLineString) = :LineString

@compat abstract type AbstractMultiLineString <: AbstractGeometry end
abstract type AbstractMultiLineString <: AbstractGeometry end
geotype(::AbstractMultiLineString) = :MultiLineString

@compat abstract type AbstractPolygon <: AbstractGeometry end
abstract type AbstractPolygon <: AbstractGeometry end
geotype(::AbstractPolygon) = :Polygon

@compat abstract type AbstractMultiPolygon <: AbstractGeometry end
abstract type AbstractMultiPolygon <: AbstractGeometry end
geotype(::AbstractMultiPolygon) = :MultiPolygon

@compat abstract type AbstractGeometryCollection <: AbstractGeometry end
abstract type AbstractGeometryCollection <: AbstractGeometry end
geotype(::AbstractGeometryCollection) = :GeometryCollection
geometries(obj::AbstractGeometryCollection) = error("geometries(::AbstractGeometryCollection) not defined.")

@compat abstract type AbstractFeature end
abstract type AbstractFeature end
geotype(::AbstractFeature) = :Feature
geometry(obj::AbstractFeature) = error("geometry(::AbstractFeature) not defined.")
# optional
properties(obj::AbstractFeature) = Dict{String,Any}()
bbox(obj::AbstractFeature) = nothing
crs(obj::AbstractFeature) = nothing

@compat abstract type AbstractFeatureCollection end
abstract type AbstractFeatureCollection end
geotype(::AbstractFeatureCollection) = :FeatureCollection
features(obj::AbstractFeatureCollection) = error("features(::AbstractFeatureCollection) not defined.")
# optional
Expand Down
84 changes: 42 additions & 42 deletions src/geotypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,106 +24,106 @@ hasz(p::Position) = length(p) >= 3
coordinates(obj::Position) = obj

coordinates(obj::Vector{Position}) = obj
coordinates{T <: AbstractPosition}(obj::Vector{T}) = Position[map(coordinates, obj)...]
coordinates{T <: AbstractPoint}(obj::Vector{T}) = Position[map(coordinates, obj)...]
coordinates(obj::Vector{T}) where {T <: AbstractPosition} = Position[map(coordinates, obj)...]
coordinates(obj::Vector{T}) where {T <: AbstractPoint} = Position[map(coordinates, obj)...]

coordinates(obj::Vector{Vector{Position}}) = obj
coordinates{T <: AbstractPosition}(obj::Vector{Vector{T}}) = Vector{Position}[map(coordinates, obj)...]
coordinates{T <: AbstractPoint}(obj::Vector{Vector{T}}) = Vector{Position}[map(coordinates, obj)...]
coordinates{T <: AbstractLineString}(obj::Vector{T}) = Vector{Position}[map(coordinates, obj)...]
coordinates(obj::Vector{Vector{T}}) where {T <: AbstractPosition} = Vector{Position}[map(coordinates, obj)...]
coordinates(obj::Vector{Vector{T}}) where {T <: AbstractPoint} = Vector{Position}[map(coordinates, obj)...]
coordinates(obj::Vector{T}) where {T <: AbstractLineString} = Vector{Position}[map(coordinates, obj)...]

coordinates(obj::Vector{Vector{Vector{Position}}}) = obj
coordinates{T <: AbstractPosition}(obj::Vector{Vector{Vector{T}}}) = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates{T <: AbstractPoint}(obj::Vector{Vector{Vector{T}}}) = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates{T <: AbstractLineString}(obj::Vector{Vector{T}}) = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates{T <: AbstractPolygon}(obj::Vector{T}) = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates(obj::Vector{Vector{Vector{T}}}) where {T <: AbstractPosition} = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates(obj::Vector{Vector{Vector{T}}}) where {T <: AbstractPoint} = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates(obj::Vector{Vector{T}}) where {T <: AbstractLineString} = Vector{Vector{Position}}[map(coordinates, obj)...]
coordinates(obj::Vector{T}) where {T <: AbstractPolygon} = Vector{Vector{Position}}[map(coordinates, obj)...]

type Point <: AbstractPoint
mutable struct Point <: AbstractPoint
coordinates::Position
end
Point(x::Float64,y::Float64) = Point([x,y])
Point(x::Float64,y::Float64,z::Float64) = Point([x,y,z])
Point(point::AbstractPosition) = Point(coordinates(point))
Point(point::AbstractPoint) = Point(coordinates(point))

type MultiPoint <: AbstractMultiPoint
mutable struct MultiPoint <: AbstractMultiPoint
coordinates::Vector{Position}
end
MultiPoint(point::Position) = MultiPoint(Position[point])
MultiPoint(point::AbstractPosition) = MultiPoint(Position[coordinates(point)])
MultiPoint(point::AbstractPoint) = MultiPoint(Position[coordinates(point)])

MultiPoint{T <: AbstractPosition}(points::Vector{T}) = MultiPoint(coordinates(points))
MultiPoint{T <: AbstractPoint}(points::Vector{T}) = MultiPoint(coordinates(points))
MultiPoint(points::Vector{T}) where {T <: AbstractPosition} = MultiPoint(coordinates(points))
MultiPoint(points::Vector{T}) where {T <: AbstractPoint} = MultiPoint(coordinates(points))
MultiPoint(points::AbstractMultiPoint) = MultiPoint(coordinates(points))
MultiPoint(line::AbstractLineString) = MultiPoint(coordinates(line))

type LineString <: AbstractLineString
mutable struct LineString <: AbstractLineString
coordinates::Vector{Position}
end
LineString{T <: AbstractPosition}(points::Vector{T}) = LineString(coordinates(points))
LineString{T <: AbstractPoint}(points::Vector{T}) = LineString(coordinates(points))
LineString(points::Vector{T}) where {T <: AbstractPosition} = LineString(coordinates(points))
LineString(points::Vector{T}) where {T <: AbstractPoint} = LineString(coordinates(points))
LineString(points::AbstractMultiPoint) = LineString(coordinates(points))
LineString(line::AbstractLineString) = LineString(coordinates(line))

type MultiLineString <: AbstractMultiLineString
mutable struct MultiLineString <: AbstractMultiLineString
coordinates::Vector{Vector{Position}}
end
MultiLineString(line::Vector{Position}) = MultiLineString(Vector{Position}[line])
MultiLineString{T <: AbstractPosition}(line::Vector{T}) = MultiLineString(Vector{Position}[coordinates(line)])
MultiLineString{T <: AbstractPoint}(line::Vector{T}) = MultiLineString(Vector{Position}[coordinates(line)])
MultiLineString(line::Vector{T}) where {T <: AbstractPosition} = MultiLineString(Vector{Position}[coordinates(line)])
MultiLineString(line::Vector{T}) where {T <: AbstractPoint} = MultiLineString(Vector{Position}[coordinates(line)])
MultiLineString(line::AbstractLineString) = MultiLineString(Vector{Position}[coordinates(line)])

MultiLineString{T <: AbstractPosition}(lines::Vector{Vector{T}}) = MultiLineString(coordinates(lines))
MultiLineString{T <: AbstractPoint}(lines::Vector{Vector{T}}) = MultiLineString(coordinates(lines))
MultiLineString{T <: AbstractLineString}(lines::Vector{T}) = MultiLineString(Vector{Position}[map(coordinates,lines)])
MultiLineString(lines::Vector{Vector{T}}) where {T <: AbstractPosition} = MultiLineString(coordinates(lines))
MultiLineString(lines::Vector{Vector{T}}) where {T <: AbstractPoint} = MultiLineString(coordinates(lines))
MultiLineString(lines::Vector{T}) where {T <: AbstractLineString} = MultiLineString(Vector{Position}[map(coordinates,lines)])
MultiLineString(lines::AbstractMultiLineString) = MultiLineString(coordinates(line))
MultiLineString(poly::AbstractPolygon) = MultiLineString(coordinates(poly))

type Polygon <: AbstractPolygon
mutable struct Polygon <: AbstractPolygon
coordinates::Vector{Vector{Position}}
end
Polygon(line::Vector{Position}) = Polygon(Vector{Position}[line])
Polygon{T <: AbstractPosition}(line::Vector{T}) = Polygon(Vector{Position}[coordinates(line)])
Polygon{T <: AbstractPoint}(line::Vector{T}) = Polygon(Vector{Position}[coordinates(line)])
Polygon(line::Vector{T}) where {T <: AbstractPosition} = Polygon(Vector{Position}[coordinates(line)])
Polygon(line::Vector{T}) where {T <: AbstractPoint} = Polygon(Vector{Position}[coordinates(line)])
Polygon(line::AbstractLineString) = Polygon(Vector{Position}[coordinates(line)])

Polygon{T <: AbstractPosition}(lines::Vector{Vector{T}}) = Polygon(coordinates(lines))
Polygon{T <: AbstractPoint}(lines::Vector{Vector{T}}) = Polygon(coordinates(lines))
Polygon{T <: AbstractLineString}(lines::Vector{T}) = Polygon(coordinates(lines))
Polygon(lines::Vector{Vector{T}}) where {T <: AbstractPosition} = Polygon(coordinates(lines))
Polygon(lines::Vector{Vector{T}}) where {T <: AbstractPoint} = Polygon(coordinates(lines))
Polygon(lines::Vector{T}) where {T <: AbstractLineString} = Polygon(coordinates(lines))
Polygon(lines::AbstractMultiLineString) = Polygon(coordinates(lines))
Polygon(poly::AbstractPolygon) = Polygon(coordinates(poly))

type MultiPolygon <: AbstractMultiPolygon
mutable struct MultiPolygon <: AbstractMultiPolygon
coordinates::Vector{Vector{Vector{Position}}}
end
MultiPolygon(line::Vector{Position}) = MultiPolygon(Vector{Vector{Position}}[Vector{Position}[line]])
MultiPolygon{T <: AbstractPosition}(line::Vector{T}) = MultiPolygon(Vector{Vector{Position}}[Vector{Position}[coordinates(line)]])
MultiPolygon{T <: AbstractPoint}(line::Vector{T}) = MultiPolygon(Vector{Vector{Position}}[Vector{Position}[coordinates(line)]])
MultiPolygon(line::Vector{T}) where {T <: AbstractPosition} = MultiPolygon(Vector{Vector{Position}}[Vector{Position}[coordinates(line)]])
MultiPolygon(line::Vector{T}) where {T <: AbstractPoint} = MultiPolygon(Vector{Vector{Position}}[Vector{Position}[coordinates(line)]])
MultiPolygon(line::AbstractLineString) = MultiPolygon(Vector{Vector{Position}}[Vector{Position}[coordinates(line)]])

MultiPolygon{T <: AbstractPosition}(poly::Vector{Vector{T}}) = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon{T <: AbstractPoint}(poly::Vector{Vector{T}}) = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon{T <: AbstractLineString}(poly::Vector{T}) = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon(poly::Vector{Vector{T}}) where {T <: AbstractPosition} = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon(poly::Vector{Vector{T}}) where {T <: AbstractPoint} = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon(poly::Vector{T}) where {T <: AbstractLineString} = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon(poly::AbstractMultiLineString) = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])
MultiPolygon(poly::AbstractPolygon) = MultiPolygon(Vector{Vector{Position}}[coordinates(poly)])

MultiPolygon{T <: AbstractPosition}(polys::Vector{Vector{Vector{T}}}) = MultiPolygon(coordinates(polys))
MultiPolygon{T <: AbstractPoint}(polys::Vector{Vector{Vector{T}}}) = MultiPolygon(coordinates(polys))
MultiPolygon{T <: AbstractLineString}(polys::Vector{Vector{T}}) = MultiPolygon(coordinates(polys))
MultiPolygon{T <: AbstractPolygon}(polys::Vector{T}) = MultiPolygon(coordinates(polys))
MultiPolygon(polys::Vector{Vector{Vector{T}}}) where {T <: AbstractPosition} = MultiPolygon(coordinates(polys))
MultiPolygon(polys::Vector{Vector{Vector{T}}}) where {T <: AbstractPoint} = MultiPolygon(coordinates(polys))
MultiPolygon(polys::Vector{Vector{T}}) where {T <: AbstractLineString} = MultiPolygon(coordinates(polys))
MultiPolygon(polys::Vector{T}) where {T <: AbstractPolygon} = MultiPolygon(coordinates(polys))
MultiPolygon(polys::AbstractMultiPolygon) = MultiPolygon(coordinates(polys))

for geom in (:MultiPolygon, :Polygon, :MultiLineString, :LineString, :MultiPoint, :Point)
@eval coordinates(obj::$geom) = obj.coordinates
end

type GeometryCollection <: AbstractGeometryCollection
mutable struct GeometryCollection <: AbstractGeometryCollection
geometries::Vector
end
geometries(collection::GeometryCollection) = collection.geometries

type Feature <: AbstractFeature
mutable struct Feature <: AbstractFeature
geometry::Union{Void, AbstractGeometry}
properties::Union{Void, Dict{String,Any}}
end
Expand All @@ -134,12 +134,12 @@ properties(feature::Feature) = feature.properties
bbox(feature::Feature) = get(feature.properties, "bbox", nothing)
crs(feature::Feature) = get(feature.properties, "crs", nothing)

type FeatureCollection{T <: AbstractFeature} <: AbstractFeatureCollection
mutable struct FeatureCollection{T <: AbstractFeature} <: AbstractFeatureCollection
features::Vector{T}
bbox::Union{Void, BBox}
crs::Union{Void, CRS}
end
FeatureCollection{T <: AbstractFeature}(fc::Vector{T}) = FeatureCollection(fc, nothing, nothing)
FeatureCollection(fc::Vector{T}) where {T <: AbstractFeature} = FeatureCollection(fc, nothing, nothing)
features(fc::FeatureCollection) = fc.features
bbox(fc::FeatureCollection) = fc.bbox
crs(fc::FeatureCollection) = fc.crs

0 comments on commit 6d901cd

Please sign in to comment.