Skip to content

Feature errors with missing properties keyword #119

@jd-foster

Description

@jd-foster

This errors when leaving properties= undefined inside a Feature() call, due to an unhandled internal conversion:

julia> GeoJSON.Feature(geometry=GeoJSON.LineString(coordinates=[(-34.07941, 150.80075), (-34.077, 150.8003)]))
ERROR: MethodError: Cannot `convert` an object of type @NamedTuple{} to an object of type Dict{Symbol, Any}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  Dict{K, V}(::Any) where {K, V}
   @ Base dict.jl:90
  convert(::Type{T}, ::T) where T<:AbstractDict
   @ Base abstractdict.jl:575
  convert(::Type{T}, ::AbstractDict) where T<:AbstractDict
   @ Base abstractdict.jl:577
  ...

Stacktrace:
 [1] convert(::Type{Union{Nothing, Dict{Symbol, Any}}}, x::@NamedTuple{})
   @ Base ./some.jl:37
 [2] GeoJSON.Feature{…}(id::Nothing, bbox::Nothing, geometry::GeoJSON.LineString{…}, properties::@NamedTuple{})
   @ GeoJSON ~/.julia/packages/GeoJSON/73eSw/src/geojson_types.jl:170
 [3] GeoJSON.Feature(; id::Nothing, bbox::Nothing, geometry::GeoJSON.LineString{2, Float64}, properties::@NamedTuple{})
   @ GeoJSON ~/.julia/packages/GeoJSON/73eSw/src/geojson_types.jl:173
 [4] top-level scope
   @ REPL[80]:1
Some type information was truncated. Use `show(err)` to see complete types.

Compare:

julia> GeoJSON.Feature(
	geometry=GeoJSON.LineString(coordinates=[(-34.07941, 150.80075), (-34.077, 150.8003)]),
	properties=Dict())
Feature with 2D LineString geometry and 1 properties: (:geometry,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions