File:Metrication by year map.svg

From Wikimedia Commons, the free media repository

Jump to: navigation, search

Metrication_by_year_map.svg(SVG file, nominally 940 × 477 pixels, file size: 1.54 MB)

Description

World Map showing Metrication, colour-coded by year of conversion. Using data from USMA (U.S. Metric Association); Red is preliminary 1795, and green is 1998, following script has been used to generate the CSS:

#!/usr/bin/perl -w
 
use strict;
use warnings;
 
use Graphics::ColorObject;
use Math::Trig;
use SVG::Parser;
use CSS;
 
use constant DATE_MIN => 1795;
use constant DATE_MAX => 1998;
use constant HUE_START => 0;
use constant HUE_LENGTH => 120;
use constant SATURATION => 0.7;
use constant LIGHTNESS => 0.6;
use constant LEGEND_XLABEL_SIZE => 60;
use constant LEGEND_XPOS => 0;
use constant LEGEND_YPOS => 1250;
use constant LEGEND_XOFF => 100;
use constant LEGEND_YOFF => 50;
use constant LEGEND_WIDTH => 2752.766;
use constant LEGEND_HEIGHT => 250;
 
my $dates = {
	'1795' => [ 'fr' ],
	'1820' => [ 'nl', 'be', 'lu' ],
	'1840' => [ 'dz' ],
	'1853' => [ 'co', 'mc' ],
	'1858' => [ 'cu', 'es' ],
	'1862' => [ 'br', 'mx' ],
	'1863' => [ 'it', 'uy' ],
	'1865' => [ 'cl', 'ec' ],
	'1868' => [ 'pe', 'pr' ],
	'1871' => [ 'at', 'li' ],
	'1872' => [ 'de', 'pt' ],
	'1875' => [ 'no', 'cz', 'sk' ],
	'1876' => [ 'se', 'ch', 'hu', 'mk' ],
	'1878' => [ 'mu', 'sc' ],
	'1884' => [ 'sv', 'ro' ],
	'1886' => [ 'ar', 'fi' ],
	'1891' => [ 'bo', 'bg' ],
	'1893' => [ 'ni', 'tn' ],
	'1900' => [ 'is', 'py' ],
	'1908' => [ 'dk', 'cr' ],
	'1910' => [ 'bi', 'rw', 'cd' ],
	'1911' => [ 'hn' ],
	'1912' => [ 'dm' ],
	'1915' => [ 'gt', 'sm', 'pa', 've' ],
	'1916' => [ 'ph', 'sr' ],
	'1918' => [ 'pl', 'mn' ],
	'1920' => [ 'ht', 'mt' ],
	'1922' => [ 'kh', 'ma' ],
	'1923' => [ 'af', 'ly' ],
	'1925' => [ 'ru', 'cn' ],
	'1927' => [ 'ir' ],
	'1930' => [ 'iq', 'tr' ],
	'1934' => [ 'lb', 'sy' ],
	'1946' => [ 'id', 'th' ],
	'1948' => [ 'al', 'kr', 'il' ],
	'1952' => [ 'jo', 'tw' ],
	'1954' => [ 'in', 'sd' ],
	'1957' => [ 'jp', 'gr' ],
	'1959' => [ 'ci', 'gn' ],
	'1960' => [ 'cg', 'ne', 'sn', 'tg', 'td', 'ga', 'bj', 'mr', 'ml', 'mg', 'cf', 'bf', 'so' ],
	'1961' => [ 'cm', 'eg' ],
	'1962' => [ 'et', 'ng' ],
	'1963' => [ 'la', 'vn' ],
	'1964' => [ 'sa' ],
	'1965' => [ 'gb' ],
	'1967' => [ 'ke', 'ug', 'tz', 'ie', 'pk' ],
	'1968' => [ 'za' ],
	'1969' => [ 'au', 'nz' ],
	'1970' => [ 'ca' ],
	'1998' => [ 'jm' ]
};
my $css = new CSS( { 'parser' => 'CSS::Parse::Lite', 'adaptor' => 'CSS::Adaptor::Pretty' } ); 
 
my $svg=SVG::Parser->new()->parsefile($ARGV[0]);
my $css_container = $svg->getElementbyID('style_css_sheet');
$css->read_string( $css_container->{-CDATA} );
my $hue_start = deg2rad(HUE_START);
my $hue_length = deg2rad(HUE_LENGTH, 1);
foreach my $date( sort keys %$dates ) {
	my $hue = $hue_start + (1-(DATE_MAX - $date)/(DATE_MAX - DATE_MIN)) * $hue_length;
	$css->read_string( sprintf 
		"%s {\n\tfill: #%s;\n}\n",
		join (', ', map { ".$_" } @{$dates->{$date}}),
		Graphics::ColorObject->new_HSL([rad2deg($hue), SATURATION, LIGHTNESS])->as_RGBhex()
	);
}
$css->read_string( ".us, .mm, .lr { fill: #333333 } " );
 
