comparing map data textually
Moderator: Forum Moderators
-
- Posts: 217
- Joined: December 17th, 2015, 10:27 pm
comparing map data textually
So, maybe this is too simple. Maybe that's why there isn't one already posted here or included in the
Well, I needed something to enable me to compare map data with small differences, and so I wrote one.
You cannot simply use Diff, because it doesn't do so well detecting differences within lines. There are some other tools which do so — WinMerge, for one, — but the simplicity of the map structure, textually, accomodates a much cleaner way to format it so that Diff can be used.
To make this a proper Bash executable, you need to change the first line:
You will get each tile on its own line with
EDIT: now deletes any trailing spaces in lines.
data/tools/
anywhere: because most developers of so–called UMC all have their own.Well, I needed something to enable me to compare map data with small differences, and so I wrote one.
You cannot simply use Diff, because it doesn't do so well detecting differences within lines. There are some other tools which do so — WinMerge, for one, — but the simplicity of the map structure, textually, accomodates a much cleaner way to format it so that Diff can be used.
To make this a proper Bash executable, you need to change the first line:
- change the
bash
to point toward where you keep your Bash executable, - remove all blankspaces,
- and strip off the
###
.
- requires the GNU extensions to Sed — though I doubt anyone here would be using the non-GNU version…
- uses Perl5.
You will get each tile on its own line with
$x,$y
prefixed.
Code: Select all
### #! bash
#?cat
#?diff
#?mktemp
#?perl
#?sed
##
sini="$1"
sini_smeared=$( mktemp )
dexe="$2"
dexe_smeared=$( mktemp )
prog__perl_prefixing='
# use strict;
# use warnings;
use autodie;
##
my $x = 0;
my $y = 0;
while (my $line = <STDIN>) {
## NOTE
## usr/bin/perl* cannot be given name of node on commandline if -e is used
if ($line =~ /^$/) {
$x = 0;
$y = $y + 1;
}
else {
printf "$x,$y %s", $line;
$x = $x + 1;
};
};
'
function smear {
cat "$1" \
| \
sed --regexp-extended --null-data \
--expression='s/border_size=[0123456789]+\nusage=(map|mask)\n\n//;' \
| \
sed --regexp-extended \
--expression='s/$/\n/g;s/ *, +/\n/g;s/ *$//g;' \
| \
perl \
-e "$prog__perl_prefixing" \
>| "$2"
}
smear "$sini" $sini_smeared
smear "$dexe" $dexe_smeared
diff --speed-large-files $sini_smeared $dexe_smeared
##
exit
Last edited by Can-ned_Food on August 31st, 2018, 4:59 pm, edited 5 times in total.
-
- Posts: 217
- Joined: December 17th, 2015, 10:27 pm
Re: comparing map data textually BUMP
I really don't like to do this, but the new edition of my handy program is a major improvement over the prior one — which probably shouldn't've been published at all. I doubt anyone made use of it.