-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtable.htm
More file actions
2219 lines (1911 loc) · 99.2 KB
/
Copy pathtable.htm
File metadata and controls
2219 lines (1911 loc) · 99.2 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
Copyright (c) 2015, OpenWebGIS, Fedor Kolomeyko <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<html><head><title>Edit attribute table</title>
<style type="text/css">
.blockRule {
width: 260px;
background: #99A8C7;
color:#000080;
padding: 15px;
padding-right: 15 px;
position:absolute;
top: 20px;
left: 20px;
border: solid 1px black;
float: left;
}
.blockbutOpen {
position:absolute;
top: 100px;
left: 80px;
}
.blockUpdateTable
{display:none;}
.blockFilter {
width: 260px;
background: #99A8C7;
color:#000080;
padding: 15px;
padding-right: 15 px;
position:absolute;
top: 160px;
left: 20px;
border: solid 1px black;
float: left;
}
.blockSort
{position:absolute; top: 35px;left: 180px;
}
.ok{position:absolute;left: 20px;top: 84px;}
.blockTextCalculation {
width: 260px;
background: #99A8C7;
color:#000080;
padding: 15px;
padding-right: 15 px;
position:absolute;
top: 360px;
left: 20px;
border: solid 1px black;
float: left;
}
.blockChart {
width: 260px;
background: #99A8C7;
color:#000080;
padding: 15px;
padding-right: 15 px;
position:absolute;
top: 600px;
left: 20px;
border: solid 1px black;
float: left;
}
.blockTable
{
top:20px;
left: 320px;
position:relative;
}
.ChartBlockAreaDiv
{
top:20px;
left: 320px;
position:absolute;
}
#paletteC {
width:360px; height:20px;
}
#paletteC div {
width:1px; height:20px;
float:left;
}
</style>
</head>
<body onload="init()">
<div class="blockbutOpen"><button type=button onclick=OpenTable()>Open table</button>
<button type=button display=none onclick=EditTable()>Edit table</button>
<div id="block_UpdateTable" class="blockUpdateTable"><button type=button onclick=UpdateTable()>Update</button></div>
</div>
<div class="ok"> <p> <button type=button onclick=OK()>Exit</button></p>
</div>
<center><font size=+3>
</font></center>
</div>
<div id="countRow" class="blockRule" >
<li> <a>count rows:</a>
<select id=pCount >
<option selected value="0">0</option>
<option value="1">1</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="300">300</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="1500">1500</option>
<option value="2000">2000</option>
<option value="3000">3000</option>
<option value="All">All</option>
</select><br>
<input id="select_feat_map_id" type="checkbox" value="false"><a style="font-size:12px">select features on the map</a>
</li>
</div>
<div id="id_ChartBlock" class="ChartBlockAreaDiv">
<canvas id=id_canvas1Chart width='1000px' height='640px' style='display:none; border: 2px double black;'></canvas>
</div>
<div id="table" class="blockTable">
</div>
<div id="FieldTable" class="blockFilter" >
<li> <a>Field for filter:</a>
<div class="blockSort">
<a>Sort by</a><br>
<input id="sortA" type="checkbox" value="A" onclick=SortA()>Ascending<br>
<input id="sortD" type="checkbox" value="D" onclick=SortD()>Descending
</div>
<select id=pFieldTable>
<option selected value="0">.</option>
</select>
</li><br>
<li> <a>Operator</a>
<select id=pOperTable>
<option selected value="0">.</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
<option value="==">=</option>
</select>
</li><br>
<input id=pInputFilterTable type="text" size="15"><br>
<p> <button type=button onclick=Applyfilter()>Apply filter</button></p>
</div>
<div id="CalcText" class="blockTextCalculation">
<a>Calculation</a><br>
<textarea rows="5" title="Names of all attributes must be put in square brackets. Name of the new attribute must be without any brackets. For example: calc=[LATITUDE]/[LONGITUDE]*100+[LATITUDE] . In this example 'calc' is the new attribute(field). Note: new attributes are not saved in shapefile or database in web-server from which the Layer was created. In order to save it in web-server, you must use menu item 'Export Layer' gml or csv file, or create shapefile in other software and then upload it in web-server. Without this you can anyway use new attribute to change legend Layer, use in all calculations and create chart in new window.Also use the functions: Math.sin ([newField]), Math.abs ([newField]), Math.cos ([newField]), Math.random (), Math.exp (([newField]), Math.sqrt ([newField] ), Math.log ([newField]) - natural logarithm, Math.pow ([newField]), x) - exponentiation x. Example, newField = (Math.cos ([SomeField1]) / Math.abs ([SomeField2])) + Math.sqrt (16) - Math.sqrt ([SomeField3]). To round numbers, you can use the notation: newField = [newField] .toFixed (x), where x is the desired number of decimal places.You can also use special formulas: mean, min, max. To find the average value for all rows in a column (attribute) SomeField you need to write newField = mean (SomeField). The square brackets in the title of the column are not needed. To find the average value in the column SomeField1 for each unique column values SomeField2, you need to write newField = mean (SomeField2, SomeField1). Similarly newField = min (SomeField2, SomeField1) and newField = count (SomeField2, SomeField1). This is useful for example to calculate the minimum or maximum, quantity of some value within each year, if you have a layer containing information about many years." cols="25" id="textCalc" name="text"></textarea><br>
<button type=button onclick=ApplyCalc()>Apply Calculation</button><br>
<input type="checkbox" id="CheckSaveOldAtt" value="checkbox"/><font size="2">Save result (it does not work for the new attribute)</font><br>
<input type="checkbox" id="CheckSaveTextAtt" title="if activate this checkbox, then resulted attribute will be strings concatenation. You must use apostrophe in both side of the string.Example: calc=[LATITUDE]+'text', then if [LATITUDE]=24.5 -> calc=24.5text; but if string is a number you not may use apostrophe. Example:calc=24.5+3 then calc=24.53" value="checkbox"/><a title="if activate this checkbox, then resulted attribute will be strings concatenation. You must use apostrophe in both side of the string.Example: calc=[LATITUDE]+'text', then if [LATITUDE]=24.5 -> calc=24.5text; but if string is a number you not may use apostrophe. Example:calc=24.5+3 then calc=24.53"><font size="2">strings concatenation</a></font><br>
</div>
<div id="CharBlockMenu" class="blockChart">
<a>Chart</a><br>
<div style="float:left"><a>Axis X</a><select id=fieldChartX>
<option selected value="0">.</option>
</select></div><div onclick="OptionFuncChart()" title="open options of chart" style="cursor:pointer;float:left"><img src="img/option.png"/ width="20" height="20"></div><br>
<div style="float:left"><a>Axis Y</a><select id=fieldChartY>
<option selected value="0">.</option>
</select></div><br>
<div style="float:left"><a>Axis Z </a><select id=fieldChartZ>
<option selected value="0">.</option>
</select></div><br>
<div style="float:left"><a style="font-size: 11px;">label by interval in X</a><input id=id_IntervalX type="text" size="2" value="2"><a style="font-size: 11px;">sum by interval in X</a><input id=id_IntervalXs type="text" size="2" value="0"></div><br>
<div style="float:right"><input id="id_repeatV" type="checkbox" value="check">merge repeated values on axis X in single value</div><br>
<div id="id_correlDiv" style="float:left"><input id="id_CorrRegV" type="checkbox" value="check">get line regression equation(y/x)</div><br>
<button type=button onclick=ApplyChart()>Create Chart</button>
<button type=button onclick=RemoveChart()>Remove Chart</button>
</div>
<script src="openlayers/OpenLayers.js"> </script>
<script type="text/javascript" >
var layerNameTable;
var arrFeaturesTable;
var forEdit=0;
var eee;
var sortTable_A=0;
var sortTable_D=0;
var dTheta=0.05;
var SumdTheta=0;
var SumdThetaT=0;
var SumdThetaY=0;
var SumdThetaTY=0;
var Axe='x';
var Protate;
var Protate2;
var Protate2Z;
var rtt;
var Legend3dObj;
var arrayFeatZcolor=[];
var arrayFeatZIshod=[];
var arrayFeatZfunc=[];
var function3dG;
var MainPointIndex=0;
var colorMap=["#060", "#090", "#0C0", "#0F0", "#9F0", "#9C0", "#990", "#960", "#930", "#900", "#C00"];
var AsDes=0;
var colorXmain="#000000";
var fileZIP;
//document.getElementById("pField").appendChild(t);
////end clear select list
function init(){
////Get FeatureType/////////////////////////////////////
var EditLayerList;
var body = document.body
var docElem = document.documentElement
var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop
var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft
var clientTop = docElem.clientTop || body.clientTop || 0
var clientLeft = docElem.clientLeft || body.clientLeft || 0
var topTop = 0 + scrollTop - clientTop
var leftLeft =0 + scrollLeft - clientLeft
var DivEditeLeg=document.createElement("div");
DivEditeLeg.id="id_optionsChart";
DivEditeLeg.style.width=400;
DivEditeLeg.style.height=400;
DivEditeLeg.className="id_divOptionsChart";
DivEditeLeg.style.position="absolute";
DivEditeLeg.style.display="none";
DivEditeLeg.style.left=Math.round(document.body.clientWidth/2-100);
DivEditeLeg.style.top=Math.round(document.body.clientHeight/2-0.00);
DivEditeLeg.innerHTML='<div id="id_id_divOptionsChartLeg" style="background:#ffffff; color:#0000ff;z-index: 100;position:relative;'+
'px;overflow:hidden; border: 1px solid black; width:600px;height:200px;"><img onclick="closeRemoveChartOptWin()" src="openlayers/theme/default/img/close.gif" style="position:relative; top:3px left:50px;float:right; cursor:pointer"><a style="position:relative; top:20px"></a>'+'<div id="id_id_divOptionsChartLeg2" style="top:10px;position:relative"></div><br>'+
'<div> <p>'+
'<button type="button" onclick="OKRemOptCh()">Close</button><button type="button" onclick="ApplyChart()">Create Chart</button></p></div>'
'</div>';
body.appendChild(DivEditeLeg);
var htmlRemL='';
htmlRemL+='<div style="float:left"><a>Axis X</a></div><div title="select color of Axis X" id="fieldChartXColor" onclick="clickDivColor3d(this)"'+' style="position:relative;width:10px;height:10px;cursor:pointer;background:#bbbbbb; border:1px double black; float:left"></div><div "'+' style="float:left"><a>.value:</a></div><div title="select color of value" id="fieldChartVColor" onclick="clickDivColor3d(this)" '+' style="position:relative;width:10px;height:10px;cursor:pointer;background:#bbbbbb; border:1px double black;float:left"></div><br>'+
'<div style="float:left"><a>Axis Y</a>'+
'</div><div title="select color of Axis Y" id="fieldChartYColor" onclick="clickDivColor3d(this)"'+
'style="position:relative;width:10px;height:10px;cursor:pointer;background:#bbbbbb; border:1px double black;float:left"></div><br>'+
'<div style="float:left"><a>type of chart</a><select id="typeChartGis">'+
'<option selected value="line">line</option>'+
'<option value="bar_graph">bar_graph</option>'+
'</select></div>';
document.getElementById("id_id_divOptionsChartLeg2").innerHTML=htmlRemL;
if (window.opener.editlayerMainName!=0 || window.opener.editlayerMainName!=undefined)
{
var featureTypes2=0;
for (var ak in window.opener.edilayerMainLayer.features[0].attributes)
{
var tt2=document.createElement('option');tt2.value=ak;tt2.text=ak;
document.getElementById("fieldChartX").appendChild(tt2);
var tt3=document.createElement('option');tt3.value=ak;tt3.text=ak;
document.getElementById("fieldChartY").appendChild(tt3);
var tt4=document.createElement('option');tt4.value=ak;tt4.text=ak;
document.getElementById("fieldChartZ").appendChild(tt4);
}
if(featureTypes2==0)
{
for (var ak in window.opener.edilayerMainLayer.features[0].attributes)
{ var tt=document.createElement('option');
tt.value=ak;
tt.text=ak;
document.getElementById("pFieldTable").appendChild(tt);
} ///end for (var ak in window.opener.edilayerMainLayer.features[0].attributes)
}
}//end if(featureTypes2[0])
} ///end function
function OK()
{close();}
////////////////////////////////////Chart
function OptionFuncChart()
{if(document.getElementById("id_optionsChart").style.display=='none'){document.getElementById("id_optionsChart").style.display='block'}
else{document.getElementById("id_optionsChart").style.display='none'}
}
function closeRemoveChartOptWin()
{document.getElementById("id_optionsChart").style.display='none';
}
function OKRemOptCh()
{document.getElementById("id_optionsChart").style.display='none';}
function RemoveChart()
{
if(document.getElementById('id_ NewChartImage'))
{
document.getElementById('id_ NewChartImage').parentNode.removeChild(document.getElementById('id_ NewChartImage'));
document.getElementById("table").style.top="20px"
}
}
function inRadG(num) {
//translate angle from rad to grad
return num * Math.PI / 180;
}
function draw(Axe)
{
Axe=Axe;
var myWinChartKV=window;
var drawingCanvas0 = myWinChartKV.document.getElementById('id_canvas1Chart');
drawingCanvas0.style.display="block";
var context = drawingCanvas0.getContext('2d');
//context.translate(drawingCanvas0.width/2, drawingCanvas0.height/2);
context.lineWidth = 1.5;
context.lineCap = 'butt';
//context.clearRect(0, 0, drawingCanvas0.width, drawingCanvas0.height);
var ctx=context;
window.opener.rtt=Protate;
ctx.fillRect(0, 0, 10, 10);
window.opener.rtt=Protate2;
context.lineWidth = 1.5;
////ZZZZZZZZZZZZZZ
var SumAngle=Math.abs(SumdThetaT)+Math.abs(SumdThetaTY);
//alert("Sum "+SumAngle+" X "+SumdThetaT+"Y "+SumdThetaTY);
//alert("P "+Protate[0][0]+","+Protate[1][0]+","+Protate[2][0]);
//alert("P2Z "+Protate2Z[0][0]+","+Protate2Z[1][0]+","+Protate2Z[2][0]);
//var t=(Protate2Z[0][0]-Protate[0][0])+(Protate2Z[1][0]-Protate[1][0])+(Protate2Z[2][0]-Protate[2][0]);
var drawingCanvas3d = document.getElementById('id_canvas1Chart');
//alert(Protate2Z[2][0]+" , "+Protate[2][0]);
rtt=Protate;
//alert(Protate2Z[2][0]-Protate[2][0]);
var rast=(0-Protate2Z[2][0]);
//if(Math.abs(Protate2Z[2][0])<Math.abs(Protate[2][0])){rast=(Protate[2][0]-Protate2Z[2][0]);}
if((rast>0))
{
for (var i =0; i <Protate.length-2; i++)
{
for(var h=0; h<Protate[i].length;h++)
{ ctx.fillStyle=arrayFeatZcolor[h].backgr;ctx.fillRect(Protate[i][h], Protate[i+1][h], arrayFeatZcolor[h].size, arrayFeatZcolor[h].size); } //data point
}
}
for (var i =0; i <Protate2Z.length-2; i++)
{
for(var h=0; h<Protate2Z[i].length;h++)
{
context.lineWidth = 1.5;
context.lineCap = 'butt';
context.beginPath();
context.beginPath();
context.moveTo(0, 0);
context.lineTo(Protate2Z[i][h], Protate2Z[i+1][h]);
context.lineWidth = 1.5;
//context.moveTo(0, 0);
//context.lineTo(Protate2Z[i][h+1], Protate2Z[i+1][h+1]);
context.stroke(); }
}
for (var i =0; i <Protate2.length-2; i++)
{context.lineWidth = 1.5;
for(var h=0; h<Protate2[i].length-2;h++)
{
context.lineWidth = 1.5;
context.lineCap = 'butt';
context.beginPath();
context.beginPath();
context.moveTo(0, 0); context.lineWidth = 1.5;
context.lineTo(Protate2[i][h], Protate2[i+1][h]);
context.moveTo(0, 0);
context.lineTo(Protate2[i][h+1], Protate2[i+1][h+1]);
//context.lineWidth = 0.5;
//context.lineTo(Protate2[i][h+1], Protate2[i+1][h]);
//context.lineTo(Protate2[i][h], Protate2[i+1][h]);
//context.moveTo(0, 0);
window.opener.rtt=Protate2;
//alert("fg");
context.stroke();
context.beginPath();
context.lineWidth = 0.5;
context.moveTo(0, 0);
context.lineTo(Protate2[i][h], Protate2[i+1][h]);
context.moveTo(0, 0);
context.lineTo(Protate2[i][h+1], Protate2[i+1][h+1]);
//context.moveTo(Protate2[i][h+1], Protate2[i+1][h+1]);
context.lineTo(Protate2[0][2], Protate2[1][2]);
//context.moveTo(Protate2[i][h], Protate2[i+1][h]);
//context.lineTo(Protate2[0][2], Protate2[1][2]);
context.lineTo(Protate2[i][h], Protate2[i+1][h]);
context.closePath();
context.fillStyle="rgba(100,150,185,0.80)";
context.fill();
context.stroke();
//context.stroke();
//context.fillStyle='#b1afa6';context.fillRect(Protate[i][h]/2, Protate2[i+1][h+1]/2, drawingCanvas0.width/2, drawingCanvas0.height/2);
}
}
window.opener.rtt=Protate;
//alert("jkl");
context.fillStyle='#000000';
//ctx.fillStyle = "#00F";
//ctx.strokeStyle = "#F00";
ctx.font = "italic 12pt Arial";
context.fillText('x', Protate2[0][1]-8, Protate2[1][1]-6);
context.fillText('y', Protate2[0][0]-8, Protate2[1][0]-6);
context.fillText('z', Protate2Z[0][0]+4, Protate2Z[1][0]-6);
if(rast<0){
for (var i =0; i <Protate.length-2; i++)
{
// ctx.fillStyle = this.points[i].color;
for(var h=0; h<Protate[i].length;h++)
{ ctx.fillStyle=arrayFeatZcolor[h].backgr;ctx.fillRect(Protate[i][h], Protate[i+1][h], arrayFeatZcolor[h].size, arrayFeatZcolor[h].size); } //data point
}
}
}
function erase()
{
var myWinChartKV=window;
var drawingCanvas0 = myWinChartKV.document.getElementById('id_canvas1Chart');
var context = drawingCanvas0.getContext('2d');
context.clearRect(-drawingCanvas0.width/2, -drawingCanvas0.height/2, drawingCanvas0.width, drawingCanvas0.height);
}
// -----------------------------------------------------------------------------------------------------
function multiplyMatrix(U,S)
{
var rowsA = U.length,
rowsB = S.length,
colsB,
C = new Array(rowsA);
colsB = S[0].length;
if(!S[0].length){colsB=1;}
for (var i=0; i<rowsA; i++)
{ C[i] = new Array(colsB) }
for (var k=0; k<colsB; k++)
{ for (var i=0; i<rowsA; i++)
{ var temp = parseFloat(0);
for (var j=0; j<rowsB; j++)
{
// if(U[i].length&&S[1])
// {temp = (temp + U[i][j]*S[j][k])}
// else{temp =parseFloat(temp) +parseFloat(U[i])*parseFloat(S[j][k]))}
if(!U[1]&&!S[0][1])
{temp = (parseFloat(temp) + parseFloat(U[i][j])*parseFloat(S[j]))}
else{ if(S[1]){temp = (parseFloat(temp) + parseFloat(U[i][j])*parseFloat(S[j][k]))}
else{temp =(parseFloat(temp)+parseFloat(U[i])*parseFloat(S[j][k]));}}
}
C[i][k] = parseFloat(temp);
}
}
//rtt=C;
//alert("C ");
return C;
}
function multipleMat(R,ArryXYZ,Axis,AxisZ)
/*
Assumes that R is a 3 x 3 matrix and that this.points (i.e., P) is a 3 x n matrix. This method performs P = R * P.
*/
{
var Px = 0, Py = 0, Pz = 0; // Variables to hold temporary results.
var P = ArryXYZ; // P is a pointer to the set of surface points (i.e., the set of 3 x 1 vectors).
/*window.opener.rtt=P;
alert("P");
var sum; // The sum for each row/column matrix product.
for (var V = 0; V < P.length; V++) // For all 3 x 1 vectors in the point list.
{
for(var t=0;t<P[V].length;t++){
Px = P[V][t], Py = P[V][t], Pz = P[V][t];
for (var Rrow = 0; Rrow < 3; Rrow++) // For each row in the R matrix.
{
sum = (R[Rrow][0] * Px) + (R[Rrow][1] * Py) + (R[Rrow][2] * Pz);
P[V][Rrow] = sum;
}
}// t
} */
Protate=multiplyMatrix(R,P);
Protate2=multiplyMatrix(R,Axis);
Protate2Z=multiplyMatrix(R,AxisZ)
}
// -----------------------------------------------------------------------------------------------------
function xRotate(sign,ArryXYZ,Axis,AxisZ)
/*
Assumes "sign" is either 1 or -1, which is used to rotate the surface "clockwise" or "counterclockwise".
*/
{
var Rx = [ [0, 0, 0],
[0, 0, 0],
[0, 0, 0] ]; // Create an initialized 3 x 3 rotation matrix.
Rx[0][0] = 1;
Rx[0][1] = 0; // Redundant but helps with clarity.
Rx[0][2] = 0;
Rx[1][0] = 0;
Rx[1][1] = Math.cos( sign*dTheta );
Rx[1][2] = -Math.sin( sign*dTheta );
Rx[2][0] = 0;
Rx[2][1] = Math.sin( sign*dTheta );
Rx[2][2] = Math.cos( sign*dTheta );
multipleMat(Rx,ArryXYZ,Axis,AxisZ); // If P is the set of surface points, then this method performs the matrix multiplcation: Rx * P
erase(); // Note that one could use two canvases to speed things up, which also eliminates the need to erase.
Axe="x";
SumdTheta=parseFloat(SumdTheta)+(sign)*parseFloat(dTheta);
SumdThetaT=parseFloat(SumdTheta *180/ Math.PI);
if(Math.abs(parseFloat(SumdThetaT))>parseFloat(360)){SumdTheta=0;}
if(Math.abs(parseFloat(SumdThetaT))>parseFloat(360)){SumdThetaT=parseFloat(SumdThetaT)-parseFloat(360);}
//alert(SumdThetaT);
draw(Axe);
}
// -----------------------------------------------------------------------------------------------------
function yRotate(sign,ArryXYZ,Axis,AxisZ)
/*
Assumes "sign" is either 1 or -1, which is used to rotate the surface "clockwise" or "counterclockwise".
*/
{
var Ry = [ [0, 0, 0],
[0, 0, 0],
[0, 0, 0] ]; // Create an initialized 3 x 3 rotation matrix.
Ry[0][0] = Math.cos( sign*dTheta );
Ry[0][1] = 0; // Redundant but helps with clarity.
Ry[0][2] = Math.sin( sign*dTheta );
Ry[1][0] = 0;
Ry[1][1] = 1;
Ry[1][2] = 0;
Ry[2][0] = -Math.sin( sign*dTheta );
Ry[2][1] = 0;
Ry[2][2] = Math.cos( sign*dTheta );
multipleMat(Ry,ArryXYZ,Axis,AxisZ); // If P is the set of surface points, then this method performs the matrix multiplcation: Rx * P
erase(); // Note that one could use two canvases to speed things up, which also eliminates the need to erase.
Axe="y";
SumdThetaY=parseFloat(SumdThetaY)+(sign)*parseFloat(dTheta);
SumdThetaTY=parseFloat(SumdThetaY *180/ Math.PI);
if(Math.abs(parseFloat(SumdThetaTY))>parseFloat(360)){SumdThetaY=0;}
if(Math.abs(parseFloat(SumdThetaTY))>parseFloat(360)){SumdThetaTY=parseFloat(SumdThetaTY)-parseFloat(360);}
draw(Axe);
}
// -----------------------------------------------------------------------------------------------------
function zRotate(sign,ArryXYZ,Axis,AxisZ)
/*
Assumes "sign" is either 1 or -1, which is used to rotate the surface "clockwise" or "counterclockwise".
*/
{
var Rz = [ [0, 0, 0],
[0, 0, 0],
[0, 0, 0] ]; // Create an initialized 3 x 3 rotation matrix.
Rz[0][0] = Math.cos( sign*dTheta );
Rz[0][1] = -Math.sin( sign*dTheta );
Rz[0][2] = 0; // Redundant but helps with clarity.
Rz[1][0] = Math.sin( sign*dTheta );
Rz[1][1] = Math.cos( sign*dTheta );
Rz[1][2] = 0;
Rz[2][0] = 0
Rz[2][1] = 0;
Rz[2][2] = 1;
multipleMat(Rz,ArryXYZ,Axis,AxisZ); // If P is the set of surface points, then this method performs the matrix multiplcation: Rx * P
erase(); // Note that one could use two canvases to speed things up, which also eliminates the need to erase.
draw(ArryXYZ);
}
function xRotateZaxis(sign,Zaxis)
/*
Assumes "sign" is either 1 or -1, which is used to rotate the surface "clockwise" or "counterclockwise".
*/
{
var Rx = [ [0, 0, 0],
[0, 0, 0],
[0, 0, 0] ]; // Create an initialized 3 x 3 rotation matrix.
Rx[0][0] = 1;
Rx[0][1] = 0; // Redundant but helps with clarity.
Rx[0][2] = 0;
Rx[1][0] = 0;
Rx[1][1] = Math.cos( sign*1.5708 );
Rx[1][2] = -Math.sin( sign*1.5708 );
Rx[2][0] = 0;
Rx[2][1] = Math.sin( sign*1.5708 );
Rx[2][2] = Math.cos( sign*1.5708 );
Protate2Z=multiplyMatrix(Rx,Zaxis)
//return Protate2Z;
//multipleMat(Rx,ArryXYZ,Axis); // If P is the set of surface points, then this method performs the matrix multiplcation: Rx * P
//erase(); // Note that one could use two canvases to speed things up, which also eliminates the need to erase.
//draw(ArryXYZ);
}
function closeColor()
{if(document.getElementById('id_divEditeLegColor'))
{document.getElementById('id_divEditeLegColor').parentNode.removeChild(document.getElementById('id_divEditeLegColor'));}
}
function clickDivColor3d(elem)
{
var bbox = elem.getBoundingClientRect();
//set position
var body = document.body
var docElem = document.documentElement
//get prokrutka
var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop
var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft
//get sdvig
var clientTop = docElem.clientTop || body.clientTop || 0
var clientLeft = docElem.clientLeft || body.clientLeft || 0
var topTop = bbox.top + scrollTop - clientTop
var leftLeft = bbox.left + scrollLeft - clientLeft
//var bgColor=document.getElementById("external_control2").style.background;
var DivEditeLeg=document.createElement("div");
DivEditeLeg.id="id_divEditeLegColor";
DivEditeLeg.innerHTML='<div id="id_divColorc" style="background:#97d9e0; color:#0000ff;width:380px;z-index: 1400;height:40px;position:absolute;left:'+Math.round(leftLeft+10)+'px;top:'+Math.round(topTop+10)+
'px;overflow:hidden; border: 1px solid black;"><img onclick="closeColor()" src="openlayers/theme/default/img/close.gif" style="position:relative; top:5px;float:right; cursor:pointer"><a style="position:relative; top:20px"></a><div id="paletteC"></div></div>';
if(!document.getElementById("id_divEditeLegColor"))
{body.appendChild(DivEditeLeg);drawPalette(elem); }
}
function drawPalette(elem) {var out = "";
for (var i = 0; i < 360; i++) {
out += "<div id='id_palettcolortable_"+i+"' onclick='selectColor(this);' style='background-color:" + HSLToRGB(i, 100, 100) + "'><\/div>";
} document.getElementById("paletteC").innerHTML = out;
for(var i = 0; i < 360; i++)
{document.getElementById("id_palettcolortable_"+i).onclick=function(){var nelem=elem;selectColor(this,nelem);}}
//document.getElementById("id_palettcolortable").onclick=function(){var nelem=elem;selectColor(this,nelem);}
}
function selectColor(div,nelem) {
colorElemWin = div.style.backgroundColor;
colorElemWin = rgbNormal(colorElemWin);
nelem.style.background=colorElemWin;
nelem.tempColorGIS=colorElemWin;
}
function rgbNormal(color) {
color = color.toString();
var re = /rgb\((.*?)\)/i;
if(re.test(color)) {
compose = RegExp.$1.split(",");
var hex = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
var result = "#"; for (var i = 0; i < compose.length; i++) {
rgb = parseInt(compose[i]);result += hex[parseInt(rgb / 16)] + hex[rgb % 16];
}
return result;
} else return color;
}
function HSLToRGB(Hue, Saturation, Luminance) {
var R, G, B;
var nH, nS, nL;
var nF, nP, nQ, nT;
var lH;
if (Saturation > 0) {
nH = Hue / 60;nL = Luminance / 100;nS = Saturation / 100;
lH = parseInt(nH); nF = nH - lH;nP = nL * (1 - nS);
nQ = nL * (1 - nS * nF);nT = nL * (1 - nS * (1 - nF));
switch (lH) {
case 0:
R = nL * 255;G = nT * 255;B = nP * 255;
break;
case 1:
R = nQ * 255;G = nL * 255;B = nP * 255;
break;
case 2:
R = nP * 255;G = nL * 255;B = nT * 255;
break;
case 3:
R = nP * 255;G = nQ * 255;B = nL * 255;
break;
case 4:
R = nT * 255;G = nP * 255;B = nL * 255;
break;
case 5:
R = nL * 255;G = nP * 255;B = nQ * 255;
break;
}
} else {
R = (Luminance * 255) / 100; G = R;B = R;
}
return RGBToLongSafe(R, G, B);
}
function RGBToLongSafe(R, G, B) {
R = parseInt(xLimit(R, 0, 255));
G = parseInt(xLimit(G, 0, 255));
B = parseInt(xLimit(B, 0, 255));
return decToHex([R,G,B]);
}
function decToHex(decArray) {
var hex = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
var out = "#"; for (var i = 0; i < decArray.length; i++) {
dec = parseInt(decArray[i]);out += hex[parseInt(dec / 16)] + hex[dec % 16];
}
return out;
}
function xLimit(Value, Lower, Higher) {
if (Value < Lower) Value = Lower;
if (Value > Higher) Value = Higher;
return Value;
}
function Change3dclassification()
{
if(document.getElementById('Id_Chart3dClass_inputs'))
{document.getElementById('Id_Chart3dClass_inputs').parentNode.removeChild(document.getElementById('Id_Chart3dClass_inputs'));}
if(document.getElementById("Id_Chart3dClass_GIS"))
{var count=document.getElementById("Id_Chart3dClass_GIS").value;
var max=document.getElementById("Id_Chart3dClassMax_GIS").innerHTML;
var min=document.getElementById("Id_Chart3dClassMin_GIS").innerHTML;
var dopstv=(max-min)/(count);
}
var arrayclass=document.createElement('div');
arrayclass.id="Id_Chart3dClass_inputs";
document.getElementById('id_Chart3dbutton_GIS').appendChild(arrayclass);
for(var i=0;i<count;i++)
{
var inputv=this.document.createElement('input');
inputv.type='text';
inputv.size="4";
inputv.id="IdChart3dClass_"+i+"_1";inputv.value=parseFloat(min)+dopstv*i;
var inputv2=this.document.createElement('input');
inputv2.type='text';
inputv2.size="4"
inputv2.id="IdChart3dClass_"+i+"_2";inputv2.value=parseFloat(inputv.value)+dopstv;
var inputva=this.document.createElement('a');
inputva.innerHTML="from ";
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputva);
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputv);
var inputva=this.document.createElement('a');
inputva.innerHTML="to ";
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputva);
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputv2);
var inputDiv=this.document.createElement('div');
inputDiv.id="IdChart3dClassDivColor_"+i;
inputDiv.style.width="10px";
inputDiv.style.height="10px";
inputDiv.onclick=function(){clickDivColor3d(this);}
inputDiv.style.border="1px double black";
inputDiv.style.cursor="pointer";
inputDiv.style.background="#bbbbbb";
var inputvS=this.document.createElement('a');
inputvS.innerHTML=" size ";
var inputvSize=this.document.createElement('input');
inputvSize.type='text';
inputvSize.size="3";
inputvSize.value="2";
inputvSize.id="IdChart3dLabSize_"+i;
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputvS);
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputvSize);
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputDiv);
var br1=this.document.createElement('br');
document.getElementById("Id_Chart3dClass_inputs").appendChild(br1);
}
var inputvApl=this.document.createElement('input');
inputvApl.type='button';
inputvApl.value="Apply Legend";
inputvApl.onclick=function(){ApplyLegend3d();};
document.getElementById("Id_Chart3dClass_inputs").appendChild(inputvApl);
}
function ApplyLegend3d()
{
Legend3dObj=[];
var count=document.getElementById("Id_Chart3dClass_GIS").value;
for(var i=0;i<count;i++)
{
var legobj={};
legobj.from=document.getElementById("IdChart3dClass_"+i+"_1").value;
legobj.to=document.getElementById("IdChart3dClass_"+i+"_2").value;
if(!document.getElementById("IdChart3dClassDivColor_"+i).tempColorGIS)
{document.getElementById("IdChart3dClassDivColor_"+i).tempColorGIS="#bbbbbb";}
legobj.background=document.getElementById("IdChart3dClassDivColor_"+i).tempColorGIS;
legobj.size=document.getElementById("IdChart3dLabSize_"+i).value;
Legend3dObj.push(legobj)
}
rtt=Legend3dObj;
var Zobj={}
Zobj.backgr="#000000";
Zobj.size="2";
arrayFeatZcolor=[];
arrayFeatZIshod=[];
var arrayFeatIs=window.opener.edilayerMainLayer.features;
if(document.getElementById("classFunCountCheck3d")&&arrayFeatZfunc.length>0)
{arrayFeatIs=arrayFeatZfunc;}
var fieldZvalueZClassification=document.getElementById("Id_Chart3dClassZlabel_GIS").value;
if(document.getElementById("classFunCountCheck3d").checked==true)
{ApplyChart();}
for(var s=0; s<arrayFeatIs.length;s++)
{arrayFeatZIshod.push(parseFloat(arrayFeatIs[s].attributes[fieldZvalueZClassification]));}
if(Legend3dObj&&Legend3dObj.length>0)
{
for(var g=0;g<arrayFeatZIshod.length;g++)
{var Zobj={};Zobj.backgr="#000000";Zobj.size="2";
for(var ll=0; ll<Legend3dObj.length;ll++)
{
if(arrayFeatZIshod[g]<parseFloat(Legend3dObj[ll].to)&&arrayFeatZIshod[g]>=parseFloat(Legend3dObj[ll].from))
{Zobj.backgr=Legend3dObj[ll].background;Zobj.size=Legend3dObj[ll].size;}}arrayFeatZcolor.push(Zobj);}
}
erase();
draw();
}
function Change3dClassZlabel()
{
var arrayFeat=window.opener.edilayerMainLayer.features;
var fieldZ=document.getElementById("Id_Chart3dClassZlabel_GIS").value;
var minDistC = parseFloat(arrayFeat[0].attributes[fieldZ]);
var maxDistC = parseFloat(minDistC) ;
for (ia = 1; ia < arrayFeat.length; ++ia) { var NumSS=arrayFeat[ia].attributes[fieldZ];
if (NumSS>parseFloat(maxDistC) ) maxDistC = parseFloat(NumSS);
if( NumSS<parseFloat(minDistC) ) minDistC = parseFloat(NumSS); }
document.getElementById("Id_Chart3dClassMax_GIS").innerHTML=maxDistC;
document.getElementById("Id_Chart3dClassMin_GIS").innerHTML=minDistC;
}
function ApplyChart(myWinSsqlBioTable_Layer,sqlFeatures,fieldSel)
{
var start = performance.now();
SumdTheta=0; // angle for 3d rad
SumdThetaT=0 // angle for 3d grad
SumdThetaY=0; // angle for 3d rad
SumdThetaTY=0 // angle for 3d grad
arrayFeatZfunc=[];
var fieldSel=document.getElementById('fieldChartY').value;
var fieldSel2=document.getElementById('fieldChartX').value;
var fieldZ=document.getElementById('fieldChartZ').value;
var arrayFeat=window.opener.edilayerMainLayer.features;
var formatArF = new OpenLayers.Format.GeoJSON({});var jsonstrAF=formatArF.write(arrayFeat);arrayFeat=formatArF.read(jsonstrAF);
if(document.getElementById('id_IntervalXs').value!=="0"&&document.getElementById('id_IntervalXs').value!=="")
{ var newarrayFeatsx=[];var ArrayFeaturesbx=[];var sumEl=0;
var minDistC = parseFloat(arrayFeat[0].attributes[fieldSel2]);
var maxDistC = parseFloat(minDistC) ;
for (ia = 1; ia < arrayFeat.length; ++ia) { var NumSS=arrayFeat[ia].attributes[fieldSel2];
if (NumSS>parseFloat(maxDistC) ) {maxDistC = parseFloat(NumSS);}
if( NumSS<parseFloat(minDistC) ) {minDistC = parseFloat(NumSS);}
}
var cenInt=maxDistC/parseFloat(document.getElementById('id_IntervalXs').value);
for(var x0=minDistC;x0<=maxDistC;x0=x0+cenInt)
{sumEl=0;for(var x=0;x<arrayFeat.length;x++)
{
if(parseFloat(arrayFeat[x].attributes[fieldSel2])>=x0&&parseFloat(arrayFeat[x].attributes[fieldSel2])<(x0+cenInt))
{sumEl=sumEl+parseFloat(arrayFeat[x].attributes[fieldSel]);}
}
newarrayFeatsx.push([sumEl,x0+cenInt]);
}
for(var ti=0;ti<newarrayFeatsx.length;ti++)
{var pointsbx=new OpenLayers.Geometry.Point(0, 0);
var first_point= new OpenLayers.Feature.Vector(pointsbx);
first_point.attributes=JSON.parse(JSON.stringify(arrayFeat[0].attributes));first_point.attributes[fieldSel2]=newarrayFeatsx[ti][1]; first_point.attributes[fieldSel]=newarrayFeatsx[ti][0];
ArrayFeaturesbx.push(first_point);};arrayFeat=ArrayFeaturesbx;
}
var tyTemp;
Legend3dObj= tyTemp;
// sort array Features by string is selected X is string
if(fieldZ==0){for(var x=0;x<arrayFeat.length;x++){
if(arrayFeat[x].attributes[fieldSel2]!==''){
if(typeof(arrayFeat[x].attributes[fieldSel2])=="string"&&isNaN(arrayFeat[x].attributes[fieldSel2]*1.0)==true){
arrayFeat.sort(function(a,b){
if(a.attributes[fieldSel2] < b.attributes[fieldSel2])
return -1
if(a.attributes[fieldSel2] > b.attributes[fieldSel2])
return 1
return 0
});
} // end sort array Features by string is selected X is string
break; }}///end
for(var x=0;x<arrayFeat.length;x++){
if(arrayFeat[x].attributes[fieldSel2]!==''){
if(typeof(arrayFeat[x].attributes[fieldSel2])=="number"||isNaN(arrayFeat[x].attributes[fieldSel2]*1.0)!==true){ // sort array Features by string is selected X is number
arrayFeat.sort(function(a, b) {
// Сортируем по преобразованному полю с датой
return (a.attributes[fieldSel2] - b.attributes[fieldSel2]) ;});
}
break; }}///end
var drawingCanvas0 = document.getElementById('id_canvas1Chart');
drawingCanvas0.style.display="none";}
if(fieldZ!=0)
{
if(document.getElementById("classFunCountCheck3d")&&document.getElementById("classFunCountCheck3d").checked==true)
{arrayFeat=[];
arrayFeatZfunc=[];
var strCalcFunc=document.getElementById("id_ValueFunction3d").value;
function3dG=strCalcFunc;
//var res = strCalcFunc.match(/.+/ig);
var ary=['abs','acos','asin','atan','atan2','exp','min','random','sqrt','log','round','floor','ceil','sin','cos','tan','pow','max'];
for(var nm=0;nm<ary.length;nm++)
{var regC = new RegExp(ary[nm], 'ig');
strCalcFunc=strCalcFunc.replace(regC,'Math.'+ary[nm]);
}
var res= strCalcFunc.match(/\([^(]*?\)\^[0-9]*/ig);
rtt=res;