Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate.Spatial and Sql 2008 Geography type

i'm currently working on a project where i have to deal with sql server 2008 geography types. As big parts of the projects uses NHibernate as ORM i wonder how much work it will be to use/extend NHibernate.Spatial with this type (as far as i can see Nh Spatial only supports the geometry type yet). Btw. are there any other .net ORM's out there that support this sql type? thanks

like image 565
Joachim Kerschbaumer Avatar asked Dec 22 '08 08:12

Joachim Kerschbaumer


2 Answers

I don't know specifically about spatial, but you can always extend NHibernate to deal with your custom types which is quite straightforward (see NHibernate Custom Mapping Types) but the thing is that you have to explain how to deal with geography types to NHibernate (see namespace NHibernate.Type) teling NH how to convert the value back and forth to SQL.

It may not be the easiest thing in the world but can be done, many people may help you in nhusers and you will definitely learn a lot about the inner workings of an OR/M.

like image 116
Marc Climent Avatar answered Nov 15 '22 08:11

Marc Climent


I asked the same thing in NHUsers back in January. NHSpatial has limited support for geography types. Check the thread at NHUsers below, you can 'sort of' use Geometry types for some Geography applications.

http://groups.google.com/group/nhcdevs/browse_thread/thread/752b046c0ce959b0/9596204d0dd0ff47?q=#9596204d0dd0ff47

Also see the link that Ricardo posted on the group to Isaac Kunen's blog which gives an interesting example of the nearest neighbour problem in SQL.

So basically, the answer: No NHSpatial doesn't support Geography, but you can use Geometry types for some basic geography problems (e.g distance between two points). But you're better off running a Native SQL query to get the full power of SQL Server 2008's geography types.

like image 36
reach4thelasers Avatar answered Nov 15 '22 09:11

reach4thelasers