{"id":16189005,"url":"https://github.com/fogfish/geojson","last_synced_at":"2025-04-07T13:43:32.111Z","repository":{"id":46801638,"uuid":"368985089","full_name":"fogfish/geojson","owner":"fogfish","description":"GeoJSON / RFC7946 codec for Golang","archived":false,"fork":false,"pushed_at":"2023-08-17T19:34:04.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-18T16:24:21.727Z","etag":null,"topics":["codec","decoding","encoding","geojson","geojson-parser","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/fogfish.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-19T19:50:23.000Z","updated_at":"2023-07-09T15:14:51.000Z","dependencies_parsed_at":"2024-06-20T11:58:49.263Z","dependency_job_id":"71463eb9-a65e-4b54-9ae8-f9237dc0d767","html_url":"https://github.com/fogfish/geojson","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgeojson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgeojson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgeojson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fogfish%2Fgeojson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fogfish","download_url":"https://codeload.github.com/fogfish/geojson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247665912,"owners_count":20975783,"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","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":["codec","decoding","encoding","geojson","geojson-parser","go","golang"],"created_at":"2024-10-10T07:33:19.779Z","updated_at":"2025-04-07T13:43:32.092Z","avatar_url":"https://github.com/fogfish.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch3 align=\"center\"\u003e{ ㆞ }\u003c/h3\u003e\n  \u003ch3 align=\"center\"\u003eGeoJSON\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\u003cstrong\u003eGeoJSON codec for Go structs\u003c/strong\u003e\u003c/p\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003c!-- Version --\u003e\n    \u003ca href=\"https://github.com/fogfish/geojson/releases\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/v/tag/fogfish/geojson?label=version\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- Documentation --\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/fogfish/geojson\"\u003e\n      \u003cimg src=\"https://pkg.go.dev/badge/github.com/fogfish/geojson\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- Build Status  --\u003e\n    \u003ca href=\"https://github.com/fogfish/geojson/actions/\"\u003e\n      \u003cimg src=\"https://github.com/fogfish/geojson/workflows/build/badge.svg\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub --\u003e\n    \u003ca href=\"http://github.com/fogfish/geojson\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/last-commit/fogfish/geojson.svg\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- Coverage --\u003e\n    \u003ca href=\"https://coveralls.io/github/fogfish/geojson?branch=main\"\u003e\n      \u003cimg src=\"https://coveralls.io/repos/github/fogfish/geojson/badge.svg?branch=main\" /\u003e\n    \u003c/a\u003e\n    \u003c!-- Go Card --\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/fogfish/geojson\"\u003e\n      \u003cimg src=\"https://goreportcard.com/badge/github.com/fogfish/geojson\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n---\n\nThe library implements a type safe codec for [GeoJSON](https://geojson.org) with the focus on encoding application specific data.  \n\n## Inspiration\n\nGeoJSON is a popular format for encoding a variety of geographic data structures. It defines a standard way to express points, curves, and surfaces in coordinate space together with an application specific metadata about it.\n\n```json\n{\n  \"type\": \"Feature\",\n  \"id\": \"[wikipedia:Helsinki]\",\n  \"geometry\": {\n    \"type\": \"Point\",\n    \"coordinates\": [24.9384, 60.1699]\n  },\n  \"properties\": {\n    \"name\": \"Helsinki\"\n  }\n}\n```\n\nUnfortunately, efficient and type-safe implementation of GeoJSON codec can be challenging:\n\n(i) Pure structs are verbose. The `properties` is an application specific and it's type is controlled outside of the codec library. Usage of duck type (`interface{}`) is a common trait used by other GeoJSON Golang libraries. As the results, developers are misses an ability to caught errors at compile time, any mistake becomes visible at run time as a panic. [interface{} says nothing.](https://youtu.be/PAAkCSZUG1c?t=7m40s).\n\n(ii) Implementing GeoJSON types using generics is requires overly complex type definitions. It can lead to complex type hierarchies, especially in nested GeoJSON structures like FeatureCollection. It suffers from usability for client application. Specifying types for properties at every level (e.g., Feature or FeatureCollection) adds boilerplate and increases the learning curve.\n\n\n\n## Key features\n\nThe library allows developers to use pure Golang struct to define domain models using a type safe approach of encoding/decoding these models to GeoJSON and back. The library uses type tagging technique to annotate any structure as GeoJSON feature:  \n\n```go\ntype City struct {\n  geojson.Feature\n  Name      string `json:\"name,omitempty\"`\n}\n```\n\n\n## Getting started\n\nThe latest version of the library is available at `main` branch of this repository. All development, including new features and bug fixes, take place on the `main` branch using forking and pull requests as described in contribution guidelines. The stable version is available via Golang modules.\n\nThe following code snippet demonstrates a typical usage scenario.\n\n```go\nimport \"github.com/fogfish/geojson\"\n\n//\n// declare any domain type and annotate as a geojson.Feature\ntype City struct {\n  geojson.Feature\n  Name      string `json:\"name,omitempty\"`\n}\n\n//\n// Each GeoJSON type declares JSON codes using helper functions.\nfunc (x City) MarshalJSON() ([]byte, error) {\n\ttype tStruct City\n\treturn x.Feature.EncodeGeoJSON(tStruct(x))\n}\n\nfunc (x *City) UnmarshalJSON(b []byte) error {\n\ttype tStruct *City\n\treturn x.Feature.DecodeGeoJSON(b, tStruct(x))\n}\n\n//\n// Create new instance of the type\ncity := City{\n  Feature: geojson.NewPoint(\n    \"[wikipedia:Helsinki]\",\n    geojson.Coord{24.9384, 60.1699},\n  ),\n  Name: \"Helsinki\",\n}\n\n//\n// Use type checks to validate the type of the Geometry \ncity.Feature.Geometry.Coords.(*geojson.Point)\n```\n\n### Feature Collection\n\nThe library support feature collection through the collection type. It represents a collection of spatially bounded elements, as defined by the GeoJSON FeatureCollection standard. This construct is designed to support [\"foreign members\"](https://www.rfc-editor.org/rfc/rfc7946#section-6.1) for improved exchange of geospatial data. The value of a \"foreign member\" is determined by the application.\n\n**This library reuses the \"properties\" attribute, which acts as a foreign member within the context of collections.**\n\n```go\ntype Cities struct {\n  geojson.Collection[City]\n  Country string `json:\"country,omitempty\"`\n}\n\n//\n// Each GeoJSON type declares JSON codes using helper functions.\nfunc (x Cities) MarshalJSON() ([]byte, error) {\n\ttype tStruct Cities\n\treturn x.Collection.EncodeGeoJSON(tStruct(x))\n}\n\nfunc (x *Cities) UnmarshalJSON(b []byte) error {\n\ttype tStruct *Cities\n\treturn x.Collection.DecodeGeoJSON(b, tStruct(x))\n}\n```\n\n\n## How To Contribute\n\nThe library is [MIT](LICENSE) licensed and accepts contributions via GitHub pull requests:\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\nThe build and testing process requires [Go](https://golang.org) version 1.16 or later.\n\n**build** and **test** library.\n\n```bash\ngit clone https://github.com/fogfish/geojson\ncd geojson\ngo test\n```\n\n### commit message\n\nThe commit message helps us to write a good release note, speed-up review process. The message should address two question what changed and why. The project follows the template defined by chapter [Contributing to a Project](http://git-scm.com/book/ch5-2.html) of Git book.\n\n### bugs\n\nIf you experience any issues with the library, please let us know via [GitHub issues](https://github.com/fogfish/geojson/issue). We appreciate detailed and accurate reports that help us to identity and replicate the issue. \n\n\n## License\n\n[![See LICENSE](https://img.shields.io/github/license/fogfish/geojson.svg?style=for-the-badge)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffogfish%2Fgeojson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffogfish%2Fgeojson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffogfish%2Fgeojson/lists"}