$css->get_style_by_selector( '.landxx' )->get_property_by_name( 'stroke' )->{values} = [new CSS::Value({value => 'black'})];
$css->get_style_by_selector( '.landxx' )->get_property_by_name( 'fill' )->{values} = [new CSS::Value({value => '#FFFFD0'})];
$css->get_style_by_selector( '.lake' )->get_property_by_name( 'stroke' )->{values} = [new CSS::Value({value => '#1821DE'})];
$css->get_style_by_selector( '.ocean' )->get_property_by_name( 'fill' )->{values} = [new CSS::Value({value => '#9ec7f3'})];
my $coastxx = $css->get_style_by_selector( '.coastxx' );
$coastxx->add_property( new CSS::Property( { property => 'stroke', value => '#1821DE' } ) );
$coastxx->add_property( new CSS::Property( { property => 'stroke-opacity', value => '1.0' } ) );
$coastxx->add_property( new CSS::Property( { property => 'stroke-width', value => '0.5' } ) );
my $legend = $svg->group( 
	id => 'legend',
	transform => 'translate('.LEGEND_XPOS.','.LEGEND_YPOS.')'
);
my $gradient = $legend->gradient(
	-type => "linear",
	id    => "legend_gradient"
);
my $legend_box = $legend->rectangle(
	x     => 0, y      => 0,
	width => LEGEND_WIDTH, height => LEGEND_HEIGHT,
	rx    => 10, ry     => 10,
	id    => 'legend_box'
);
 
my $gradbox = $legend->rectangle(
	x     => LEGEND_XOFF, y      => LEGEND_YOFF,
	width => LEGEND_WIDTH - LEGEND_XOFF * 2, height => 100,
	id    => 'legend_grad'
);
 
{
	my $span = scalar keys %$dates;
	my $counter = 0;
	foreach my $date( sort keys %$dates ) {
		my $hue = $hue_start + (1-(DATE_MAX - $date)/(DATE_MAX - DATE_MIN)) * $hue_length;
		$gradient->stop(
			offset => sprintf( "%d%%", $counter / $span * 100 ),
			'stop-color' => '#'.Graphics::ColorObject->new_HSL([rad2deg($hue), SATURATION, LIGHTNESS])->as_RGBhex(),
		);
		++$counter;
	}
	my $datespan = DATE_MAX - DATE_MIN;
	foreach my $id(0..10) {
		my $xpos = LEGEND_XOFF + $id / 10 * (LEGEND_WIDTH - LEGEND_XOFF * 2);
		$legend->line(
			x1 => $xpos - 2,
			x2 => $xpos - 2,
			y1 => LEGEND_YOFF,
			y2 => 170,
			'stroke-width' => '4',
		);
		$legend->text( 
			x =>  $xpos - LEGEND_XLABEL_SIZE,
			y => 220,
			fill => 'black',
			'font-family' => 'sans-serif',
			'fill-opacity' => 1,
			'font-size' => LEGEND_XLABEL_SIZE,
			'stroke' => 'none',
		)->cdata(DATE_MIN + int($id/10 * $datespan) );
	}
}
 
 
 
$css->read_string( "#legend { fill: blue; fill-opacity: .3; stroke: black; stroke-width: 10; } " );
$css->read_string( "#legend_grad { fill: url(#legend_gradient); fill-opacity: 1; stroke: black; stroke-width: 1; } " );
 
$css_container->CDATA( "\n".$css->output() );
 
print $svg->xmlify();
Date

2009-03-18 23:35 (UTC)

Source
Author
Permission
(Reusing this image)

see below


I, the copyright holder of this work, hereby publish it under the following license:
Public domain I, the copyright holder of this work, hereby release it into the public domain. This applies worldwide.

In case this is not legally possible:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.


Afrikaans | Alemannisch | Aragonés | العربية | Asturianu | Azərbaycan | Беларуская (тарашкевіца) | Български | Català | Cebuano | Soranî / کوردی | Česky | Cymraeg | Dansk | Deutsch | Ελληνικά | English | Esperanto | Español | Eesti | Euskara | Estremeñu | فارسی | Suomi | Français | Galego | עברית | हिन्दी | Hrvatski | Magyar | Հայերեն | Bahasa Indonesia | Ido | Íslenska | Italiano | 日本語 | ქართული | ភាសាខ្មែរ | 한국어 | Ripoarisch | Kurdî / كوردی | Latina | Lietuvių | Latviešu | 文言 | Македонски | Bahasa Melayu | Plattdüütsch | Nederlands | ‪Norsk (nynorsk)‬ | ‪Norsk (bokmål)‬ | Polski | Português | Română | Русский | Slovenčina | Slovenščina | Shqip | Српски / Srpski | Svenska | ไทย | Tagalog | Türkçe | Українська | Vèneto | Tiếng Việt | Walon | 吴语 | 中文 | ‪中文(简体)‬ | ‪中文(繁體)‬ | 粵語 | +/−

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current02:21, 23 March 2009Thumbnail for version as of 02:21, 23 March 2009940×477 (1.54 MB)AzaToth (talk | contribs) (correctify the gradient)
02:13, 23 March 2009Thumbnail for version as of 02:13, 23 March 2009940×477 (1.54 MB)AzaToth (talk | contribs) (don't want to have ugly gray there :/)
02:11, 23 March 2009Thumbnail for version as of 02:11, 23 March 2009940×477 (1.54 MB)AzaToth (talk | contribs) (forgot to readd the ocean color)
02:07, 23 March 2009Thumbnail for version as of 02:07, 23 March 2009940×477 (1.54 MB)AzaToth (talk | contribs) (updated with legend)
23:37, 18 March 2009Thumbnail for version as of 23:37, 18 March 2009940×477 (1.53 MB)AzaToth (talk | contribs) ({{Information |Description=World Map showing Metrication, colour-coded by year of conversion. Using data from USMA (U.S. Metric Association); Red is preliminary 1795, and green is 1998, following script has been used to generate the CSS: <script language=)

There are no pages that link to this file.