Isoraqathedh

planet.ahk

Jul 17th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     GUI frontend for planet.exe
  3. */
  4.  
  5. /*
  6.  
  7. Usage: planet [options]
  8.  
  9. options:
  10.  
  11.   -s seed       Specifies seed as number between 0.0 and 1.0
  12.   -w width      Specifies width in pixels, default = 800
  13.   -h height     Specifies height in pixels, default = 600
  14.   -m magnification  Specifies magnification, default = 1.0
  15.   -o output_file    Specifies output file, default is standard output
  16.   -l longitude      Specifies longitude of centre in degrees, default = 0.0
  17.   -L latitude       Specifies latitude of centre in degrees, default = 0.0
  18.   -g gridsize       Specifies vertical gridsize in degrees, default = 0.0 (no grid)
  19.   -G gridsize       Specifies horisontal gridsize in degrees, default = 0.0 (no grid)
  20.   -i init_alt       Specifies initial altitude (default = -0.02)
  21.   -c            Colour depends on latitude (default: only altitude)
  22.   -C file       Read colour definitions from file
  23.   -O            Produce a black and white outline map
  24.   -E            Trace the edges of land in black on colour map
  25.   -B            Use ``bumpmap'' shading
  26.   -b            Use ``bumpmap'' shading on land only
  27.   -d                Use ``daylight'' shading
  28.   -a angle      Angle of ``light'' in bumpmap shading
  29.                     or longitude of sun in daylight shading
  30.   -A latitude       Latitude of sun in daylight shading
  31.   -P            Use PPM file format (default is BMP)
  32.   -x            Use XPM file format (default is BMP)
  33.   -V number         Distance contribution to variation (default = 0.035)
  34.   -v number         Altitude contribution to variation (default = 0.45)
  35.   -p projection     Specifies projection: m = Mercator (default)
  36.                       p = Peters
  37.                       q = Square
  38.                       s = Stereographic
  39.                       o = Orthographic
  40.                       g = Gnomonic
  41.                       a = Area preserving azimuthal
  42.                       c = Conical (conformal)
  43.                       M = Mollweide
  44.                       S = Sinusoidal
  45.                       h = Heightfield
  46.                           i = Icosahedral
  47.                       f = Find match, see below
  48.                      
  49. */
  50.  
  51. #SingleInstance force
  52.  
  53. GUI font, s9, Segoe UI
  54.  
  55. ;{ planet.exe options
  56. GUI add, text, , Seed (0 ~ 1, omit 0.)
  57. GUI add, edit, xp+200 yp vseed number w150, 11111 ; -s seed
  58. GUI add, text, xm, Width (px)
  59. GUI add, edit, xp+200 yp vwidth number w150, 800 ; -w width
  60. GUI add, text, xm, Height (px)
  61. GUI add, edit, xp+200 yp vheight number w150, 600 ; -h height
  62. GUI add, text, xm, Magnification (×)
  63. GUI add, edit, xp+200 yp vmagnification w150, 1 ; -m magnification
  64. ; output is downloads\mover -o out
  65. GUI add, text, xm, Centred longitude (°)
  66. GUI add, edit, xp+200 yp w150, 0 ; -l longitude
  67. GUI add, UpDown, vlongitude Range-360-360 ; -g Gridsize
  68. GUI add, text, xm, Centred latitude (°)
  69. GUI add, edit, xp+200 yp w150, 0 ; -L latitude
  70. GUI add, UpDown, vlatitude Range-90-90 ; -G gridsize
  71.  
  72. GUI add, text, xm, Degrees per vertical gridline (°)
  73. GUI add, DDL, xp+200 yp w150 vvertGridline, 0||1|2|3|5|6|10|15|20|30|45|60|90 ; -g Gridsize
  74. GUI add, text, xm, Degrees per horizontal gridline (°)
  75. GUI add, DDL, xp+200 yp w150 vhorizGridline, 0||1|2|3|5|6|10|15|20|30|45 ; -G gridsize
  76. GUI add, text, xm, Amount of Land
  77. ;~ GUI add, edit, xp+200 yp vseaLevel w150, -0.2 ; -i *(multiply this number by 0.1 before exporting!!!)
  78. GUI add, text, vMinSlider yp xp, None
  79. GUI add, text, vMaxSlider yp xp, Lots
  80. GUI add, Slider, Range-1000-1000 xp+200 yp vseaLevel w150 Buddy1MinSlider Buddy2MaxSlider tickinterval200 ToolTipLeft Page200, -200 ; -i *(multiply this number by 0.0001 before exporting!!!)
  81.  
  82. GUI add, text, xm, Projection type
  83. GUI add, DDL, xp+200 yp sort vProjectionType w150
  84.     , Mercator|Peters|Square|Stereographic|Orthographic|Gnomonic|Area-preserving azimuthal|Conical|Mollweide||Sinusoidal|Heightfield|Icosahedral
  85. ; m, p, q, s, o, g, a, c, M, S, h, i
  86.  
  87. GUI add, text, xm, Colour Scheme
  88. GUI add, DDL, xp+200 yp sort vColourScheme w150
  89.     , Olsson.col|default.col|defaultB.col|burrows.col|burrowsB.col|Lefebvre.col||Lefebvre2.col|mars.col|wood.col|white.col
  90.  
  91. GUI add, groupbox, r4 w350 xm, Daylight option
  92. GUI add, checkbox, vsunshade xp+15 yp+25, Shade by sun ; -d
  93. GUI add, text, xm+15 y+10, Sun longitude
  94. GUI add, edit, xp+185 w135, 0 ; -a
  95. GUI add, UpDown, vsunLongitude Range-360-360
  96. GUI add, text, xm+15 y+5, Sun latitude
  97. GUI add, edit, xp+185 w135, 0 ; -A
  98. GUI add, UpDown, vsunLatitude Range-90-90
  99.  
  100. GUI add, checkbox, vcolouringDependsLatitude xm, Colour depends on latitude ; -c
  101. GUI add, checkbox, voutlineOnly, Produce a black and white outline map ; -O
  102. GUI add, checkbox, vblackCoastlines, Trace the edges of land in black on colour map ; -E
  103.  
  104. /*
  105. GUI add, groupbox, r8, Bumpmap shading
  106. GUI add, radio, xm+15 yp+15 vBumpNone, No bumpmap shading
  107. GUI add, radio, vBumpAll, Bumpmap shading on land and sea
  108. GUI add, radio, vBumpLand, Bumpmap shading on land only
  109. */
  110. ;}
  111.  
  112. ;{ Imagemagick options
  113. GUI add, Groupbox, xm+400 ym w350 r3.5 section, External border
  114. GUI add, radio, xp+15 yp+25 vBorderNone Checked, None
  115. GUI add, radio, vBorderInclude, Include within dimensions
  116. GUI add, radio, vBorderExclude, Append outside dimensions
  117. GUI add, Groupbox, xs w350 r4.5 section, Scale Bar
  118. GUI add, radio, xp+15 yp+25 vScaleBarNone Checked, No scale bar
  119. GUI add, radio, vScaleBarBelow, Scale bar outside image
  120. GUI add, radio, vScaleBarInside, Scale bar inside image
  121. GUI add, checkbox, vScaleBarDisclaimer disabled, Insert scale bar disclaimer text
  122. GUI add, checkbox, vshowCommand xs, Show Command used (debug)
  123. ;}
  124.  
  125.  
  126.  
  127. GUI add, button, xm w150 gBegin section, OK
  128. GUI add, button, ys xs+160 w150 gEnd, Cancel
  129. GUI show, Center, planet.exe
  130. Return
  131.  
  132. Begin:
  133. GUI submit
  134. ; ---
  135. ; Remake the options
  136. FormatTime, currTime, , yyyyMMddHHmmss
  137. currTime = Z:\Documents\Junk\maps\%currTime%-%seed%
  138. seed           = -s 0.%seed%
  139. width         := width         = 800  ? "" : " -w " width
  140. height        := height        = 600  ? "" : " -h " height
  141. magnification := magnification = 1    ? "" : " -m " magnification
  142. longitude     := longitude     = 0    ? "" : " -l " longitude
  143. latitude      := latitude      = 0    ? "" : " -L " latitude
  144. vertGridline  := vertGridline  = 0    ? "" : " -g " vertGridline
  145. horizGridline := horizGridline = 0    ? "" : " -G " horizGridline
  146. seaLevel      := seaLevel      = -0.2 ? "" : " -i " (seaLevel / 10000)
  147. projection    := projectionType = "Mercator" ? ""
  148.     : projectionType = "Peters" ? " -pp "
  149.     : projectionType = "Square" ? " -pq "
  150.     : projectionType = "Stereographic" ? " -ps "
  151.     : projectionType = "Orthographic" ? " -po "
  152.     : projectionType = "Gnomonic" ? " -pg"
  153.     : projectionType = "Area-preserving azimuthal" ? " -pa "
  154.     : projectionType = "Conical" ? " -pc "
  155.     : projectionType = "Mollweide" ? " -pM "
  156.     : projectionType = "Sinusoidal" ? " -pS "
  157.     : projectionType = "Heightfield" ? " -ph "
  158.     : projectionType = "Icosahedral" ? " -pi " : ""
  159. ColourScheme := ColourScheme = "Olsson.col" ? "" : " -C " ColourScheme
  160.    
  161. if sunshade
  162.     sunshade := " -d -a " sunLongitude " -A " sunLatitude, altPiping := true
  163. else
  164.     sunshade =
  165.  
  166. options := seed . width . height . magnification . longitude . latitude . vertGridline
  167.     . horizGridline . seaLevel . projection . ColourScheme . sunshade
  168. ; ---
  169. ; concat 'em and throw them into the program; pipe it to pngout for maximum pngness
  170. initCommands = echo Options: %options% && pause && planet.exe %options% ;Common command core
  171.  
  172. if BorderInclude ;borders
  173.     crop = -shave 76x76 -bordercolor black -border 1 -bordercolor white -border 75
  174. else if BorderExclude
  175.     crop = -bordercolor black -border 1 -bordercolor white -border 75
  176. else
  177.     crop =
  178.    
  179. if ScaleBarBelow ;scale bar.
  180.     scaleBar = -background white -gravity South -splice 0x40 scaleWhite.png -gravity East -append
  181. else if ScaleBarInside
  182.     scaleBar = - | composite -gravity SouthEast scale.png -
  183. else
  184.     crop =
  185.    
  186. pngout = pngout - %currTime%.png
  187. display = %currTime%.png
  188. workingDir = C:\Program Files (x86)\planet\
  189.  
  190. if altPiping ; planet.exe seems to have trouble stdouting .bmp files if sun shading is activated.
  191.     command = %initCommands% -o %currTime%.bmp && convert %currTime%.bmp %crop% %scaleBar% png:- | %pngout% && %display%
  192. else
  193.     command = %initCommands% | convert bmp:- %crop% %scaleBar% png:- | %pngout% && %display%
  194. ifEqual showCommand, 1, MsgBox %command%
  195. else, RunWait %comspec% /c "%command%", %workingDir%
  196. FileDelete %currTime%.bmp ; The BMP is temp and wasting useless space anyway.
  197.  
  198. ; Bleed through
  199.  
  200. End:
  201. GUI Destroy
  202. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment