Re: [mkgmap-dev] Splitter question

2010-11-26 Thread Lambertus

On 2010-11-25 19:45, Danny Backx wrote:

On Thu, 2010-11-25 at 14:17 +0100, Lambertus wrote:

If there is interest in my script (PHP) then I can clean it up a bit and
post it here.


Yes please.

Danny


The script is attached. I've added some inline comments and hope all is 
clear. Don't hesitate to ask if you have any questions.
= 10) {
		echo "Splitting $tileid with nodes=$nodes, starting at $mapid. Max id was $maxid, level = $level\n";

		$command = "java -Xmx1792M -jar ~/garmin/utils/splitter/splitter.jar --no-trim --mapid=".$mapid." --max-nodes=".$nodes." --write-kml=".$tileid.".kml --geonames-file=$cities $tileid.osm.gz";
		passthru($command);
		$newtileid = $maxid;

		// Determine the maximum id produced by the split
		$newmaxid = getMaxSourceId();
		
		// require at least two sub files
		if (($newmaxid - $maxid) < 2) {
			echo "The split did not result in at least two subtiles, try again with less nodes per tile\n";
			$level++;
			$newmaxid = subsplit($tileid, $maxid, $level);
		} else {
			// Render the new source files
			$maxid++;
			$tiles = $newmaxid - $maxid;
			for ($i = 0; $i <= $tiles; $i++) {
echo "Start a new recursive render with $maxid, $newmaxid, $level, $nodes\n";
$newmaxid = render($maxid, $newmaxid, $level);
$maxid++;
			}
			echo "Done with subsplit at level $level\n";
		}
	} else {
		echo "Subsplitting passed the minimum node count. Giving up\n";
		$newmaxid = $maxid;
	}	
	return $newmaxid;
}

// Return the number of the file with the highest filenumber
function getMaxSourceId() {
	$maxid = 0;
	$ids = getSourceIds();
	foreach ($ids as $id) {
		if ($id > $maxid)
			$maxid = $id;
	}
	return $maxid;
}

// Return the available filenumbers
function getSourceIds() {
	$ids = array();
	foreach (glob("*.osm.gz") as $filename) {
		$parts = explode(".", $filename);
		$ids[] = $parts[0];
	}
	return $ids;
}

// Delete a directory tree. Please ensure $dir ends with a slash
function delTree($dir) {
$files = glob( $dir . '*', GLOB_MARK );
foreach( $files as $file ){
if( substr( $file, -1 ) == '/' )
delTree( $file );
else
unlink( $file );
}
rmdir( $dir );
} 

/* 
 * Below are some functions to update the list of available tiles from the initial split with the subsplit results
 */
function simplexml_append(SimpleXMLElement $parent, SimpleXMLElement $new_child){
$node1 = dom_import_simplexml($parent);
$dom_sxe = dom_import_simplexml($new_child);
$node2 = $node1->ownerDocument->importNode($dom_sxe, true);
$node1->appendChild($node2);
} 

function simplexml_replace(SimpleXMLElement $parent, SimpleXMLElement $new_child){
   $node1 = dom_import_simplexml($parent);
   $dom_sxe = dom_import_simplexml($new_child);
   $node2 = $node1->ownerDocument->importNode($dom_sxe, true);
   $node1->parentNode->replaceChild($node2,$node1);
}

