Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote-tracking branch 'upstream/master'

Conflicts:
	node.js/config.json
  • Loading branch information...
commit 3a69f773c7d23af44b5ac9fafaa755f4919d59b2 2 parents 698a5bb + ea740fe
blackivory86 authored July 06, 2012
56  node.js/makemaps.js
@@ -45,10 +45,27 @@ for (var f in folders) if (folders.hasOwnProperty(f)) {
45 45
 }
46 46
 
47 47
 function makemap(geoFile, kantFile, folder) {
48  
-	var svg = [];
49  
-	svg.push('<?xml version="1.0" encoding="utf-8"?>');
50  
-	svg.push('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">');
51  
-	svg.push('<svg>');
  48
+	var
  49
+		xMin = 5,
  50
+		xMax = 16,
  51
+		yMin = 46,
  52
+		yMax = 56
  53
+		zoom = 600;
  54
+		
  55
+	var
  56
+		xZoom = 1.0*zoom,
  57
+		yZoom = 1.5*zoom,
  58
+		width  = (xMax - xMin)*xZoom,
  59
+		height = (yMax - yMin)*yZoom;
  60
+	
  61
+	var output = [];
  62
+	/*output.push('<?xml version="1.0" encoding="utf-8"?>');
  63
+	output.push('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">');
  64
+	output.push('<svg version="1.1" x="0px" y="0px" width="'+width+'px" height="'+height+'px">');*/
  65
+	output.push('push graphic-context');
  66
+	output.push('viewbox 0 0 '+width+' '+height);
  67
+	output.push('affine 1 0 0 1 0 0');
  68
+	
52 69
 	
53 70
 	var geo  = JSON.parse(fs.readFileSync(geoFile , 'utf8'));
54 71
 	var kant = JSON.parse(fs.readFileSync(kantFile, 'utf8'));
@@ -63,23 +80,26 @@ function makemap(geoFile, kantFile, folder) {
63 80
 			if (id1 < id2) {
64 81
 				var px2 = geo[id2].lon;
65 82
 				var py2 = geo[id2].lat;
66  
-				if (true || (px1>13) && (px1<14) && (py1>52.3) && (py1<52.7) &&
67  
-					 (px2>13) && (px2<14) && (py2>52.3) && (py2<52.7)) {
68  
-					var x1 = (px1-13)*1000;
69  
-					var y1 = (py1-52.3)*1750;
70  
-					var x2 = (px2-13)*1000;
71  
-					var y2 = (py2-52.3)*1750;
72  
-					var r = Math.sqrt(Math.pow(x1-x2, 2) + Math.pow(y1-y2, 2));
73  
-					var opa = 2/(siblings[j].dauer+1);
74  
-					if (opa > 1) opa = 1;
75  
-					svg.push('<line stroke-width="0.1" stroke-opacity="'+opa+'" fill="none" stroke="#000000" x1="'+x1+'" y1="'+y1+'" x2="'+x2+'" y2="'+y2+'"/>');
76  
-				}
  83
+
  84
+				var x1 = (px1 - xMin)*xZoom, y1 = (yMax - py1)*yZoom;
  85
+				var x2 = (px2 - xMin)*xZoom, y2 = (yMax - py2)*yZoom;
  86
+				
  87
+				var r = Math.sqrt(Math.pow(x1-x2, 2) + Math.pow(y1-y2, 2))/zoom;
  88
+				var opa = 10*r/(siblings[j].dauer+1);
  89
+				if (opa > 1) opa = 1;
  90
+				//output.push('<line stroke-width="0.02" stroke-opacity="'+opa+'" stroke="#000000" x1="'+x1+'" y1="'+y1+'" x2="'+x2+'" y2="'+y2+'"/>');
  91
+				
  92
+				output.push('push graphic-context');
  93
+				output.push('stroke-width 1');
  94
+				output.push('opacity '+(opa*100)+'%');
  95
+				output.push('line '+x1+','+y1+' '+x2+','+y2);
  96
+				output.push('pop graphic-context');
77 97
 			}
78 98
 		}
79 99
 	}
