-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFunctionsGenDiv.php
More file actions
198 lines (171 loc) · 6.3 KB
/
Copy pathFunctionsGenDiv.php
File metadata and controls
198 lines (171 loc) · 6.3 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
//*****************************************************************************************************************************************
//*************************************** FUNCTIONS ***********************************************************
//*****************************************************************************************************************************************
// creates and writes the xml; not used for the moment
function createSLD($nameCol, $ClassNumber, $ClassColor,$wwwDirectory, $nameXML) { //not used for the moment. should change things if used
$textXML="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<StyledLayerDescriptor version=\"1.0.0\"
xsi:schemaLocation=\"http://www.opengis.net/sld StyledLayerDescriptor.xsd\"
xmlns=\"http://www.opengis.net/sld\"
xmlns:ogc=\"http://www.opengis.net/ogc\"
xmlns:xlink=\"http://www.w3.org/1999/xlink\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
<NamedLayer>
<Name>cite:plzo_plz</Name>
<UserStyle>
<Title>inbreeding</Title>
<FeatureTypeStyle>
<Rule>
<ogc:Filter>
<ogc:PropertyIsNull>
<ogc:PropertyName>".$nameCol."</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name=\"fill\">#ffffff</CssParameter>
</Fill>
<Stroke>
<CssParameter name=\"stroke\">#000000</CssParameter>
<CssParameter name=\"stroke-width\">0</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>";
for ($i=0; $i<count($ClassNumber); $i++){
$textXML=$textXML."
<FeatureTypeStyle>
<Rule>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>".$nameCol."</ogc:PropertyName>
<ogc:Literal>".$ClassNumber[$i]."</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name=\"fill\">".$ClassColor[$i]."</CssParameter>
</Fill>
<Stroke>
<CssParameter name=\"stroke\">#000000</CssParameter>
<CssParameter name=\"stroke-width\">0</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>";
}
$textXML=$textXML."
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>";
$myFile2 = $wwwDirectory.$nameXML.".xml";
$fh = fopen($myFile2, 'w') or die("can't open file");
fwrite($fh, $textXML);
fclose($fh);
return;
}
function createJSfile($nameCol,$nameXML,$wwwDirectory,$fileName) {//not used for the moment. should change things if used
$textJScode="
var map, layer, select, control, meaninb=0.00;
function init(){
OpenLayers.ProxyHost= \"http://localhost/cgi-bin/proxy.cgi?url=\";
map = new OpenLayers.Map(\"map\", {
projection: new OpenLayers.Projection(\"EPSG:3857\"),
displayProjection: new OpenLayers.Projection(\"EPSG:3857\"),
units: \"m\",
maxExtent: new OpenLayers.Bounds(
650527.0,5742685.0,1176362.0,6081613.0
),
controls: [
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.Navigation()
]
});
//changed the projection and bounds of the map
layer = new OpenLayers.Layer.WMS(
\"States WMS/WFS\",
\"http://localhost:8085/geoserver/cite/wms?\",
{layers: \"cite:plzo_plz\",
sld: 'http://localhost/genomap/".$nameXML.".xml',
format: 'image/gif'
}
);
//changed the url of the wms
select = new OpenLayers.Layer.Vector(\"Selection\", {styleMap:
new OpenLayers.Style(OpenLayers.Feature.Vector.style[\"select\"])
});
map.addLayers([layer, select]);
control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
box: true,
click: true,
multipleKey: \"shiftKey\",
toggleKey: \"ctrlKey\"
});
control.events.register(\"featureselected\", this, function(e) {
select.addFeatures([e.feature]);
boucle(map.layers[1].features);
});
control.events.register(\"featureunselected\", this, function(e) {
select.removeFeatures([e.feature]);
});
map.addControl(control);
control.activate();
map.zoomToMaxExtent();
}
function boucle(obj){
var i=0;
var j=0;
meaninb=0.00;
for (i in obj){
if (map.layers[1].features[i].attributes.".$nameCol."){
meaninb=meaninb+1*map.layers[1].features[i].attributes.inbreeding;
j=j+1;}}
meaninb=meaninb/(j);
var dummystring='mean inbreeding: ';
showStatus(dummystring.concat(meaninb));
}
function showStatus(text) {
document.getElementById(\"status\").innerHTML = text;
}";
// javaScript file writing
$myFile2 = $wwwDirectory .$fileName.".js";
$fh = fopen($myFile2, 'w') or die("can't open file");
fwrite($fh, $textJScode);
fclose($fh);
return;
}
function joinSQL($refstud){
$sql_mean_inb="UPDATE plzo_plz
SET mean_inb_lastgi = (SELECT mean_inb_lastgi
FROM breed".$refstud."_inb_plz p
WHERE p.plz=plzo_plz.plz)";
pg_query($sql_mean_inb);
$sql_max_inb="UPDATE plzo_plz
SET max_inb_lastgi = (SELECT max_inb_lastgi
FROM breed".$refstud."_inb_plz p
WHERE p.plz=plzo_plz.plz)";
pg_query($sql_max_inb);
$sql_num_ind="UPDATE plzo_plz
SET num_ind_lastgi = (SELECT num_ind_lastgi
FROM breed".$refstud."_inb_plz p
WHERE p.plz=plzo_plz.plz)";
pg_query($sql_num_ind);
$sql_introgr="UPDATE plzo_plz
SET mean_introgr_lastgi = (SELECT mean_introgr_lastgi
FROM breed".$refstud."_inb_plz p
WHERE p.plz=plzo_plz.plz)";
pg_query($sql_introgr);
$sql_inb_gen="UPDATE plzo_plz
SET mean_inb_gen_lastgi = (SELECT mean_inb_gen_lastgi
FROM breed".$refstud."_inb_plz p
WHERE p.plz=plzo_plz.plz)";
pg_query($sql_inb_gen);
//To know which breed is stored in the plzo_plz => update the last_log table
$sql_log="UPDATE last_log SET db_breed = ".$refstud."";
pg_query($sql_log);
return;
}
?>