//Ext.BLANK_IMAGE_URL = '../media/images/s.gif'; Ext.ns('RGIS'); Ext.Ajax.disableCaching = false; //RGIS.host = window.location.protocol + "//" + window.location.host; RGIS.host = 'http://gstore.unm.edu/apps/rgis'; RGIS.formats = new Ext.util.MixedCollection(); RGIS.formats.addAll({ 'shp' : { format: 'shp', text: 'Shapefile in Geographic projection (EPSG:4326)'} , 'kml' : { format: 'kml', text: 'KML'} , 'xls' : { format: 'xls', text: 'Excel'} , 'csv' : { format: 'csv', text: 'CSV'} , 'json': { format: 'json', text: 'GeoJson'}, 'gml': { format: 'gml', text: 'GML'}, 'ecw' : { format: 'ecw', text: 'ECW'} , 'tif' : { format: 'tif', text: 'GeoTIFF'} , 'sid' : { format: 'sid', text: 'MrSID'} , 'las' : { format: 'las', text: 'LAS'} , 'flt' : { format: 'flt', text: 'FLT'} , 'asc' : { format: 'asc', text: 'ASCII'} , 'dem' : { format: 'dem', text: 'DEM'} , 'xyz' : { format: 'xyz', text: 'XYZ'}, 'htm' : { format: 'htm', text: 'External link'}, 'html' : { format: 'html', text: 'External link'}, 'zip' : { format: 'zip', text: 'Original data (ZIP)'}, '' : { format: 'file', text: 'File'} }); RGIS.services = new Ext.util.MixedCollection(); RGIS.services.addAll({ 'wms': { service: 'wms', text: 'WMS', baseurl: RGIS.host + '/{parent.what}s/{parent.id}/services/ogc/{service}?VERSION=1.1.1&SERVICE=WMS&REQUEST=GetCapabilities' } , 'wfs': { service: 'wfs', text: 'WFS', baseurl: RGIS.host + '/{parent.what}s/{parent.id}/services/ogc/{service}?VERSION=1.0.0&SERVICE=WFS&REQUEST=GetCapabilities'} , 'wcs': { service: 'wcs', baseurl: RGIS.host + '/{parent.what}s/{parent.id}/services/ogc/{service}?SERVICE=wcs&REQUEST=GetCapabilities', text: 'WCS' } , 'geojson': { service: 'geojson', text: 'GeoJSON' } , 'kml': { service: 'kml', text: 'KML' } }); RGIS.metadata = new Ext.util.MixedCollection(); RGIS.metadata.addAll({ 'xml': { format: 'xml', text: 'XML', baseurl: RGIS.host + '/{parent.what}s/{parent.id}/metadata/{parent.id}.xml' } , 'txt': { format: 'txt', text: 'TXT', baseurl: RGIS.host + '/{parent.what}s/{parent.id}/metadata/{parent.id}.txt' } , 'html': { format: 'html', text: 'HTML', baseurl: RGIS.host + '/{parent.what}s/{parent.id}/metadata/{parent.id}.html' } }); RGIS.downloadHandler = function(item, event){ // item.format; } RGIS.mapHandler = function(what, dataset_id) { var window_id = what + '__' + dataset_id; var url = what + "s/" + dataset_id + "/mapper"; var width = Ext.isGecko3 ? 610 : 612; var height = Ext.isGecko3 ? 616: 617; var win_config = String.format('status=0,toolbar=0,height={1},width={0},directories=0,menubar=0', width, height); if(typeof RGIS.mapHandler.edac_mapper == 'undefined'){ RGIS.mapHandler.edac_mapper = {}; } if(typeof RGIS.mapHandler.edac_mapper[window_id] == 'undefined' || RGIS.mapHandler.edac_mapper[window_id].closed){ RGIS.mapHandler.edac_mapper[window_id] = window.open(url,'rgis_edac_mapper' + dataset_id, win_config); } else{ RGIS.mapHandler.edac_mapper[window_id].focus(); } } RGIS.servicesHandler = function(config){ //config.services[0]; var win = Ext.getCmp('dataset_panel_window'); win.add( { xtype: 'box', autoEl: { html: 'Services Here' } }); } RGIS.metadataHandler = function(config){ //config.services[0]; var win = Ext.getCmp('dataset_panel_window'); win.add( { xtype: 'box', autoEl: { html: 'Metadata' } }); } RGIS.printHandler = function(item) { } RGIS.cartHandler = function(item) { } RGIS.buttons = new Ext.util.MixedCollection(); RGIS.buttons.addAll({ 0: { xtype: 'tbsplit', cls: 'x-btn-text-icon', icon: '../media/images/download.png', text: 'Download', disabled: true, id: 'dataset_tbar_download_menu' }, 1: { xtype: 'tbbutton', text: 'View in map', cls: 'x-btn-text-icon', icon: '../media/images/view.png', disabled: true, handler: RGIS.mapHandler }, 2: { xtype: 'tbbutton', text: 'Metadata', cls: 'x-btn-text-icon', icon: '../media/images/metadata.jpg', handler: RGIS.metadataHandler, disabled: true, id: 'dataset_tbar_metadata_menu' }, 3: { xtype: 'tbbutton', text: 'Web services', cls: 'x-btn-text-icon', icon: '../media/images/services.png', handler: RGIS.servicesHandler, disabled: true, id: 'dataset_tbar_services_menu' }, 4: { xtype: 'tbbutton', text: 'Print map', cls: 'x-btn-text-icon', icon: '../media/images/print.png', handler: RGIS.printHandler, disabled: true }, 5: { xtype: 'tbbutton', text: 'Add to Cart', cls: 'x-btn-text-icon', icon: '../media/images/shopping_cart.gif', handler: RGIS.cartHandler, disabled: true } }); RGIS.tabs = new Ext.util.MixedCollection(); RGIS.tabs.addAll({ 0: { title: 'Download', iconCls: 'rgis-tab-download', disabled: true, id: 'dataset_tab_download_menu', tpl: new Ext.XTemplate( '', '', '', '
{format}{text}
', { compile: true, disableFormats: true } ) }, 1: { title: 'View in map', iconCls: 'rgis-tab-map', disabled: true, id: 'dataset_tab_map_menu', handler: RGIS.mapHandler, tpl: new Ext.XTemplate( '

