{"id":13741970,"url":"https://github.com/mitchellh/libflightplan","last_synced_at":"2025-07-24T08:39:26.217Z","repository":{"id":39727697,"uuid":"443915031","full_name":"mitchellh/libflightplan","owner":"mitchellh","description":"A library for reading and writing flight plans in various formats. Available as both a C and Zig library.","archived":false,"fork":false,"pushed_at":"2022-01-23T05:19:59.000Z","size":227,"stargazers_count":155,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-11T16:57:43.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchellh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-03T02:00:50.000Z","updated_at":"2025-05-25T12:02:38.000Z","dependencies_parsed_at":"2022-07-20T13:32:25.483Z","dependency_job_id":null,"html_url":"https://github.com/mitchellh/libflightplan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mitchellh/libflightplan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Flibflightplan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Flibflightplan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Flibflightplan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Flibflightplan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchellh","download_url":"https://codeload.github.com/mitchellh/libflightplan/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Flibflightplan/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266815283,"owners_count":23988564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:01:04.691Z","updated_at":"2025-07-24T08:39:26.161Z","avatar_url":"https://github.com/mitchellh.png","language":"Zig","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# libflightplan (Zig and C)\n\nlibflightplan is a library for reading and writing flight plans in\nvarious formats. Flight plans are used in aviation to save properties of\none or more flights such as route (waypoints), altitude, source and departure\nairport, etc. This library is written primarily in Zig but exports a C ABI\ncompatible shared and static library so that any programming language that\ncan interface with C can interface with this library.\n\n**Warning!** If you use this library with the intention of using the\nflight plan for actual flight, be very careful to verify the plan in\nyour avionics or EFB. Never trust the output of this library for actual\nflight.\n\n**Library status: Unstable.** This library is _brand new_ and was built for\nhobby purposes. It only supports a handful of formats, with limitations.\nMy primary interest at the time of writing this is ForeFlight flight plans\nand being able to use them to build supporting tools, but I'm interested\nin supporting more formats over time.\n\n## Formats\n\n| Name | Ext | Read | Write |\n| :--- | :---: | :---: | :---: |\n| ForeFlight | FPL | ✅ | ✅* |\n| Garmin | FPL | ✅ | ✅* |\n| X-Plane FMS 11 | FMS | ❌ | ✅* |\n\n\\*: The C API doesn't support creating flight plans from scratch or\nmodifying existing flight plans. But you can read in one format and\nencode in another. The Zig API supports full creation and modification.\n\n## Usage\n\nlibflightplan can be used from C and [Zig](https://ziglang.org/). Examples\nfor each are shown below.\n\n### C\n\nThe C API is documented as\n[man pages](https://github.com/mitchellh/libflightplan/tree/main/doc) as well as the\n[flightplan.h header file](https://github.com/mitchellh/libflightplan/blob/main/include/flightplan.h).\nAn example program is available in [`examples/basic.c`](https://github.com/mitchellh/libflightplan/blob/main/examples/basic.c),\nand a simplified version is reproduced below. This example shows how to\nread and extract information from a ForeFlight flight plan.\n\nThe C API is available as both a static and shared library. To build them,\ninstall [Zig](https://ziglang.org/) and run `zig build install`. This also\ninstalls `pkg-config` files so the header and libraries can be easily found\nand integrated with other build systems.\n\n```c\n#include \u003cstddef.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cflightplan.h\u003e\n\nint main() {\n\t// Parse our flight plan from an FPL file out of ForeFlight.\n\tflightplan *fpl = fpl_garmin_parse_file(\"./test/basic.fpl\");\n\tif (fpl == NULL) {\n\t\t// We can get a more detailed error.\n\t\tflightplan_error *err = fpl_last_error();\n\t\tprintf(\"error: %s\\n\", fpl_error_message(err));\n\t\tfpl_cleanup();\n\t\treturn 1;\n\t}\n\n\t// Iterate and output the full ordered route.\n\tint max = fpl_route_points_count(fpl);\n\tprintf(\"\\nroute: \\\"%s\\\" (points: %d)\\n\", fpl_route_name(fpl), max);\n\tfor (int i = 0; i \u003c max; i++) {\n\t\tflightplan_route_point *point = fpl_route_points_get(fpl, i);\n\t\tprintf(\"  %s\\n\", fpl_route_point_identifier(point));\n\t}\n\n\t// Convert this to an X-Plane 11 flight plan.\n\tfpl_xplane11_write_to_file(fpl, \"./copy.fms\");\n\n\tfpl_free(fpl);\n\tfpl_cleanup();\n\treturn 0;\n}\n```\n\n### Zig\n\n```zig\nconst std = @import(\"std\");\nconst flightplan = @import(\"flightplan\");\n\nfn main() !void {\n\tdefer flightplan.deinit();\n\n\tvar alloc = std.heap.ArenaAllocator.init(std.heap.page_allocator);\n\tdefer alloc.deinit();\n\n\tvar fpl = try flightplan.Format.Garmin.initFromFile(alloc, \"./test/basic.fpl\");\n\tdefer fpl.deinit();\n\n\tstd.debug.print(\"route: \\\"{s}\\\" (points: {d})\\n\", .{\n\t\tfpl.route.name.?,\n\t\tfpl.route.points.items.len,\n\t});\n\tfor (fpl.route.points.items) |point| {\n\t\tstd.debug.print(\"  {s}\\n\", .{point});\n\t}\n\n\t// Convert to an X-Plane 11 flight plan format\n\tflightplan.Format.XPlaneFMS11.Format.writeToFile(\"./copy.fms\", fpl);\n}\n```\n\n## Build\n\nTo build libflightplan, you need to have the following installed:\n\n  * [Zig](https://ziglang.org/)\n  * [Libxml2](http://www.xmlsoft.org/)\n\nWith the dependencies installed, you can run `zig build` to make a local\nbuild of the libraries. You can run `zig build install` to build and install\nthe libraries and headers to your standard prefix. And you can run `zig build test`\nto run all the tests.\n\nA [Nix](https://nixos.org/) flake is also provided. If you are a Nix user, you\ncan easily build this library, depend on it, etc. You know who you are and you\nknow what to do.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Flibflightplan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchellh%2Flibflightplan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Flibflightplan/lists"}