コード例 #1
0
        protected NpgsqlConnection OpenConnection(string?connectionString = null, GeoJSONOptions option = GeoJSONOptions.None)
        {
            var conn = base.OpenConnection(connectionString);

            conn.TypeMapper.UseGeoJson(option);
            return(conn);
        }
コード例 #2
0
        /// <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()));
        }
コード例 #3
0
ファイル: GeoJSONHandler.cs プロジェクト: veikkoeeva/npgsql
 internal GeoJsonHandler(PostgresType postgresType, GeoJSONOptions options, CrsMap crsMap)
     : base(postgresType)
 {
     _options = options;
     _crsMap  = crsMap;
 }
コード例 #4
0
ファイル: GeoJSONHandler.cs プロジェクト: veikkoeeva/npgsql
 public GeoJSONHandlerFactory(GeoJSONOptions options = GeoJSONOptions.None)
 => _options = options;
コード例 #5
0
ファイル: GeoJSONHandler.cs プロジェクト: TonicAI/npgsql
 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);
 }
コード例 #8
0
ファイル: GeoJSONHandler.cs プロジェクト: zhnc/npgsql
 internal GeoJsonHandler(GeoJSONOptions options, CrsMap crsMap)
 {
     _options = options;
     _crsMap  = crsMap;
 }