The map viewer should open in a separate window. If you are not seeing it please ensure your browser allows popups for this site.

', '

If you are still having problems opening or finding the window [click here].

', { disableFormats: true } ), listeners: { 'activate': function(config){ RGIS.mapHandler(config.what, config.dataset_id); } } }, 2: { title: 'Metadata', iconCls: 'rgis-tab-metadata', handler: RGIS.metadataHandler, tpl: new Ext.XTemplate( '', '', '', '', '', '', '', '', '', '', '', '
XML
TXT
HTML
', { compile: true, disableFormats: true } ), disabled: true, id: 'dataset_tbar_metadata_menu' }, 3: { title: 'Web services', iconCls: 'rgis-tab-services', handler: RGIS.servicesHandler, tpl: new Ext.XTemplate( '', '', '', '', '', '', '', '
WMS'+RGIS.services.map['wms'].baseurl+'WFS'+RGIS.services.map['wfs'].baseurl+'WCS'+RGIS.services.map['wcs'].baseurl+'
', { compile: true, disableFormats: true } ), disabled: true, id: 'dataset_tbar_services_menu' }, 4: { title: 'Print map', iconCls: 'rgis-tab-print', handler: RGIS.printHandler, tpl: new Ext.XTemplate( '', { disableFormats: true } ), disabled: true }, 5: { title: 'Add to Cart', itemCls: 'rgis-tab-cart', handler: RGIS.cartHandler, tpl: new Ext.XTemplate( '', { disableFormats: true } ), disabled: true } }); RGIS.DatasetTabPanel = function(config) { /* 0 : Download 1 : Map 2 : View Metadata 3 : Services 4 : Print 5 : Cart */ if(Ext.getCmp('dataset_panel_window')){ Ext.getCmp('dataset_panel_window').destroy(); } if(!config.mapped_formats){ var formats = []; Ext.each(config.formats, function(k,v){ formats[v] = RGIS.formats.map[k]; }); config.mapped_formats = formats; } if(!config.mapped_services){ var services = []; Ext.each(config.services, function(k,v){ services[v] = RGIS.services.map[k]; }); config.mapped_services = services; } if(!config.mapped_metadata){ con = config; var metadata = []; Ext.each(config.metadata, function(k,v){ metadata[v] = RGIS.metadata.map[k]; }); config.mapped_metadata = metadata; } var tabs = new Ext.util.MixedCollection(); Ext.each(RGIS.tabs.keys, function(k,v) { var tab = RGIS.tabs.get(k); if(config.tools[k]){ tab.dataset_id = config.id; tab.what = config.what; tab.disabled = false; tab.html = "
" + tab.tpl.apply(config) + "
"; /* if(k == 2 ){ tab.autoLoad = '/' + config.what + 's/' + config.id + '/metadata'; tab.autoScroll = true; } */ } else{ tab.disabled = true; } tabs.add(tab); }); tab_panel = new Ext.TabPanel({ //tbar: new Ext.Toolbar({id:'dptb'}), activeTab: 0, width: '100%', height: 200, items: tabs.items }); var dataset_panel_window = new Ext.Window({ title: config.title, id: 'dataset_panel_window', minimizable: false, maximizable: false, draggable: true, closable: true, border: false, modal: true, layout: 'fit', width: 600, items: tab_panel, hideBorders: true, resizable: true }); dataset_panel_window.setTitle(config.title); dataset_panel_window.show(); }; RGIS.DatasetPanel = function(config) { // 0 : Download // 1 : Map // 2 : View Metadata // 3 : Services // 4 : Print // 5 : Cart if(Ext.getCmp('dataset_panel_window')){ Ext.getCmp('dataset_panel_window').destroy(); } var dataset_panel_window = new Ext.Window({ title: config.title, id: 'dataset_panel_window', tbar: new Ext.Toolbar({id:'dptb'}), height: 34, minimizable: false, maximizable: false, draggable: true, closable: true, border: false, modal: true, layout: 'fit', hideBorders: true, resizable: false }); dataset_panel_window.setTitle(config.title); dataset_panel_window.show(); var toolbar = dataset_panel_window.getTopToolbar(); Ext.each(RGIS.buttons.keys, function(k) { var bconf = RGIS.buttons.get(k); bconf.dataset_id = config.id; if(config.tools[k]){ bconf.disabled = false; bconf.what = config.what; if(k == 0){ var btb = new Ext.menu.Menu(); for(var i=0; i< config.formats.length; i++){ var fmt = RGIS.formats.get(config.formats[i]); btb.add({ text: fmt.text, href: "/datasets/" + config.id + "." + fmt.format }); }; bconf.menu = btb; } if(k == 2){ bconf.services = config.services; } if(k == 1 && config.in_mapper){ bconf = null; } } if(bconf){ var b = new Ext.Button(bconf); toolbar.add(b); if(bconf.text == 'Download'){ var download_menu = toolbar.items.get("dataset_tbar_download_menu"); download_menu.menu.showAt([download_menu.getEl().getX(),download_menu.getEl().getY()+21]); } } }); }; RGIS.DataGrid = function(type, store, selModel){ // types: b = browse, s = spatial config = { grid_id : type == 'b' ? 'browsegrid' : 'spatialgrid', description_width : type == 'b' ? 362 : 580, page_size: type == 's' ? 30 : 25, sm: selModel ? selModel : new Ext.grid.RowSelectionModel() } clickRow = function(row, row_id, evt) { if (!row){ var r = store.getById(row_id); } else{ var r = store.getAt(row_id); } var config = r.get('config'); config.title = r.get('text') + ' - Available tools'; RGIS.DatasetTabPanel(config); } var spatial_bbar = new Ext.Toolbar({ items: [ // {xtype: 'button', text: 'Reset search'}, // {xtype: 'tbseparator' }, {xtype: 'tbtext', text: 'Browse more results: '}, new Ext.Slider({ id: 'georelevance', width: 114, value: 0, increment: 1, minValue: 0, maxValue: 10, //disabled: true listeners: { change: function(t, v){ var page = Ext.getCmp('pageid'); page.setValue(v); } } }), {xtype: 'textfield', id: 'pageid', value: 1, hidden: true } ] }); var browse_bbar = new Ext.PagingToolbar({ id: 'browse_pager', pageSize: config.page_size, store: store, paramNames: { start: 'offset', limit: 'limit' }, displayInfo: true, displayMsg: 'Displaying results {0} - {1} of {2}', emptyMsg: "No data to display" }); config.bbar = type == 's' ? spatial_bbar : browse_bbar; return new Ext.grid.GridPanel({ id: config.grid_id, ds: store, loadMask: new Ext.LoadMask(Ext.getBody(), {msg:"Searching ..."}), collapsible: false, sm: config.sm, columns: [ { header: 'Type', width: 36, menuDisabled: true, renderer: function(v,p,row){ var t = row.data.config['taxonomy']; var img_src, taxonomy; switch(t){ case 'vector': img_src = '../media/images/vector.png'; taxonomy = 'Vector dataset'; break; case 'geoimage': img_src = '../media/images/raster.png'; taxonomy = 'Raster image'; break; case 'vtindex': img_src = '../media/images/vtindex.png'; taxonomy = 'Vector Tile Index'; break; case 'rtindex': img_src = '../media/images/rtindex.png'; taxonomy = 'Raster Tile Index'; break; case 'zip': img_src = '../media/images/zip.png'; taxonomy = 'ZIP file'; break; default: img_src = '../media/images/file.png'; taxonomy = 'File'; } return "" + taxonomy + ""; } }, { header: 'Tools', width: 37, menuDisabled: true, renderer: function(v,p,row) { return row.data.config['id'] ? String.format('  \'Open',row.data.config['id'],row.id): ''; }, bodyStyle: 'margin: 0' }, { header: 'Dataset', width: config.description_width, sortable: true, dataIndex: 'text' }, { header: 'Last update', width: 80, sortable: true, dataIndex: 'lastupdate' }, { header: 'config', width: 2, dataIndex: 'config', hidden: true }], viewConfig: { forcefit: true }, listeners: { 'rowdblclick': { 'fn': clickRow } }, tbar: config.bbar }); } /* USAGE var config = { in_mapper: false, title: 'Hello dataset', what: 'dataset', id: 1406, tools: [true,true,true,false,true], formats: ['ecw','tif'], services: ['wms','wfs'] }; dataset_panel = new Ext.Window({ title: config.title, id: 'dataset_panel_window', tbar: new Ext.Toolbar({id:'dptb'}), minimizable: false, maximizable: false, draggable: true, closable: true, border: false, modal: true, hideBorders: true, resizable: false }); dataset_panel.show(); RGIS.DatasetPanel(dataset_panel, config); */