package mlgpx
Library and CLI for parsing and generating GPS Exchange (GPX) formats
Install
dune-project
Dependency
Authors
Maintainers
Sources
mlgpx-1.0.0.tbz
md5=5342bb7e601273245a9fe263e5a08770
sha512=cd73b16e988b3ed3cc427a6c6c6d6c9c745adb1eb7efaae3c34e8d006e9c03d9f9d2616cd4118564bd9873903969d3e4053b585e79dbd3e3e7d0f541e2faac83
doc/src/mlgpx.core/waypoint.ml.html
Source file waypoint.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
(** Waypoint data and GPS fix types *) (** GPS fix types as defined in GPX spec *) type fix_type = | None_fix | Fix_2d | Fix_3d | Dgps | Pps (** Main waypoint type - shared by waypoints, route points, track points *) type t = { lat : Coordinate.latitude; lon : Coordinate.longitude; ele : float option; time : Ptime.t option; magvar : Coordinate.degrees option; geoidheight : float option; name : string option; cmt : string option; desc : string option; src : string option; links : Link.t list; sym : string option; type_ : string option; fix : fix_type option; sat : int option; hdop : float option; vdop : float option; pdop : float option; ageofdgpsdata : float option; dgpsid : int option; extensions : Extension.t list; } (** {2 Fix Type Operations} *) let fix_type_to_string = function | None_fix -> "none" | Fix_2d -> "2d" | Fix_3d -> "3d" | Dgps -> "dgps" | Pps -> "pps" let fix_type_of_string = function | "none" -> Some None_fix | "2d" -> Some Fix_2d | "3d" -> Some Fix_3d | "dgps" -> Some Dgps | "pps" -> Some Pps | _ -> None let compare_fix_type f1 f2 = match f1, f2 with | None_fix, None_fix -> 0 | None_fix, _ -> -1 | _, None_fix -> 1 | Fix_2d, Fix_2d -> 0 | Fix_2d, _ -> -1 | _, Fix_2d -> 1 | Fix_3d, Fix_3d -> 0 | Fix_3d, _ -> -1 | _, Fix_3d -> 1 | Dgps, Dgps -> 0 | Dgps, _ -> -1 | _, Dgps -> 1 | Pps, Pps -> 0 (** {2 Waypoint Operations} *) (** Create waypoint with required coordinates *) let make lat lon = { lat; lon; ele = None; time = None; magvar = None; geoidheight = None; name = None; cmt = None; desc = None; src = None; links = []; sym = None; type_ = None; fix = None; sat = None; hdop = None; vdop = None; pdop = None; ageofdgpsdata = None; dgpsid = None; extensions = []; } (** Create waypoint from float coordinates *) let make_from_floats ~lat ~lon ?name ?desc () = match Coordinate.latitude lat, Coordinate.longitude lon with | Ok lat_coord, Ok lon_coord -> let wpt = make lat_coord lon_coord in Ok { wpt with name; desc } | Error e, _ | _, Error e -> Error e (** Get coordinate pair *) let coordinate t = Coordinate.make t.lat t.lon (** Get latitude *) let lat t = t.lat (** Get longitude *) let lon t = t.lon (** Get coordinate as float pair *) let to_floats t = (Coordinate.latitude_to_float t.lat, Coordinate.longitude_to_float t.lon) (** Get elevation *) let elevation t = t.ele (** Get time *) let time t = t.time (** Get name *) let name t = t.name (** Get description *) let description t = t.desc (** Get comment *) let comment t = t.cmt (** Get source *) let source t = t.src (** Get symbol *) let symbol t = t.sym (** Get type *) let type_ t = t.type_ (** Get fix type *) let fix t = t.fix (** Get satellite count *) let sat t = t.sat (** Get horizontal dilution of precision *) let hdop t = t.hdop (** Get vertical dilution of precision *) let vdop t = t.vdop (** Get position dilution of precision *) let pdop t = t.pdop (** Get magnetic variation *) let magvar t = t.magvar (** Get geoid height *) let geoidheight t = t.geoidheight (** Get age of DGPS data *) let ageofdgpsdata t = t.ageofdgpsdata (** Get DGPS ID *) let dgpsid t = t.dgpsid (** Get links *) let links t = t.links (** Get extensions *) let extensions t = t.extensions (** Update elevation *) let with_elevation t ele = { t with ele = Some ele } (** Update time *) let with_time t time = { t with time } (** Update name *) let with_name t name = { t with name = Some name } (** Update comment *) let with_comment t cmt = { t with cmt = Some cmt } (** Update description *) let with_description t desc = { t with desc = Some desc } (** Update source *) let with_source t src = { t with src = Some src } (** Update symbol *) let with_symbol t sym = { t with sym = Some sym } (** Update type *) let with_type t type_ = { t with type_ = Some type_ } (** Update fix *) let with_fix t fix = { t with fix } (** Update satellite count *) let with_sat t sat = { t with sat = Some sat } (** Update HDOP *) let with_hdop t hdop = { t with hdop = Some hdop } (** Update VDOP *) let with_vdop t vdop = { t with vdop = Some vdop } (** Update PDOP *) let with_pdop t pdop = { t with pdop = Some pdop } (** Update magnetic variation *) let with_magvar t magvar = { t with magvar = Some magvar } (** Update geoid height *) let with_geoidheight t geoidheight = { t with geoidheight = Some geoidheight } (** Update age of DGPS data *) let with_ageofdgpsdata t ageofdgpsdata = { t with ageofdgpsdata = Some ageofdgpsdata } (** Update DGPS ID *) let with_dgpsid t dgpsid = { t with dgpsid = Some dgpsid } (** Add link *) let add_link t link = { t with links = link :: t.links } (** Add extensions *) let add_extensions t extensions = { t with extensions = extensions @ t.extensions } (** Compare waypoints *) let compare t1 t2 = let lat_cmp = Float.compare (Coordinate.latitude_to_float t1.lat) (Coordinate.latitude_to_float t2.lat) in if lat_cmp <> 0 then lat_cmp else let lon_cmp = Float.compare (Coordinate.longitude_to_float t1.lon) (Coordinate.longitude_to_float t2.lon) in if lon_cmp <> 0 then lon_cmp else let ele_cmp = Option.compare Float.compare t1.ele t2.ele in if ele_cmp <> 0 then ele_cmp else Option.compare Ptime.compare t1.time t2.time (** Test waypoint equality *) let equal t1 t2 = compare t1 t2 = 0 (** Pretty print waypoint *) let pp ppf t = let lat, lon = to_floats t in match t.name with | Some name -> Format.fprintf ppf "%s @ (%g, %g)" name lat lon | None -> Format.fprintf ppf "(%g, %g)" lat lon (** Pretty print fix type *) let pp_fix_type ppf = function | None_fix -> Format.fprintf ppf "none" | Fix_2d -> Format.fprintf ppf "2d" | Fix_3d -> Format.fprintf ppf "3d" | Dgps -> Format.fprintf ppf "dgps" | Pps -> Format.fprintf ppf "pps"
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>