import org.springframework.beans.factory.InitializingBean import javax.media.jai.JAI import joms.oms.DataInfo class MapViewController implements InitializingBean { def grailsApplication def baseWMS def dataWMS def dataInfo = new DataInfo() //def parser = new OmsInfoParser() def index = { def rasterEntryIds = params.rasterEntryIds?.split(',') def left = null def right = null def top = null def bottom = null def rasterEntries = [] def hasKML = false rasterEntryIds.each { def rasterEntry = RasterEntry.get(it) rasterEntries << rasterEntry if ( left == null || rasterEntry.groundGeom?.bounds?.minLon < left ) { left = rasterEntry.groundGeom?.bounds?.minLon } if ( bottom == null || rasterEntry.groundGeom?.bounds?.minLat < bottom ) { bottom = rasterEntry.groundGeom?.bounds?.minLat } if ( right == null || rasterEntry.groundGeom?.bounds?.maxLon > right ) { right = rasterEntry.groundGeom?.bounds?.maxLon } if ( top == null || rasterEntry.groundGeom?.bounds?.maxLat > top ) { top = rasterEntry.groundGeom?.bounds?.maxLat } hasKML |= RasterEntryFile.findByTypeAndRasterEntry("kml", rasterEntry) ? true : false } [rasterEntries: rasterEntries, left: left, top: top, right: right, bottom: bottom, hasKML: hasKML] } def multiLayer = { def rasterEntryIds = params.rasterEntryIds?.split(',') def left = null def right = null def top = null def bottom = null def rasterEntries = [] def hasKML = false rasterEntryIds.each { def rasterEntry = RasterEntry.get(it) rasterEntries << rasterEntry if ( left == null || rasterEntry.groundGeom?.bounds?.minLon < left ) { left = rasterEntry.groundGeom?.bounds?.minLon } if ( bottom == null || rasterEntry.groundGeom?.bounds?.minLat < bottom ) { bottom = rasterEntry.groundGeom?.bounds?.minLat } if ( right == null || rasterEntry.groundGeom?.bounds?.maxLon > right ) { right = rasterEntry.groundGeom?.bounds?.maxLon } if ( top == null || rasterEntry.groundGeom?.bounds?.maxLat > top ) { top = rasterEntry.groundGeom?.bounds?.maxLat } hasKML |= RasterEntryFile.findByTypeAndRasterEntry("kml", rasterEntry) ? true : false } [rasterEntries: rasterEntries, left: left, top: top, right: right, bottom: bottom, hasKML: hasKML, baseWMS: baseWMS] } def test = { [baseWMS: baseWMS, dataWMS: dataWMS] } def imageSpace = { //println params def rasterEntry = RasterEntry.get(params.id) def inputFile = rasterEntry.mainFile.name def width def height def mode = "OSSIM" switch ( mode ) { case "JAI": def image = JAI.create("imageread", inputFile) width = image.width height = image.height break case "OSSIM": width = rasterEntry?.width height = rasterEntry?.height break } //println "${[width: width, height: height, inputFile: inputFile, entry: rasterEntry.entryId]}" def numRLevels = 1 def tileSize = 256 while ( width > tileSize ) { width /= 2 height /= 2 numRLevels++ } [width: rasterEntry?.width, height: rasterEntry?.height, numRLevels: numRLevels, rasterEntry: rasterEntry] } public void afterPropertiesSet() { baseWMS = grailsApplication.config.wms.base dataWMS = grailsApplication.config.wms.data.raster } }