X Tutup
using Npgsql.GeoJSON; using Npgsql.GeoJSON.Internal; using Npgsql.TypeMapping; // ReSharper disable once CheckNamespace namespace Npgsql; /// /// Extension allowing adding the GeoJSON plugin to an Npgsql type mapper. /// public static class NpgsqlGeoJSONExtensions { // Note: defined for binary compatibility and NpgsqlConnection.GlobalTypeMapper. /// /// Sets up GeoJSON mappings for the PostGIS types. /// /// The type mapper to set up (global or connection-specific) /// Options to use when constructing objects. /// Specifies that the geography type is used for mapping by default. public static INpgsqlTypeMapper UseGeoJson(this INpgsqlTypeMapper mapper, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false) { mapper.AddTypeInfoResolverFactory(new GeoJSONTypeInfoResolverFactory(options, geographyAsDefault, crsMap: null)); return mapper; } // Note: defined for binary compatibility and NpgsqlConnection.GlobalTypeMapper. /// /// Sets up GeoJSON mappings for the PostGIS types. /// /// The type mapper to set up (global or connection-specific) /// A custom crs map that might contain more or less entries than the default well-known crs map. /// Options to use when constructing objects. /// Specifies that the geography type is used for mapping by default. public static INpgsqlTypeMapper UseGeoJson(this INpgsqlTypeMapper mapper, CrsMap crsMap, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false) { mapper.AddTypeInfoResolverFactory(new GeoJSONTypeInfoResolverFactory(options, geographyAsDefault, crsMap)); return mapper; } /// /// Sets up GeoJSON mappings for the PostGIS types. /// /// The type mapper to set up (global or connection-specific) /// Options to use when constructing objects. /// Specifies that the geography type is used for mapping by default. public static TMapper UseGeoJson(this TMapper mapper, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false) where TMapper : INpgsqlTypeMapper { mapper.AddTypeInfoResolverFactory(new GeoJSONTypeInfoResolverFactory(options, geographyAsDefault, crsMap: null)); return mapper; } /// /// Sets up GeoJSON mappings for the PostGIS types. /// /// The type mapper to set up (global or connection-specific) /// A custom crs map that might contain more or less entries than the default well-known crs map. /// Options to use when constructing objects. /// Specifies that the geography type is used for mapping by default. public static TMapper UseGeoJson(this TMapper mapper, CrsMap crsMap, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false) where TMapper : INpgsqlTypeMapper { mapper.AddTypeInfoResolverFactory(new GeoJSONTypeInfoResolverFactory(options, geographyAsDefault, crsMap)); return mapper; } }
X Tutup