File: ircmarkers

package info (click to toggle)
ircmarkers 0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 160 kB
  • ctags: 69
  • sloc: perl: 704; ansic: 199; makefile: 71
file content (602 lines) | stat: -rwxr-xr-x 15,979 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
#!/usr/bin/perl -w
#
# Copyright (C) 2003-2008 Christoph Berg <cb@df7cb.de>
#
# Part of this file originate from example.pl from the MapMarker distribution:
#   Author  :  Guillaume Leclanche (Mo-Ize) <mo-ize@nul-en.info>
#   Version :  2.0 beta 1
#   Date    :  08 Feb 2003
#
# See the pod section at the end of this file for copyright details.

# 2003-12-01 cb: uses @ARGV
# 2004-07-04 cb: cleaned up code, introduced config file
# see debian/changelog for further entries

use strict;
use warnings;
use Getopt::Long;

use IrcMarkers::File;
use IrcMarkers::Map;

my $VERSION = "0.14";

sub VERSION_MESSAGE {
	print "IrcMarkers $VERSION (C) 2003-2008 Christoph Berg <cb\@df7cb.de>, GNU GPL.\n";
}

sub HELP_MESSAGE {
	VERSION_MESSAGE();
	print <<EOT;
usage: $0 [options] config [inputmap outputmap]
-q             be quiet
-o command     configuration command
-x west/east   longitude bounds of input map
-y south/north latitude bounds of input map
EOT
	exit 0;
}

my $config = IrcMarkers::File->new;

my ($x, $y);
GetOptions(
	'x=s' => \$x,
	'y=s' => \$y,
	'q' => \$config->{quiet},
	'o=s' => sub { $config->parse($_[1]); },
	crop => \$config->{help_convert_crop},
	help => sub { HELP_MESSAGE(); },
	version => sub { VERSION_MESSAGE(); exit(0); },
) or HELP_MESSAGE();

HELP_MESSAGE() unless $ARGV[0];
$config->read($ARGV[0]);

if($config->{pisg}) {
	foreach my $marker (@{$config->{markers}}) {
		next unless $marker->{text};
		print "<user nick=\"$marker->{text}\"";
		print " alias=\"$marker->{alias}\"" if $marker->{alias};
		print " link=\"$marker->{href}\"" if $marker->{href};
		print " pic=\"$marker->{pic}\"" if $marker->{pic};
		print " bigpic=\"$marker->{bigpic}\"" if $marker->{bigpic};
		print " sex=\"$marker->{sex}\"" if $marker->{sex};
		print ">\n";
	}
	exit 0;
}

if($x) { # after $config->read so -x can override lon
	$x =~ /(.*)\/(.*)/ or die "invalid -x format";
	($config->{west}, $config->{east}) = ($1, $2);
}
if($y) {
	$y =~ /(.*)\/(.*)/ or die "invalid -y format";
	($config->{south}, $config->{north}) = ($1, $2);
}

$config->{read} = $ARGV[1] if $ARGV[1];
$config->{write} = $ARGV[2] if $ARGV[2];

die "no input map" unless $config->{read};
die "no output map" unless $config->{write};

## Print a correct 'convert -crop' command. More info at convert(1)
#if ($config->{help_convert_crop}) {
#	use Image::Size;
#	my $type;
#	($config->{w}, $config->{h}, $type) = imgsize($config->{read});
#
#	# fallback
#	$config->{view_west} = $config->{west} unless defined $config->{view_west};
#	$config->{view_east} = $config->{east} unless defined $config->{view_east};
#	$config->{view_north} = $config->{north} unless defined $config->{view_north};
#	$config->{view_south} = $config->{south} unless defined $config->{view_south};
#	
#	# print the info
#	printf("\$ convert -crop %dx%d+%d+%d %s new.%s\n",
#			$config->{w}, # width
#			$config->{h}, # height
#			$config->{w} * ($config->{view_east} - $config->{view_west}) / ($config->{east} - $config->{west}), # x
#			$config->{h} * ($config->{view_north} - $config->{view_south}) / ($config->{north} - $config->{south}), # y
#			$config->{read}, # src file
#			lc $type, # file type
#		);
#	
#	exit;
#}

my $map = IrcMarkers::Map->new($config);

foreach my $marker (@{$config->{markers}}) {
	next unless $marker->{lat};
	($marker->{x}, $marker->{y}, $marker->{visible}) = $config->coord2pixel($marker->{lat}, $marker->{lon});
	next unless $marker->{visible};
	if ($marker->{text} ne "") {
		($marker->{labelx}, $marker->{labely}) =
			($marker->{x} + $marker->{dot_size} + 3, $marker->{y} + $marker->{dot_size});
		# TODO: make '3' configurable?
		print "$marker->{text} at $marker->{lat}, $marker->{lon} ($marker->{y}, $marker->{x})\n" unless $config->{quiet};
	} else {
		print "$marker->{lat}, $marker->{lon} ($marker->{y}, $marker->{x})\n" unless $config->{quiet};
	}
}

if($config->{link_color} and $config->{gpg}) {
	$config->get_gpg_links();
}

$config->set_line_style();
if($config->{links}) {
	foreach my $link (@{$config->{links}}) {
		my $src = $config->{markers}->[$link->{src}];
		my $dst = $config->{markers}->[$link->{dst}];
		print "$src->{text} $link->{arrow} $dst->{text}\n" unless $config->{quiet};
		if ($src->{lon} > $dst->{lon}) {
			($src, $dst) = ($dst, $src);
		}
		($link->{xs}, $link->{ys}) = ($src->{x}, $src->{y});
		($link->{xd}, $link->{yd}) = ($dst->{x}, $dst->{y});
		if ($src->{lon} - $dst->{lon} < -180) { # cross-Pacific links
			($link->{xd}) = $config->coord2pixel($dst->{lat}, $dst->{lon}-360);
			$config->draw_line_new($link);
			($link->{xs}) = $config->coord2pixel($src->{lat}, $src->{lon}+360);
			$link->{xd} = $dst->{x};
		}
		$config->draw_line_new($link);
	}
}

if($config->{markers}) {
	my $visible;
	foreach my $marker (@{$config->{markers}}) {
		next unless $marker->{visible};
		$visible = 1;
		$config->labelsize($marker);
		$map->draw_dot_new($marker);
	}
	print "warning: all markers are outside the visible area\n"
		unless $visible or $config->{quiet};
	$map->compute_overlap() if($config->{overlap_correction});
	foreach my $marker (@{$config->{markers}}) {
		next unless $marker->{visible};
		next if $marker->{text} eq "";
		$map->draw_label_new($marker);
		$config->compute_boundingbox($marker);
	}
}
if($config->{yxlabels}) {
	foreach my $label (@{$config->{yxlabels}}) {
		print "label \"$label->{text}\" at $label->{labely}, $label->{labelx}\n"
			unless $config->{quiet};
		$config->labelsize($label);
		$map->draw_label_new($label, 1);
		$config->compute_boundingbox($label);
	}
}
$map->write($config->{write});

if($config->{imagemap}) {
	$map->write_imagemap();
}

if(not $config->{quiet} and defined $config->{min_x}) {
	$config->{max_y} = $config->{h} if $config->{max_y} > $config->{h};
	$config->{max_x} = $config->{w} if $config->{max_x} > $config->{w};
	print "Area used by markers is: ".
		"y: $config->{min_y}..$config->{max_y} ".
		"x: $config->{min_x}..$config->{max_x}\n";
}

__END__

=head1 NAME

B<ircmarkers> - place markers on maps at given coordinates

=head1 SYNOPSIS

B<ircmarkers> [-q] [-o command] [-y I<south/north> -x I<west/east>] F<config> [F<inputmap> F<outputmap>]

=head1 DESCRIPTION

IrcMarkers takes a map in .png or .jpg format and a list of coordinates
and labels in xplanet format and places markers on the map.
It was written to generate user maps of IRC channels.

GnuPG/PGP key ids can be associated with each marker, to create "maps of trust".

IrcMarkers reads its configuration and the list of markers from a config file.
The most important options (map to read/write, map dimensions) can be specified
on the command line. Settings on the command line override settings in the
config file.

=head1 OPTIONS

=over

=item F<config>

Config file to read markers and options from. This parameter is mandatory.

=item F<inputmap>

Read input map from F<inputmap>. Supported formats are .gif, .jpg/jpeg, .png,
.xbm, .xpm, and the libgd-Formats .gd/gd1 and .gd2.

=item F<outputmap>

Write output map to F<outputmap>. Supported formats are .gif, .jpg/jpeg, .png,
.gd/gd1, .gd2, and .wbmp.

=item -q

