<commit_before>.. _grails:

Using GeoScript with Grails
===========================

Install Grails
--------------


Create a Web Application
------------------------

grails create-app geoscript

Copy Libraries
--------------

Copy all jar files from the GeoScript Groovy installation except xml-apis-1.0.b2.jar and xml-apis-xerces-2.7.1.jar to the lib
directory of your Grails application.

Create a Controller
-------------------

grails create-controller geoscript.Buffer

Edit Controller Code
--------------------

grails-app/controllers/geoscript/BufferController.groovy

package geoscript

import geoscript.geom.Geometry

class BufferController {

    def index = {
        def g = Geometry.fromWKT(params.geom)
        def d = params.distance as Double
        def wkt = g.buffer(d).wkt
        render(wkt)
    }

}

Try it out
----------

Run your Grails application:

grails run-app

And enter the following url:

http://localhost:8080/geoscript/buffer?geom=POINT%20(10%2010)&distance=7<commit_msg>Updating grails documentation<commit_after>.. _grails:

Using GeoScript with Grails
===========================

Install Grails
--------------

You can download Grails from their `web site <http://www.grails.org/>`_

Create a Web Application
------------------------

command::
    grails create-app geoscript

Copy Libraries
--------------

Copy all jar files from the GeoScript Groovy installation

command::
    cp $GEOSCRIPT_GROOVY_HOME/lib/*.jar lib/

Except xml-apis-1.0.b2.jar and xml-apis-xerces-2.7.1.jar to the lib
directory of your Grails application.

command::
    rm lib/*.xml-apis*

Create a Controller
-------------------

command::
    grails create-controller geoscript.Buffer

Edit Controller Code
--------------------


grails-app/controllers/geoscript/BufferController.groovy

.. code-block:: java
    package geoscript

    import geoscript.geom.Geometry

    class BufferController {

        def index = {
            def g = Geometry.fromWKT(params.geom)
            def d = params.distance as Double
            def wkt = g.buffer(d).wkt
            render(wkt)
        }

    }

Try it out
----------

Run your Grails application:

command::
    grails run-app

And enter the following url:

http://localhost:8080/geoscript/buffer?geom=POINT%20(10%2010)&distance=7
{'fraction_non_alphanumeric': 0.18268812527185732, 'fraction_numerical': 0.01652892561983471, 'mean_word_length': 2.3333333333333335, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '566814', 'n_tokens_mistral': 718, 'n_tokens_neox': 675, 'n_words': 188}