+ $sCMD = CONST_Osmosis_Binary.' --read-xml \''.$aResult['import-file'].'\' --read-empty --derive-change --write-xml-change '.$sTemporaryFile;
+ echo $sCMD."\n";
+ exec($sCMD, $sJunk, $iErrorLevel);
+ if ($iErrorLevel)
+ {
+ echo "Error converting osm to osc, osmosis returned: $iErrorLevel\n";
+ exit;
+ }
+ }
+ else
+ {
+ $aSpec = array(
+ 0 => array("pipe", "r"), // stdin
+ 1 => array("pipe", "w"), // stdout
+ 2 => array("pipe", "w") // stderr
+ );
+ $sCMD = CONST_Osmosis_Binary.' --read-xml - --read-empty --derive-change --write-xml-change '.$sTemporaryFile;
+ echo $sCMD."\n";
+ $hProc = proc_open($sCMD, $aSpec, $aPipes);
+ if (!is_resource($hProc))
+ {
+ echo "Error converting osm to osc, osmosis failed\n";
+ exit;
+ }
+ fwrite($aPipes[0], $sModifyXMLstr);
+ fclose($aPipes[0]);
+ $sOut = stream_get_contents($aPipes[1]);
+ if ($aResult['verbose']) echo $sOut;
+ fclose($aPipes[1]);
+ $sErrors = stream_get_contents($aPipes[2]);
+ if ($aResult['verbose']) echo $sErrors;
+ fclose($aPipes[2]);
+ if ($iError = proc_close($hProc))
+ {
+ echo "Error converting osm to osc, osmosis returned: $iError\n";
+ echo $sOut;
+ echo $sErrors;
+ exit;
+ }
+ }
+
+ // import generated change file
+ $sCMD = CONST_Osm2pgsql_Binary.' -klas -C 2000 -O gazetteer -d '.$aDSNInfo['database'].' '.$sTemporaryFile;
+ if (!is_null(CONST_Osm2pgsql_Flatnode_File))
+ {
+ $sCMD .= ' --flat-nodes '.CONST_Osm2pgsql_Flatnode_File;