Skip to content

A libary that provides spatial types and support for the GeoJSON format.

License

Notifications You must be signed in to change notification settings

fluxera/Fluxera.Spatial

Repository files navigation

Build Status

Fluxera.Spatial

A libary that provides spatial types based on GeoJSON defined in RFC 7946.

Usage

Just use the provied structs to define your classes that need gep-spatial informations in it.

public sealed class Restaurant
{
	public string Name { get; set; }

	public Point Location { get; set; }
}

Supported GeoJSON objects

This libary privide an inclomple implementation of RFC 7946 at the moment. The basic geometries are supported.

  • Point
  • MultiPoint
  • LineString
  • MultiLineString
  • Polygon
  • MultiPolygon
  • GeometryCollection

Please refer to the documentation of RFC 7946 for details.

Serialization Support

At the moment serialization support is available for:

The serializers make sure that the objects are serialized in the GeoJSON format and in case of databases also stored im the correct format to support indexing and geo queries.

Newtonsoft.Json (JSON.NET)

To support the GeoJSON objects in JSON.NET use the UseSpatial extension method on the JsonSerializerSettings.

JsonSerializerSettings settings = new JsonSerializerSettings();

// Use the serialization support for GeoJSON objects.
settings.UseSpatial();

JsonConvert.DefaultSettings = () => settings;

LiteDB

To support the GeoJSON objects in LiteDB use the UseSpatial extension method on the global BsonMapper.

BsonMapper.Global.UseSpatial();

MongoDB

To support the GeoJSON objects in MongoDB use the UseSpatial extension method on a ConventionPack.

ConventionPack pack = new ConventionPack();
pack.UseSpatial();
ConventionRegistry.Register("ConventionPack", pack, t => true);

System.Text.Json

To support the GeoJSON objects in System.Text.Json use the UseSpatial extension method on the JsonSerializerOptions.

private JsonSerializerOptions options;

this.options = new JsonSerializerOptions
{
	WriteIndented = false
};
this.options.UseSpatial();

JsonSerializer.Serialize(Point.Empty, this.options);

References

RFC 7946

Future

We plan to add support for EFCore and OData and to add the missing pieces of the RFC Specification.