function updateKml($name) {
	$kmlRed = "
  ";
	$kmlBlue = "
  ";

	// Load the original KML file
	if (file_exists("$name.kml")) {
		$xml = simplexml_load_file("$name.kml");
	} else {
		exit("Failed to open $name.kml.");
	}
	
	// loop through all KML files to update the original KML file
	foreach (glob("*.kml") as $replacement) {
		if (strpos($replacement, $name) === false) {
			$id = explode(".", $replacement);
		
			// Load each new KML file
			$newxml = simplexml_load_file($replacement);
			foreach ($xml->Document->Placemark as $oldPlacemark) {
if (strpos($oldPlacemark->name, $id[0]) !== false) {
	// This KML file contains subtiles -> delete the tile they replace

	$
	$oNode->parentNode->removeChild($oNode);
	break;
}
			}
		
			// Add the subtiles
			foreach ($newxml->Document->Placemark as $newPlacemark) {
simplexml_append($xml->Document, $newPlacemark);
			}
		}
	}

	// Determine which tiles actually exist (update KML rendering)
	$red = simplexml_load_string($kmlRed);
	$blue = simplexml_load_string($kmlBlue);
	simplexml_replace($xml->Document->Style, $red);
	simplexml_append($xml->Document, $blue);
	
	foreach ($xml->Document->Placemark as $tile) {
		$id = $tile->name;
		if (file_exists($id.".img") == true) {
			$tile->styleUrl = "#Blue";
		} else {
			$tile->styleUrl = "#Red";
		}
	}

	// Write out the new version of the KML file
	$fh = fopen("$name.kml.1", "w+");
	if ($fh) {
		fwrite($fh, $xml->asXML());
		fclose($fh);
	}
	// rename original KML file to old
	rename("$name.kml", "$name.kml.old");
	
	// rename new KML file to original
	rename("$name.kml.1", "$name.kml");
}

/* The original Mkgmap commandline from the render() function:
 * $output = passthru("ulimit -t 600 && java -Xmx1792M -ea -jar ~/garmin/utils/mkgmap/mkgmap.jar --adjust-turn-headings --latin1 --name-tag-list=name:en,int_name,name:zh_py,name:engels,name --remove-short-arcs --add-pois-to-areas --make-opposite-cycleways --link-pois-to-ways --route --description='OSM World Routable' --series-name='OSM World Routable' --input-file=$file", $retval);
 */
?>


[mkgmap-dev] first map-tile is missing in tdb-file?

2010-11-26 Thread Torsten Leistikow
Moin,

I am creatig my maps with mkgmam-r1733 with the following command:

java -jar  -Xmx8096M ../../mkgmap-r1733/mkgmap.jar
--style-file=../../styles/topo_v005 --remove-short-arcs=5
--generate-sea=extend-sea-sectors --family-id=62 --country-name=Deutschland
--country-abbr=D --family-name=Topo Map --series-name=Topo Map
--description=Topo Map --tdbfile --max-jobs=3 --draw-priority=11 -c 
maplist.txt

The configuration file maplist.txt is the following:

mapname: 8001
description: FR - Macon
input-file: ../../osm/Europa/8001.osm.gz

mapname: 8002
description: FR - Dijon
input-file: ../../osm/Europa/8002.osm.gz

mapname: 8003
description: CH - Geneve
input-file: ../../osm/Europa/8003.osm.gz

mapname: 8004
description: FR - Besancon
input-file: ../../osm/Europa/8004.osm.gz

mapname: 8005
description: CH - Aigle
input-file: ../../osm/Europa/8005.osm.gz

...

The problem now is the first map tile 8001. The img file is correctly
created, but the tile is missing in mapsource and it looks like, the tile is
missing in the tdb-file:

PC   �Topo Map d Topo Map      �  '    D�   OSM
Street map   http://www.openstreetmap.org/   Map data licenced under
Creative Commons Attribution ShareAlike 2.0 
http://creativecommons.org/licenses/by-sa/2.0/   Map created with mkgmap-r1733
    Program released under the GPL R �Test preview map B% @��  �'
 �  �   Overview Map Ll �e�...@��  @  �  @!  FR - Dijon (8002)   
3
 ��� a � �   8002.TRE 8002.RGN 8002.LBL Lm �e�...@��  0!  �  �
  �CH - Geneve (8003)   X%  �_A � � �   8003.TRE 8003.RGN
8003.LBL Lo �e�...@��  @  �  0!  �FR - Besancon (8004)   \*  y
;N � �   8004.TRE 8004.RGN 8004.LBL Ll �e�...@��  0!  �  �   
�CH
- Aigle (8005)   �#  H�, = � �   8005.TRE 8005.RGN
8005.LBL Lk �e�...@��  �!  �  0!  �CH - Bern (8006)   �F  ��Z �( 
�
�   8006.TRE 8006.RGN 8006.LBL Lo �e�...@��  @  `  �!  �FR -
Mulhouse (8007)  

...

I dont't get any error messages from mkgmap. So where is the map tile lost?

Gruss
Torsten
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev