-
Notifications
You must be signed in to change notification settings - Fork 2
/
getLayers.php
301 lines (265 loc) · 12.9 KB
/
getLayers.php
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
<?php
require_once('backend/functions.php');
require_once('backend/CableType.php');
require_once('backend/NetworkNode.php');
require_once('backend/FS.php');
ini_set('display_errors', false);
if ( $_GET[ 'mode' ] == 'GetCableLines' )
{ // кабельные линии
$res = getCableLineList( 0, '', -1, -1 );
/* if ( $res[ 'count' ] == 0 )
{
die();
} */
$rows = $res[ 'rows' ];
$dom = new DomDocument( '1.0', 'UTF-8' );
$cableLines = $dom->appendChild( $dom->createElement( 'cableLines' ) );
$cableLinesFrag = getCableLinesFrag( $rows, FALSE );
//print_r($cableLinesFrag);
$cableInfo = array();
for ( $i = 0; $i < $res[ 'count' ]; $i++ )
{
$cableInfo[ $rows[ $i ][ 'id' ] ] = $rows[ $i ];
}
foreach ( $cableLinesFrag as $key => $value )
{
//print_r($value);
//print_r($key);
$cableLineId = $key;
for ( $i = 0; $i < count( $value ); $i++ )
{
$cableLine = $cableLines->appendChild( $dom->createElement( 'cableLine' ) );
for ( $j = 0; $j < count( $value[ $i ] ); $j++ )
{
$node = $cableLine->appendChild( $dom->createElement( 'node' ) );
$node_attr = $dom->createAttribute( 'lat' );
$node_attr->value = $value[ $i ][ $j ][ 'lat' ];
$node->appendChild( $node_attr );
$node_attr = $dom->createAttribute( 'lon' );
$node_attr->value = $value[ $i ][ $j ][ 'lon' ];
$node->appendChild( $node_attr );
$node_attr = $dom->createAttribute( 'id' );
$node_attr->value = $value[ $i ][ $j ][ 'id' ];
$node->appendChild( $node_attr );
}
$direction_row = getCableLineDirection( $cableLineId, -1, -1 );
$direction_href = '';
if ( isset($direction_row[ 0 ]) && $direction_row[ 0 ][ 'name' ] != '-' )
{
$direction_href .= '<a href="NetworkNodes.php?mode=charac&nodeid='.$direction_row[ 0 ][ 'NetworkNode' ].'">'.$direction_row[ 0 ][ 'name' ].'</a>';
}
$direction_href .= '-';
if ( isset($direction_row[ 1 ]) && $direction_row[ 1 ][ 'name' ] != '-' )
{
$direction_href .= '<a href="NetworkNodes.php?mode=charac&nodeid='.$direction_row[ 1 ][ 'NetworkNode' ].'">'.$direction_row[ 1 ][ 'name' ].'</a>';
}
$cableId = $cableLine->appendChild( $dom->createElement( 'cableLineId' ) );
$cableId = $cableId->appendChild( $dom->createTextNode( $cableLineId ) );
$name = $cableLine->appendChild( $dom->createElement( 'name' ) );
$name = $name->appendChild( $dom->createTextNode( $cableInfo[ $cableLineId ][ 'name' ] ) );
$cableTypeId = $cableLine->appendChild( $dom->createElement( 'cableTypeId' ) );
if ( isset( $cableInfo[ $cableLineId ][ 'CableType' ] ) )
{
$cableTypeId = $cableTypeId->appendChild( $dom->createTextNode( $cableInfo[ $cableLineId ][ 'CableType' ] ) );
}
else
{
$cableTypeId = $cableTypeId->appendChild( $dom->createTextNode( 'NULL' ) );
}
$cableTypeId = $cableLine->appendChild( $dom->createElement( 'cableTypeMarking' ) );
if ( isset( $cableInfo[ $cableLineId ][ 'marking' ] ) )
{
$cableTypeId = $cableTypeId->appendChild( $dom->createTextNode( $cableInfo[ $cableLineId ][ 'marking' ] ) );
}
else
{
$cableTypeId = $cableTypeId->appendChild( $dom->createTextNode( 'NULL' ) );
}
$direction = $cableLine->appendChild( $dom->createElement( 'direction' ) );
$direction = $direction->appendChild( $dom->createTextNode( $direction_href ) );
$modules = $cableLine->appendChild( $dom->createElement( 'modules' ) );
if ( $cableInfo[ $cableLineId ][ 'fiberPerTube' ] != 0 )
{
$modules = $modules->appendChild( $dom->createTextNode( (int)( ($cableInfo[ $cableLineId ][ 'fibers' ] - 1) / $cableInfo[ $cableLineId ][ 'fiberPerTube' ] + 1 ) ) );
}
else
{
$modules = $modules->appendChild( $dom->createTextNode( 'NULL' ) );
}
$fibers = $cableLine->appendChild( $dom->createElement( 'fibers' ) );
if ( isset( $cableInfo[ $cableLineId ][ 'fibers' ] ) )
{
$fibers = $fibers->appendChild( $dom->createTextNode( $cableInfo[ $cableLineId ][ 'fibers' ] ) );
}
else
{
$fibers = $fibers->appendChild( $dom->createTextNode( 'NULL' ) );
}
$free_fibers = $cableLine->appendChild( $dom->createElement( 'free_fibers' ) );
$free_fibers = $free_fibers->appendChild( $dom->createTextNode( (int)($cableInfo[ $cableLineId ][ 'fibers' ] - $cableInfo[ $cableLineId ][ 'FiberSpliceCount' ]) ) );
$sequenceStart = $cableLine->appendChild( $dom->createElement( 'sequenceStart' ) );
$sequenceStart = $sequenceStart->appendChild( $dom->createTextNode( $value[ $i ][ 0 ][ 'sequence' ] ) );
$sequenceEnd = $cableLine->appendChild( $dom->createElement( 'sequenceEnd' ) );
$sequenceEnd = $sequenceEnd->appendChild( $dom->createTextNode( $value[ $i ][ count( $value[ $i ] ) - 1 ][ 'sequence' ] ) );
$superSequenceEnd = $cableLine->appendChild( $dom->createElement( 'superSequenceEnd' ) );
$superSequenceEnd = $superSequenceEnd->appendChild( $dom->createTextNode( $value[ $i ][ 0 ][ 'superSequenceEnd' ] ) );
}
}
$dom->formatOutput = true;
$res = $dom->saveXML();
header( "content-type: text/xml" );
print( $res );
}
elseif ( $_GET[ 'mode' ] == 'GetNodesMarkers' )
{
//header('Content-Type: text/html; charset=utf-8', true);
$res = getNetworkNodeList_NetworkBoxName( '', '', '' );
$rows = $res[ 'rows' ];
$pois_text = "lat\tlon\ttitle\tdescription\ticon\ticonSize\ticonOffset\n";
for ( $i = 0; $i < $res[ 'count' ]; $i++ )
{
$OpenGIS = $rows[ $i ][ 'OpenGIS' ];
if ( preg_match_all( '/(?<x>[0-9.]+),(?<y>[0-9.]+)/', $OpenGIS, $matches ) )
{
$fiberSpliceCount = $rows[ $i ][ 'fiberSpliceCount' ];
$cableLines_row = getCableLineInfo( $rows[ $i ][ 'id' ], 1 );
$cableLinesZeroFibers = 0;
$cableLinesNotZeroFibers = 0;
for ( $j = 0; $j < $cableLines_row[ 'count' ]; $j++ )
{
if ( $cableLines_row[ 'rows' ][ $j ][ 'fiber' ] > 0 )
{
$cableLinesNotZeroFibers++;
}
else
{
$cableLinesZeroFibers++;
}
}
$lat = $matches[ 'y' ][ 0 ];
$lon = $matches[ 'x' ][ 0 ];
$title = '<a target="_blank" href="NetworkNodes.php?mode=charac&nodeid='.$rows[ $i ][ 'id' ].'">'.$rows[ $i ][ 'name' ].'</a>';
$description = $i;
$icon = "pic/node_pic.png";
$iconSize = "10,10";
$iconOffset = "-5,-5";
$pois_text .= $lat."\t".$lon."\t".$title."\t".$description."\t".$icon."\t".$iconSize."\t".$iconOffset."\n";
}
}
print($pois_text );
}
elseif ( $_GET[ 'mode' ] == 'GetNodesLabels' )
{
$res = getNetworkNodeList_NetworkBoxName( '', '', '' );
/* if ( $res[ 'count' ] == 0 )
{
die();
} */
$rows = $res[ 'rows' ];
$dom = new DomDocument( '1.0', 'UTF-8' );
$nodesLabels = $dom->appendChild( $dom->createElement( 'nodesLabels' ) );
for ( $i = 0; $i < $res[ 'count' ]; $i++ )
{
$nodeLabel = $nodesLabels->appendChild( $dom->createElement( 'nodeLabel' ) );
$OpenGIS = $rows[ $i ][ 'OpenGIS' ];
if ( preg_match_all( '/(?<x>[0-9.]+),(?<y>[0-9.]+)/', $OpenGIS, $matches ) )
{
$lat = $matches[ 'y' ][ 0 ];
$lon = $matches[ 'x' ][ 0 ];
$node = $nodeLabel->appendChild( $dom->createElement( 'node' ) );
$node_attr = $dom->createAttribute( 'lat' );
$node_attr->value = $matches[ 'y' ][ 0 ];
$node->appendChild( $node_attr );
$node_attr = $dom->createAttribute( 'lon' );
$node_attr->value = $matches[ 'x' ][ 0 ];
$node->appendChild( $node_attr );
$title = $nodeLabel->appendChild( $dom->createElement( 'title' ) );
$title = $title->appendChild( $dom->createTextNode( $rows[ $i ][ 'name' ] ) );
$ident = $nodeLabel->appendChild( $dom->createElement( 'ident' ) );
$ident = $ident->appendChild( $dom->createTextNode( $i ) );
}
}
$dom->formatOutput = true;
$res = $dom->saveXML();
header( "content-type: text/xml" );
print($res );
}
elseif ( $_GET[ 'mode' ] == 'GetSingularCableLinePoints' )
{
$res = getSingularCableLinePoints( 1 );
$rows = $res[ 'rows' ];
$pois_text = "lat\tlon\ttitle\tdescription\ticon\ticonSize\ticonOffset\n";
for ( $i = 0; $i < $res[ 'count' ]; $i++ )
{
$OpenGIS = $rows[ $i ][ 'OpenGIS' ];
if ( preg_match_all( '/(?<x>[0-9.]+),(?<y>[0-9.]+)/', $OpenGIS, $matches ) )
{
$lat = $matches[ 'y' ][ 0 ];
$lon = $matches[ 'x' ][ 0 ];
$clpId = $rows[ $i ][ 'CLPId' ];
$title = '<a target="_blank" href="CableLine.php?mode=charac&cablelineid='.$rows[ $i ][ 'CableLine' ].'">'.$rows[ $i ][ 'CableLineName' ].'</a>';
$description = '<a target="_blank" href="CableLinePoint.php?mode=change&cablelineid='.$rows[ $i ][ 'CableLine' ].'&cablelinepointid='.$clpId.'">Отметка: '.$rows[ $i ][ 'meterSign' ].'<br/>Комментарий: '.$rows[ $i ][ 'note' ].'</a>';
$icon = "pic/rhomb_pic.png";
$iconSize = "8,8";
$iconOffset = "-4,-4";
$pois_text .= $lat."\t".$lon."\t".$title."\t".$description."\t".$icon."\t".$iconSize."\t".$iconOffset."\n";
}
}
print($pois_text );
}
elseif ( $_GET[ 'mode' ] == 'GetNetworkNodesDescription' )
{
require_once 'func/FiberSplice.php';
$res = getNetworkNodeList_NetworkBoxName( '', '', '' );
$rows = $res[ 'rows' ];
$dom = new DomDocument( '1.0', 'UTF-8' );
$nodesDescriptions = $dom->appendChild( $dom->createElement( 'nodesDescriptions' ) );
for ( $i = 0; $i < $res[ 'count' ]; $i++ )
{
$nodeDescription = $nodesDescriptions->appendChild( $dom->createElement( 'nodeDescription' ) );
$OpenGIS = $rows[ $i ][ 'OpenGIS' ];
if ( preg_match_all( '/(?<x>[0-9.]+),(?<y>[0-9.]+)/', $OpenGIS, $matches ) )
{
//$fiberSpliceCount = getFiberSpliceCount_NetworkNode($rows[$i]['id']);
$fiberSpliceCount = $rows[ $i ][ 'fiberSpliceCount' ];
$cableLines_row = getCableLineInfo( $rows[ $i ][ 'id' ] );
$cableLinesZeroFibers = 0;
$cableLinesNotZeroFibers = 0;
for ( $j = 0; $j < $cableLines_row[ 'count' ]; $j++ )
{
if ( $cableLines_row[ 'rows' ][ $j ][ 'fiber' ] > 0 )
{
$cableLinesNotZeroFibers++;
}
else
{
$cableLinesZeroFibers++;
}
}
$desc = 'Ящик: <a target="_blank" href="NetworkBox.php?mode=charac&boxid='.$rows[ $i ][ 'NetworkBox' ].'">'.$rows[ $i ][ 'inventoryNumber' ].'</a><br>'.
'Тип ящика: <a target="_blank" href="NetworkBoxType.php?mode=charac&boxtypeid='.$rows[ $i ][ 'NetworkBoxType' ].'">'.$rows[ $i ][ 'NBTmarking' ].'</a><br>'.
'Расположение: '.$rows[ $i ][ 'place' ].'<br>'.
'Примечание: '.str_replace(array("\r\n", "\n", "\r"), "<br>", $rows[ $i ][ 'note' ] ).'<br>'.
'Входящие линии: <ul>'.
'<li>Всего: '.(string)($cableLinesZeroFibers + $cableLinesNotZeroFibers).'</li>'.
'<li>0 волокон: '.$cableLinesZeroFibers.'</li>'.
'<li>1+ волокон: '.$cableLinesNotZeroFibers.'</li>'.
'</ul>'.
'К-во сварок: '.$fiberSpliceCount;
$fibRes = getFiberTable( $rows[ $i ][ 'id' ] );
if ( $fibRes[ 'maxfiber' ] > 0 )
{
$desc .= '<br>[<a target="_blank" href="FiberSplice.php?networknodeid='.$rows[ $i ][ 'id' ].'">Таблица сварок</a>]';
}
$index = $nodeDescription->appendChild( $dom->createElement( 'index' ) );
$index = $index->appendChild( $dom->createTextNode( $i ) );
$description = $nodeDescription->appendChild( $dom->createElement( 'description' ) );
$description = $description->appendChild( $dom->createTextNode( $desc ) );
}
}
$dom->formatOutput = true;
$res = $dom->saveXML();
header( "content-type: text/xml" );
print($res );
}
?>