|
|
@@ -1,4 +1,9 @@
|
|
|
<?php
|
|
|
+
|
|
|
+ ini_set('display_errors', 'On');
|
|
|
+error_reporting(E_ALL);
|
|
|
+
|
|
|
+
|
|
|
$_SERVER['SERVER_NAME'] = 'biuro.biall-net.pl';
|
|
|
//when used in /Library/Server/Web/Data/Sites/bzyk-biale-plamy-php-temp/SE/dev on biuro.biall-net.pl
|
|
|
if( file_exists ( "../../se-lib/bootstrap.php"))
|
|
|
@@ -66,7 +71,7 @@ function check() {
|
|
|
|
|
|
init_sh_check();
|
|
|
|
|
|
-$query = "select astext(the_geom) as multiway from Rozdzielcza_test_bzyk_drogi where numpoints(the_geom)>1";
|
|
|
+$query = "select astext(the_geom) as multiway ,ID as ID_Way from Rozdzielcza_test_bzyk_drogi where numpoints(the_geom)>1";
|
|
|
$result = DB::getPDO()->fetchall($query);
|
|
|
$joins_asText = array();
|
|
|
foreach ($result as $row) {
|
|
|
@@ -75,16 +80,18 @@ foreach ($result as $row) {
|
|
|
for ($i = 1; $i < $n = $multiway->numPoints(); $i++) {
|
|
|
$way = new LineString(array($multiway->pointN($i), $multiway->pointN($i+1)));
|
|
|
$ways_asText[] = $way->asText();
|
|
|
+ $ways_2ID_Way[]=$row['ID_Way'];
|
|
|
if (!in_array($multiway->pointN($i)->asText(), $joins_asText)) $joins_asText[] = $multiway->pointN($i)->asText();
|
|
|
}
|
|
|
if (!in_array($multiway->pointN($n)->asText(), $joins_asText)) $joins_asText[] = $multiway->pointN($n)->asText();
|
|
|
}
|
|
|
|
|
|
-$query = "select ID, astext(the_geom) as point, astext(the_geom_nearest_way) as way, astext(the_geom_xpoint) as xpoint from Rozdzielcza_test_bzyk_punkty_adresowe";
|
|
|
+$query = "select ID, astext(the_geom) as point, astext(the_geom_nearest_way) as way, astext(the_geom_xpoint) as xpoint, ID_Way from Rozdzielcza_test_bzyk_punkty_adresowe";
|
|
|
$result = DB::getPDO()->fetchall($query);
|
|
|
$xpoints = array();
|
|
|
foreach ($result as $row) {
|
|
|
$points[$row['ID']] = Vendor_Geophp::load($row['point'], 'wkt');
|
|
|
+ $points2ID_Way[$row['ID']] = $row['ID_Way'] ;
|
|
|
$points_asText[$row['ID']] = $points[$row['ID']]->asText();
|
|
|
$xpoint = Vendor_Geophp::load($row['xpoint'], 'wkt');
|
|
|
if (!($key = array_search($xpoint->asText(), $xpoints))) $key = array_push($xpoints, $xpoint->asText())-1;
|
|
|
@@ -146,26 +153,140 @@ foreach (array_keys($ways_asText) as $way_key) {
|
|
|
$joins2ways[$join_key][] = $way_key;
|
|
|
}
|
|
|
}
|
|
|
+/*
|
|
|
+// $val=array(A=>asd,B=>cos) ---
|
|
|
+// <xml>
|
|
|
+// <A>cos</A>
|
|
|
+ <B>cos></B>
|
|
|
+ </xml>
|
|
|
+ array(0=asd,1=asd)
|
|
|
+ <xml>
|
|
|
+ <item id=0>asd</>
|
|
|
+ <item id=2>asd</>
|
|
|
+
|
|
|
+ array(A=>asd,B=>array(0=>asd,1=>asd))
|
|
|
+ <xml>
|
|
|
+ <A>asd</>
|
|
|
+ <B><item id=0>asd</>
|
|
|
+ <item id=1>asd</>
|
|
|
+
|
|
|
+// $pozA[1]=dupa
|
|
|
+// $pozA[2]=jasiu
|
|
|
+*/
|
|
|
+// function defination to convert array to xml
|
|
|
+function array_to_xml( $data, &$xml_data ) {
|
|
|
+ foreach( $data as $key => $value ) {
|
|
|
+ $key_="";
|
|
|
+
|
|
|
+ if( is_numeric($key) ){
|
|
|
+ $key_ = 'item';
|
|
|
+ }
|
|
|
+
|
|
|
+ if( is_array($value) ) {
|
|
|
+ $subnode = $xml_data->addChild($key_);
|
|
|
+ $subnode->addAttribute('id', $key);
|
|
|
+ array_to_xml($value, $subnode);
|
|
|
+ } else {
|
|
|
+ $subnode=$xml_data->addChild("$key_",htmlspecialchars("$value"));
|
|
|
+ if( is_numeric($key) ){
|
|
|
+ $subnode->addAttribute('id', $key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+file_put_contents('points2ID_Way.txt',serialize($points2ID_Way));
|
|
|
+//for better debug to see variables in editor i make also print_r
|
|
|
+ ob_start();print_r($points2ID_Way); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('points2ID_Way_print_r.txt',$contents);
|
|
|
+
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><points2ID_Way></points2ID_Way>');
|
|
|
+ array_to_xml($points2ID_Way,$xml_data);
|
|
|
+ print $xml_data->asXML("points2ID_Way.xml");
|
|
|
+ unset($xml_data);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+file_put_contents('ways_2ID_Way.txt',serialize($ways_2ID_Way));
|
|
|
+//for better debug to see variables in editor i make also print_r
|
|
|
+ ob_start();print_r($ways_2ID_Way); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('ways_2ID_Way_print_r.txt',$contents);
|
|
|
+
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><ways_2ID_Way></ways_2ID_Way>');
|
|
|
+ array_to_xml($ways_2ID_Way,$xml_data);
|
|
|
+ print $xml_data->asXML("ways_2ID_Way.xml");
|
|
|
+ unset($xml_data);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
file_put_contents('ways2joins.txt',serialize($ways2joins));
|
|
|
//for better debug to see variables in editor i make also print_r
|
|
|
-file_put_contents('ways2joins_print_r.txt',print_r($ways2joins));
|
|
|
+ ob_start();print_r($ways2joins); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('ways2joins_print_r.txt',$contents);
|
|
|
+
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><ways2joins></ways2joins>');
|
|
|
+ array_to_xml($ways2joins,$xml_data);
|
|
|
+ print $xml_data->asXML("ways2joins.xml");
|
|
|
+ unset($xml_data);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
file_put_contents('joins2ways.txt',serialize($joins2ways));
|
|
|
-file_put_contents('joins2ways_print_r.txt',print_r($joins2ways));
|
|
|
+ ob_start();print_r($joins2ways); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('joins2ways_print_r.txt',$contents);
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><joins2ways></joins2ways>');
|
|
|
+ array_to_xml($joins2ways,$xml_data);
|
|
|
+ print $xml_data->asXML("joins2ways.xml");
|
|
|
+ unset($xml_data);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
file_put_contents('points2joins.txt',serialize($points2joins));
|
|
|
-file_put_contents('points2joins_print_r.txt',print_r($points2joins));
|
|
|
+ ob_start();print_r($points2joins); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('points2joins_print_r.txt',$contents);
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><points2joins></points2joins>');
|
|
|
+ array_to_xml($points2joins,$xml_data);
|
|
|
+ print $xml_data->asXML("points2joins.xml");
|
|
|
+ unset($xml_data);
|
|
|
|
|
|
file_put_contents('joins_asText.txt',serialize($joins_asText));
|
|
|
-file_put_contents('joins_asText_print_r.txt',print_r($joins_asText));
|
|
|
+ ob_start();print_r($joins_asText); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('joins_asText_print_r.txt',$contents);
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><joins_asText></joins_asText>');
|
|
|
+ array_to_xml($joins_asText,$xml_data);
|
|
|
+ print $xml_data->asXML("joins_asText.xml");
|
|
|
+ unset($xml_data);
|
|
|
+
|
|
|
|
|
|
file_put_contents('ways_asText.txt',serialize($ways_asText));
|
|
|
-file_put_contents('ways_asText_print_r.txt',print_r($ways_asText));
|
|
|
+ ob_start();print_r($ways_asText); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('ways_asText_print_r.txt',$contents);
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><ways_asText></ways_asText>');
|
|
|
+ array_to_xml($ways_asText,$xml_data);
|
|
|
+ print $xml_data->asXML("ways_asText.xml");
|
|
|
+ unset($xml_data);
|
|
|
|
|
|
|
|
|
file_put_contents('points_asText.txt',serialize($points_asText));
|
|
|
-file_put_contents('points_asText_print_r.txt',print_r($points_asText));
|
|
|
+ ob_start();print_r($points_asText); $contents = ob_get_contents();ob_end_clean();
|
|
|
+ file_put_contents('points_asText_print_r.txt',$contents);
|
|
|
+ $xml_data = new SimpleXMLElement('<?xml version="1.0"?><points_asText></points_asText>');
|
|
|
+ array_to_xml($points_asText,$xml_data);
|
|
|
+ print $xml_data->asXML("points_asText.xml");
|
|
|
+ unset($xml_data);
|
|
|
|
|
|
|
|
|
|