Check out some of the pros and cons of ESRI'S PaaS offering...
Then try it out yourself using CodePen.io and ESRI's ArcGIS developer account...
Focus on spatial development
Check out some of the pros and cons of ESRI'S PaaS offering...
Then try it out yourself using CodePen.io and ESRI's ArcGIS developer account...
https://github.com/geoneubie/groovyScripts/blob/master/csb/xyzToGeoJSON.groovy
grails create-domain-class GeoEvent import com.vividsolutions.jts.geom.Geometry import com.vividsolutions.jts.geom.GeometryFactory import com.vividsolutions.jts.geom.Coordinate class GeoEvent { String name String status String type double lat double lon Geometry shape static constraints = { shape nullable: true } def beforeInsert( ) { if ( lat!=null && lon!=null ) { shape = ( new GeometryFactory( ) ).createPoint( new Coordinate( lon.value, lat.value ) ) } } }We'll use a simple scaffold based controller...
class GeoEventController { static scaffold = true }Finally compile test and deploy to OpenShift.
grails>compile grails>run-app grails>prod warIn our OpenShift managed repo copy the war generated above into webapps/ROOT.war
git commit -a -m 'latest update!' git push
repositories { inherits true // Whether to inherit repository definitions from plugins grailsPlugins() grailsHome() grailsCentral() mavenLocal() mavenCentral() // Hibernate Spatial repo mavenRepo "http://www.hibernatespatial.org/repository" }Because the postgis libs are hosted in external maven repo we'll load these into our local mavenRepo.
mvn install:install-file -Dfile=/tmp/postgresql-9.2-1003.jdbc4.jar / -DgroupId=org.postgres -DartifactId=postgresql -Dversion=9.2-1003 / -Dpackaging=jar mvn install:install-file -Dfile=/tmp/postgis-jdbc-2.1.0SVN.jar -DgroupId=org.postgis / -DartifactId=postgis-jdbc -Dversion=2.1 -Dpackaging=jarNow we can add the dependencies we need.
dependencies { // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g. runtime "org.postgres:postgresql:9.2-1003" //local repo addition // Hibernate Spatial dependencies runtime "org.postgis:postgis-jdbc:2.1" //local repo addition runtime "org.hibernatespatial:hibernate-spatial-postgis:1.1.1" compile "com.vividsolutions:jts:1.13" }Next we update our DataSource.groovy.
dataSource { pooled = true dialect = org.hibernatespatial.postgis.PostgisDialect driverClassName = "org.postgresql.Driver" } production { dataSource { dbCreate = "update" url = "jdbc:postgresql://${dbHost}:${dbPort}/spatialapp"; username = "myuser"; password = "******"; } }Now we are ready to code up a domain object, see next post!
rhc show-domain ssh host createlang -dspatialapp plpgsql psql -dspatialapp -f /usr/share/pgsql/contrib/postgis-64.sql psql -dspatialapp -f /usr/share/pgsql/contrib/spatial_ref_sys.sql psql -dspatialappWe should now be at the psql prompt. Let's create a new spatial table to store point events.
spatialapp=# CREATE TABLE eventpoints ( gid serial NOT NULL, name text, -- name of the point type text, -- event type the_geom geometry, CONSTRAINT eventpoints_pk PRIMARY KEY (gid ), CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2), CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL), CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 4326) ) WITH ( OIDS=FALSE ); CREATE INDEX eventpoints_spatial_idx ON eventpoints USING gist ( the_geom );Finally let's insert our first record and then view it to confirm the entry.
Insert into eventpoints (name, type, the_geom) VALUES ('First point!', 'FIRE', ST_GeomFromText('POINT(-85.7302 37.5332)', 4326)); select * from eventpoints; gid | name | type | the_geom -----+-------------+------+---------------------------------------------------- 1 | First point! | FIRE | 0101000020E610000082E2C798BB6E55C0151DC9E53FC44240 (1 row)
dataSource {
pooled = true
driverClassName = "oracle.jdbc.OracleDriver"
dialect = "org.hibernate.dialect.Oracle10gDialect"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
url = "jdbc:oracle:thin:@myserver:1521:MYINSTANCE"
schema = "MYSCHEMA"
username = "myuser"
password = "mypassword"
}
}
// other environments to follow...
}
package osmcreporter
class DailySummaryMappingController {
static allowedMethods = []
def dataSource // the groovy "dataSource" is auto-injected
def index = {
redirect(action: "list", params: params)
}
def list = {
println "params: " + params.sensor + "," + params.transectid + "," + params.distance
def dsrs = new SearchByDistanceService()
dsrs.setDbHandle(dataSource)
def observations = dsrs.serviceMethod(params.sensor, params.transectid, params.distance)
[ observations: observations] // return the results as model
}
}