Ingests GeoJSON into Meridian.Graph structures.
Requires the optional :jason dependency.
Supported Geometry Types
Point— single nodeLineString— edge path; intermediate vertices become nodesMultiLineString— multiple edgesPolygon— ring of edgesFeatureCollection— iterated over features
Examples
geojson = ~s[{"type":"FeatureCollection","features":[...]}]
{:ok, graph} = Meridian.IO.GeoJSON.from_string(geojson)
Summary
Functions
Reads a GeoJSON file and builds a Meridian.Graph.
Reads a GeoJSON file and builds a Meridian.Graph, raising on error.
Builds a graph from a decoded GeoJSON map.
Parses a GeoJSON string and builds a Meridian.Graph.
Parses a GeoJSON string and builds a Meridian.Graph, raising on error.
Functions
@spec from_file( Path.t(), keyword() ) :: {:ok, Meridian.Graph.t()} | {:error, String.t()}
Reads a GeoJSON file and builds a Meridian.Graph.
Returns {:ok, graph} on success or {:error, reason} on failure.
@spec from_file!( Path.t(), keyword() ) :: Meridian.Graph.t()
Reads a GeoJSON file and builds a Meridian.Graph, raising on error.
@spec from_map( map(), keyword() ) :: Meridian.Graph.t()
Builds a graph from a decoded GeoJSON map.
@spec from_string( String.t(), keyword() ) :: {:ok, Meridian.Graph.t()} | {:error, String.t()}
Parses a GeoJSON string and builds a Meridian.Graph.
Returns {:ok, graph} on success or {:error, reason} on failure.
Options
:kind—:directed(default) or:undirected:crs— CRS string override, default"EPSG:4326":weight_fn— function(%Geo.LineString{} -> number)to compute edge weights
Examples
iex> geojson = ~s|{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[0,0],[0,1]]},"properties":{}}]}|
iex> {:ok, graph} = Meridian.IO.GeoJSON.from_string(geojson)
iex> Meridian.Graph.node_count(graph) == 2
true
iex> Meridian.Graph.edge_count(graph) == 1
true
@spec from_string!( String.t(), keyword() ) :: Meridian.Graph.t()
Parses a GeoJSON string and builds a Meridian.Graph, raising on error.