- // Hack into a modify request
- $sModifyXML = str_replace('<osm version="0.6" generator="OpenStreetMap server">',
- '<osmChange version="0.6" generator="OpenStreetMap server"><modify>', $sModifyXML);
- $sModifyXML = str_replace('<osm version=\'0.6\' upload=\'true\' generator=\'JOSM\'>',
- '<osmChange version="0.6" generator="OpenStreetMap server"><modify>', $sModifyXML);
- $sModifyXML = str_replace('</osm>', '</modify></osmChange>', $sModifyXML);
-
- // Outputing this is too verbose
- if ($aResult['verbose'] && false) var_dump($sModifyXML);
-
- $sDatabaseName = 'nominatim';
- $aSpec = array(
- 0 => array("pipe", "r"), // stdin
- 1 => array("pipe", "w"), // stdout
- 2 => array("pipe", "w") // stderr
- );
- $aPipes = array();
- $sCMD = CONST_Osm2pgsql_Binary.' -klas -C 2000 -O gazetteer -d '.$sDatabaseName.' -';
- echo $sCMD."\n";
- $hProc = proc_open($sCMD, $aSpec, $aPipes);
- if (!is_resource($hProc))
+ // derive change from normal osm file with osmosis
+ $sTemporaryFile = CONST_BasePath.'/data/osmosischange.osc';
+ if (isset($aResult['import-file']) && $aResult['import-file'])
+ {
+ $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