grails and postgis

3 messages Options
Embed this post
Permalink
ahmueller

grails and postgis

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was twiddling for quite a while with the integration of PostGIS
(spatial extension to PostgreSQL) into grails.
Now I think I've found the (a) solution:

1. Put PostgreSQL driver and postgis.jar into lib directory of your
grails app (YourGrailsApp)

2. Put the package org.postgis.hibernate and its contents into
YourGrailsApp/src/java (you find it in the postgis svn repository at
http://svn.refractions.net/postgis/trunk/java/ejb3/src/org/postgis/hibernate/
 - big thanks to Norman Barker!)

3. Use driverClassName="org.postgis.DriverWrapper" and
dialect=org.postgis.hibernate.PostGISDialect

4. Create a suitable domain class, e.g. Event.groovy

import org.postgis.Geometry;
import org.postgis.hibernate.GeometryType;

class Event {
  String title
  Geometry location
  Date date

  static mapping = {
    columns {
      location type:GeometryType
    }
  }
}


5. Throw some test data into Bootstrap.groovy, e.g.

import org.postgis.Point;
class BootStrap {
  def init = { servletContext ->
    def evt1 = new Event(title:"First Event", date:new Date(),
location:new Point(1.0, 2.0))
    evt1.save()
    def evt2 = new Event(title:"Second Event", date:new Date(),
location:new Point(12.0, 23.0))
    evt2.save()
  }
  def destroy = {
  }
}


6. Start your Application


7. In your spatially enabled PostgreSQL database you'll find a table
events with two entries.
When you create the controller and the corresponding views  for the
Event Domain object you will see a list of two events at
http://localhost:8080/YourGrailsApp/event/list, but the other views will
not work automatically, of course.

Any comments and optimization are highly appreciated - I'm still a
newbie to grails and might have got something wrong.

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjbWgQACgkQvyi4dZK5FSDf3QCeIXni7oRf18UzY7AAPWB9dnzL
Wq8AoKeGvpwEjq/HqOGOViXXax0qUBMb
=yn32
-----END PGP SIGNATURE-----

[am.vcf]

begin:vcard
fn;quoted-printable:Dr. Andreas M=C3=BCller
n;quoted-printable:M=C3=BCller;Dr. Andreas
org:chromgruen Planungs- und Beratungs- GmbH & Co. KG
adr:;;Alfredstr. 51;Essen;NRW;45130;Deutschland
email;internet:[hidden email]
title;quoted-printable:Gesch=C3=A4ftsf=C3=BChrer
tel;work:+49(201)185355-0
tel;fax:+49(201)185355-1
tel;cell:+49(177)3185355
x-mozilla-html:FALSE
url:http://www.chromgruen.com
version:2.1
end:vcard




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
rmz

Re: grails and postgis

Reply Threaded More More options
Print post
Permalink
That's brilliant ;)  I twiddled a bit, followed your instructions, and got things working up to and including the insertion of GIS data into a postgis database.  Where I'm stuck right now is how to get them out, in particular how to get them out using both  grails and "geometric search" (i.e. finding things close to something else).   It would be nice to use criteria, but so far I haven't had any luck. Have you?

Rmz


ahmueller wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was twiddling for quite a while with the integration of PostGIS
(spatial extension to PostgreSQL) into grails.
Now I think I've found the (a) solution:

1. Put PostgreSQL driver and postgis.jar into lib directory of your
grails app (YourGrailsApp)

2. Put the package org.postgis.hibernate and its contents into
YourGrailsApp/src/java (you find it in the postgis svn repository at
http://svn.refractions.net/postgis/trunk/java/ejb3/src/org/postgis/hibernate/
 - big thanks to Norman Barker!)

3. Use driverClassName="org.postgis.DriverWrapper" and
dialect=org.postgis.hibernate.PostGISDialect

4. Create a suitable domain class, e.g. Event.groovy

import org.postgis.Geometry;
import org.postgis.hibernate.GeometryType;

class Event {
  String title
  Geometry location
  Date date

  static mapping = {
    columns {
      location type:GeometryType
    }
  }
}


5. Throw some test data into Bootstrap.groovy, e.g.

import org.postgis.Point;
class BootStrap {
  def init = { servletContext ->
    def evt1 = new Event(title:"First Event", date:new Date(),
location:new Point(1.0, 2.0))
    evt1.save()
    def evt2 = new Event(title:"Second Event", date:new Date(),
location:new Point(12.0, 23.0))
    evt2.save()
  }
  def destroy = {
  }
}


6. Start your Application


7. In your spatially enabled PostgreSQL database you'll find a table
events with two entries.
When you create the controller and the corresponding views  for the
Event Domain object you will see a list of two events at
http://localhost:8080/YourGrailsApp/event/list, but the other views will
not work automatically, of course.

Any comments and optimization are highly appreciated - I'm still a
newbie to grails and might have got something wrong.

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjbWgQACgkQvyi4dZK5FSDf3QCeIXni7oRf18UzY7AAPWB9dnzL
Wq8AoKeGvpwEjq/HqOGOViXXax0qUBMb
=yn32
-----END PGP SIGNATURE-----

begin:vcard
fn;quoted-printable:Dr. Andreas M=C3=BCller
n;quoted-printable:M=C3=BCller;Dr. Andreas
org:chromgruen Planungs- und Beratungs- GmbH & Co. KG
adr:;;Alfredstr. 51;Essen;NRW;45130;Deutschland
email;internet:am@chromgruen.com
title;quoted-printable:Gesch=C3=A4ftsf=C3=BChrer
tel;work:+49(201)185355-0
tel;fax:+49(201)185355-1
tel;cell:+49(177)3185355
x-mozilla-html:FALSE
url:http://www.chromgruen.com
version:2.1
end:vcard



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
ahmueller