Be quiet. Per default, IrcMarkers prints which labels and links are placed on
the map.

=item -y I<south/north>

=item -x I<west/east>

Declare input map dimensions. Unless specified otherwise in the config file,
the map is assumed to be in mercator projection. -y specifies the lower/upper
latitude coordinates, -x the left/right edge longitude. Per default, the map is
assumed to be a world map (-y -90/90 -x -180/180).

=item -o I<command>

Evaluate a configuration command. It will be executed before any commands in
the config file (i.e. it will not override commands there).

=back

=head1 CONFIG FILE SYNTAX

The following directives can be used in the config file:

=head2 Marker and Label Definitions

=over

=item I<lat> I<lon> "I<marker>"

=item I<lat> I<lon> "I<marker>" I<options>

=item I<aa11aa> "I<marker>" I<options>

=item "I<marker>" I<options>

Place marker with label I<marker> on map at given coordinates.
Use negative values for south/east, positive for north/west.
This (decimal) format is compatible with the xplanet syntax.

 49.2532 7.0425 "Myon"

Alternative formats recognized are:

 N51°11.123 E006°25.846
 N 51 11.123 E 006 25.846
 N 51° 11' 7.38" E 006° 25' 50.76"

The noise characters °'" are optional.

Also recognized are Maidenhead (QTH) locators.

 JN39PF "Myon"

=item label I<y> I<x> "I<text>"

=item label I<y> I<x> "I<text>" I<options>

Place a label at position I<y>/I<x> (in pixels). Useful for headlines etc.
Using negative values will count from the bottom/right border in X11's
-geometry style.

=back

=head2 Marker and Label Options

The following options can be specified per marker or globally (except gpg).
Global options set defaults for all following marker definitions.

=over

=item gpg I<keyid>

Associate GnuPG/PGP I<keyid> with the marker. If two keys have signed each
other, and both markers are visible on the map, a link will be drawn between
the markers. Multiple keyids can be given. Example:

B<"Myon" gpg B46B923B6D8ABE71 gpg C5AF774A58510B5A>

B<Note:> This is the long, 16 character keyid. To retrieve it, use C<gpg
--list-key --with-colon>.

=item label_color I<R G B>

=item label_border I<R G B>|none

Color of the labels placed on the map. Default is label_color 255 255 0,
label_border 0 0 0. The border can be removed by specifying the "none" color.

=item font F<fontfile>

Full pathname to the .ttf font used for the labels. Default is
font F</usr/share/ircmarkers/fixed_01.ttf>.

=item fontsize|ptsize I<size>

Size in points of the labels. Default is fontsize 6.

=item dot_color I<R G B>

=item dot_border I<R G B>|none

Color of the dots placed on the map. Default is dot_color 255 255 255,
dot_border 0 0 0.

=item dot_size I<size>

Size of the dots. Default is 2.

=item dot_shape dot|circle

Dots are filled (dot) or hollow (circle). Default is dot.

=item href I<link>

Link target to use in an imagemap.

=item alias|pic|bigpic|sex I<string>

Options for export to pisg(1), see the B<pisg> option below.

=back

=head2 Link Definition and Options

=over

=item "I<marker1>" <-> "I<marker2>"

=item "I<marker1>" <-> "I<marker2>" I<options>

Draw a link between I<marker1> and I<marker2>.

=item link_color|sign2_color I<R G B>|none

Color of the lines drawn between the markers. Default is link_color 255 128 0.

=back

=head2 Global Options

=over

=item read F<inputmap>

Read input map from F<inputmap>. Supported formats are .jpg and .png.

=item write F<outputmap>

Write output map to F<outputmap>. Supported formats are .jpg, .png, .gd1, .gd2,
and .wbmp.

=item lat|south_north I<south/north>

=item lon|west_east I<west/east>

Declare input map dimensions. Default is lat -90/90, lon -180/180.

B<Note:> It is possible to use "unusual" values like lon 0/360 if you adjust
the coordinates as well. (-20 becomes 340 etc.)

=item view_lat|view_south_north I<south/north>

=item view_lon|view_west_east I<west/east>

Only show part of the map in the output. Default is to show the whole map.

=item view_width I<pixels>

=item view_height I<pixels>

Size of output map. Default is input map, or size of part selected.

=item projection mercator|sinusoidal

=item center_lon I<center>

Map projection. Default is mercator.
center_lon is only used for sinusoidal projection.
There is no default for center_lon.

