use yojson to make geojson: fix bug with utf8

This commit is contained in:
Swrup 2022-02-19 02:19:13 +01:00
parent 18d2b56e07
commit dfda60c3e9
2 changed files with 17 additions and 14 deletions

View file

@ -190,20 +190,22 @@ let get_markers () =
let markers = List.map Result.get_ok (List.filter Result.is_ok markers_res) in
let pp_marker fmt (lat, lng, content, thread_id) =
Format.fprintf fmt
{|{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [%s,%s]
},
"properties": {
"content": "%s",
"thread_id": "%s"
}}|}
(* geojson use lng lat, and not lat lng*)
(Float.to_string lng)
(Float.to_string lat) (String.escaped content) thread_id
(* geojson use lng lat, and not lat lng*)
let json =
`Assoc
[ ("type", `String "Feature")
; ( "geometry"
, `Assoc
[ ("type", `String "Point")
; ("coordinates", `List [ `Float lng; `Float lat ])
] )
; ( "properties"
, `Assoc
[ ("content", `String content); ("thread_id", `String thread_id) ]
)
]
in
Yojson.pretty_print fmt json
in
let markers =
Format.asprintf "[%a]"