use yojson to make geojson: fix bug with utf8
This commit is contained in:
parent
18d2b56e07
commit
dfda60c3e9
2 changed files with 17 additions and 14 deletions
1
src/dune
1
src/dune
|
|
@ -18,6 +18,7 @@
|
||||||
user
|
user
|
||||||
user_profile)
|
user_profile)
|
||||||
(libraries
|
(libraries
|
||||||
|
yojson
|
||||||
uuidm
|
uuidm
|
||||||
caqti.blocking
|
caqti.blocking
|
||||||
caqti-driver-sqlite3
|
caqti-driver-sqlite3
|
||||||
|
|
|
||||||
|
|
@ -190,20 +190,22 @@ let get_markers () =
|
||||||
let markers = List.map Result.get_ok (List.filter Result.is_ok markers_res) in
|
let markers = List.map Result.get_ok (List.filter Result.is_ok markers_res) in
|
||||||
|
|
||||||
let pp_marker fmt (lat, lng, content, thread_id) =
|
let pp_marker fmt (lat, lng, content, thread_id) =
|
||||||
Format.fprintf fmt
|
(* geojson use lng lat, and not lat lng*)
|
||||||
{|{
|
let json =
|
||||||
"type": "Feature",
|
`Assoc
|
||||||
"geometry": {
|
[ ("type", `String "Feature")
|
||||||
"type": "Point",
|
; ( "geometry"
|
||||||
"coordinates": [%s,%s]
|
, `Assoc
|
||||||
},
|
[ ("type", `String "Point")
|
||||||
"properties": {
|
; ("coordinates", `List [ `Float lng; `Float lat ])
|
||||||
"content": "%s",
|
] )
|
||||||
"thread_id": "%s"
|
; ( "properties"
|
||||||
}}|}
|
, `Assoc
|
||||||
(* geojson use lng lat, and not lat lng*)
|
[ ("content", `String content); ("thread_id", `String thread_id) ]
|
||||||
(Float.to_string lng)
|
)
|
||||||
(Float.to_string lat) (String.escaped content) thread_id
|
]
|
||||||
|
in
|
||||||
|
Yojson.pretty_print fmt json
|
||||||
in
|
in
|
||||||
let markers =
|
let markers =
|
||||||
Format.asprintf "[%a]"
|
Format.asprintf "[%a]"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue