Author Topic: World map  (Read 6285 times)

0 Members and 1 Guest are viewing this topic.

Offline dickel

  • Newbie
  • Posts: 8
    • View Profile
World map
« on: October 15, 2018, 09:06:51 am »
New member here.
I have a requirement for a world map, Mercator-type projection, showing continental outlines - in the form of a 360 x 180 'dot' array to be used as an on-screen overlay for previously calculated data.  Does anyone know where I might find such an array?

Attached is an image of the general idea.

FellippeHeitor

  • Guest
Re: World map
« Reply #1 on: October 15, 2018, 10:19:09 am »
I don't remember anyone doing anything similar to what you need, though. Hope something will appear.

Welcome to the forum.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: World map
« Reply #2 on: October 15, 2018, 11:26:48 am »
Well if this is not homework I have something:


Oh and here's a txt file of O's and X's:
« Last Edit: October 15, 2018, 11:57:30 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: World map
« Reply #3 on: October 15, 2018, 03:51:00 pm »
Hey! What did you do with Tasmainia? (... and on a lesser note, New Zealand?)
Logic is the beginning of wisdom.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: World map
« Reply #4 on: October 15, 2018, 04:38:10 pm »
Something tells me this *is* homework (without some more background elaboration on the OP's end) - and not to mention, I bet Ashish could solve this in seconds. I've seen him do similar.
You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: World map
« Reply #5 on: October 15, 2018, 05:01:31 pm »
If this is a case of needing to plot points (such as for the guy who created weather maps over at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] before it was shut down), the center looks like it should be the middle of the map, so _SCREENWIDTH \ 2, _SCREENHEIGHT \ 2 would give point 0,0....  To plot points, just calculate their distance from there. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline dickel

  • Newbie
  • Posts: 8
    • View Profile
Re: World map
« Reply #6 on: October 15, 2018, 06:21:54 pm »
Thanks for all your replies.  Homework?  Where did that come from?  Nope, not homework!  Here's the background. 

About 25 years ago I re-wrote an existing HF radio propagation program.  The original calculated only between two fixed points — a transmitter and a receiver.  I re-wrote it to calculate from a single point (receiver) to all other points on the earth's surface at fifteen degree intervals.  (Point of interest — that version took 5 days to run on a 2Mhz Motorola MC6809 running XBASIC.)  Several years ago (when machines started to get seriously fast) I changed that to calculate at one degree intervals, i.e., a 360 x 180 map.  (I don't know how to grab a screenshot of the result but will do so when I figure it out.)

A couple of months ago I came across this site and decided to try the program again — it ran just fine and super fast too — about 5 seconds!  I never did get around to overlaying the screen plot with a world map but I am intending to do that now.

Looks to me like bplus is on the mark and I will see what I can do with his text file as that seems the best way to go.  My map is centered on 180 degrees (roughly New Zealand) so I will need to rearrange.  Thanks again.

