GeoGenius.Providers.GeoJSON (geo_genius v0.2.0)

Copy Markdown View Source

Provider for a single GeoJSON FeatureCollection artifact.

One feature becomes one staged row: payload is the feature's "properties" map, geom is its decoded geometry or nil for a feature that carries none. normalize/2 reads the code and name out of payload using the manifest's options, so the same module serves any collection whose properties name their code and display name differently.

required_options/0 requires "area_type" and "code_property". The remaining options keys are optional:

  • "name_property" -- defaults to "name".
  • "authority" -- defaults to the manifest's own authority, when it declares exactly one.
  • "attribute_properties" -- a list; defaults to [].
  • "alias_properties" -- a list; defaults to [].
  • "code_properties" -- a list of %{"type" => ..., "property" => ...}; defaults to [].

See the option-vocabulary table in GeoGenius.Provider's moduledoc for how these correspond to GeoGenius.Providers.CSV's own option keys.

Summary

Functions

Every artifact declared across the manifest's sources; a GeoJSON collection's artifacts are all GeoJSON.

Asserts an edge from each area the row implies to the row's own area.

Reads the code and name out of the staged row's payload, using the manifest's options.

GeoJSON areas carry no hierarchy of their own; relations are always rebuilt.

Requires area_type and code_property in the manifest's options.

Reads path as a GeoJSON FeatureCollection and emits its features in chunks of 1000 rows.

Validates the manifest's implied_areas entries, whose code key is code_property.

Functions

artifacts(manifest)

Every artifact declared across the manifest's sources; a GeoJSON collection's artifacts are all GeoJSON.

asserted_relations(manifest, row)

@spec asserted_relations(GeoGenius.Manifest.t(), GeoGenius.Staging.Row.t()) :: [
  {String.t(), String.t(), String.t()}
]

Asserts an edge from each area the row implies to the row's own area.

normalize(manifest, row)

@spec normalize(GeoGenius.Manifest.t(), GeoGenius.Staging.Row.t()) ::
  {:ok, GeoGenius.Provider.Area.t()}
  | {:ok, [GeoGenius.Provider.Area.t()]}
  | :skip
  | {:error, String.t()}

Reads the code and name out of the staged row's payload, using the manifest's options.

relations(manifest)

@spec relations(GeoGenius.Manifest.t()) :: :rebuild

GeoJSON areas carry no hierarchy of their own; relations are always rebuilt.

required_options()

@spec required_options() :: [String.t()]

Requires area_type and code_property in the manifest's options.

stage(manifest, artifact, path, emit, opts)

Reads path as a GeoJSON FeatureCollection and emits its features in chunks of 1000 rows.

validate_options(options)

@spec validate_options(map()) :: :ok | {:error, String.t()}

Validates the manifest's implied_areas entries, whose code key is code_property.