=item link_outside on|off

Whether to draw lines to markers that are not visible on the map. Default is
link_outside off.

=item sign1_color I<R G B>|none

Color of the lines drawn for uni-directional GnuPG/PGP signatures. Default is
link_color none.

=item imagemap F<file>

Write HTML image map to F<file>. The map contains areas for all markers and
labels with a href option. The name of the imagemap is the basename of the
output map with the extension stripped.

=item overlap F<overlapcorrector>

Full pathname to the binary that moves the labels around to reduce overlap.
Default is overlapcorrector F</usr/lib/ircmarkers/overlap>.
Chances are that you only need to change that parameter if you are debugging
the overlap corrector.

=item overlap_correction on|off

Whether to use the overlap corrector or not. Default is overlap_correction on.
Turn it off if you have really many labels.

=item pisg

Instead of writing a map, print a config file suitable for pisg(1), most useful
with B<ircmarkers -o pisg> I<file>. The exported marker options are B<alias>,
B<pic>, B<bigpic>, B<sex>, and B<href> (the latter as B<link>).

=item recv-keys

Call gpg --recv-keys (most useful with B<ircmarkers -o recv-keys>).

=item quiet on|off

Be quiet. Default is quiet off.

=item #include "F<configfile>"

Read auxillary config file.

=item # comment

Anything else starting with a # character is a comment.

=back

=head1 EXAMPLES

B<ircmarkers -x -10.4/29.4 -y 32/72 coordinates.txt europe.jpg mutt-eu.jpg>

	read dl.jpg
	write debian.de.jpg
	lat 44/56
	lon 4/20
	label_color 0 255 0
	49.2532 7.0425 "Myon"
	50.8574 6.4585 "formorer" label_color 255 255 0
	N 51° 11.123 E 006° 25.846 "GC1ACE3"
	#include "debian.de.txt"
	#include "debian.de.keys"

=head1 BUGS

The GD library keeps a raw bitmap of the map in memory. Big maps will use lots
of memory. Precompute the map you are going to use, i.e. downsample it to the
target size using Imagemagick's I<convert> or IrcMarkers view_* functions.

Please report bugs in IrcMarkers using the Debian bug tracking system. The
IrcMarkers bug page is at B<http://bugs.debian.org/ircmarkers>.

=head1 SEE ALSO

=head2 Library used

=over

=item *

L<GD(3)> - GD version 2

=back

=head2 Programs related to IrcMarkers

=over

=item *

MapMarkers: http://www.nul-en.info/mapmarkers/ - IrcMarkers' predecessor

=item *

xplanet(1): http://xplanet.sourceforge.net/

=item *

Image::WorldMap: http://www.astray.com/WorldMap/

=item *

pisg(1): http://pisg.sourceforge.net/

=back

=head2 Locating coordinates

=over

=item *

http://www.multimap.com/ - online maps to everywhere

=item *

http://www.calle.com/world/ - directory of cities and towns in world

=item *

http://tiger.census.gov/cgi-bin/mapbrowse-tbl - United States

=item *

http://www.ckdhr.com/dns-loc/finding.html - more pointers

=back

=head2 Maps

=over

=item *

http://visibleearth.nasa.gov/cgi-bin/viewrecord?11656 - nice copyright-free world map

=item *

http://www.elho.net/misc/xplanet/ - compilation of suitable maps from NASA

=back

=head1 AUTHOR

IrcMarkers was written by Christoph Berg <cb@df7cb.de>.
You can find me (Myon) on ircnet/freenode/oftc.

Thanks go to Uli Martens for the "map of trust" idea.

Alexander Wirt suggested the capability to draw selected parts of the map.

Elmar Hoffmann suggested several error checks and config options.

Rico Gloeckner suggested to support Maidenhead locators.

The IrcMarkers homepage is at B<http://www.df7cb.de/projects/ircmarkers/>.

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2003-2008 Christoph Berg <cb@df7cb.de>

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License with the
Debian GNU/Linux distribution in file F</usr/share/common-licenses/GPL>; if not,
write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA  02110-1301 USA

IrcMarkers is an improved version of MapMarkers.

Copyright (C) 2002, 2003 Guillaume Leclanche (Mo-Ize) <mo-ize@nul-en.info>

The font provided with this package, fixed_01.ttf, has been created by the
Orgdot team, http://www.orgdot.com/aliasfonts/.

(C) 2001 http://www.orgdot.com