(Yes, NZ would be a great addition (and on a lesser note, Tasmania).  Ha!  (Kiwi)

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: World map
« Reply #7 on: October 15, 2018, 06:55:38 pm »
My bad on the homework thing - I mean, you know how this question was sounding. Can't blame us (me)! Anyway, welcome aboard.

Lemme make one question-comment... are you trying to get accurate distances on the globe using a Mercator projection? Cause... you can't right? My humble understanding of geometry (taking the earth as a sphere) dictates that you need to correct for the actual shape of the planet using a suitable coordinate system.

If you've done so, then great. If this sounds foreign, then imagine a 6 inch line in the map drawn just under the north pole. How many miles long is that? Next imagine the same-length line drawn horizontally near the equator. That one will represent way more miles.

So that's the comment. The question is: what's your distance formula?

-STx
You're not done when it works, you're done when it's right.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: World map
« Reply #8 on: October 15, 2018, 07:21:44 pm »
Here is code, should be easy to modify if you get a map with NZ and Hawaii!

Code: QB64: [Select]
  1. _TITLE "get points from map.bas for QB64 by B+ 2018-10-15"
  2. CONST mw = 700 'map width
  3. CONST mh = 391 ' map hieght
  4. SCREEN _NEWIMAGE(700, 391, 32) 'these were map dimensions from file properties setting up a graphics screen for map
  5. m& = _LOADIMAGE("map.png") 'load map
  6. _PUTIMAGE , m& 'fill screen with map 1 to 1 ratio
  7.  
  8. 'now find corners of map inside frame borders
  9. PRINT "Click top left corner."
  10. getClick tlx, tly, qkeycode '                    top corner: tlx = top left x, tly = top left y
  11.  
  12. PRINT "Ok now click bottom right corner."
  13. getClick brx, bry, qkeycode '                    bottom right corner: brx, bry
  14. 'debug check our clicked points
  15. 'PRINT tlx, tly, brx, bry
  16.  
  17. 'using corners divide distance left x and right x by 360
  18. dx## = (brx - tlx) / 360
  19. 'using corners divide distance bottom y to top y  by 180
  20. dy## = (bry - tly) / 180
  21.  
  22. 'map dots array
  23. DIM mp(360, 180)
  24.  
  25. 'for color of point x, y
  26.  
  27. 'fill array with point data 1 or 0 depending if line there or not
  28. FOR y = 0 TO 180
  29.     FOR x = 0 TO 360
  30.         ding = 0 'signal a line hit in area
  31.  
  32.         'search around the dot for a line, otherwise too mang gaps in outlines
  33.         FOR yy = -1 TO 0 'try -1 to 1, -1 to 0, or 0 to 0   to adjust number of dots on same line
  34.             FOR xx = -1 TO -1 'try -1 to 1, -1 to 0, or 0 to 0  to adjust number of dots on same line
  35.                 p = POINT(INT(tlx + x * dx##) + xx, INT(tly + y * dy##) + yy)
  36.                 IF _RED32(p) < 100 AND _GREEN32(p) < 100 AND _BLUE32(p) < 100 THEN ding = 1: GOTO skipout
  37.             NEXT
  38.         NEXT
  39.         skipout:
  40.         IF ding THEN mp(x, y) = 1 ELSE mp(x, y) = 0
  41.  
  42.     NEXT
  43.  
  44. 'draw map of dots exactly where the map.png was set
  45. FOR y = 0 TO 180
  46.     FOR x = 0 TO 360
  47.         IF mp(x, y) = 1 THEN PSET (tlx + x * dx##, tly + y * dy##), _RGB32(255, 255, 255)
  48.     NEXT
  49.  
  50. 'frame the dots in a box
  51. LINE (tlx, tly)-(brx, bry), _RGB32(0, 0, 200), B
  52. LINE (tlx + 180 * dx##, tly)-(tlx + 180 * dx##, bry), _RGB32(0, 0, 200)
  53. LINE (tlx, tly + 90 * dy##)-(brx, tly + 90 * dy##), _RGB32(0, 0, 200)
  54.  
  55. 'Write results to file, actually this is 361 x data points by 181 y data points
  56. OPEN "360 x 180 dot array.txt" FOR OUTPUT AS #1
  57. FOR y = 0 TO 180
  58.     FOR x = 0 TO 360
  59.         IF mp(x, y) THEN PRINT #1, "X"; ELSE PRINT #1, "O";
  60.     NEXT
  61.     PRINT #1, ""
  62.  
  63. 'this gets mouse click location
  64. SUB getClick (mx, my, q)
  65.     WHILE _MOUSEINPUT: WEND ' clear previous mouse activity
  66.     mx = -1: my = -1: q = 0
  67.     DO WHILE mx = -1 AND my = -1
  68.         q = _KEYHIT
  69.         IF q = 27 OR (q > 31 AND q < 126) THEN EXIT SUB
  70.         i = _MOUSEINPUT: mb = _MOUSEBUTTON(1)
  71.         IF mb THEN
  72.             DO WHILE mb 'wait for release
  73.                 q = _KEYHIT
  74.                 IF q = 27 OR (q > 31 AND q < 126) THEN EXIT SUB
  75.                 i = _MOUSEINPUT: mb = _MOUSEBUTTON(1): mx = _MOUSEX: my = _MOUSEY
  76.                 _LIMIT 1000
  77.             LOOP
  78.             EXIT SUB
  79.         END IF
  80.         _LIMIT 1000
  81.     LOOP
  82.  
  83.  
« Last Edit: October 15, 2018, 07:27:19 pm by bplus »

Offline dickel

  • Newbie
  • Posts: 8
    • View Profile
Re: World map
« Reply #9 on: October 15, 2018, 08:05:28 pm »
Thanks bplus.  It so happens that I DO have a map with more detail (NZ AND Tasmania!) but it also has a lot of "flyspots" on it which will require a tidy-up first.  I'll give it a shot. . .

Offline dickel

  • Newbie
  • Posts: 8
    • View Profile
Re: World map
« Reply #10 on: October 15, 2018, 08:23:22 pm »
Quote
My bad on the homework thing - I mean, you know how this question was sounding. Can't blame us (me)! Anyway, welcome aboard.

Lemme make one question-comment... are you trying to get accurate distances on the globe using a Mercator projection? Cause... you can't right? My humble understanding of geometry (taking the earth as a sphere) dictates that you need to correct for the actual shape of the planet using a suitable coordinate system.

If you've done so, then great. If this sounds foreign, then imagine a 6 inch line in the map drawn just under the north pole. How many miles long is that? Next imagine the same-length line drawn horizontally near the equator. That one will represent way more miles.

So that's the comment. The question is: what's your distance formula?

Thanks STx.  I don't see how "homework" came into it — must be something between the lines that I can't see — but hey, no problem at all.

No, the distances are all calculated internally for a 'spherical' earth (using high-falutin' trig functions that I couldn't possibly understand!) but the RESULTS are plotted on a 360 x 180 map — hence "Mercator" projection.

I'll see if I can find a link to the original program: "MicroMUF".

Offline dickel

  • Newbie
  • Posts: 8
    • View Profile
Re: World map
« Reply #11 on: October 15, 2018, 09:07:34 pm »
Screenshot was easier than I thought!

Two plots on screen:  Top represents Maximum Usable Frequency (MUF); Bottom represents Absorption Limiting Frequency (ALF).
"Maps" are centered on equator and 180 degrees with a 15-degree grid.  Legend stuff at the bottom.

A white "continental outline" overlay will be nice!

Best
Dick

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: World map
« Reply #12 on: October 15, 2018, 09:23:49 pm »
Hi dickel,

Another way to try is transparent colors over a map background.

Offline dickel

  • Newbie
  • Posts: 8
    • View Profile
Re: World map
« Reply #13 on: October 15, 2018, 09:34:55 pm »
Here's the right one WITH the legend stuff — used only "Dos" available colors.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: World map
« Reply #14 on: October 15, 2018, 10:12:40 pm »
Beautifully retro!

I think I see what you're up to on this mission. We're all tuned in, so keep up the flow.

As for the homework thing, the red flag, so to speak, is when someone pops in out of the blue, and asks a straightforward question about... well... hm... Maybe to answer this, I defer to the supreme court's definition of pornography. I can't define it, but I know it when I see it. They were wrong about that, and so was I in this case.
You're not done when it works, you're done when it's right.