Skip to content

ahokinson/GeoJson.NET-Unity

 
 

Repository files navigation

GeoJson.NET for Unity

GeoJSON.Net is a .NET library for the RFC 7946 The GeoJSON Format and it uses and provides Newtonsoft Json.NET converters for serialization and deserialization of GeoJSON data.

Why is a port needed?

Unity has historically used .NET 3.5 which limited C# programmers to C# 3.0 language features. As of Unity 2017, an experimental .NET 4.6 Runtime version has been introduced allowing C# 6.0 features. However, because GeoJson.NET is written with the latest language features, it is still incompatible with Unity. This project will serve as a continuous backport of GeoJson.NET to .NET 4.6 while preserving features and bug-fixes.

Installation & Usage

Download and import the .unitypackage to your project.

Serialization

Position position = new Position(51.899523, -2.124156);
Point point = new Point(position);

string json = JsonConvert.SerializeObject(point);

Deserialization

string json = "{\"coordinates\":[-2.124156,51.899523],\"type\":\"Point\"}";

Point point = JsonConvert.DeserializeObject<Point>(json);

See the Tests for more examples.

About

A port of the .NET library for GeoJSON types & corresponding Json.NET (de)serializers that works with Unity and .NET 4.6 (C# 6.0)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%