From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
Aditya Mahajan <adityam@umich.edu>
Subject: Re: mp-geo Metapost package with ConTeXt
Date: Thu, 15 Jul 2021 19:58:56 +0200 [thread overview]
Message-ID: <ca1a3fa4-7379-4ca2-e3af-351be783c7cb@xs4all.nl> (raw)
In-Reply-To: <nycvar.YAK.7.78.908.2107151215280.837077@nqv-guvaxcnq>
On 7/15/2021 6:22 PM, Aditya Mahajan wrote:
> On Thu, 15 Jul 2021, Hans Hagen wrote:
>
>> On 7/14/2021 4:43 PM, Gavin wrote:
>>> Hello ConTeXters,
>>>
>>> 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/
>>>
>>> It looks like the last update was 2008 and I don’t read French, so I though
>> my chances of getting anything to work were pretty small. However, I was
>> pleasantly surprised that this MWE found the mp-geo package, the necessary
>> Metapost files in the ConTeXt installation, and the data files.
>>>
>>> \starttext
>>> \startMPcode
>>> input mp-geo;
>>> figure(-10u,-10u,10u,10u);
>>> Mercator(3,48,30);
>>> fin;
>>> end
>>> \stopMPcode
>>> \stoptext
>>>
>>> While all of the files were found, it did not produce a globe. Instead I got
>> an error complaining about an invalid character in the data files. This error
>> is repeated for about 20 files (a small fraction of the total). I put the
>> first error and its data file below. All the others are identical with
>> different .dat files.
>>>
>>> Maybe it’s just an encoding mismatch or a hidden character I can easily
>> delete or replace. On the other hand, maybe I shouldn't even be attempting
>> this? 2008 is a long time ago in ConTeXt time. Feel free to tell me this
>> project is crazy, but if you have an idea how I can make this work, I’d really
>> appreciate it! It looks like a fun package.
>> Looks interesting (I didn't know about it, also the surface stuff).
>> Anyway, the message relates to scantokens not liking what gets read from
>> a file, quite probably a missing file (I'll make it return a different
>> message but still one needs to be aware of the fact that fiel reading in
>> mp is kind of weird so it really expects a file).
>
> 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.
I was wondering about that too. I admit that I looked into maps years
ago but never could find quality data files.
\starttext
\startluacode
function mp.maptopath(filename)
local t = { cycle = true }
for x, y in
string.gmatch(io.loaddata(filename),"%(([%+%-%d]+),([%+%-%d]+)%)") do
t[#t+1] = { tonumber(x), tonumber(y) }
end
mp.inject.path(t)
end
\stopluacode
\startMPpage
draw lua.mp.maptopath("slovenia.dat") ;
\stopMPpage
\startMPpage
draw lua.mp.maptopath("usa1.dat") rotated 90 ;
\stopMPpage
\startMPpage
draw lua.mp.maptopath("usa2.dat") ;
\stopMPpage
\stoptext
way to low quality ... we also want multiple shapes i guess .. i wonder
if someone knows where to get good free data
(projections are more your turf)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2021-07-15 17:58 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 [this message]
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
[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=ca1a3fa4-7379-4ca2-e3af-351be783c7cb@xs4all.nl \
--to=j.hagen@xs4all.nl \
--cc=adityam@umich.edu \
--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).