ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Gavin <gavinpublic@comcast.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Hans Hagen <j.hagen@xs4all.nl>
Subject: Re: mp-geo Metapost package with ConTeXt
Date: Fri, 16 Jul 2021 10:20:31 -0600	[thread overview]
Message-ID: <4687ACFD-F694-4FA1-9B18-6A7881705D4B@comcast.net> (raw)
In-Reply-To: <ca1a3fa4-7379-4ca2-e3af-351be783c7cb@xs4all.nl>


[-- Attachment #1.1: Type: text/plain, Size: 2090 bytes --]

Hi Hans, Aditya, and all,

Me:
>>>> I’d like to use the mp-geo Metapost package with ConTeXt to draw simple
>>> globes viewed from various directions. The package is here:
>>>> 
>>>> 	https://melusine.eu.org/syracuse/poulecl/mp-geo/ <https://melusine.eu.org/syracuse/poulecl/mp-geo/>

Aditya:
>> Actually the data files are fairly simple:
>> no_of_points
>> <list of coordinates>
>> So, it would be much simpler to read and parse it via lua rather than scantokens. Rest of the code simply determines a "view" of what to show. So, it can be a good exercise in lua-MP interface.

Hans:
> I was wondering about that too. I admit that I looked into maps years ago but never could find quality data files.

This is great fun! I slightly altered Hans’ code to produce the most basic area preserving projection of North America (code and map below). If anyone else is playing with the mp-geo data, it is in arc minutes, so divide by 60 to get degrees.

For my book I only want 5cm diameter globes with continents, so the map data in the mp-geo package is far more detailed than I need. The code is so fast, the detail doesn’t seem to be a problem.

I just started learning Metapost a month ago, and it’s great. I know almost nothing about Lua, but this looks like a fun project for learning more!

Thanks!
Gavin


P.S. I marked the location of our local ConTeXt users group on the map, in case any of you want to visit.


\starttext

\startluacode
  function mp.maptopath(filename)
      local t = { cycle = true }
      for phi, theta in string.gmatch(io.loaddata(filename),"%(([%+%-%d]+),([%+%-%d]+)%)") do
          t[#t+1] = { math.cosd(tonumber(phi)/60)*tonumber(theta+6125)/12, tonumber(phi)/12 }
      end
      mp.inject.path(t)
  end
\stopluacode

\startMPpage
  fill lua.mp.maptopath("data/usa1.dat");
  fill lua.mp.maptopath("data/usa2.dat") ;
  fill lua.mp.maptopath("data/mexique.dat") ;
  fill lua.mp.maptopath("data/canada.dat") ;
  fill fullcircle scaled 5 shifted (0, 203) withcolor white;
\stopMPpage

\stoptext





[-- Attachment #1.2.1: Type: text/html, Size: 4105 bytes --]

[-- Attachment #1.2.2: HansMap.png --]
[-- Type: image/png, Size: 19847 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2021-07-16 16:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 14:43 Gavin
2021-07-15 15:48 ` Hans Hagen
2021-07-15 16:22   ` Aditya Mahajan
2021-07-15 17:58     ` Hans Hagen
2021-07-15 20:30       ` Bruce Horrocks
2021-07-16 19:55         ` Hans Hagen
2021-07-17  9:53           ` Bruce Horrocks
2021-07-17 10:20             ` Henning Hraban Ramm
2021-07-17 10:45               ` Hans Hagen
2021-07-17 11:05                 ` Henning Hraban Ramm
2021-10-22  9:31                 ` Henning Hraban Ramm via ntg-context
2021-10-22 13:35                   ` Hans Hagen via ntg-context
2021-10-22 14:16                   ` Henning Hraban Ramm via ntg-context
2021-10-22 14:27                     ` Hans Hagen via ntg-context
2021-07-17 10:53               ` Henning Hraban Ramm
2021-07-17 10:53               ` Hans Hagen
2021-07-17 12:42                 ` Arthur Rosendahl
2021-07-17 18:50                   ` Hans Hagen
2021-07-18 17:36                     ` Henning Hraban Ramm
2021-07-16 16:20       ` Gavin [this message]
     [not found]       ` <E1B2010C-A435-46AD-BD8E-F4D930827791@me.com>
2021-07-16 19:51         ` Hans Hagen
2021-07-16 20:08           ` Alan Braslau
2021-07-26 21:29             ` Gavin via ntg-context
2021-07-26 23:01               ` Aditya Mahajan via ntg-context
2021-07-27  6:12                 ` Gavin via ntg-context
2021-07-27  6:29                   ` Alan Braslau via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4687ACFD-F694-4FA1-9B18-6A7881705D4B@comcast.net \
    --to=gavinpublic@comcast.net \
    --cc=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).