function render_to_osm($nodeList, $file) { $osm = new OSMWriter(); $osm->xmlHeader(); $osm->openOsm("0.6", "osm-tools"); foreach ($nodeList as $node) { $osm->openNode($node['lat'], $node['lon']); $osm->writeTag('osmanalysis', 'missing'); $osm->writeTag("name", htmlspecialchars($node['name'], ENT_QUOTES)); $osm->closeNode(); } $osm->closeOsm(); file_put_contents($file, $osm->get()); }
static function convert($filename, OSMWriter $osm, $namePrefix = '') { $osm->xmlHeader(); $osm->openOsm("0.6", "osm-tools"); $s = simplexml_load_file($filename); foreach ($s->wpt as $point) { $osm->openNode($point['lat'], $point['lon']); $osm->writeTag('osmanalysis', 'mismatch'); $prefix = "OSB {$point->extensions->id}: "; $osm->writeTag('name', $prefix . htmlspecialchars((string) $point->desc, ENT_QUOTES, 'UTF-8')); $osm->closeNode(); } $osm->closeOsm(); return $osm->get(); }
$osm->openOsm("0.6", "osm-tools"); $f = fopen("compress.zlib://matches-latest.csv.gz", 'r'); while (false !== ($line = fgetcsv($f))) { if ($line[1] == '' && $line[2] == '') { continue; } if ((strlen(trim($line[8])) > 0 || strlen(trim($line[9])) > 0) && $line[5] == 0) { continue; } if (strlen(trim($line[8])) == 0 && strlen(trim($line[9])) == 0) { $osm->openNode($line[4], $line[3]); $missing = strlen($line[1]) ? $line[1] : $line[2]; $osm->writeTag('osmanalysis', 'missing'); $osm->writeTag("name", htmlspecialchars("{$missing}", ENT_QUOTES)); $osm->writeTag("addr:street", htmlspecialchars("OSM has nothing", ENT_QUOTES)); $osm->closeNode(); continue; } else { if (strlen(trim($line[2])) != 0 && strlen(trim($line[9])) == 0) { $osm->openNode($line[4], $line[3]); $osm->writeTag('osmanalysis', 'missing'); $osm->writeTag("name", htmlspecialchars("{$line[2]}", ENT_QUOTES)); $osm->writeTag("addr:street", htmlspecialchars("OSM has nothing", ENT_QUOTES)); $osm->closeNode(); continue; } else { if (strlen(trim($line[1])) != 0 && strlen(trim($line[8])) == 0) { $osm->openNode($line[4], $line[3]); $osm->writeTag('osmanalysis', 'missing'); $osm->writeTag("name", htmlspecialchars("{$line[1]}", ENT_QUOTES)); $osm->writeTag("addr:street", htmlspecialchars("OSM has nothing", ENT_QUOTES));