biale_put_Cables_to_PE.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. $_SERVER['SERVER_NAME'] = 'biuro.biall-net.pl';
  3. //when used in /Library/Server/Web/Data/Sites/bzyk-biale-plamy-php-temp/SE/dev on biuro.biall-net.pl
  4. if( file_exists ( "../../se-lib/bootstrap.php"))
  5. require("../../se-lib/bootstrap.php");
  6. //when used in in native SE
  7. else require("../../../../SE-production-git/SE/se-lib/bootstrap.php");
  8. Lib::loadClass("Vendor_Geophp");
  9. $cables_from_joins_to_PE=simplexml_load_file('cables_from_joins_to_PE.xml');
  10. $cables_from_joins_to_PE->registerXPathNamespace('bp', 'https://procesy5.pl/biale_plamy-schema.xsd');
  11. /*
  12. <?xml version="1.0" encoding="UTF-8"?>
  13. <cables_from_joins_to_PE xmlns:bp="https://procesy5.pl/biale_plamy-schema.xsd">
  14. <cable_to_PE_to_be_calculated ID_Way="3"
  15. Joins="4"
  16. Join_X="18.7896425"
  17. Join_Y="51.698063399083">
  18. <not_found Pos="1"
  19. X="18.636657356658"
  20. Y="51.253416226324"
  21. srch_X="18.7896425"
  22. srch_Y="51.698063399083"
  23. diff_X="0.15298514334200064"
  24. diff_Y="0.444647172758998"/>
  25. <found_in_path_in_edge_joins_filled_path diff_X="-0.00006424369499669069"
  26. diff_Y="0.0013892901829990478"
  27. position="5">
  28. <bp:Path_Point Pos="5" X="18.960657743695" Y="51.612137008899"/>
  29. <detect_next_PE Pos_found="5"
  30. Next_PE_Pos="20"
  31. Prev_PE_Pos=""
  32. Going_to_next="20">
  33. <bp:Path_Point Pos="5" X="18.960657743695" Y="51.612137008899"/>
  34. <bp:Path_Point Pos="6" X="18.960110541501" Y="51.612105643896"/>
  35. <bp:Path_Point Pos="7" X="18.959774447246" Y="51.612086379359"/>
  36. <bp:Path_Point Pos="8" X="18.959754322927" Y="51.612085225856"/>
  37. <bp:Path_Point Pos="9" X="18.959645426785" Y="51.612078984054"/>
  38. <bp:Path_Point Pos="10" X="18.959455431877" Y="51.612068093763"/>
  39. <bp:Path_Point Pos="11" X="18.959126615445" Y="51.612049246382"/>
  40. <bp:Path_Point Pos="12" X="18.958655233785" Y="51.612022227326"/>
  41. <bp:Path_Point Pos="13" X="18.958386790309" Y="51.612006840454"/>
  42. <bp:Path_Point Pos="14" X="18.957723493448" Y="51.611968821038"/>
  43. <bp:Path_Point Pos="15" X="18.957421446031" Y="51.611951508026"/>
  44. <bp:Path_Point Pos="16" X="18.9573044" Y="51.611944799082"/>
  45. <bp:Path_Point Pos="17" X="18.956794400864" Y="51.611932376808"/>
  46. <bp:Path_Point Pos="18" X="18.9566352" Y="51.611928499082"/>
  47. <bp:Path_Point Pos="19" X="18.955813488168" Y="51.611951817689"/>
  48. <bp:Path_Point Pos="20" X="18.955739759724" Y="51.611953909961"/>
  49. <LINESTRING>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)</LINESTRING>
  50. </detect_next_PE>
  51. */
  52. //print_r($edge_joins);
  53. $cables_from_joins_to_PE_arr=array();
  54. $id_j=0;
  55. foreach($cables_from_joins_to_PE->xpath('cable_to_PE_to_be_calculated') as $child) { //cable_to_PE_to_be_calculated
  56. // echo "\n<br>";
  57. //$attrs=$child->attributes("ID_Way");
  58. foreach($child->attributes() as $a=>$b) {
  59. // echo "#87Child";print_r($b[0]);
  60. if($a=='ID_Way') $ID_Way=$b[0];
  61. if($a=='Joins') $Joins=$b[0];
  62. if($a=='ID_Point') $ID_Point=$b[0];
  63. //if($a=='Count') $Count=$b[0];
  64. }
  65. //echo $child->getName() . ": " . " ID_Way: ".$ID_Way. " : ";
  66. settype($ID_Way, "integer");
  67. settype($Joins, "integer");
  68. settype($ID_Point, "integer");
  69. foreach($child->xpath('found_in_path_in_edge_joins_filled_path') as $Path_Point_xml) {
  70. // detect_next_PE/LINESTRING
  71. $id_j++;
  72. $LINESTRING=$Path_Point_xml->xpath('detect_next_PE/LINESTRING/text()');
  73. $LINESTRING=$LINESTRING[0];
  74. settype($LINESTRING, "string");
  75. $cables_from_joins_to_PE_arr[$id_j]['LINESTRING']=$LINESTRING;
  76. $cables_from_joins_to_PE_arr[$id_j]['Joins']=$Joins;
  77. $cables_from_joins_to_PE_arr[$id_j]['ID_Way']=$ID_Way;
  78. $cables_from_joins_to_PE_arr[$id_j]['ID_Point']=$ID_Point;
  79. foreach($Path_Point_xml->xpath('detect_next_PE') as $detect_next_PE ) {
  80. foreach($detect_next_PE->attributes() as $a=>$b) {
  81. if($a=='len') $len=$b[0];
  82. if($a=='PE_ID_Join') $PE_ID_Join=$b[0];
  83. }
  84. settype($len, "integer");
  85. settype($PE_ID_Join, "integer");
  86. $cables_from_joins_to_PE_arr[$id_j]['len']=$len;
  87. $cables_from_joins_to_PE_arr[$id_j]['PE_ID_Join']=$PE_ID_Join;
  88. }
  89. }
  90. }
  91. echo "\n<br>#150 cables_from_joins_to_PE_arr";
  92. print_r($cables_from_joins_to_PE_arr);
  93. DB::getPDO()->query("truncate table Rozdzielcza_test_bzyk_Cables_to_PE");
  94. unset($ID_Way);
  95. foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) {
  96. $sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way,ID_Point,len,PE_ID_Join)
  97. values (ST_GeomFromText('".$Path_Point_val['LINESTRING']."'),'".$Path_Point_val['ID_Way']."',
  98. '".$Path_Point_val['ID_Point']."' ,'".$Path_Point_val['len']."','".$Path_Point_val['PE_ID_Join']."' ) ";
  99. echo "#216Query path ins:: ".$sql_Path_Point_val." ";
  100. //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2)
  101. if(strlen($Path_Point_val['LINESTRING'])>1)
  102. DB::getPDO()->query($sql_Path_Point_val);
  103. else echo " ERROR blad danych!!! dla ID_Point:".$Path_Point_val['ID_Point'];
  104. //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n";
  105. }