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(); $cables_from_joins_to_PE=simplexml_load_file("cables_from_joins_to_PE.xml"); $cables_from_joins_to_PE->registerXPathNamespace('bp', 'https://procesy5.pl/biale_plamy-schema.xsd'); /* LINESTRING (18.960657743695 51.612137008899, 18.960110541501 51.612105643896, 18.959774447246 51.612086379359, 18.959754322927 51.612085225856, 18.959645426785 51.612078984054, 18.959455431877 51.612068093763, 18.959126615445 51.612049246382, 18.958655233785 51.612022227326, 18.958386790309 51.612006840454, 18.957723493448 51.611968821038, 18.957421446031 51.611951508026, 18.9573044 51.611944799082, 18.956794400864 51.611932376808, 18.9566352 51.611928499082, 18.955813488168 51.611951817689, 18.955739759724 51.611953909961) */ //print_r($edge_joins); $cables_from_joins_to_PE_arr=array(); $id_j=0; foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $child) { //cable_to_PE_to_be_calculated // 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=='Joins') $Joins=$b[0]; if($a=='ID_Point') $ID_Point=$b[0]; //if($a=='Count') $Count=$b[0]; } //echo $child->getName() . ": " . " ID_Way: ".$ID_Way. " : "; settype($ID_Way, "integer"); settype($Joins, "integer"); settype($ID_Point, "integer"); foreach($child->xpath('found_in_path_in_edge_joins_filled_path') as $Path_Point_xml) { // detect_next_PE/LINESTRING $id_j++; $LINESTRING=$Path_Point_xml->xpath('detect_next_PE/LINESTRING/text()'); $LINESTRING=$LINESTRING[0]; settype($LINESTRING, "string"); $cables_from_joins_to_PE_arr[$id_j]['LINESTRING']=$LINESTRING; $cables_from_joins_to_PE_arr[$id_j]['Joins']=$Joins; $cables_from_joins_to_PE_arr[$id_j]['ID_Way']=$ID_Way; $cables_from_joins_to_PE_arr[$id_j]['ID_Point']=$ID_Point; } } echo "\n
#150 cables_from_joins_to_PE_arr"; print_r($cables_from_joins_to_PE_arr); DB::getPDO()->query("truncate table Rozdzielcza_test_bzyk_Cables_to_PE"); unset($ID_Way); foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) { $sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way,ID_Point) values (ST_GeomFromText('".$Path_Point_val['LINESTRING']."'),'".$Path_Point_val['ID_Way']."', '".$Path_Point_val['ID_Point']."' ) "; echo "#216Query path ins:: ".$sql_Path_Point_val." "; //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2) if(strlen($Path_Point_val['LINESTRING'])>1) DB::getPDO()->query($sql_Path_Point_val); else echo " ERROR blad danych!!! dla ID_Point:".$Path_Point_val['ID_Point']; //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n"; }