this script could be run from bash e.g. php biale_plamy.php --help
" ;
check();
}
}
function check() {
echo "
\n i run check()";
//todo to set arguments to rebuild tables etc:
$check_tbls=array('Rozdzielcza_test_bzyk_drogi','Rozdzielcza_test_bzyk_joins','Rozdzielcza_test_bzyk_przylacza_HIST',
'Rozdzielcza_test_bzyk_przylacza','Rozdzielcza_test_bzyk_punkty_adresowe','Rozdzielcza_test_bzyk_ways');
//$tables = DB::getPDO()->list_tables();
foreach($check_tbls as $tbl) {
$query = "select ID from ".$tbl." limit 1 ";
echo "
\nresult chk for tbl:".$tbl." ;";
try{
$result = DB::getPDO()->fetchall($query);
} catch(Exception $exception) {
// return $exception;
echo "
\n jest blad z tbl:".$tbl." i get sample table structure with data from ../sql/".$tbl.".sql - it should be manually replaced by correct/newer!";
$sql = file_get_contents('../sql/'.$tbl.'.sql');
try{
$result = DB::getPDO()->fetchall($sql);
} catch(Exception $exception2) {
echo "
\n jest blad dump dla tbl:".$tbl;
}
}
// print_r($exception);
print_r($result);
}
}
init_sh_check();
$edge_paths_with_PE=simplexml_load_file("edge_paths_with_PE.xml");
$edge_paths_with_PE->registerXPathNamespace('bp', 'https://procesy5.pl/biale_plamy-schema.xsd');
/*
*/
//print_r($edge_joins);
$edge_paths_with_PE_arr=array();
foreach($edge_paths_with_PE->children() as $child) {
// echo "\n
";
//$attrs=$child->attributes("ID_Way");
foreach($child->attributes() as $a=>$b) {
// echo "#87Child";print_r($b[0]);
if($a=='ID_Way') $ID_Way=$b[0];
//if($a=='Count') $Count=$b[0];
}
//echo $child->getName() . ": " . " ID_Way: ".$ID_Way. " : ";
settype($ID_Way, "integer");
//$ID_Way=var_dump($ID_Way);
// echo "#88Child:"; print_r($ID_Way);
//$edge_joins_path['ID_Way'][$attrs['ID_Way']]=array();
// $result = $xml->xpath('/a/b/c');
$id_j=0;
foreach($child->xpath('bp:Path_Point') as $Path_Point_xml) {
$id_j++;
$Path_Point=$Path_Point_xml->attributes();
//echo " #93 ID_Join ".$attrs_join["Joins"]." ";
$Path_Point['Pos']=$Path_Point['Pos'][0]; settype($Path_Point['Pos'], "integer");
$Path_Point['X']=$Path_Point['X'][0]; settype($Path_Point['X'], "string");
$Path_Point['Y']=$Path_Point['Y'][0]; settype($Path_Point['Y'], "string");
$Path_Point['ID_Join']=$Path_Point['ID_Join'][0]; settype($Path_Point['ID_Join'], "integer");
$edge_paths_with_PE_arr[$ID_Way][$id_j]=$Path_Point;
}
}
echo "\n
edge_paths_with_PE_arr";
print_r($edge_paths_with_PE_arr);
DB::getPDO()->query("truncate table Rozdzielcza_test_bzyk_PE");
unset($ID_Way);
$edge_joins_filled_paths=array();
foreach($edge_paths_with_PE_arr as $ID_Way=>$Path_Point) {
foreach($Path_Point as $Path_Point_val) {
$sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_PE (the_geom,ID_Way,ID_Join)
values (ST_GeomFromText('POINT(".$Path_Point_val['X']." ".$Path_Point_val['Y'].")'),'".$ID_Way."' ,
'".$Path_Point_val['ID_Join']."' ) ";
echo "#216Query path ins:: ".$sql_Path_Point_val." ";
//if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
if( strlen($Path_Point_val['X'])>1 and strlen($Path_Point_val['Y'])>1 ) DB::getPDO()->query($sql_Path_Point_val);
//else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
}
}