function divCableLine1($coors, $CableLineId, $nodeInfo, $tmpT = FALSE) { $OpenGIS = "(" . $coors[0]->lon . "," . $coors[0]->lat . ")"; $wr['id'] = $CableLineId; $res = CableLine_SELECT(0, $wr, $tmpT); $CableLine = $res['rows'][0]; unset($wr); $wr['CableLine'] = $CableLineId; $query = 'SELECT * FROM "' . tmpTable('CableLinePoint', $tmpT) . '"' . genWhere($wr) . 'ORDER BY "sequence"'; $res2 = PQuery($query); $CableLinePoints = $res2['rows']; for ($i = 0; $i < count($CableLinePoints); $i++) { $point = $CableLinePoints[$i]; if ($point['OpenGIS'] == $OpenGIS) { $name = $nodeInfo['name']; $NetworkBoxId = $nodeInfo['NetworkBoxId']; $note = $nodeInfo['note']; $SettlementGeoSpatial = "NULL"; $building = $nodeInfo['building']; $apartment = $nodeInfo['apartment']; $res3 = NetworkNode_Add($name, $NetworkBoxId, $note, $OpenGIS, $SettlementGeoSpatial, $building, $apartment, $tmpT); $NetworkNodeId = $res3['rows'][0]['id']; $seq = $point['sequence']; $wr['sequence'] = $seq; $upd['OpenGIS'] = "NULL"; $upd['NetworkNode'] = $NetworkNodeId; CableLinePoint_UPDATE($upd, $wr, $tmpT); $wr1 = array('sequence' => array('val' => $seq, 'sign' => '>')); error_log(genWhere($wr1)); $ins = array(); $ins['CableType'] = $CableLine['CableType']; $ins['name'] = $CableLine['name'] . "_div"; $ins['comment'] = $CableLine['comment']; $query = 'INSERT INTO "' . tmpTable('CableLine', $tmpT) . '"' . genInsert($ins) . ' RETURNING id'; error_log($query); $res4 = PQuery($query); $NCableLineId = $res4['rows'][0]['id']; $ins = array(); foreach ($point as $key => $value) { if ($key != "id" && $key != "sequence") { if ($value != "") { $ins[$key] = $value; } else { $ins[$key] = "NULL"; } } } $ins['CableLine'] = $NCableLineId; $ins['sequence'] = 1; $ins['OpenGIS'] = 'NULL'; $ins['NetworkNode'] = $NetworkNodeId; $query = 'INSERT INTO "' . tmpTable('CableLinePoint', $tmpT) . '"' . genInsert($ins); error_log($query); PQuery($query); $query = 'UPDATE "' . tmpTable('CableLinePoint', $tmpT) . '" SET "CableLine" = ' . $NCableLineId . ', sequence = sequence + 1 - ' . $seq . ' WHERE "sequence" > ' . $seq . ' AND "CableLine" = ' . $CableLineId; error_log($query); PQuery($query); break; } } }
function CableLinePoint_Mod($id, $OpenGIS, $CableLine, $meterSign, $networkNode, $note, $Apartment, $Building, $SettlementGeoSpatial) { if (CableLinePoint_Check($OpenGIS, $CableLine, $meterSign, $networkNode, $note, $Apartment, $Building, $SettlementGeoSpatial) == 0) { return 0; } if ($meterSign == '') { $meterSign = 'NULL'; } if ($OpenGIS == '') { $OpenGIS = 'NULL'; } $upd['OpenGIS'] = $OpenGIS; //$upd['CableLine'] = $CableLine; $upd['meterSign'] = $meterSign; //$upd['NetworkNode'] = $networkNode; $upd['note'] = $note; $upd['Apartment'] = "NULL"; $upd['Building'] = "NULL"; $upd['SettlementGeoSpatial'] = "NULL"; $wr['id'] = $id; $res = CableLinePoint_UPDATE($upd, $wr); if (isset($res['error'])) { return $res; } return 1; }