80 100
 	
81  
-	svg.push('</svg>');
82  
-	fs.writeFileSync(folder+'/map.svg', svg.join('\r'), 'utf8');
83  
-	console.log('map');
  101
+	//output.push('</svg>');	
  102
+	output.push('pop graphic-context');
  103
+	fs.writeFileSync(folder+'/mapkant.mvg', output.join('\r'), 'utf8');
84 104
 }
85 105
 
92  node.js/modules/plan_utils.js
@@ -57,6 +57,7 @@ function decodeFile(file, outputFolder) {
57 57
 		case 'planbetr': decodePlanBETR( file.fullname, outputFile); break;
58 58
 		case 'planbz':   decodePlanBZ(   file.fullname, outputFile); break;
59 59
 		case 'plancon':  decodePlanCON(  file.fullname, outputFile); break;
  60
+		case 'plangat':  decodePlanGAT(  file.fullname, outputFile); break;
60 61
 		case 'plangls':  decodePlanGLS(  file.fullname, outputFile); break;
61 62
 		case 'planitxt': decodePlanITXT( file.fullname, outputFile); break;
62 63
 		case 'plankant': decodePlanKANT( file.fullname, outputFile); break;
@@ -70,7 +71,7 @@ function decodeFile(file, outputFolder) {
70 71
 		case 'planw':    decodePlanW(    file.fullname, outputFile); break;
71 72
 		case 'planzug':  decodePlanZUG(  file.fullname, outputFile); break;
72 73
 		default:
73  
-			console.log('# unkown;' + file.filetype + ';' + stats.size);
  74
+			console.log('# unknown;' + file.filetype + ';' + stats.size);
74 75
 	}
75 76
 }
76 77
 
@@ -329,11 +330,8 @@ function decodePlanBZ(filename, outputFile) {
329 330
 	header.unknown.push(f.readHexDump(4));
330 331
 	
331 332
 	header.description = f.readString(header.size - f.pos);
332  
-	
333 333
 	var
334  
-		list1 = [],
335  
-		debug = [],
336  
-		debug2 = [];
  334
+		list1 = [];
337 335
 	
338 336
 	for (var i = 0; i < header.listLength1; i++) {
339 337
 		list1[i] = [i, f.readInteger(-4), f.readInteger(2)];
@@ -347,22 +345,13 @@ function decodePlanBZ(filename, outputFile) {
347 345
 	do { i1++ } while (list1[i1][1] < 0);
348 346
 	
349 347
 	while (f.pos < f.length) {
350  
-		if (debug[i1] === undefined) debug[i1] = '';
351 348
 		if (f.pos >= list1[i1][1]) {
352  
-			//if ((i0 >= 0) && list1[i0].length % 2 == 1) debug[i1] += '99999999';
353  
-			//debug[i1] += '99999999';
354 349
 			i0 = i1;
355 350
 			do { i1++ } while (list1[i1][1] < 0);
356 351
 		}
357 352
 		var v = f.readInteger(1);
358 353
 		list1[i0].push(f.getAsHexDump(v));
359  
-		
360  
-		if (i0 == 3392) {
361  
-			debug[i0] += f.getAsBinDump(v);
362  
-			debug2.push('' + v);
363  
-		}
364 354
 	}
365  
-	
366 355
 	list1.pop();
367 356
 	
368 357
 	
@@ -370,8 +359,6 @@ function decodePlanBZ(filename, outputFile) {
370 359
 	
371 360
 	exportHeader(outputFile, header);
372 361
 	exportTSV(outputFile, '1', list1);
373  
-	fs.writeFileSync(outputFile+'_debug.raw', debug.join(''), 'binary');
374  
-	fs.writeFileSync(outputFile+'_debug2.raw', debug2.join('\n'), 'binary');
375 362
 }
376 363
 
377 364
 // Noch nicht fertig
@@ -500,6 +487,61 @@ function decodePlanGLS(filename, outputFile) {
500 487
 	exportTSV(outputFile, '4', data4);
501 488
 }
502 489
 
  490
+function decodePlanGAT(filename, outputFile) {
  491
+	var header = {unknown:[]};
  492
+
  493
+	var f = new PlanFile(filename);
  494
+
  495
+	header.size = f.readInteger(2);
  496
+	header.version = f.readInteger(2) + '.' + f.readInteger(2);
  497
+	header.creationDate = f.readTimestamp();
  498
+
  499
+	header.listLength1 = f.readInteger(2);
  500
+	header.unknown.push(f.readInteger(4));
  501
+	header.listLength2 = f.readInteger(2);
  502
+	header.listLength3 = f.readInteger(4);
  503
+	header.unknown.push(f.readInteger(4));
  504
+
  505
+	f.checkBytes('00 00 00 00');
  506
+
  507
+	header.unknown.push(f.readInteger(4));
  508
+	header.unknown.push(f.readInteger(2));
  509
+
  510
+	header.description = f.readString(header.size - f.pos);
  511
+
  512
+	var
  513
+		data1 = [],
  514
+		data2 = [],
  515
+		data3 = [];
  516
+
  517
+	for (var i = 0; i < header.listLength1; i++) {
  518
+		data1[i] = [];
  519
+		data1[i][0] = f.readString(4);
  520
+		data1[i][1] = f.readInteger(2);
  521
+		data1[i][2] = f.readString(8);
  522
+		for (var j = 0; j < 10; ++j) {
  523
+			data1[i][3 + j] = f.readInteger(2);
  524
+		}
  525
+	}
  526
+
  527
+	for (var i = 0; i < header.listLength2; i++) {
  528
+		data2[i] = [];
  529
+		data2[i][0] = f.readHexDump(614);
  530
+	}
  531
+
  532
+	for (var i = 0; i < header.listLength3; i++) {
  533
+		data3[i] = [];
  534
+		data3[i][0] = f.readNullString();
  535
+	}
  536
+
  537
+	header.bytesLeft = f.check(outputFile);
  538
+
  539
+	exportHeader(outputFile, header);
  540
+	exportTSV(outputFile, '1', data1);
  541
+	exportTSV(outputFile, '2', data2);
  542
+	exportTSV(outputFile, '3', data3);
  543
+}
  544
+
503 545
 function decodePlanITXT(filename, outputFile) {
504 546
 	var header = {unknown:[]};
505 547
 	
@@ -1094,9 +1136,19 @@ function decodePlanZUG(filename, outputFile) {
1094 1136
 	header.blockSize = (f.length - f.pos)/(2*header.listLength1);
1095 1137
 
1096 1138
 	for (var i = 0; i < header.listLength1; i++) {
1097  
-		for (var j = 0; j < header.blockSize; j++) { 
1098  
-			data1[i][j+1] = f.readInteger(2);
1099  
-		}
  1139
+		data1[i][1] = f.readInteger(2);
  1140
+		data1[i][2] = f.readInteger(2);
  1141
+		data1[i][3] = f.readInteger(2);
  1142
+		data1[i][4] = f.readInteger(2);
  1143
+		data1[i][5] = f.readInteger(2);
  1144
+		data1[i][6] = f.readInteger(2);
  1145
+		data1[i][7] = f.readInteger(2);
  1146
+		data1[i][8] = f.readInteger(2);
  1147
+		// Feld referenziert eine 'LAUF'-id
  1148
+		data1[i][9] = f.readInteger(4);
  1149
+		data1[i][10] = f.readInteger(2);
  1150
+		if (header.blockSize > 11)
  1151
+			data1[i][11] = f.readInteger(2);
1100 1152
 	}
1101 1153
 
1102 1154
 	header.bytesLeft = f.check(outputFile);
@@ -1334,4 +1386,4 @@ if (!Array.prototype.each) {
1334 1386
 			if (i in t) fun(t[i], i);
1335 1387
 		}
1336 1388
 	};
1337  
-}
  1389
+}

0 notes on commit 3a69f77

Please sign in to comment.
Something went wrong with that request. Please try again.