protected NpgsqlConnection OpenConnection(string?connectionString = null, GeoJSONOptions option = GeoJSONOptions.None) { var conn = base.OpenConnection(connectionString); conn.TypeMapper.UseGeoJson(option); return(conn); }
/// <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) { var factory = new GeoJSONHandlerFactory(options); return(mapper .AddMapping(new NpgsqlTypeMappingBuilder { PgTypeName = "geometry", NpgsqlDbType = NpgsqlDbType.Geometry, ClrTypes = geographyAsDefault ? Type.EmptyTypes : ClrTypes, InferredDbType = DbType.Object, TypeHandlerFactory = factory }.Build()) .AddMapping(new NpgsqlTypeMappingBuilder { PgTypeName = "geography", NpgsqlDbType = NpgsqlDbType.Geography, ClrTypes = geographyAsDefault ? ClrTypes : Type.EmptyTypes, InferredDbType = DbType.Object, TypeHandlerFactory = factory }.Build())); }
internal GeoJsonHandler(PostgresType postgresType, GeoJSONOptions options, CrsMap crsMap) : base(postgresType) { _options = options; _crsMap = crsMap; }
public GeoJSONHandlerFactory(GeoJSONOptions options = GeoJSONOptions.None) => _options = options;
internal GeoJsonHandler(PostgresType postgresType, GeoJSONOptions options, CrsMap crsMap) { PostgresType = postgresType; _options = options; _crsMap = crsMap; }
public GeoJSONTypeHandlerResolverFactory(GeoJSONOptions options, bool geographyAsDefault) => (_options, _geographyAsDefault) = (options, geographyAsDefault);
/// <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); }
internal GeoJsonHandler(GeoJSONOptions options, CrsMap crsMap) { _options = options; _crsMap = crsMap; }