Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Inspired by the Debian Developer's Center of Mass, I've taken the monk position list from PM Statistics via XML, parsed it and did some basic math calculations, then used the program XPlanet to generate the needed views, all to calculate and locate the center of mass for the registered Perlmonks.

Short story: ignoring the fact that it's probably buried a few miles into the earth, the center of mass is somewhere in northern Quebec, near the southern tip of Hudson Bay. The specific coordinates are 53.19 deg N, 75.25 deg W. Notice that there are a few monks with rather questionable locations (like, middle of the Indian/Pacific oceans), but these probably aren't pulling the average that far out of whack.

If you don't see what you think is you position, please visit PM Statistics to find out how to get yourself located, such that future generations of these images will include you.

Currently, you can see the maps here and here. jcwren has considered adding this to his PM Stats pages as well, since it's sort of an obvious extention to it.

Update - I've now done the NA and EU 'subsets' for center of mass; the maps are here for NA and here for EU. Respectively, the centers of mass are at 40.89N, 93.46W (About 40 miles south of Des Moines, Iowa), and 51.05N, 4.8E (About 20 miles NE of Bruselles, Belguim). Additionally, I worked out the 'depth' of these points, assuming about 3900 mile radius of the earth; The overall center of mass is about 829 miles deep, the NA one is 129 miles deep, and the EU one is only 25 miles deep.

For those interested, here's the code that I used to generate the maps above; the code that might end on jcwren's box might be subtly different.

#!/usr/bin/perl -w use strict; use LWP::Simple; use XML::Simple; use POSIX qw(atan2); my $xml = ""; # Step 1 : Get data my $data = get( $xml ); my $ref = XMLin( $data ); # Step 2 : Calculate Center of Mass, need to write out coordinates too my $coordfile = "monk.coord"; open FILE, ">$coordfile" or die $!; my ( $total, $avg_x, $avg_y, $avg_z ) = ( 0,0,0,0 ); foreach my $monk ( keys %{ $ref->{ monk } } ) { my $lat = $ref->{ monk }->{ $monk }->{ location }->{ latitude }; my $long = $ref->{ monk }->{ $monk }->{ location }->{ longitude }; print FILE "$lat $long color=white\n"; $lat *= 3.14159/180; $long *= 3.14159/180; $total++; $avg_x += cos( $lat ) * sin( $long ); $avg_y += -cos( $lat ) * cos( $long ); $avg_z += sin( $lat ); } $avg_x = $avg_x/$total; $avg_y = $avg_y/$total; $avg_z = $avg_z/$total; close FILE; my $lat_av = atan2( $avg_z, sqrt( $avg_x*$avg_x + $avg_y*$avg_y ) ); my $long_av = atan2( $avg_x, -$avg_y ); $lat_av *= 180/3.14159; $long_av *= 180/3.14159; # Step 3: Write arcs to file my $arcfile = "monk.arcs"; open FILE, ">$arcfile" or die $!; foreach my $monk ( keys %{ $ref->{ monk } } ) { my $lat = $ref->{ monk }->{ $monk }->{ location }->{ latitude }; my $long = $ref->{ monk }->{ $monk }->{ location }->{ longitude }; printf FILE "%+8.2f %+8.2f %+8.2f %+8.2f color=ForestGreen spacing +=0.5\n", $lat, $long, $lat_av, $long_av; } close FILE; my $avgfile = "monk.avg"; open FILE, ">$avgfile" or die $!; printf FILE "%+8.2f %+8.2f \"Average\" color=white\n", $lat_av, $long_ +av; close FILE; # Step 4 : Run xplanet my $mercator_map = "map1.png"; my $globe_map = "map2.png"; my $caption = "Copyright Michael K. Neylon -- Generated on " . localti +me(time); my $lat_long = sprintf "Average location: Latitude %+3.2f, Longitude %+3.2f", $lat_av, $lon +g_av; my $capfile = "monks.cap"; open FILE, ">$capfile" or die $!; print FILE "15 15 \"$caption\" image=none position=pixel color=yellow\ +n"; print FILE "580 15 \"$lat_long\" image=none position=pixel color=yello +w\n"; close FILE; my $capfile2 = "monks2.cap"; open FILE, ">$capfile2" or die $!; print FILE "15 15 \"$caption\" image=none position=pixel color=darkred +\n"; print FILE "580 15 \"$lat_long\" image=none position=pixel color=darkr +ed\n"; close FILE; my $mercator_command = qq( xplanet -markerfile $coordfile -markerfile $avgfile -long $long_ +av -greatarcfile $arcfile -shade 100 -output $mercator_map -geometry + 800x600 -grid -projection mercator -markerfile $capfile2 -grid1 6 -grid2 +5 ); my $globe_command = qq( xplanet -markerfile $coordfile -markerfile $avgfile -long $long_ +av -lat $lat_av -greatarcfile $arcfile -output $globe_map -geometry +800x600 -starfreq 0 -grid -proj hemisphere -shade 100 -markerfile $capfil +e -grid1 6 -grid2 5 ); # Strip those returns... I like my code neat. $mercator_command =~ s/\n/ /g; $globe_command =~ s/\n/ /g; system $mercator_command; system $globe_command; 1;

Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain

In reply to The Center of PerlMonk Mass by Masem

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (4)
    As of 2018-05-25 01:57 GMT
    Find Nodes?
      Voting Booth?