forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlGeoJSONExtensions.cs
More file actions
23 lines (21 loc) · 954 Bytes
/
NpgsqlGeoJSONExtensions.cs
File metadata and controls
23 lines (21 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using Npgsql.GeoJSON.Internal;
using Npgsql.TypeMapping;
// ReSharper disable once CheckNamespace
namespace Npgsql;
/// <summary>
/// Extension allowing adding the GeoJSON plugin to an Npgsql type mapper.
/// </summary>
public static class NpgsqlGeoJSONExtensions
{
/// <summary>
/// Sets up GeoJSON mappings for the PostGIS types.
/// </summary>
/// <param name="mapper">The type mapper to set up (global or connection-specific)</param>
/// <param name="options">Options to use when constructing objects.</param>
/// <param name="geographyAsDefault">Specifies that the geography type is used for mapping by default.</param>
public static INpgsqlTypeMapper UseGeoJson(this INpgsqlTypeMapper mapper, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false)
{
mapper.AddTypeResolverFactory(new GeoJSONTypeHandlerResolverFactory(options, geographyAsDefault));
return mapper;
}
}