diff --git a/.travis.yml b/.travis.yml index e8adaeb..2e91687 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ os: - linux - osx julia: - - 0.4 - 0.5 + - 0.6 - nightly notifications: email: false diff --git a/README.md b/README.md index 92097bf..a57dd88 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ To support operations or visualization of multiple (but similar) implementations ## GEO Interface ### AbstractPosition -A position can be thought of as a tuple of numbers. There must be at least two elements, and may be more. The order of elements must follow `x`, `y`, `z` order (e.g. easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Hence it requires the following methods: +A position can be thought of as a tuple of numbers. There must be at least two elements, and may be more. The order of elements must follow `x`, `y`, `z` order (e.g. easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). It requires the following methods: -- `x(::AbstractPosition)::Float64` -- `y(::AbstractPosition)::Float64` -- `z(::AbstractPosition)::Float64` +- `xcoord(::AbstractPosition)::Float64` +- `ycoord(::AbstractPosition)::Float64` +- `zcoord(::AbstractPosition)::Float64` - `hasz(::AbstractPosition)::Bool` (`false` by default) -Remark: Although the specification allows the representation of up to 3 dimensions, not all algorithms support require all 3 dimensions. Also, if you are working with an arbitrary `obj::AbstractPosition`, you should call `hasz(obj)` before calling `z(obj)`. +Remark: Although the specification allows the representation of up to 3 dimensions, not all algorithms support require all 3 dimensions. Also, if you are working with an arbitrary `obj::AbstractPosition`, you should call `hasz(obj)` before calling `zcoord(obj)`. ### AbstractGeometry Represents vector geometry, and encompasses the following abstract types: `AbstractPoint, AbstractMultiPoint, AbstractLineString, AbstractMultiLineString, AbstractMultiPolygon, AbstractPolygon`. It requires the `coordinates` method, where diff --git a/REQUIRE b/REQUIRE index 2564873..94237c0 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1 @@ -julia 0.4 -Compat 0.8 +julia 0.5 diff --git a/src/GeoInterface.jl b/src/GeoInterface.jl index bfc948b..edae629 100644 --- a/src/GeoInterface.jl +++ b/src/GeoInterface.jl @@ -2,8 +2,6 @@ __precompile__() module GeoInterface - using Compat - export AbstractPosition, Position, AbstractGeometry, AbstractGeometryCollection, GeometryCollection, AbstractPoint, Point, @@ -16,7 +14,7 @@ module GeoInterface AbstractFeatureCollection, FeatureCollection, geotype, # methods - x, y, z, hasz, + xcoord, ycoord, zcoord, hasz, coordinates, geometries, geometry, bbox, crs, properties, @@ -24,19 +22,19 @@ module GeoInterface abstract AbstractPosition{T <: Real} <: AbstractVector{T} geotype(::AbstractPosition) = :Position - x(::AbstractPosition) = error("x(::AbstractPosition) not defined.") - y(::AbstractPosition) = error("y(::AbstractPosition) not defined.") + xcoord(::AbstractPosition) = error("xcoord(::AbstractPosition) not defined.") + ycoord(::AbstractPosition) = error("ycoord(::AbstractPosition) not defined.") # optional - z(::AbstractPosition) = error("z(::AbstractPosition) not defined.") + zcoord(::AbstractPosition) = error("zcoord(::AbstractPosition) not defined.") hasz(::AbstractPosition) = false - coordinates(p::AbstractPosition) = hasz(p) ? Float64[x(p),y(p),z(p)] : Float64[x(p),y(p)] + 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.ndims(AbstractPosition) = 1 Base.length(p::AbstractPosition) = hasz(p) ? 3 : 2 Base.size(p::AbstractPosition) = (length(p),) Base.size(p::AbstractPosition, n::Int) = (n == 1) ? length(p) : 1 - Base.getindex(p::AbstractPosition, i::Int) = (i==1) ? x(p) : (i==2) ? y(p) : (i==3) ? z(p) : nothing + Base.getindex(p::AbstractPosition, i::Int) = (i==1) ? xcoord(p) : (i==2) ? ycoord(p) : (i==3) ? zcoord(p) : nothing Base.convert(::Type{Vector{Float64}}, p::AbstractPosition) = coordinates(p) # Base.linearindexing{T <: AbstractPosition}(::Type{T}) = LinearFast() @@ -69,7 +67,7 @@ module GeoInterface geotype(::AbstractFeature) = :Feature geometry(obj::AbstractFeature) = error("geometry(::AbstractFeature) not defined.") # optional - properties(obj::AbstractFeature) = Dict{AbstractString,Any}() + properties(obj::AbstractFeature) = Dict{String,Any}() bbox(obj::AbstractFeature) = nothing crs(obj::AbstractFeature) = nothing diff --git a/src/geotypes.jl b/src/geotypes.jl index c783d2f..749cbe8 100644 --- a/src/geotypes.jl +++ b/src/geotypes.jl @@ -1,7 +1,7 @@ # Coordinate Reference System Objects # (has keys "type" and "properties") # TODO: Handle full CRS spec -typealias CRS Dict{AbstractString,Any} +typealias CRS Dict{String,Any} # Bounding Boxes # The value of the bbox member must be a 2*n array, @@ -17,9 +17,9 @@ typealias Position Vector{Float64} # (x, y, [z, ...]) - meaning of additional elements undefined. # In an object's contained geometries, Positions must have uniform dimensions. geotype(::Position) = :Position -x(p::Position) = p[1] -y(p::Position) = p[2] -z(p::Position) = hasz(p) ? p[3] : zero(T) +xcoord(p::Position) = p[1] +ycoord(p::Position) = p[2] +zcoord(p::Position) = hasz(p) ? p[3] : zero(T) hasz(p::Position) = length(p) >= 3 coordinates(obj::Position) = obj @@ -125,10 +125,10 @@ geometries(collection::GeometryCollection) = collection.geometries type Feature <: AbstractFeature geometry::Union{Void, AbstractGeometry} - properties::Union{Void, Dict{AbstractString,Any}} + properties::Union{Void, Dict{String,Any}} end -Feature(geometry::Union{Void,GeoInterface.AbstractGeometry}) = Feature(geometry, Dict{AbstractString,Any}()) -Feature(properties::Dict{AbstractString,Any}) = Feature(nothing, properties) +Feature(geometry::Union{Void,GeoInterface.AbstractGeometry}) = Feature(geometry, Dict{String,Any}()) +Feature(properties::Dict{String,Any}) = Feature(nothing, properties) geometry(feature::Feature) = feature.geometry properties(feature::Feature) = feature.properties bbox(feature::Feature) = get(feature.properties, "bbox", nothing)