Grails + Spatial Data 2.0

May 11th, 2009

This is intended as a follow up to this artile: Grails + Spatial Data

We recently discovered (actually we were nudged in the right direction…) that one can completely do away with the manual hibernate mapping, by adding the following code to the domain class that contains spatial data:

class Event {
  String title
  String description
  Url url
  Point spatial

  static mapping = {
    columns {
      spatial type: org.hibernatespatial.GeometryUserType
    }
  }
}

I think it doesn’t get any sweeter than that.

3 Responses to “Grails + Spatial Data 2.0”

  1. Mulone says:

    Hi Silvio, Sorry for disturbing you but I’ve come across your posts on Grails + PostGIS because I’m outlining a GIS application for my research. A thread on the project: http://bit.ly/kJcHl I’d really love to use Grails, it looks extremely nice and simple, but it doesn’t support PostGIS natively, which looks quite painful. So I had a look at GeoServer and I soon realised that it’s not suitable to define new web services, so Grails is still my main option. What can you say about the combination Grails + Hibernate Spatial? Do they get along well?

    (If you could reply by email it would be highly appreciated :-))

    Thanks for any hints! Mulone

  2. Silvio says:

    @Mulone:

    As you might have seen, there’s two other posts that discuss Grails + Hibernate Spatial. I have not done anything too fancy with this, as I had another showstopper bug in another application. In the original post i write about how to set up hibernate-spatial and grails, so that you an store the geotypes more or less transparently. Calling the postgis stored procedures is a bit of a pain, but I think it won’t get much easier anywhere. These are database specific functions, so I doubt they will find their way into hibernate-spatial.

    Anyway, I’d say the combo gets along pretty well.

  3. Mulone says:

    Hi, I’m trying to add a Point member to a domain class but it doesn’t compile. I added the libraries you have recommended to add (hibernatespatial, jts, etc) to the /lib directory in Grails, but Grails can’t find the Point type. What am I supposed to do to make it work?

    Thanks again! Mulone

Leave a Reply

You can use Textile markup in your comments!