/simplekml/constants.py

https://code.google.com/p/simplekml/ · Python · 311 lines · 214 code · 32 blank · 65 comment · 0 complexity · adcffd0ede77970eaa929e51ba2231a5 MD5 · raw file

  1. """
  2. Copyright 2011-2012 Kyle Lancaster
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. Contact me at kyle.lan@gmail.com
  14. """
  15. class AltitudeMode(object):
  16. """AltitudeMode constants."""
  17. clamptoground = "clampToGround"
  18. relativetoground = "relativeToGround"
  19. absolute = "absolute"
  20. class GxAltitudeMode(object):
  21. """gx:AltitudeMode constants."""
  22. clampToSeaFloor = "clampToSeaFloor "
  23. relativeToSeaFloor = "relativeToSeaFloor "
  24. class ColorMode(object):
  25. """ColorMode constants."""
  26. normal = "normal"
  27. random = "random"
  28. class DisplayMode(object):
  29. """DisplayMode constants."""
  30. default = "default"
  31. hide = "hide"
  32. class ListItemType(object):
  33. """ListItemType constants."""
  34. check = "check"
  35. radiofolder = "radioFolder"
  36. checkoffonly = "checkOffOnly"
  37. checkhidechildren = "checkHideChildren"
  38. class State(object):
  39. """State constants."""
  40. open = 'open'
  41. closed = 'closed'
  42. error = 'error'
  43. fetching0 = 'fetching0'
  44. fetching1 = 'fetching1'
  45. fetching2 = 'fetching2'
  46. class Units(object):
  47. """Units constants."""
  48. pixel = 'pixel'
  49. fraction = 'fraction'
  50. insetpixels = 'insetPixels'
  51. class Shape(object):
  52. """Shape constants."""
  53. rectangle = 'rectangle'
  54. circle = 'circle'
  55. sphere = 'sphere'
  56. class GridOrigin(object):
  57. """GridOrigin constants."""
  58. lowerleft = 'lowerLeft'
  59. upperleft = 'upperLeft'
  60. class RefreshMode(object):
  61. """RefreshMode constants."""
  62. onchange = 'onChange'
  63. oninterval = 'onInterval '
  64. onexpire = 'onExpire'
  65. class ViewRefreshMode(object):
  66. """ViewRefreshMode constants."""
  67. never = 'never '
  68. onstop = 'onStop '
  69. onrequest = 'onRequest '
  70. onregion = 'onRegion '
  71. class Types(object):
  72. """Types constants."""
  73. string = 'string'
  74. int = 'int'
  75. uint = 'uint'
  76. short = 'short'
  77. ushort = 'ushort'
  78. float = 'float'
  79. double = 'double'
  80. bool = 'bool'
  81. class Color(object):
  82. """Color constants (HTML and CSS) and converters.
  83. Constants:
  84. Same as HTML and CSS standard colors. All constants are lowercase.
  85. Class methods:
  86. * :func:`simplekml.Color.rgb`
  87. * :func:`simplekml.Color.hex`
  88. * :func:`simplekml.Color.hexa`
  89. * :func:`simplekml.Color.changealpha`
  90. """
  91. @classmethod
  92. def rgb(cls, r, g, b, a=255):
  93. """Convert rgba to GE hex value.
  94. Args:
  95. * r: int between 0 - 255 representing red
  96. * g: int between 0 - 255 representing green
  97. * b: int between 0 - 255 representing blue
  98. * a: int between 0 - 255 representing alpha (default 255)
  99. """
  100. return '%0.2x%0.2x%0.2x%0.2x' % (a, b, g, r)
  101. @classmethod
  102. def hex(cls, hstr):
  103. """Convert hex (without alpha) to GE hex value.
  104. Args:
  105. * hstr: hex string without alpha value
  106. """
  107. return "ff{0}".format(hstr[::-1])
  108. @classmethod
  109. def hexa(cls, hstr):
  110. """Convert hex (with alpha) to GE hex value.
  111. Args:
  112. * hstr: hex string without alpha value
  113. """
  114. return hstr[::-1]
  115. @classmethod
  116. def changealpha(cls, alpha, gehex):
  117. """Changes the alpha value of the given Google Earth hex value.
  118. Args:
  119. * alpha: aplha hex string
  120. * gehex: Google Earth hex string
  121. """
  122. return alpha + gehex[2:]
  123. aliceblue = 'fffff8f0'
  124. antiquewhite = 'ffd7ebfa'
  125. aqua = 'ffffff00'
  126. aquamarine = 'ffd4ff7f'
  127. azure = 'fffffff0'
  128. beige = 'ffdcf5f5'
  129. bisque = 'ffc4e4ff'
  130. black = 'ff000000'
  131. blanchedalmond = 'ffcdebff'
  132. blue = 'ffff0000'
  133. blueviolet = 'ffe22b8a'
  134. brown = 'ff2a2aa5'
  135. burlywood = 'ff87b8de'
  136. cadetblue = 'ffa09e5f'
  137. chartreuse = 'ff00ff7f'
  138. chocolate = 'ff1e69d2'
  139. coral = 'ff507fff'
  140. cornflowerblue = 'ffed9564'
  141. cornsilk = 'ffdcf8ff'
  142. crimson = 'ff3c14dc'
  143. cyan = 'ffffff00'
  144. darkblue = 'ff8b0000'
  145. darkcyan = 'ff8b8b00'
  146. darkgoldenrod = 'ff0b86b8'
  147. darkgray = 'ffa9a9a9'
  148. darkgrey = 'ffa9a9a9'
  149. darkgreen = 'ff006400'
  150. darkkhaki = 'ff6bb7bd'
  151. darkmagenta = 'ff8b008b'
  152. darkolivegreen = 'ff2f6b55'
  153. darkorange = 'ff008cff'
  154. darkorchid = 'ffcc3299'
  155. darkred = 'ff00008b'
  156. darksalmon = 'ff7a96e9'
  157. darkseagreen = 'ff8fbc8f'
  158. darkslateblue = 'ff8b3d48'
  159. darkslategray = 'ff4f4f2f'
  160. darkslategrey = 'ff4f4f2f'
  161. darkturquoise = 'ffd1ce00'
  162. darkviolet = 'ffd30094'
  163. deeppink = 'ff9314ff'
  164. deepskyblue = 'ffffbf00'
  165. dimgray = 'ff696969'
  166. dimgrey = 'ff696969'
  167. dodgerblue = 'ffff901e'
  168. firebrick = 'ff2222b2'
  169. floralwhite = 'fff0faff'
  170. forestgreen = 'ff228b22'
  171. fuchsia = 'ffff00ff'
  172. gainsboro = 'ffdcdcdc'
  173. ghostwhite = 'fffff8f8'
  174. gold = 'ff00d7ff'
  175. goldenrod = 'ff20a5da'
  176. gray = 'ff808080'
  177. grey = 'ff808080'
  178. green = 'ff008000'
  179. greenyellow = 'ff2fffad'
  180. honeydew = 'fff0fff0'
  181. hotpink = 'ffb469ff'
  182. indianred = 'ff5c5ccd'
  183. indigo = 'ff82004b'
  184. ivory = 'fff0ffff'
  185. khaki = 'ff8ce6f0'
  186. lavender = 'fffae6e6'
  187. lavenderblush = 'fff5f0ff'
  188. lawngreen = 'ff00fc7c'
  189. lemonchiffon = 'ffcdfaff'
  190. lightblue = 'ffe6d8ad'
  191. lightcoral = 'ff8080f0'
  192. lightcyan = 'ffffffe0'
  193. lightgoldenrodyellow = 'ffd2fafa'
  194. lightgray = 'ffd3d3d3'
  195. lightgrey = 'ffd3d3d3'
  196. lightgreen = 'ff90ee90'
  197. lightpink = 'ffc1b6ff'
  198. lightsalmon = 'ff7aa0ff'
  199. lightseagreen = 'ffaab220'
  200. lightskyblue = 'ffface87'
  201. lightslategray = 'ff998877'
  202. lightslategrey = 'ff998877'
  203. lightsteelblue = 'ffdec4b0'
  204. lightyellow = 'ffe0ffff'
  205. lime = 'ff00ff00'
  206. limegreen = 'ff32cd32'
  207. linen = 'ffe6f0fa'
  208. magenta = 'ffff00ff'
  209. maroon = 'ff000080'
  210. mediumaquamarine = 'ffaacd66'
  211. mediumblue = 'ffcd0000'
  212. mediumorchid = 'ffd355ba'
  213. mediumpurple = 'ffd87093'
  214. mediumseagreen = 'ff71b33c'
  215. mediumslateblue = 'ffee687b'
  216. mediumspringgreen = 'ff9afa00'
  217. mediumturquoise = 'ffccd148'
  218. mediumvioletred = 'ff8515c7'
  219. midnightblue = 'ff701919'
  220. mintcream = 'fffafff5'
  221. mistyrose = 'ffe1e4ff'
  222. moccasin = 'ffb5e4ff'
  223. navajowhite = 'ffaddeff'
  224. navy = 'ff800000'
  225. oldlace = 'ffe6f5fd'
  226. olive = 'ff008080'
  227. olivedrab = 'ff238e6b'
  228. orange = 'ff00a5ff'
  229. orangered = 'ff0045ff'
  230. orchid = 'ffd670da'
  231. palegoldenrod = 'ffaae8ee'
  232. palegreen = 'ff98fb98'
  233. paleturquoise = 'ffeeeeaf'
  234. palevioletred = 'ff9370d8'
  235. papayawhip = 'ffd5efff'
  236. peachpuff = 'ffb9daff'
  237. peru = 'ff3f85cd'
  238. pink = 'ffcbc0ff'
  239. plum = 'ffdda0dd'
  240. powderblue = 'ffe6e0b0'
  241. purple = 'ff800080'
  242. red = 'ff0000ff'
  243. rosybrown = 'ff8f8fbc'
  244. royalblue = 'ffe16941'
  245. saddlebrown = 'ff13458b'
  246. salmon = 'ff7280fa'
  247. sandybrown = 'ff60a4f4'
  248. seagreen = 'ff578b2e'
  249. seashell = 'ffeef5ff'
  250. sienna = 'ff2d52a0'
  251. silver = 'ffc0c0c0'
  252. skyblue = 'ffebce87'
  253. slateblue = 'ffcd5a6a'
  254. slategray = 'ff908070'
  255. slategrey = 'ff908070'
  256. snow = 'fffafaff'
  257. springgreen = 'ff7fff00'
  258. steelblue = 'ffb48246'
  259. tan = 'ff8cb4d2'
  260. teal = 'ff808000'
  261. thistle = 'ffd8bfd8'
  262. tomato = 'ff4763ff'
  263. turquoise = 'ffd0e040'
  264. violet = 'ffee82ee'
  265. wheat = 'ffb3def5'
  266. white = 'ffffffff'
  267. whitesmoke = 'fff5f5f5'
  268. yellow = 'ff00ffff'
  269. yellowgreen = 'ff32cd9a'