35 If instead you have a format like M 1234.678,9875.323 2345.0,123.45 - you'll want to convert if you want to try the crude script in (10) - otherwise a smarter script would be needed. Here's some Vim commands for that syntax {{{s/\(\d\) \(\d\)/\1 L\2/g}}} and {{{s/,/ /g}}} and {{{s/\([LM]\)\s*/\1/g}}} |
35 If instead you have a format like M 1234.678,9875.323 2345.0,123.45 - you'll want to convert if you want to try the crude script in (10) - otherwise a smarter script would be needed. Here's some Vim commands for that syntax {{{s/\(\d\) \(\d\)/\1 L\2/g}}} and {{{s/,/ /g}}} and {{{s/\([LM]\)\s*/\1/g}}} |
36 |
36 |
37 The coordinates should now be rounded for use by the crude script in (10) unless you plan to handle that yourself in some way. Here is a vim one-liner to do it. |
37 The coordinates should now be rounded for use by the crude script in (10) unless you plan to handle that yourself in some way. Here is a vim one-liner to do it. |
38 {{{:s/[0-9][0-9.]*/\=float2nr(floor(submatch(0)*1))/g}}} |
38 {{{:s/[0-9][0-9.]*/\=float2nr(floor(submatch(0)*1))/g}}} |
39 |
39 |
40 Also, it is probably a good idea to remove duplicate points. Here's a regex for that. {{{s/\(L\d\+ \d\+ \)\1/\1/g}}} - you should run that a couple of times, then {{{s/M\(\d\+ \d\+ \)L\1/M\1/g}}}. That just cuts down on a bit of redundancy. |
40 Also, it is probably a good idea to remove duplicate points. Here's a regex for that. {{{s/\(L\d\+ \d\+ \)\1/\1/g}}} - you should run that a couple of times, then {{{s/M\(\d\+ \d\+ \)L\1/M\1/g}}}. That just cuts down on a bit of redundancy. If these regexes match anything, you probably should rerun them. |
41 |
41 Since this page is a mass of hacks, here's one more redundancy reducer, in bash this time. |
|
42 {{{rm dupes.txt;PREVXY=(99999 99999);sed 's/\([LM]\)/\n\1/g' inputfile | while read f;do read -a XY <<< "${f:1}";if [ "${f:0:1}" != "M" ];then if((${XY[0]}-${PREVXY[0]}<3&&${XY[0]}-${PREVXY[0]}>-3&&${XY[1]}-${PREVXY[1]}<3&&${XY[1]}-${PREVXY[1]}>-3));then echo "$f" >> dupes.txt;else echo $f;fi;else echo $f;fi;PREVXY[0]=${XY[0]};PREVXY[1]=${XY[1]};done | xargs > inputfile.dedupe}}} |
|
43 If dupes.txt has anything in it, you probably should run it again. Anyway, running these reduced a complex test trace from ~8800 points down to ~6500. |
42 |
44 |
43 9) Convert the path data. Here is a crude script to do that. Note this one uses a line size of 1 (that's the 0x01 business). |
45 9) Convert the path data. Here is a crude script to do that. Note this one uses a line size of 1 (that's the 0x01 business). |
44 If you want larger lines you can pick anything between 0x00 and 0x3F. That's 6-636. See the [DrawnMapFormat] wiki page. |
46 If you want larger lines you can pick anything between 0x00 and 0x3F. That's 6-636. See the [DrawnMapFormat] wiki page. |
45 {{{ |
47 {{{ |
46 #!/usr/bin/perl |
48 #!/usr/bin/perl |