Last updated by 5 years ago

Page: MySQL GIS-Geometry with Grails, Version:0

1 MySQL GIS/Geometry with Grails

Setting up grails to use GIS geometry is pretty simple (I will do a plugin sometime). So while I wait for 1.1 beta2 to download I thought I'd quickly describe the bits you need and the steps.

I assume you already know what GIS capabilities exist in MySql. If not consult the MySql website.

The OGC Open Geopatial Consortium publish a standard Geometry model amongst a plethora of documents which describes geometry elements and coordinate transformations for storing and manipulating geospatial data.

To access this from a Grails project you need a few things:

  • A recent version of MySql (4.1 or above) with appropriate driver
  • The JTS Topology Suite - an open (LGPL) library of geometry primitives and operations see
  • A set of hibernate mapping UserType classes from
Put the jar files in your grails lib.

In your DataSource you need something like this

dialect = org.hibernatespatial.mysql.MySQLSpatialDialect

and then you are free to write domain classes something like this:

<code> */ import com.vividsolutions.jts.geom.Polygon import org.hibernatespatial.GeometryUserType

public class MyPoly { String name Polygon poly

static mapping = { poly type: GeometryUserType }

} </code>