Skip to content

Commit

Permalink
Merge pull request #10 from JuliaGeo/0.4rc4-depwarn
Browse files Browse the repository at this point in the history
fix dep warnings
  • Loading branch information
yeesian committed Oct 19, 2015
2 parents b6fbc33 + c4bb3eb commit 30d4e58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/parser.jl
@@ -1,6 +1,6 @@
# Dict -> GeoJSON

function dict2geojson(obj::Dict{String,Any})
function dict2geojson(obj::Dict{@compat(AbstractString),Any})
t = symbol(obj["type"])
if t == :FeatureCollection
return FeatureCollection(obj)
Expand Down Expand Up @@ -68,10 +68,10 @@ end

geojson2dict(obj::Nothing) = obj

# String/File -> GeoJSON
# @compat(AbstractString)/File -> GeoJSON
parse(input; kwargs...) = dict2geojson(JSON.parse(input; kwargs...))
parsefile(filename; kwargs...) = dict2geojson(JSON.parsefile(filename; kwargs...))

# GeoJSON -> String/IO
# GeoJSON -> @compat(AbstractString)/IO
geojson(obj::AbstractGeoJSON) = JSON.json(geojson2dict(obj))
print(io::IO, obj::AbstractGeoJSON) = JSON.print(io, geojson2dict(obj))
20 changes: 10 additions & 10 deletions src/types.jl
Expand Up @@ -3,7 +3,7 @@

# Coordinate Reference System Objects
# (has keys "type" and "properties")
typealias CRS Union(Nothing, Dict{String,Any})
typealias CRS @compat(Union{Void, Dict{@compat(AbstractString),Any}})
# TODO: Handle full CRS spec

# Position
Expand Down Expand Up @@ -93,14 +93,14 @@ end
# Feature Objects

type Feature <: AbstractGeoJSON
geometry::Union(Nothing, Geometry)
properties::Union(Nothing, Dict{String,Any})
geometry::@compat(Union{Void, Geometry})
properties::@compat(Union{Void, Dict{@compat(AbstractString),Any}})
# optional
id
bbox::Vector{Float64}
crs::CRS

Feature(geometry::Union(Nothing, Geometry)=nothing, properties::Union(Nothing, Dict{String,Any})=nothing; kwargs...) =
Feature(geometry::@compat(Union{Void, Geometry})=nothing, properties::@compat(Union{Void, Dict{@compat(AbstractString),Any}})=nothing; kwargs...) =
fill_options!(new(geometry, properties); kwargs...)
end
hasid(obj::Feature) = isdefined(obj, :id)
Expand All @@ -117,7 +117,7 @@ end

# Helper Functions

function fill_options!(obj::AbstractGeoJSON, param::String, value)
function fill_options!(obj::AbstractGeoJSON, param::@compat(AbstractString), value)
if param == "id"
obj.id = value
elseif param == "bbox"
Expand Down Expand Up @@ -146,7 +146,7 @@ function fill_options!(obj::AbstractGeoJSON; kwargs...)
obj
end

function fill_options!(obj::AbstractGeoJSON, kwargs::Dict{String,Any})
function fill_options!(obj::AbstractGeoJSON, kwargs::Dict{@compat(AbstractString),Any})
for (param, value) in kwargs
fill_options!(obj, param, value)
end
Expand All @@ -155,7 +155,7 @@ end

# Additional Constructors (Dict -> GeoJSON)

function GeometryCollection(obj::Dict{String,Any})
function GeometryCollection(obj::Dict{@compat(AbstractString),Any})
collection = GeometryCollection()
geometries = obj["geometries"]
sizehint!(collection.geometries, length(geometries))
Expand All @@ -166,18 +166,18 @@ function GeometryCollection(obj::Dict{String,Any})
end

for geom in (:MultiPolygon, :Polygon, :MultiLineString, :LineString, :MultiPoint, :Point)
@eval $(geom)(obj::Dict{String,Any}) = fill_options!($(geom)(obj["coordinates"]), obj)
@eval $(geom)(obj::Dict{@compat(AbstractString),Any}) = fill_options!($(geom)(obj["coordinates"]), obj)
end

function Feature(obj::Dict{String,Any})
function Feature(obj::Dict{@compat(AbstractString),Any})
feature = Feature(dict2geojson(obj["geometry"]), obj["properties"])
if haskey(obj, "id")
feature.id = obj["id"]
end
fill_options!(feature, obj)
end

function FeatureCollection(obj::Dict{String,Any})
function FeatureCollection(obj::Dict{@compat(AbstractString),Any})
features = obj["features"]
collection = FeatureCollection(Feature[])
sizehint!(collection.features, length(features))
Expand Down

0 comments on commit 30d4e58

Please sign in to comment.