-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added STMaximumInscribedCircle function support with result type mapping
- Loading branch information
Showing
5 changed files
with
133 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
LinqToDBPostGisNetTopologySuite/PostGisCompositeTypeMapper.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using LinqToDB.Data; | ||
using LinqToDB.Mapping; | ||
using Npgsql; | ||
|
||
using NTSG = NetTopologySuite.Geometries.Geometry; | ||
|
||
namespace LinqToDBPostGisNetTopologySuite | ||
{ | ||
/// <summary> | ||
/// Utility class with methods for registering PostGIS types mappings. | ||
/// </summary> | ||
public static class PostGisTypesMapper | ||
{ | ||
/// <summary> | ||
/// Registers PostGIS types mappings for given <paramref name="dataConnection"/>. | ||
/// </summary> | ||
/// <param name="dataConnection">Database connection.</param> | ||
public static void RegisterPostGisMappings(this DataConnection dataConnection) | ||
{ | ||
var typeMapper = (dataConnection.Connection as NpgsqlConnection).TypeMapper; | ||
typeMapper.MapComposite<ValidDetail>(ValidDetail.CompositeTypeName); | ||
|
||
dataConnection.MappingSchema.SetConverter<object[], GeometryProcessing.MaximumInscribedCircleResult>(objs => CreateMaximumInscribedCircleResult(objs)); | ||
} | ||
|
||
/// <summary> | ||
/// Registers PostGIS types mappings globally for all database connections. | ||
/// </summary> | ||
public static void RegisterPostGisMappingsGlobally() | ||
{ | ||
NpgsqlConnection.GlobalTypeMapper.MapComposite<ValidDetail>(ValidDetail.CompositeTypeName); | ||
|
||
MappingSchema.Default.SetConverter<object[], GeometryProcessing.MaximumInscribedCircleResult>(objs => CreateMaximumInscribedCircleResult(objs)); | ||
} | ||
|
||
private static GeometryProcessing.MaximumInscribedCircleResult CreateMaximumInscribedCircleResult(object[] objs) => | ||
new GeometryProcessing.MaximumInscribedCircleResult | ||
{ | ||
Center = objs[0] as NTSG, | ||
Nearest = objs[1] as NTSG, | ||
Radius = (double)objs[2], | ||
}; | ||
} | ||
} |