Compare commits

...

2 Commits

  1. 4
      HexGrid/Path.pm
  2. 62
      wiki-map.pl

@ -79,9 +79,7 @@ sub render($this, $grid, $svg)
my ($qx,$qy) = $grid->coords_of_centre($current_tile->nw, $current_tile->sw); my ($qx,$qy) = $grid->coords_of_centre($current_tile->nw, $current_tile->sw);
($x2,$y2) = $grid->coords_of_edge($current_tile->nw, $current_tile->sw, $next_edge); ($x2,$y2) = $grid->coords_of_edge($current_tile->nw, $current_tile->sw, $next_edge);
# TODO: Draw curve from $current_tile:$previous_edge to $current_tile:$next_edge $g->path(d => curve_path($x1,$y1, $qx,$qy, $x2,$y2), fill => 'transparent',
# with $current_tile centre as the control point
$g->path(d => curve_path($x1,$y1, $qx,$qy, $x2,$y2),
stroke => $this->colour, style => $this->style, class => $this->css_class stroke => $this->colour, style => $this->style, class => $this->css_class
); );

@ -24,6 +24,7 @@ my $region_template_name = "MapRegion";
my $subregion_template_name = "MapSubregion"; my $subregion_template_name = "MapSubregion";
my $location_template_name = "MapLocation"; my $location_template_name = "MapLocation";
my $site_template_name = "MapSite"; my $site_template_name = "MapSite";
my $path_template_name = "MapPath";
my $border_width = 1; my $border_width = 1;
my $border_colour = 'black'; my $border_colour = 'black';
@ -299,6 +300,67 @@ foreach my $site_page_ref (values %{$site_query_results->{query}{pages}})
$grid->get_tile_at($nw, $sw)->pin($pin); $grid->get_tile_at($nw, $sw)->pin($pin);
} }
my (%path_specs);
say STDERR "Getting Path pages";
my $path_query_results = $mw->api
( {
action => 'query',
generator => 'categorymembers',
prop => 'info|revisions',
gcmtitle => 'Category:Paths',
gcmlimit => 'max',
rvprop => 'content',
inprop => 'url',
} ) || croak $mw->{error}->{code} . ': ' . $mw->{error}->{details};
foreach my $path_page_ref (values %{$path_query_results->{query}{pages}})
{
next if $path_page_ref->{title} =~ /^Category:/;
my $path_name = $path_page_ref->{title};
say STDERR "Processing Path $path_name";
my $path_url = $path_page_ref->{canonicalurl};
my $path_content = $path_page_ref->{revisions}[0]{'*'};
my $parsed_template = MWTemplate::Parse($path_content, $path_template_name);
next unless $parsed_template;
$path_specs{$path_name} =
{
id => "$path_name-path",
tile_page => "$path_name/Tiles",
colour => $parsed_template->{named_params}{colour},
stroke_width => $parsed_template->{named_params}{stroke_width}
};
}
say STDERR "Getting Path Tile pages";
my $path_tile_query_results = $mw->api
( {
action => 'query',
titles => join('|', map { $_->{tile_page} } values %path_specs),
prop => 'revisions',
rvprop => 'content',
} ) || croak $mw->{error}->{code} . ': ' . $mw->{error}->{details};
foreach my $page (values %{$path_tile_query_results->{query}{pages}})
{
my $content = $page->{revisions}[0]{'*'};
my ($path_name) = $page->{title} =~ /(.*)\/Tiles/;
say STDERR "Processing tiles for: $path_name";
my %path_spec = %{$path_specs{$path_name}};
my @path_coords;
foreach my $coords (split /;/, $content)
{
do { carp "Skipping bad spec: $coords"; next; } unless $coords =~ $coords_regex;
push @path_coords, [$1,$2];
}
$grid->make_path_from($path_spec{id}, \@path_coords, css_class => 'path',
colour => $path_spec{colour}, style => { 'stroke-width' => $path_spec{stroke_width} });
}
open (my $fh, "> $outfile") or croak "Couldn't open $outfile for writing: $!"; open (my $fh, "> $outfile") or croak "Couldn't open $outfile for writing: $!";

Loading…
Cancel
Save