Re: grails and postgis

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Unfortunately not.
We have implemented a GeoService class which makes abundant use of Vivid
Solutions' Java Topology Suite
(http://www.vividsolutions.com/jts/jtshome.htm)

We have used this way to "talk" to Postgis for the first time. All
retrieval and data analysis in our use cases is usually done by some
fairly advanced clients (like, e.g. JUMP or uDig) and/or via OGC Web
Feature Services.

But I agree that it would be very handy to spatially enable Grails a bit
more ... at least we should try ...

I'll keep you informed on any progress on our side.

Andreas



rmz schrieb:

> That's brilliant ;)  I twiddled a bit, followed your instructions, and got
> things working up to and including the insertion of GIS data into a postgis
> database.  Where I'm stuck right now is how to get them out, in particular
> how to get them out using both  grails and "geometric search" (i.e. finding
> things close to something else).   It would be nice to use criteria, but so
> far I haven't had any luck. Have you?
>
> Rmz
>
>
>
> ahmueller wrote:
> I was twiddling for quite a while with the integration of PostGIS
> (spatial extension to PostgreSQL) into grails.
> Now I think I've found the (a) solution:
>
> 1. Put PostgreSQL driver and postgis.jar into lib directory of your
> grails app (YourGrailsApp)
>
> 2. Put the package org.postgis.hibernate and its contents into
> YourGrailsApp/src/java (you find it in the postgis svn repository at
> http://svn.refractions.net/postgis/trunk/java/ejb3/src/org/postgis/hibernate/
>  - big thanks to Norman Barker!)
>
> 3. Use driverClassName="org.postgis.DriverWrapper" and
> dialect=org.postgis.hibernate.PostGISDialect
>
> 4. Create a suitable domain class, e.g. Event.groovy
>
> import org.postgis.Geometry;
> import org.postgis.hibernate.GeometryType;
>
> class Event {
>   String title
>   Geometry location
>   Date date
>
>   static mapping = {
>     columns {
>       location type:GeometryType
>     }
>   }
> }
>
>
> 5. Throw some test data into Bootstrap.groovy, e.g.
>
> import org.postgis.Point;
> class BootStrap {
>   def init = { servletContext ->
>     def evt1 = new Event(title:"First Event", date:new Date(),
> location:new Point(1.0, 2.0))
>     evt1.save()
>     def evt2 = new Event(title:"Second Event", date:new Date(),
> location:new Point(12.0, 23.0))
>     evt2.save()
>   }
>   def destroy = {
>   }
> }
>
>
> 6. Start your Application
>
>
> 7. In your spatially enabled PostgreSQL database you'll find a table
> events with two entries.
> When you create the controller and the corresponding views  for the
> Event Domain object you will see a list of two events at
> http://localhost:8080/YourGrailsApp/event/list, but the other views will
> not work automatically, of course.
>
> Any comments and optimization are highly appreciated - I'm still a
> newbie to grails and might have got something wrong.
>
> Andreas
>>
begin:vcard
fn;quoted-printable:Dr. Andreas M=C3=BCller
n;quoted-printable:M=C3=BCller;Dr. Andreas
org:chromgruen Planungs- und Beratungs- GmbH & Co. KG
adr:;;Alfredstr. 51;Essen;NRW;45130;Deutschland
email;internet:[hidden email]
title;quoted-printable:Gesch=C3=A4ftsf=C3=BChrer
tel;work:+49(201)185355-0
tel;fax:+49(201)185355-1
tel;cell:+49(177)3185355
x-mozilla-html:FALSE
url:http://www.chromgruen.com
version:2.1
end:vcard
>>
>>
>>
- ---------------------------------------------------------------------
To unsubscribe from this list, please visit:
>>
    http://xircles.codehaus.org/manage_email
>>
>>

- --
chromgruen Planungs- und Beratungs- GmbH & Co. KG
Alfredstr. 51
D-45130 Essen
Telefon +49(0)201 - 185 355 0
Telefax +49(0)201 - 185 355 1
http://www.chromgruen.com
- -------------------------------------------------
Geschäftsführer: Dr. Andreas Müller
Sitz der Gesellschaft: Essen
Amtsgericht Essen HR A 8547
UStIDNr.: DE244104036

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkj96wAACgkQvyi4dZK5FSB2gwCeKpttSzKYE2GQ2MBLn0UdlA/p
pXYAoK91hWQKh8IpWAbMmJGcnYgBfLQs
=0O+z
-----END PGP SIGNATURE-----

[am.vcf]

begin:vcard
fn;quoted-printable:Dr. Andreas M=C3=BCller
n;quoted-printable:M=C3=BCller;Dr. Andreas
org:chromgruen Planungs- und Beratungs- GmbH & Co. KG
adr:;;Alfredstr. 51;Essen;NRW;45130;Deutschland
email;internet:[hidden email]
title;quoted-printable:Gesch=C3=A4ftsf=C3=BChrer
tel;work:+49(201)185355-0
tel;fax:+49(201)185355-1
tel;cell:+49(177)3185355
x-mozilla-html:FALSE
url:http://www.chromgruen.com
version:2.1
end:vcard




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email