1:- module(
    2  geojson,
    3  [
    4    geojson_shape/2 % +Dict, -Shape
    5  ]
    6).

GeoJSON support

*/

   12:- use_module(library(apply)).
 geojson_shape(+Dict:dict, -Shape:compound) is det
   20geojson_shape(Dict, shape(_Z,_LRS,_Crs,Shape)) :-
   21  _{coordinates: Coords, type: Type0} :< Dict,
   22  downcase_atom(Type0, Type),
   23  geojson_shape_(Type, Coords, Shape).
   24
   25geojson_shape_(linestring, L, 'LineString'(Points)) :- !,
   26  maplist(geojson_shape_(point), L, Points).
   27geojson_shape_(multilinestring, L, 'MultiLineString'(Lines)) :- !,
   28  maplist(geojson_shape_(linestring), L, Lines).
   29geojson_shape_(multipoint, L, 'MultiPoint'(Points)) :- !,
   30  maplist(geojson_shape_(point), L, Points).
   31geojson_shape_(multipolygon, L, 'MultiPolygon'(Polygons)) :- !,
   32  maplist(geojson_shape_(polygon), L, Polygons).
   33geojson_shape_(point, L, 'Point'(L)) :- !.
   34geojson_shape_(polygon, L, 'Polygon'(Lines)) :-
   35  maplist(geojson_shape_(linestring), L, Lines)