https://github.com/fluxera/fluxera.spatial
A libary that provides spatial types and support for the GeoJSON format.
https://github.com/fluxera/fluxera.spatial
dotnet dotnet8 dotnetcore geojson geolocation geospatial spatial
Last synced: 15 days ago
JSON representation
A libary that provides spatial types and support for the GeoJSON format.
- Host: GitHub
- URL: https://github.com/fluxera/fluxera.spatial
- Owner: fluxera
- License: mit
- Created: 2022-02-21T09:31:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T15:36:03.000Z (6 months ago)
- Last Synced: 2024-11-14T15:52:13.463Z (6 months ago)
- Topics: dotnet, dotnet8, dotnetcore, geojson, geolocation, geospatial, spatial
- Language: C#
- Homepage:
- Size: 160 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://dev.azure.com/fluxera/Foundation/_build/latest?definitionId=81&branchName=main)
# Fluxera.Spatial
A libary that provides spatial types based on GeoJSON defined in [RFC 7946](https://datatracker.ietf.org/doc/html/rfc7946).## Usage
Just use the provied structs to define your classes that need gep-spatial informations in it.
```C#
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](https://datatracker.ietf.org/doc/html/rfc7946) at the moment.
The basic geometries are supported.- ```Point```
- ```MultiPoint```
- ```LineString```
- ```MultiLineString```
- ```Polygon```
- ```MultiPolygon```
- ```GeometryCollection```Please refer to the documentation of [RFC 7946](https://datatracker.ietf.org/doc/html/rfc7946) for details.
## Serialization Support
At the moment serialization support is available for:
- [Newtonsoft.Json (JSON.NET)](https://github.com/JamesNK/Newtonsoft.Json)
- [LiteDB](https://github.com/mbdavid/LiteDB)
- [MongoDB](https://github.com/mongodb/mongo-csharp-driver)
- [System.Text.Json](https://github.com/dotnet/corefx/tree/master/src/System.Text.Json)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```.
```c#
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```.
```C#
BsonMapper.Global.UseSpatial();
```### MongoDB
To support the GeoJSON objects in MongoDB use the ```UseSpatial``` extension method on a ```ConventionPack```.
```C#
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```.
```C#
private JsonSerializerOptions options;this.options = new JsonSerializerOptions
{
WriteIndented = false
};
this.options.UseSpatial();JsonSerializer.Serialize(Point.Empty, this.options);
```## References
[RFC 7946](https://datatracker.ietf.org/doc/html/rfc7946)
## Future
We plan to add support for EFCore and OData and to add the missing pieces of the RFC Specification.