-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresultFunctions.js
114 lines (95 loc) · 3.64 KB
/
resultFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function retrieveRecord(fileid) {
store = Ext.getCmp("csw-tab-container").searchStore;
index = store.find('fileid', fileid);
return store.getAt(index);
}
function retrievePanel(fileid) {
record = retrieveRecord(fileid);
if (record == null) { return null; }
return Ext.getCmp("csw-search-table").findById(record.id + "-search-row");
}
function downloadFile(url, filename) {
window.open(url, filename);
}
function zoomRecord(fileid) {
record = retrieveRecord(fileid);
map = record.store.viewerMap;
map.zoomToExtent(record.get('bbox'));
bboxSelector = map.getControl('bbox-select-control');
if (map.getLayersByName("Search Result Footprints")[0].selectedFeatures.length > 0) { bboxSelector.unselectAll(); }
bboxSelector.select(retrievePanel(fileid).feature);
}
function detailsRecord(fileid) {
// TODO: Use GetRecordsByID for details
var record = retrieveRecord(fileid);
var detailsUrl = record.get('protocols').details;
window.open(detailsUrl);
}
function lockRecord(fileid) {
tabContainer = Ext.getCmp("csw-tab-container");
savedStore = tabContainer.savedStore;
if (tabContainer.findById("csw-saved-table") == null) {
tabContainer.add(Ext.apply(savedStore.panel, {
listeners: {
add: function() {
Ext.getCmp("csw-saved-table").setTitle("Saved Results (" + savedStore.getCount() + ")");
},
remove: function() {
Ext.getCmp("csw-saved-table").setTitle("Saved Results (" + savedStore.getCount() + ")");
},
scope: this
}
}));
}
retrievePanel(fileid).addClass("hidden-result");
record = retrieveRecord(fileid).copy();
tabContainer.savedStore.add([ record ]);
}
function unlockRecord(fileid) {
tabContainer = Ext.getCmp("csw-tab-container");
savedStore = tabContainer.savedStore;
searchStore = tabContainer.searchStore;
record = savedStore.getAt(savedStore.find('fileid', fileid));
savedStore.remove(record);
showThisPanel = retrievePanel(fileid);
if (showThisPanel != null) {
showThisPanel.removeClass("hidden-result");
tabContainer.activate(searchStore.getTable());
}
}
function removeRecord(fileid) {
record = retrieveRecord(fileid);
store = Ext.getCmp("csw-tab-container").searchStore;
store.remove(record);
}
function downloadRecord(fileid, url) {
downloadFile(url, fileid);
}
function addRecord(fileid, protocols) {
// determine which protocol to use. Preference is WMS, ESRI, WFS
var connectUrl = "";
var connectProtocol = "";
if (protocols.hasOwnProperty("wfs")) { connectUrl = protocols['wfs']; connectProtocol = 'wfs';}
if (protocols.hasOwnProperty("esri")) { connectUrl = protocols['esri']; connectProtocol = 'esri';}
if (protocols.hasOwnProperty("wms")) { connectUrl = protocols['wms']; connectProtocol = 'wms';}
// Create the appropriate type of layer
var layer = new mapLayer(connectProtocol, connectUrl, fileid);
layer.connect();
}
function arcmapRecord(fileid, url) {
// Construct the URL to download a layer file
layerUrl = url + "?f=lyr&v=9.2";
// Give some little instructions
arcmapHelp = new Ext.Window({
title: "Adding a Data Service to ArcMap",
id: "add-arcmap-service",
html: "<p class='window-text'>Clicking the download button below will prompt you to download a layer file. This layer file can be opened in ArcMap and will display the contents of the data service you selected.",
width: 300,
bbar: [
{ text: "Download Layer File", icon: "csw/img/arrow_down.png", handler: function(btn, e) { downloadFile(btn.layerUrl); Ext.getCmp("add-arcmap-service").destroy();}, layerUrl: layerUrl },
"->",
{ text: "Cancel", icon: "csw/img/cancel.png", handler: function(btn, e) { Ext.getCmp("add-arcmap-service").destroy(); } }
]
});
arcmapHelp.show();
}