Ejemplo n.º 1
0
function getCableLinesFrag($cableLines, $tmpT = FALSE)
{
    $resFrags = array();
    for ($i = 0; $i < count($cableLines); $i++) {
        $cableLine = $cableLines[$i]['id'];
        $cableLinePoints = getCableLinePoints($cableLine, FALSE, $tmpT);
        $rows = $cableLinePoints['rows'];
        $b = 0;
        $n = 0;
        for ($j = 0; $j < count($rows); $j++) {
            $rows[$j]['sequence'] = $j + 1;
        }
        for ($j = 0; $j < count($rows); $j++) {
            $OpenGIS = $rows[$j]['OpenGIS'];
            $NNOpenGis = $rows[$j]['NNOpenGIS'];
            $rows[$j]['sequence'] = $j + 1;
            if (!preg_match_all('/(?<lon>[0-9.]+),(?<lat>[0-9.]+)/', $OpenGIS, $matches)) {
                if (!preg_match_all('/(?<lon>[0-9.]+),(?<lat>[0-9.]+)/', $NNOpenGis, $matches)) {
                    error_log("Line {$cableLine}, point " . $rows[$j]['id'] . ": no coordinates!!!");
                    continue;
                }
            }
            if ($rows[$j]['note'] != '' || $rows[$j]['meterSign'] != '') {
                $resFrags[$cableLine][$b][$n] = retCable($matches, $rows[$j], $rows[count($rows) - 1]['sequence']);
                //$n++;
                $b++;
                $n = 0;
                $OpenGIS = $rows[$j]['OpenGIS'];
                $NNOpenGis = $rows[$j]['NNOpenGIS'];
                if (!preg_match_all('/(?<lon>[0-9.]+),(?<lat>[0-9.]+)/', $OpenGIS, $matches)) {
                    preg_match_all('/(?<lon>[0-9.]+),(?<lat>[0-9.]+)/', $NNOpenGis, $matches);
                }
                $resFrags[$cableLine][$b][$n] = retCable($matches, $rows[$j], $rows[count($rows) - 1]['sequence']);
                $n++;
            } else {
                $resFrags[$cableLine][$b][$n] = retCable($matches, $rows[$j], $rows[count($rows) - 1]['sequence']);
                $n++;
            }
        }
    }
    return $resFrags;
}
Ejemplo n.º 2
0
function fillCableLengthBySign($res)
{
    for ($j = 0; $j < $res['count']; $j++) {
        $res2 = getCableLinePoints($res['rows'][$j]['CableLine']);
        if ($res2['count'] > 1) {
            $start = $res2['rows'][0]['meterSign'];
            $end = end($res2['rows'])['meterSign'];
            if (is_numeric($start) && is_numeric($end)) {
                $res['rows'][$j]['length2'] = abs((int) $end - (int) $start);
                if (!$res['rows'][$j]['length']) {
                    $res['rows'][$j]['length'] = $res['rows'][$j]['length2'];
                }
            } else {
                $res['rows'][$j]['length2'] = NULL;
            }
        } else {
            $res['rows'][$j]['length2'] = NULL;
        }
    }
    return $res;
}
Ejemplo n.º 3
0
} elseif ($_GET['mode'] == "GetNetworkBoxTypes") {
    require_once "backend/NetworkBoxType.php";
    $res = NetworkBoxType_SELECT('', '');
    $rows = $res['rows'];
    $boxTypesJSON['BoxTypes'] = array();
    $i = -1;
    while (++$i < $res['count']) {
        $boxTypesJSON['BoxTypes'][$i]['id'] = (int) $rows[$i]['id'];
        $boxTypesJSON['BoxTypes'][$i]['marking'] = $rows[$i]['marking'];
    }
    $resJ = json_encode($boxTypesJSON);
    print $resJ;
} elseif ($_GET['mode'] == "GetFreeLinePoints") {
    require_once 'backend/CableType.php';
    $CableLineId = $_GET['id'];
    $res = getCableLinePoints($CableLineId, TRUE, TRUE);
    $rows = $res['rows'];
    $pointsJSON['Points'] = array();
    $i = -1;
    while (++$i < $res['count']) {
        $OpenGIS = $rows[$i]['OpenGIS'];
        if (preg_match_all('/(?<x>[0-9.]+),(?<y>[0-9.]+)/', $OpenGIS, $matches)) {
            $lat = $matches['y'][0];
            $lon = $matches['x'][0];
        }
        $pointsJSON['Points'][$i]['lat'] = $lat;
        $pointsJSON['Points'][$i]['lon'] = $lon;
    }
    $res = json_encode($pointsJSON);
    print $res;
}