GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Npgsql/src/Npgsql.GeoJSON/NpgsqlGeoJSONExtensions.cs at main · roji/Npgsql Expand file tree/ Copy pathNpgsqlGeoJSONExtensions.csMore file actions 55 lines (52 loc) · 2.22 KB / Copy pathNpgsqlGeoJSONExtensions.csFile metadata and controls55 lines (52 loc) · 2.22 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 using System; using System.Data; using GeoJSON.Net; using GeoJSON.Net.Geometry; using Npgsql.GeoJSON.Internal; using Npgsql.TypeMapping; using NpgsqlTypes; #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member // ReSharper disable once CheckNamespace namespace Npgsql { /// <summary> /// Extension allowing adding the GeoJSON plugin to an Npgsql type mapper. /// </summary> public static class NpgsqlGeoJSONExtensions { static readonly Type[] ClrTypes = { typeof(GeoJSONObject), typeof(IGeoJSONObject), typeof(IGeometryObject), typeof(Point), typeof(LineString), typeof(Polygon), typeof(MultiPoint), typeof(MultiLineString), typeof(MultiPolygon), typeof(GeometryCollection) }; /// <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()); } } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |