metadata.py 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  1. """!@package grass.temporal
  2. @brief GRASS Python scripting module (temporal GIS functions)
  3. Temporal GIS related metadata functions to be used in Python scripts and tgis packages.
  4. Usage:
  5. @code
  6. >>> import grass.temporal as tgis
  7. >>> tgis.init()
  8. >>> meta = tgis.RasterMetadata()
  9. >>> meta = tgis.Raster3DMetadata()
  10. >>> meta = tgis.VectorMetadata()
  11. >>> meta = tgis.STRDSMetadata()
  12. >>> meta = tgis.STR3DSMetadata()
  13. >>> meta = tgis.STVDSMetadata()
  14. @endcode
  15. (C) 2012-2013 by the GRASS Development Team
  16. This program is free software under the GNU General Public
  17. License (>=v2). Read the file COPYING that comes with GRASS
  18. for details.
  19. @author Soeren Gebbert
  20. """
  21. from base import *
  22. ###############################################################################
  23. class RasterMetadataBase(SQLDatabaseInterface):
  24. """!This is the metadata base class for time stamped raster and raster3d maps
  25. Usage:
  26. @code
  27. >>> init()
  28. >>> meta = RasterMetadataBase(table="metadata", ident="soil@PERMANENT",
  29. ... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
  30. ... ewres=0.1, min=0, max=100)
  31. >>> meta.datatype
  32. 'CELL'
  33. >>> meta.cols
  34. 100
  35. >>> meta.rows
  36. 100
  37. >>> meta.number_of_cells
  38. 10000
  39. >>> meta.nsres
  40. 0.1
  41. >>> meta.ewres
  42. 0.1
  43. >>> meta.min
  44. 0.0
  45. >>> meta.max
  46. 100.0
  47. >>> meta.print_info()
  48. | Datatype:................... CELL
  49. | Number of columns:.......... 100
  50. | Number of rows:............. 100
  51. | Number of cells:............ 10000
  52. | North-South resolution:..... 0.1
  53. | East-west resolution:....... 0.1
  54. | Minimum value:.............. 0.0
  55. | Maximum value:.............. 100.0
  56. >>> meta.print_shell_info()
  57. datatype=CELL
  58. cols=100
  59. rows=100
  60. number_of_cells=10000
  61. nsres=0.1
  62. ewres=0.1
  63. min=0.0
  64. max=100.0
  65. @endcode
  66. """
  67. def __init__(self, table=None, ident=None, datatype=None, cols=None,
  68. rows=None, number_of_cells=None, nsres=None, ewres=None,
  69. min=None, max=None):
  70. SQLDatabaseInterface.__init__(self, table, ident)
  71. self.set_id(ident)
  72. self.set_datatype(datatype)
  73. self.set_cols(cols)
  74. self.set_rows(rows)
  75. self.set_number_of_cells(number_of_cells)
  76. self.set_nsres(nsres)
  77. self.set_ewres(ewres)
  78. self.set_min(min)
  79. self.set_max(max)
  80. def set_id(self, ident):
  81. """!Convenient method to set the unique identifier (primary key)"""
  82. self.ident = ident
  83. self.D["id"] = ident
  84. def set_datatype(self, datatype):
  85. """!Set the datatype"""
  86. self.D["datatype"] = datatype
  87. def set_cols(self, cols):
  88. """!Set the number of cols"""
  89. if cols is not None:
  90. self.D["cols"] = int(cols)
  91. else:
  92. self.D["cols"] = None
  93. def set_rows(self, rows):
  94. """!Set the number of rows"""
  95. if rows is not None:
  96. self.D["rows"] = int(rows)
  97. else:
  98. self.D["rows"] = None
  99. def set_number_of_cells(self, number_of_cells):
  100. """!Set the number of cells"""
  101. if number_of_cells is not None:
  102. self.D["number_of_cells"] = int(number_of_cells)
  103. else:
  104. self.D["number_of_cells"] = None
  105. def set_nsres(self, nsres):
  106. """!Set the north-south resolution"""
  107. if nsres is not None:
  108. self.D["nsres"] = float(nsres)
  109. else:
  110. self.D["nsres"] = None
  111. def set_ewres(self, ewres):
  112. """!Set the east-west resolution"""
  113. if ewres is not None:
  114. self.D["ewres"] = float(ewres)
  115. else:
  116. self.D["ewres"] = None
  117. def set_min(self, min):
  118. """!Set the minimum raster value"""
  119. if min is not None:
  120. self.D["min"] = float(min)
  121. else:
  122. self.D["min"] = None
  123. def set_max(self, max):
  124. """!Set the maximum raster value"""
  125. if max is not None:
  126. self.D["max"] = float(max)
  127. else:
  128. self.D["max"] = None
  129. def get_id(self):
  130. """!Convenient method to get the unique identifier (primary key)
  131. @return None if not found
  132. """
  133. if "id" in self.D:
  134. return self.D["id"]
  135. else:
  136. return None
  137. def get_datatype(self):
  138. """!Get the map type
  139. @return None if not found"""
  140. if "datatype" in self.D:
  141. return self.D["datatype"]
  142. else:
  143. return None
  144. def get_cols(self):
  145. """!Get number of cols
  146. @return None if not found"""
  147. if "cols" in self.D:
  148. return self.D["cols"]
  149. else:
  150. return None
  151. def get_rows(self):
  152. """!Get number of rows
  153. @return None if not found"""
  154. if "rows" in self.D:
  155. return self.D["rows"]
  156. else:
  157. return None
  158. def get_number_of_cells(self):
  159. """!Get number of cells
  160. @return None if not found"""
  161. if "number_of_cells" in self.D:
  162. return self.D["number_of_cells"]
  163. else:
  164. return None
  165. def get_nsres(self):
  166. """!Get the north-south resolution
  167. @return None if not found"""
  168. if "nsres" in self.D:
  169. return self.D["nsres"]
  170. else:
  171. return None
  172. def get_ewres(self):
  173. """!Get east-west resolution
  174. @return None if not found"""
  175. if "ewres" in self.D:
  176. return self.D["ewres"]
  177. else:
  178. return None
  179. def get_min(self):
  180. """!Get the minimum cell value
  181. @return None if not found"""
  182. if "min" in self.D:
  183. return self.D["min"]
  184. else:
  185. return None
  186. def get_max(self):
  187. """!Get the maximum cell value
  188. @return None if not found"""
  189. if "max" in self.D:
  190. return self.D["max"]
  191. else:
  192. return None
  193. # Properties
  194. datatype = property(fget=get_datatype, fset=set_datatype)
  195. cols = property(fget=get_cols, fset=set_cols)
  196. rows = property(fget=get_rows, fset=set_rows)
  197. number_of_cells = property(fget=get_number_of_cells, fset=set_number_of_cells)
  198. nsres = property(fget=get_nsres, fset=set_nsres)
  199. ewres = property(fget=get_ewres, fset=set_ewres)
  200. min = property(fget=get_min, fset=set_min)
  201. max = property(fget=get_max, fset=set_max)
  202. def print_info(self):
  203. """!Print information about this class in human readable style"""
  204. # 0123456789012345678901234567890
  205. print " | Datatype:................... " + str(self.get_datatype())
  206. print " | Number of columns:.......... " + str(self.get_cols())
  207. print " | Number of rows:............. " + str(self.get_rows())
  208. print " | Number of cells:............ " + str(
  209. self.get_number_of_cells())
  210. print " | North-South resolution:..... " + str(self.get_nsres())
  211. print " | East-west resolution:....... " + str(self.get_ewres())
  212. print " | Minimum value:.............. " + str(self.get_min())
  213. print " | Maximum value:.............. " + str(self.get_max())
  214. def print_shell_info(self):
  215. """!Print information about this class in shell style"""
  216. print "datatype=" + str(self.get_datatype())
  217. print "cols=" + str(self.get_cols())
  218. print "rows=" + str(self.get_rows())
  219. print "number_of_cells=" + str(self.get_number_of_cells())
  220. print "nsres=" + str(self.get_nsres())
  221. print "ewres=" + str(self.get_ewres())
  222. print "min=" + str(self.get_min())
  223. print "max=" + str(self.get_max())
  224. ###############################################################################
  225. class RasterMetadata(RasterMetadataBase):
  226. """!This is the raster metadata class
  227. This class is the interface to the raster_metadata table in the
  228. temporal database that stores the metadata of all registered raster maps.
  229. The metadata includes the datatype, number of cols, rows and cells and
  230. the north-south and east west resolution of the map. Additionally the
  231. minimum and maximum valuesare stored.
  232. Usage:
  233. @code
  234. >>> init()
  235. >>> meta = RasterMetadata(ident="soil@PERMANENT",
  236. ... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
  237. ... ewres=0.1, min=0, max=100)
  238. >>> meta.datatype
  239. 'CELL'
  240. >>> meta.cols
  241. 100
  242. >>> meta.rows
  243. 100
  244. >>> meta.number_of_cells
  245. 10000
  246. >>> meta.nsres
  247. 0.1
  248. >>> meta.ewres
  249. 0.1
  250. >>> meta.min
  251. 0.0
  252. >>> meta.max
  253. 100.0
  254. >>> meta.print_info()
  255. +-------------------- Metadata information ----------------------------------+
  256. | Datatype:................... CELL
  257. | Number of columns:.......... 100
  258. | Number of rows:............. 100
  259. | Number of cells:............ 10000
  260. | North-South resolution:..... 0.1
  261. | East-west resolution:....... 0.1
  262. | Minimum value:.............. 0.0
  263. | Maximum value:.............. 100.0
  264. >>> meta.print_shell_info()
  265. datatype=CELL
  266. cols=100
  267. rows=100
  268. number_of_cells=10000
  269. nsres=0.1
  270. ewres=0.1
  271. min=0.0
  272. max=100.0
  273. @endcode
  274. """
  275. def __init__(self, ident=None, datatype=None,
  276. cols=None, rows=None, number_of_cells=None, nsres=None,
  277. ewres=None, min=None, max=None):
  278. RasterMetadataBase.__init__(self, "raster_metadata", ident, datatype,
  279. cols, rows, number_of_cells, nsres,
  280. ewres, min, max)
  281. def print_info(self):
  282. """!Print information about this class in human readable style"""
  283. print " +-------------------- Metadata information ----------------------------------+"
  284. # 0123456789012345678901234567890
  285. RasterMetadataBase.print_info(self)
  286. def print_shell_info(self):
  287. """!Print information about this class in shell style"""
  288. RasterMetadataBase.print_shell_info(self)
  289. ###############################################################################
  290. class Raster3DMetadata(RasterMetadataBase):
  291. """!This is the raster3d metadata class
  292. This class is the interface to the raster3d_metadata table in the
  293. temporal database that stores the metadata of all registered
  294. 3D raster maps.
  295. The metadata includes all raster metadata variables and additional
  296. the number of depths, the top-bottom resolution and the space time 3D
  297. raster dataset register table is stored.
  298. Usage:
  299. @code
  300. >>> init()
  301. >>> meta = Raster3DMetadata(ident="soil@PERMANENT",
  302. ... datatype="FCELL", cols=100, rows=100, depths=100,
  303. ... number_of_cells=1000000, nsres=0.1, ewres=0.1, tbres=0.1,
  304. ... min=0, max=100)
  305. >>> meta.datatype
  306. 'FCELL'
  307. >>> meta.cols
  308. 100
  309. >>> meta.rows
  310. 100
  311. >>> meta.depths
  312. 100
  313. >>> meta.number_of_cells
  314. 1000000
  315. >>> meta.nsres
  316. 0.1
  317. >>> meta.ewres
  318. 0.1
  319. >>> meta.tbres
  320. 0.1
  321. >>> meta.min
  322. 0.0
  323. >>> meta.max
  324. 100.0
  325. >>> meta.print_info()
  326. +-------------------- Metadata information ----------------------------------+
  327. | Datatype:................... FCELL
  328. | Number of columns:.......... 100
  329. | Number of rows:............. 100
  330. | Number of cells:............ 1000000
  331. | North-South resolution:..... 0.1
  332. | East-west resolution:....... 0.1
  333. | Minimum value:.............. 0.0
  334. | Maximum value:.............. 100.0
  335. | Number of depths:........... 100
  336. | Top-Bottom resolution:...... 0.1
  337. >>> meta.print_shell_info()
  338. datatype=FCELL
  339. cols=100
  340. rows=100
  341. number_of_cells=1000000
  342. nsres=0.1
  343. ewres=0.1
  344. min=0.0
  345. max=100.0
  346. depths=100
  347. tbres=0.1
  348. @endcode
  349. """
  350. def __init__(self, ident=None, datatype=None,
  351. cols=None, rows=None, depths=None, number_of_cells=None,
  352. nsres=None, ewres=None, tbres=None, min=None, max=None):
  353. RasterMetadataBase.__init__(self, "raster3d_metadata", ident,
  354. datatype, cols, rows, number_of_cells, nsres,
  355. ewres, min, max)
  356. self.set_tbres(tbres)
  357. self.set_depths(depths)
  358. def set_depths(self, depths):
  359. """!Set the number of depths"""
  360. if depths is not None:
  361. self.D["depths"] = int(depths)
  362. else:
  363. self.D["depths"] = None
  364. def set_tbres(self, tbres):
  365. """!Set the top-bottom resolution"""
  366. if tbres is not None:
  367. self.D["tbres"] = float(tbres)
  368. else:
  369. self.D["tbres"] = None
  370. def get_depths(self):
  371. """!Get number of depths
  372. @return None if not found"""
  373. if "depths" in self.D:
  374. return self.D["depths"]
  375. else:
  376. return None
  377. def get_tbres(self):
  378. """!Get top-bottom resolution
  379. @return None if not found"""
  380. if "tbres" in self.D:
  381. return self.D["tbres"]
  382. else:
  383. return None
  384. depths = property(fget=get_depths, fset=set_depths)
  385. tbres = property(fget=get_tbres, fset=set_tbres)
  386. def print_info(self):
  387. """!Print information about this class in human readable style"""
  388. print " +-------------------- Metadata information ----------------------------------+"
  389. # 0123456789012345678901234567890
  390. RasterMetadataBase.print_info(self)
  391. # 0123456789012345678901234567890
  392. print " | Number of depths:........... " + str(self.get_depths())
  393. print " | Top-Bottom resolution:...... " + str(self.get_tbres())
  394. def print_shell_info(self):
  395. """!Print information about this class in shell style"""
  396. RasterMetadataBase.print_shell_info(self)
  397. print "depths=" + str(self.get_depths())
  398. print "tbres=" + str(self.get_tbres())
  399. ###############################################################################
  400. class VectorMetadata(SQLDatabaseInterface):
  401. """!This is the vector metadata class
  402. This class is the interface to the vector_metadata table in the
  403. temporal database that stores the metadata of all registered
  404. vector maps.
  405. Usage:
  406. @code
  407. >>> init()
  408. >>> meta = VectorMetadata(ident="lidar@PERMANENT", is_3d=True,
  409. ... number_of_points=1, number_of_lines=2, number_of_boundaries=3,
  410. ... number_of_centroids=4, number_of_faces=5, number_of_kernels=6,
  411. ... number_of_primitives=7, number_of_nodes=8, number_of_areas=9,
  412. ... number_of_islands=10, number_of_holes=11, number_of_volumes=12)
  413. >>> meta.id
  414. 'lidar@PERMANENT'
  415. >>> meta.is_3d
  416. True
  417. >>> meta.number_of_points
  418. 1
  419. >>> meta.number_of_lines
  420. 2
  421. >>> meta.number_of_boundaries
  422. 3
  423. >>> meta.number_of_centroids
  424. 4
  425. >>> meta.number_of_faces
  426. 5
  427. >>> meta.number_of_kernels
  428. 6
  429. >>> meta.number_of_primitives
  430. 7
  431. >>> meta.number_of_nodes
  432. 8
  433. >>> meta.number_of_areas
  434. 9
  435. >>> meta.number_of_islands
  436. 10
  437. >>> meta.number_of_holes
  438. 11
  439. >>> meta.number_of_volumes
  440. 12
  441. >>> meta.print_info()
  442. +-------------------- Metadata information ----------------------------------+
  443. | Is map 3d .................. True
  444. | Number of points ........... 1
  445. | Number of lines ............ 2
  446. | Number of boundaries ....... 3
  447. | Number of centroids ........ 4
  448. | Number of faces ............ 5
  449. | Number of kernels .......... 6
  450. | Number of primitives ....... 7
  451. | Number of nodes ............ 8
  452. | Number of areas ............ 9
  453. | Number of islands .......... 10
  454. | Number of holes ............ 11
  455. | Number of volumes .......... 12
  456. >>> meta.print_shell_info()
  457. is_3d=True
  458. points=1
  459. lines=2
  460. boundaries=3
  461. centroids=4
  462. faces=5
  463. kernels=6
  464. primitives=7
  465. nodes=8
  466. areas=9
  467. islands=10
  468. holes=11
  469. volumes=12
  470. @endcode
  471. """
  472. def __init__(
  473. self, ident=None, is_3d=False,
  474. number_of_points=None, number_of_lines=None, number_of_boundaries=None,
  475. number_of_centroids=None, number_of_faces=None, number_of_kernels=None,
  476. number_of_primitives=None, number_of_nodes=None, number_of_areas=None,
  477. number_of_islands=None, number_of_holes=None, number_of_volumes=None):
  478. SQLDatabaseInterface.__init__(self, "vector_metadata", ident)
  479. self.set_id(ident)
  480. self.set_3d_info(is_3d)
  481. self.set_number_of_points(number_of_points)
  482. self.set_number_of_lines(number_of_lines)
  483. self.set_number_of_boundaries(number_of_boundaries)
  484. self.set_number_of_centroids(number_of_centroids)
  485. self.set_number_of_faces(number_of_faces)
  486. self.set_number_of_kernels(number_of_kernels)
  487. self.set_number_of_primitives(number_of_primitives)
  488. self.set_number_of_nodes(number_of_nodes)
  489. self.set_number_of_areas(number_of_areas)
  490. self.set_number_of_islands(number_of_islands)
  491. self.set_number_of_holes(number_of_holes)
  492. self.set_number_of_volumes(number_of_volumes)
  493. def set_id(self, ident):
  494. """!Convenient method to set the unique identifier (primary key)"""
  495. self.ident = ident
  496. self.D["id"] = ident
  497. def set_3d_info(self, is_3d):
  498. """!Set True if the vector map is three dimensional"""
  499. self.D["is_3d"] = is_3d
  500. def set_number_of_points(self, number_of_points):
  501. """!Set the number of points of the vector map"""
  502. self.D["points"] = number_of_points
  503. def set_number_of_lines(self, number_of_lines):
  504. """!Set the number of lines of the vector map"""
  505. self.D["lines"] = number_of_lines
  506. def set_number_of_boundaries(self, number_of_boundaries):
  507. """!Set the number of boundaries of the vector map"""
  508. self.D["boundaries"] = number_of_boundaries
  509. def set_number_of_centroids(self, number_of_centroids):
  510. """!Set the number of centroids of the vector map"""
  511. self.D["centroids"] = number_of_centroids
  512. def set_number_of_faces(self, number_of_faces):
  513. """!Set the number of faces of the vector map"""
  514. self.D["faces"] = number_of_faces
  515. def set_number_of_kernels(self, number_of_kernels):
  516. """!Set the number of kernels of the vector map"""
  517. self.D["kernels"] = number_of_kernels
  518. def set_number_of_primitives(self, number_of_primitives):
  519. """!Set the number of primitives of the vector map"""
  520. self.D["primitives"] = number_of_primitives
  521. def set_number_of_nodes(self, number_of_nodes):
  522. """!Set the number of nodes of the vector map"""
  523. self.D["nodes"] = number_of_nodes
  524. def set_number_of_areas(self, number_of_areas):
  525. """!Set the number of areas of the vector map"""
  526. self.D["areas"] = number_of_areas
  527. def set_number_of_islands(self, number_of_islands):
  528. """!Set the number of islands of the vector map"""
  529. self.D["islands"] = number_of_islands
  530. def set_number_of_holes(self, number_of_holes):
  531. """!Set the number of holes of the vector map"""
  532. self.D["holes"] = number_of_holes
  533. def set_number_of_volumes(self, number_of_volumes):
  534. """!Set the number of volumes of the vector map"""
  535. self.D["volumes"] = number_of_volumes
  536. def get_id(self):
  537. """!Convenient method to get the unique identifier (primary key)
  538. @return None if not found
  539. """
  540. if "id" in self.D:
  541. return self.D["id"]
  542. else:
  543. return None
  544. def get_3d_info(self):
  545. """!Return True if the map is three dimensional,
  546. False if not and None if not info was found"""
  547. if "is_3d" in self.D:
  548. return self.D["is_3d"]
  549. else:
  550. return None
  551. def get_number_of_points(self):
  552. """!Get the number of points of the vector map
  553. @return None if not found"""
  554. if "points" in self.D:
  555. return self.D["points"]
  556. else:
  557. return None
  558. def get_number_of_lines(self):
  559. """!Get the number of lines of the vector map
  560. @return None if not found"""
  561. if "lines" in self.D:
  562. return self.D["lines"]
  563. else:
  564. return None
  565. def get_number_of_boundaries(self):
  566. """!Get the number of boundaries of the vector map
  567. @return None if not found"""
  568. if "boundaries" in self.D:
  569. return self.D["boundaries"]
  570. else:
  571. return None
  572. def get_number_of_centroids(self):
  573. """!Get the number of centroids of the vector map
  574. @return None if not found"""
  575. if "centroids" in self.D:
  576. return self.D["centroids"]
  577. else:
  578. return None
  579. def get_number_of_faces(self):
  580. """!Get the number of faces of the vector map
  581. @return None if not found"""
  582. if "faces" in self.D:
  583. return self.D["faces"]
  584. else:
  585. return None
  586. def get_number_of_kernels(self):
  587. """!Get the number of kernels of the vector map
  588. @return None if not found"""
  589. if "kernels" in self.D:
  590. return self.D["kernels"]
  591. else:
  592. return None
  593. def get_number_of_primitives(self):
  594. """!Get the number of primitives of the vector map
  595. @return None if not found"""
  596. if "primitives" in self.D:
  597. return self.D["primitives"]
  598. else:
  599. return None
  600. def get_number_of_nodes(self):
  601. """!Get the number of nodes of the vector map
  602. @return None if not found"""
  603. if "nodes" in self.D:
  604. return self.D["nodes"]
  605. else:
  606. return None
  607. def get_number_of_areas(self):
  608. """!Get the number of areas of the vector map
  609. @return None if not found"""
  610. if "areas" in self.D:
  611. return self.D["areas"]
  612. else:
  613. return None
  614. def get_number_of_islands(self):
  615. """!Get the number of islands of the vector map
  616. @return None if not found"""
  617. if "islands" in self.D:
  618. return self.D["islands"]
  619. else:
  620. return None
  621. def get_number_of_holes(self):
  622. """!Get the number of holes of the vector map
  623. @return None if not found"""
  624. if "holes" in self.D:
  625. return self.D["holes"]
  626. else:
  627. return None
  628. def get_number_of_volumes(self):
  629. """!Get the number of volumes of the vector map
  630. @return None if not found"""
  631. if "volumes" in self.D:
  632. return self.D["volumes"]
  633. else:
  634. return None
  635. # Set the properties
  636. id = property(fget=get_id, fset=set_id)
  637. is_3d = property(fget=get_3d_info, fset=set_3d_info)
  638. number_of_points = property(fget=get_number_of_points,
  639. fset=set_number_of_points)
  640. number_of_lines = property(fget=get_number_of_lines,
  641. fset=set_number_of_lines)
  642. number_of_boundaries = property(fget=get_number_of_boundaries,
  643. fset=set_number_of_boundaries)
  644. number_of_centroids = property(fget=get_number_of_centroids,
  645. fset=set_number_of_centroids)
  646. number_of_faces = property(fget=get_number_of_faces,
  647. fset=set_number_of_faces)
  648. number_of_kernels = property(fget=get_number_of_kernels,
  649. fset=set_number_of_kernels)
  650. number_of_primitives = property(fget=get_number_of_primitives,
  651. fset=set_number_of_primitives)
  652. number_of_nodes = property(fget=get_number_of_nodes,
  653. fset=set_number_of_nodes)
  654. number_of_areas = property(fget=get_number_of_areas,
  655. fset=set_number_of_areas)
  656. number_of_islands = property(fget=get_number_of_islands,
  657. fset=set_number_of_islands)
  658. number_of_holes = property(fget=get_number_of_holes,
  659. fset=set_number_of_holes)
  660. number_of_volumes = property(fget=get_number_of_volumes,
  661. fset=set_number_of_volumes)
  662. def print_info(self):
  663. """!Print information about this class in human readable style"""
  664. # 0123456789012345678901234567890
  665. print " +-------------------- Metadata information ----------------------------------+"
  666. print " | Is map 3d .................. " + str(self.get_3d_info())
  667. print " | Number of points ........... " + str(self.get_number_of_points())
  668. print " | Number of lines ............ " + str(self.get_number_of_lines())
  669. print " | Number of boundaries ....... " + str(self.get_number_of_boundaries())
  670. print " | Number of centroids ........ " + str(self.get_number_of_centroids())
  671. print " | Number of faces ............ " + str(self.get_number_of_faces())
  672. print " | Number of kernels .......... " + str(self.get_number_of_kernels())
  673. print " | Number of primitives ....... " + str(self.get_number_of_primitives())
  674. print " | Number of nodes ............ " + str(self.get_number_of_nodes())
  675. print " | Number of areas ............ " + str(self.get_number_of_areas())
  676. print " | Number of islands .......... " + str(self.get_number_of_islands())
  677. print " | Number of holes ............ " + str(self.get_number_of_holes())
  678. print " | Number of volumes .......... " + str(self.get_number_of_volumes())
  679. def print_shell_info(self):
  680. """!Print information about this class in shell style"""
  681. print "is_3d=" + str(self.get_3d_info())
  682. print "points=" + str(self.get_number_of_points())
  683. print "lines=" + str(self.get_number_of_lines())
  684. print "boundaries=" + str(self.get_number_of_boundaries())
  685. print "centroids=" + str(self.get_number_of_centroids())
  686. print "faces=" + str(self.get_number_of_faces())
  687. print "kernels=" + str(self.get_number_of_kernels())
  688. print "primitives=" + str(self.get_number_of_primitives())
  689. print "nodes=" + str(self.get_number_of_nodes())
  690. print "areas=" + str(self.get_number_of_areas())
  691. print "islands=" + str(self.get_number_of_islands())
  692. print "holes=" + str(self.get_number_of_holes())
  693. print "volumes=" + str(self.get_number_of_volumes())
  694. ###############################################################################
  695. class STDSMetadataBase(SQLDatabaseInterface):
  696. """!This is the space time dataset metadata base class for
  697. strds, stvds and str3ds datasets
  698. setting/getting the id, the title and the description
  699. Usage:
  700. @code
  701. >>> init()
  702. >>> meta = STDSMetadataBase(ident="soils@PERMANENT",
  703. ... title="Soils", description="Soils 1950 - 2010")
  704. >>> meta.id
  705. 'soils@PERMANENT'
  706. >>> meta.title
  707. 'Soils'
  708. >>> meta.description
  709. 'Soils 1950 - 2010'
  710. >>> meta.number_of_maps
  711. >>> meta.print_info()
  712. | Number of registered maps:.. None
  713. |
  714. | Title:
  715. | Soils
  716. | Description:
  717. | Soils 1950 - 2010
  718. | Command history:
  719. >>> meta.print_shell_info()
  720. number_of_maps=None
  721. @endcode
  722. """
  723. def __init__(self, table=None, ident=None, title=None, description=None, command=None):
  724. SQLDatabaseInterface.__init__(self, table, ident)
  725. self.set_id(ident)
  726. self.set_title(title)
  727. self.set_description(description)
  728. self.set_command(command)
  729. # No setter for this
  730. self.D["number_of_maps"] = None
  731. def set_id(self, ident):
  732. """!Convenient method to set the unique identifier (primary key)"""
  733. self.ident = ident
  734. self.D["id"] = ident
  735. def set_title(self, title):
  736. """!Set the title"""
  737. self.D["title"] = title
  738. def set_description(self, description):
  739. """!Set the number of cols"""
  740. self.D["description"] = description
  741. def set_command(self, command):
  742. """!Set the number of cols"""
  743. self.D["command"] = command
  744. def get_id(self):
  745. """!Convenient method to get the unique identifier (primary key)
  746. @return None if not found
  747. """
  748. if "id" in self.D:
  749. return self.D["id"]
  750. else:
  751. return None
  752. def get_title(self):
  753. """!Get the title
  754. @return None if not found"""
  755. if "title" in self.D:
  756. return self.D["title"]
  757. else:
  758. return None
  759. def get_description(self):
  760. """!Get description
  761. @return None if not found"""
  762. if "description" in self.D:
  763. return self.D["description"]
  764. else:
  765. return None
  766. def get_command(self):
  767. """!Get command
  768. @return None if not found"""
  769. if "command" in self.D:
  770. return self.D["command"]
  771. else:
  772. return None
  773. def get_number_of_maps(self):
  774. """!Get the number of registered maps,
  775. this value is set in the database
  776. automatically via SQL, so no setter exists
  777. @return None if not found"""
  778. if "number_of_maps" in self.D:
  779. return self.D["number_of_maps"]
  780. else:
  781. return None
  782. id = property(fget=get_id, fset=set_id)
  783. title = property(fget=get_title, fset=set_title)
  784. description = property(fget=get_description, fset=set_description)
  785. number_of_maps = property(fget=get_number_of_maps)
  786. def print_info(self):
  787. """!Print information about this class in human readable style"""
  788. # 0123456789012345678901234567890
  789. print " | Number of registered maps:.. " + str(
  790. self.get_number_of_maps())
  791. print " |"
  792. print " | Title:"
  793. print " | " + str(self.get_title())
  794. print " | Description:"
  795. print " | " + str(self.get_description())
  796. print " | Command history:"
  797. command = self.get_command()
  798. if command:
  799. for token in command.split("\n"):
  800. print " | " + str(token)
  801. def print_history(self):
  802. """!Print history information about this class in human readable
  803. shell style
  804. """
  805. # 0123456789012345678901234567890
  806. print "# Title:"
  807. print "# " + str(self.get_title())
  808. print "# Description:"
  809. print "# " + str(self.get_description())
  810. print "# Command history:"
  811. command = self.get_command()
  812. if command:
  813. tokens = command.split("\n")
  814. print_list = []
  815. for token in tokens:
  816. token = str(token).rstrip().lstrip()
  817. if len(token) > 1:
  818. print_list.append(token)
  819. count = 0
  820. for token in print_list:
  821. count += 1
  822. if len(token) > 1:
  823. if token[0] == "#":
  824. print token
  825. elif count < len(print_list):
  826. print token + " \\"
  827. else:
  828. print token
  829. def print_shell_info(self):
  830. """!Print information about this class in shell style"""
  831. print "number_of_maps=" + str(self.get_number_of_maps())
  832. ###############################################################################
  833. class STDSRasterMetadataBase(STDSMetadataBase):
  834. """!This is the space time dataset metadata base
  835. class for strds and str3ds datasets
  836. Most of the metadata values are set by SQL scripts in the database when
  837. new maps are added. Therefor only some set- an many
  838. get-functions are available.
  839. Usage:
  840. @code
  841. >>> init()
  842. >>> meta = STDSRasterMetadataBase(ident="soils@PERMANENT",
  843. ... title="Soils", description="Soils 1950 - 2010")
  844. >>> meta.id
  845. 'soils@PERMANENT'
  846. >>> meta.title
  847. 'Soils'
  848. >>> meta.description
  849. 'Soils 1950 - 2010'
  850. >>> meta.number_of_maps
  851. >>> meta.min_max
  852. >>> meta.max_max
  853. >>> meta.min_min
  854. >>> meta.max_min
  855. >>> meta.nsres_min
  856. >>> meta.nsres_max
  857. >>> meta.ewres_min
  858. >>> meta.ewres_max
  859. >>> meta.print_info()
  860. | North-South resolution min:. None
  861. | North-South resolution max:. None
  862. | East-west resolution min:... None
  863. | East-west resolution max:... None
  864. | Minimum value min:.......... None
  865. | Minimum value max:.......... None
  866. | Maximum value min:.......... None
  867. | Maximum value max:.......... None
  868. | Aggregation type:........... None
  869. | Number of registered maps:.. None
  870. |
  871. | Title:
  872. | Soils
  873. | Description:
  874. | Soils 1950 - 2010
  875. | Command history:
  876. >>> meta.print_shell_info()
  877. aggregation_type=None
  878. number_of_maps=None
  879. nsres_min=None
  880. nsres_max=None
  881. ewres_min=None
  882. ewres_max=None
  883. min_min=None
  884. min_max=None
  885. max_min=None
  886. max_max=None
  887. @endcode
  888. """
  889. def __init__(self, table=None, ident=None, title=None, description=None, aggregation_type=None):
  890. STDSMetadataBase.__init__(self, table, ident, title, description)
  891. # Initialize the dict to select all values from the db
  892. self.D["min_max"] = None
  893. self.D["max_max"] = None
  894. self.D["min_min"] = None
  895. self.D["max_min"] = None
  896. self.D["nsres_min"] = None
  897. self.D["nsres_max"] = None
  898. self.D["ewres_min"] = None
  899. self.D["ewres_max"] = None
  900. self.D["aggregation_type"] = aggregation_type
  901. def set_aggregation_type(self, aggregation_type):
  902. """!Set the aggregation type of the dataset (mean, min, max, ...)"""
  903. self.D["aggregation_type"] = aggregation_type
  904. def get_aggregation_type(self):
  905. """!Get the aggregation type of the dataset (mean, min, max, ...)
  906. @return None if not found
  907. """
  908. if "aggregation_type" in self.D:
  909. return self.D["aggregation_type"]
  910. else:
  911. return None
  912. def get_max_min(self):
  913. """!Get the minimal maximum of all registered maps,
  914. this value is set in the database
  915. automatically via SQL, so no setter exists
  916. @return None if not found"""
  917. if "max_min" in self.D:
  918. return self.D["max_min"]
  919. else:
  920. return None
  921. def get_min_min(self):
  922. """!Get the minimal minimum of all registered maps,
  923. this value is set in the database
  924. automatically via SQL, so no setter exists
  925. @return None if not found"""
  926. if "min_min" in self.D:
  927. return self.D["min_min"]
  928. else:
  929. return None
  930. def get_max_max(self):
  931. """!Get the maximal maximum of all registered maps,
  932. this value is set in the database
  933. automatically via SQL, so no setter exists
  934. @return None if not found"""
  935. if "max_max" in self.D:
  936. return self.D["max_max"]
  937. else:
  938. return None
  939. def get_min_max(self):
  940. """!Get the maximal minimum of all registered maps,
  941. this value is set in the database
  942. automatically via SQL, so no setter exists
  943. @return None if not found"""
  944. if "min_max" in self.D:
  945. return self.D["min_max"]
  946. else:
  947. return None
  948. def get_nsres_min(self):
  949. """!Get the minimal north-south resolution of all registered maps,
  950. this value is set in the database
  951. automatically via SQL, so no setter exists
  952. @return None if not found"""
  953. if "nsres_min" in self.D:
  954. return self.D["nsres_min"]
  955. else:
  956. return None
  957. def get_nsres_max(self):
  958. """!Get the maximal north-south resolution of all registered maps,
  959. this value is set in the database
  960. automatically via SQL, so no setter exists
  961. @return None if not found"""
  962. if "nsres_max" in self.D:
  963. return self.D["nsres_max"]
  964. else:
  965. return None
  966. def get_ewres_min(self):
  967. """!Get the minimal east-west resolution of all registered maps,
  968. this value is set in the database
  969. automatically via SQL, so no setter exists
  970. @return None if not found"""
  971. if "ewres_min" in self.D:
  972. return self.D["ewres_min"]
  973. else:
  974. return None
  975. def get_ewres_max(self):
  976. """!Get the maximal east-west resolution of all registered maps,
  977. this value is set in the database
  978. automatically via SQL, so no setter exists
  979. @return None if not found"""
  980. if "ewres_max" in self.D:
  981. return self.D["ewres_max"]
  982. else:
  983. return None
  984. nsres_min = property(fget=get_nsres_min)
  985. nsres_max = property(fget=get_nsres_max)
  986. ewres_min = property(fget=get_ewres_min)
  987. ewres_max = property(fget=get_ewres_max)
  988. min_min = property(fget=get_min_min)
  989. min_max = property(fget=get_min_max)
  990. max_min = property(fget=get_max_min)
  991. max_max = property(fget=get_max_max)
  992. aggregation_type = property(fset=set_aggregation_type,
  993. fget=get_aggregation_type)
  994. def print_info(self):
  995. """!Print information about this class in human readable style"""
  996. # 0123456789012345678901234567890
  997. print " | North-South resolution min:. " + str(self.get_nsres_min())
  998. print " | North-South resolution max:. " + str(self.get_nsres_max())
  999. print " | East-west resolution min:... " + str(self.get_ewres_min())
  1000. print " | East-west resolution max:... " + str(self.get_ewres_max())
  1001. print " | Minimum value min:.......... " + str(self.get_min_min())
  1002. print " | Minimum value max:.......... " + str(self.get_min_max())
  1003. print " | Maximum value min:.......... " + str(self.get_max_min())
  1004. print " | Maximum value max:.......... " + str(self.get_max_max())
  1005. print " | Aggregation type:........... " + str(self.get_aggregation_type())
  1006. STDSMetadataBase.print_info(self)
  1007. def print_shell_info(self):
  1008. """!Print information about this class in shell style"""
  1009. print "aggregation_type=" + str(self.get_aggregation_type())
  1010. STDSMetadataBase.print_shell_info(self)
  1011. print "nsres_min=" + str(self.get_nsres_min())
  1012. print "nsres_max=" + str(self.get_nsres_max())
  1013. print "ewres_min=" + str(self.get_ewres_min())
  1014. print "ewres_max=" + str(self.get_ewres_max())
  1015. print "min_min=" + str(self.get_min_min())
  1016. print "min_max=" + str(self.get_min_max())
  1017. print "max_min=" + str(self.get_max_min())
  1018. print "max_max=" + str(self.get_max_max())
  1019. ###############################################################################
  1020. class STRDSMetadata(STDSRasterMetadataBase):
  1021. """!This is the raster metadata class
  1022. This class is the interface to the strds_metadata table in the
  1023. temporal database that stores the metadata of all registered
  1024. space time raster datasets
  1025. Most of the metadata values are set by SQL scripts in the database when
  1026. new raster maps are added. Therefor only some set- an many
  1027. get-functions are available.
  1028. Usage:
  1029. @code
  1030. >>> init()
  1031. >>> meta = STRDSMetadata(ident="soils@PERMANENT",
  1032. ... title="Soils", description="Soils 1950 - 2010")
  1033. >>> meta.id
  1034. 'soils@PERMANENT'
  1035. >>> meta.title
  1036. 'Soils'
  1037. >>> meta.description
  1038. 'Soils 1950 - 2010'
  1039. >>> meta.number_of_maps
  1040. >>> meta.min_max
  1041. >>> meta.max_max
  1042. >>> meta.min_min
  1043. >>> meta.max_min
  1044. >>> meta.nsres_min
  1045. >>> meta.nsres_max
  1046. >>> meta.ewres_min
  1047. >>> meta.ewres_max
  1048. >>> meta.raster_register
  1049. >>> meta.print_info()
  1050. +-------------------- Metadata information ----------------------------------+
  1051. | Raster register table:...... None
  1052. | North-South resolution min:. None
  1053. | North-South resolution max:. None
  1054. | East-west resolution min:... None
  1055. | East-west resolution max:... None
  1056. | Minimum value min:.......... None
  1057. | Minimum value max:.......... None
  1058. | Maximum value min:.......... None
  1059. | Maximum value max:.......... None
  1060. | Aggregation type:........... None
  1061. | Number of registered maps:.. None
  1062. |
  1063. | Title:
  1064. | Soils
  1065. | Description:
  1066. | Soils 1950 - 2010
  1067. | Command history:
  1068. >>> meta.print_shell_info()
  1069. aggregation_type=None
  1070. number_of_maps=None
  1071. nsres_min=None
  1072. nsres_max=None
  1073. ewres_min=None
  1074. ewres_max=None
  1075. min_min=None
  1076. min_max=None
  1077. max_min=None
  1078. max_max=None
  1079. raster_register=None
  1080. @endcode
  1081. """
  1082. def __init__(self, ident=None, raster_register=None, title=None, description=None):
  1083. STDSRasterMetadataBase.__init__(
  1084. self, "strds_metadata", ident, title, description)
  1085. self.set_raster_register(raster_register)
  1086. def set_raster_register(self, raster_register):
  1087. """!Set the raster map register table name"""
  1088. self.D["raster_register"] = raster_register
  1089. def get_raster_register(self):
  1090. """!Get the raster map register table name
  1091. @return None if not found"""
  1092. if "raster_register" in self.D:
  1093. return self.D["raster_register"]
  1094. else:
  1095. return None
  1096. raster_register = property(fget=get_raster_register,
  1097. fset=set_raster_register)
  1098. def print_info(self):
  1099. """!Print information about this class in human readable style"""
  1100. print " +-------------------- Metadata information ----------------------------------+"
  1101. # 0123456789012345678901234567890
  1102. print " | Raster register table:...... " + str(
  1103. self.get_raster_register())
  1104. STDSRasterMetadataBase.print_info(self)
  1105. def print_shell_info(self):
  1106. """!Print information about this class in shell style"""
  1107. STDSRasterMetadataBase.print_shell_info(self)
  1108. print "raster_register=" + str(self.get_raster_register())
  1109. ###############################################################################
  1110. class STR3DSMetadata(STDSRasterMetadataBase):
  1111. """!This is the space time 3D raster metadata class
  1112. This class is the interface to the str3ds_metadata table in the
  1113. temporal database that stores the metadata of all registered
  1114. space time 3D raster datasets
  1115. Most of the metadata values are set by SQL scripts in the database when
  1116. new 3D raster maps are added. Therefor only some set- an many
  1117. get-functions are available.
  1118. Usage:
  1119. @code
  1120. >>> init()
  1121. >>> meta = STR3DSMetadata(ident="soils@PERMANENT",
  1122. ... title="Soils", description="Soils 1950 - 2010")
  1123. >>> meta.id
  1124. 'soils@PERMANENT'
  1125. >>> meta.title
  1126. 'Soils'
  1127. >>> meta.description
  1128. 'Soils 1950 - 2010'
  1129. >>> meta.number_of_maps
  1130. >>> meta.min_max
  1131. >>> meta.max_max
  1132. >>> meta.min_min
  1133. >>> meta.max_min
  1134. >>> meta.nsres_min
  1135. >>> meta.nsres_max
  1136. >>> meta.ewres_min
  1137. >>> meta.ewres_max
  1138. >>> meta.tbres_min
  1139. >>> meta.tbres_max
  1140. >>> meta.raster3d_register
  1141. >>> meta.print_info()
  1142. +-------------------- Metadata information ----------------------------------+
  1143. | 3D raster register table:... None
  1144. | Top-bottom resolution min:.. None
  1145. | Top-bottom resolution max:.. None
  1146. | North-South resolution min:. None
  1147. | North-South resolution max:. None
  1148. | East-west resolution min:... None
  1149. | East-west resolution max:... None
  1150. | Minimum value min:.......... None
  1151. | Minimum value max:.......... None
  1152. | Maximum value min:.......... None
  1153. | Maximum value max:.......... None
  1154. | Aggregation type:........... None
  1155. | Number of registered maps:.. None
  1156. |
  1157. | Title:
  1158. | Soils
  1159. | Description:
  1160. | Soils 1950 - 2010
  1161. | Command history:
  1162. >>> meta.print_shell_info()
  1163. aggregation_type=None
  1164. number_of_maps=None
  1165. nsres_min=None
  1166. nsres_max=None
  1167. ewres_min=None
  1168. ewres_max=None
  1169. min_min=None
  1170. min_max=None
  1171. max_min=None
  1172. max_max=None
  1173. tbres_min=None
  1174. tbres_max=None
  1175. raster3d_register=None
  1176. @endcode
  1177. """
  1178. def __init__(self, ident=None, raster3d_register=None, title=None, description=None):
  1179. STDSRasterMetadataBase.__init__(
  1180. self, "str3ds_metadata", ident, title, description)
  1181. self.set_raster3d_register(raster3d_register)
  1182. self.D["tbres_min"] = None
  1183. self.D["tbres_max"] = None
  1184. def set_raster3d_register(self, raster3d_register):
  1185. """!Set the raster map register table name"""
  1186. self.D["raster3d_register"] = raster3d_register
  1187. def get_raster3d_register(self):
  1188. """!Get the raster3d map register table name
  1189. @return None if not found"""
  1190. if "raster3d_register" in self.D:
  1191. return self.D["raster3d_register"]
  1192. else:
  1193. return None
  1194. def get_tbres_min(self):
  1195. """!Get the minimal top-bottom resolution of all registered maps,
  1196. this value is set in the database
  1197. automatically via SQL, so no setter exists
  1198. @return None if not found"""
  1199. if "tbres_min" in self.D:
  1200. return self.D["tbres_min"]
  1201. else:
  1202. return None
  1203. def get_tbres_max(self):
  1204. """!Get the maximal top-bottom resolution of all registered maps,
  1205. this value is set in the database
  1206. automatically via SQL, so no setter exists
  1207. @return None if not found"""
  1208. if "tbres_max" in self.D:
  1209. return self.D["tbres_max"]
  1210. else:
  1211. return None
  1212. raster3d_register = property(fget=get_raster3d_register,
  1213. fset=set_raster3d_register)
  1214. tbres_min = property(fget=get_tbres_min)
  1215. tbres_max = property(fget=get_tbres_max)
  1216. def print_info(self):
  1217. """!Print information about this class in human readable style"""
  1218. print " +-------------------- Metadata information ----------------------------------+"
  1219. # 0123456789012345678901234567890
  1220. # 0123456789012345678901234567890
  1221. print " | 3D raster register table:... " + str(
  1222. self.get_raster3d_register())
  1223. print " | Top-bottom resolution min:.. " + str(self.get_ewres_min())
  1224. print " | Top-bottom resolution max:.. " + str(self.get_ewres_max())
  1225. STDSRasterMetadataBase.print_info(self)
  1226. def print_shell_info(self):
  1227. """!Print information about this class in shell style"""
  1228. STDSRasterMetadataBase.print_shell_info(self)
  1229. print "tbres_min=" + str(self.get_tbres_min())
  1230. print "tbres_max=" + str(self.get_tbres_max())
  1231. print "raster3d_register=" + str(self.get_raster3d_register())
  1232. ###############################################################################
  1233. class STVDSMetadata(STDSMetadataBase):
  1234. """!This is the space time vector dataset metadata class
  1235. This class is the interface to the stvds_metadata table in the
  1236. temporal database that stores the metadata of all registered
  1237. space time vector datasets
  1238. Most of the metadata values are set by SQL scripts in the database when
  1239. new vector maps are added. Therefor only some set- an many get-functions
  1240. are available.
  1241. Usage:
  1242. @code
  1243. >>> init()
  1244. >>> meta = STVDSMetadata(ident="lidars@PERMANENT",
  1245. ... title="LIDARS", description="LIDARS 2008 - 2010")
  1246. >>> meta.id
  1247. 'lidars@PERMANENT'
  1248. >>> meta.title
  1249. 'LIDARS'
  1250. >>> meta.description
  1251. 'LIDARS 2008 - 2010'
  1252. >>> meta.number_of_maps
  1253. >>> meta.number_of_points
  1254. >>> meta.number_of_lines
  1255. >>> meta.number_of_boundaries
  1256. >>> meta.number_of_centroids
  1257. >>> meta.number_of_faces
  1258. >>> meta.number_of_kernels
  1259. >>> meta.number_of_primitives
  1260. >>> meta.number_of_nodes
  1261. >>> meta.number_of_areas
  1262. >>> meta.number_of_islands
  1263. >>> meta.number_of_holes
  1264. >>> meta.number_of_volumes
  1265. >>> meta.print_info()
  1266. +-------------------- Metadata information ----------------------------------+
  1267. | Vector register table:...... None
  1268. | Number of points ........... None
  1269. | Number of lines ............ None
  1270. | Number of boundaries ....... None
  1271. | Number of centroids ........ None
  1272. | Number of faces ............ None
  1273. | Number of kernels .......... None
  1274. | Number of primitives ....... None
  1275. | Number of nodes ............ None
  1276. | Number of areas ............ None
  1277. | Number of islands .......... None
  1278. | Number of holes ............ None
  1279. | Number of volumes .......... None
  1280. | Number of registered maps:.. None
  1281. |
  1282. | Title:
  1283. | LIDARS
  1284. | Description:
  1285. | LIDARS 2008 - 2010
  1286. | Command history:
  1287. >>> meta.print_shell_info()
  1288. number_of_maps=None
  1289. vector_register=None
  1290. points=None
  1291. lines=None
  1292. boundaries=None
  1293. centroids=None
  1294. faces=None
  1295. kernels=None
  1296. primitives=None
  1297. nodes=None
  1298. areas=None
  1299. islands=None
  1300. holes=None
  1301. volumes=None
  1302. @endcode
  1303. """
  1304. def __init__(
  1305. self, ident=None, vector_register=None, title=None, description=None):
  1306. STDSMetadataBase.__init__(
  1307. self, "stvds_metadata", ident, title, description)
  1308. self.set_vector_register(vector_register)
  1309. self.D["points"] = None
  1310. self.D["lines"] = None
  1311. self.D["boundaries"] = None
  1312. self.D["centroids"] = None
  1313. self.D["faces"] = None
  1314. self.D["kernels"] = None
  1315. self.D["primitives"] = None
  1316. self.D["nodes"] = None
  1317. self.D["areas"] = None
  1318. self.D["islands"] = None
  1319. self.D["holes"] = None
  1320. self.D["volumes"] = None
  1321. def set_vector_register(self, vector_register):
  1322. """!Set the vector map register table name"""
  1323. self.D["vector_register"] = vector_register
  1324. def get_vector_register(self):
  1325. """!Get the vector map register table name
  1326. @return None if not found"""
  1327. if "vector_register" in self.D:
  1328. return self.D["vector_register"]
  1329. else:
  1330. return None
  1331. def get_number_of_points(self):
  1332. """!Get the number of points of all registered maps,
  1333. this value is set in the database
  1334. automatically via SQL, so no setter exists
  1335. @return None if not found"""
  1336. if "points" in self.D:
  1337. return self.D["points"]
  1338. else:
  1339. return None
  1340. def get_number_of_lines(self):
  1341. """!Get the number of lines of all registered maps,
  1342. this value is set in the database
  1343. automatically via SQL, so no setter exists
  1344. @return None if not found"""
  1345. if "lines" in self.D:
  1346. return self.D["lines"]
  1347. else:
  1348. return None
  1349. def get_number_of_boundaries(self):
  1350. """!Get the number of boundaries of all registered maps,
  1351. this value is set in the database
  1352. automatically via SQL, so no setter exists
  1353. @return None if not found"""
  1354. if "boundaries" in self.D:
  1355. return self.D["boundaries"]
  1356. else:
  1357. return None
  1358. def get_number_of_centroids(self):
  1359. """!Get the number of centroids of all registered maps,
  1360. this value is set in the database
  1361. automatically via SQL, so no setter exists
  1362. @return None if not found"""
  1363. if "centroids" in self.D:
  1364. return self.D["centroids"]
  1365. else:
  1366. return None
  1367. def get_number_of_faces(self):
  1368. """!Get the number of faces of all registered maps,
  1369. this value is set in the database
  1370. automatically via SQL, so no setter exists
  1371. @return None if not found"""
  1372. if "faces" in self.D:
  1373. return self.D["faces"]
  1374. else:
  1375. return None
  1376. def get_number_of_kernels(self):
  1377. """!Get the number of kernels of all registered maps,
  1378. this value is set in the database
  1379. automatically via SQL, so no setter exists
  1380. @return None if not found"""
  1381. if "kernels" in self.D:
  1382. return self.D["kernels"]
  1383. else:
  1384. return None
  1385. def get_number_of_primitives(self):
  1386. """!Get the number of primitives of all registered maps,
  1387. this value is set in the database
  1388. automatically via SQL, so no setter exists
  1389. @return None if not found"""
  1390. if "primitives" in self.D:
  1391. return self.D["primitives"]
  1392. else:
  1393. return None
  1394. def get_number_of_nodes(self):
  1395. """!Get the number of nodes of all registered maps,
  1396. this value is set in the database
  1397. automatically via SQL, so no setter exists
  1398. @return None if not found"""
  1399. if "nodes" in self.D:
  1400. return self.D["nodes"]
  1401. else:
  1402. return None
  1403. def get_number_of_areas(self):
  1404. """!Get the number of areas of all registered maps,
  1405. this value is set in the database
  1406. automatically via SQL, so no setter exists
  1407. @return None if not found"""
  1408. if "areas" in self.D:
  1409. return self.D["areas"]
  1410. else:
  1411. return None
  1412. def get_number_of_islands(self):
  1413. """!Get the number of islands of all registered maps,
  1414. this value is set in the database
  1415. automatically via SQL, so no setter exists
  1416. @return None if not found"""
  1417. if "islands" in self.D:
  1418. return self.D["islands"]
  1419. else:
  1420. return None
  1421. def get_number_of_holes(self):
  1422. """!Get the number of holes of all registered maps,
  1423. this value is set in the database
  1424. automatically via SQL, so no setter exists
  1425. @return None if not found"""
  1426. if "holes" in self.D:
  1427. return self.D["holes"]
  1428. else:
  1429. return None
  1430. def get_number_of_volumes(self):
  1431. """!Get the number of volumes of all registered maps,
  1432. this value is set in the database
  1433. automatically via SQL, so no setter exists
  1434. @return None if not found"""
  1435. if "volumes" in self.D:
  1436. return self.D["volumes"]
  1437. else:
  1438. return None
  1439. # Set the properties
  1440. vector_register = property(fget=get_vector_register,
  1441. fset=set_vector_register)
  1442. number_of_points = property(fget=get_number_of_points)
  1443. number_of_lines = property(fget=get_number_of_lines)
  1444. number_of_boundaries = property(fget=get_number_of_boundaries)
  1445. number_of_centroids = property(fget=get_number_of_centroids)
  1446. number_of_faces = property(fget=get_number_of_faces)
  1447. number_of_kernels = property(fget=get_number_of_kernels)
  1448. number_of_primitives = property(fget=get_number_of_primitives)
  1449. number_of_nodes = property(fget=get_number_of_nodes)
  1450. number_of_areas = property(fget=get_number_of_areas)
  1451. number_of_islands = property(fget=get_number_of_islands)
  1452. number_of_holes = property(fget=get_number_of_holes)
  1453. number_of_volumes = property(fget=get_number_of_volumes)
  1454. def print_info(self):
  1455. """!Print information about this class in human readable style"""
  1456. print " +-------------------- Metadata information ----------------------------------+"
  1457. # 0123456789012345678901234567890
  1458. print " | Vector register table:...... " + str(
  1459. self.get_vector_register())
  1460. print " | Number of points ........... " + str(self.number_of_points)
  1461. print " | Number of lines ............ " + str(self.number_of_lines)
  1462. print " | Number of boundaries ....... " + str(self.number_of_boundaries)
  1463. print " | Number of centroids ........ " + str(self.number_of_centroids)
  1464. print " | Number of faces ............ " + str(self.number_of_faces)
  1465. print " | Number of kernels .......... " + str(self.number_of_kernels)
  1466. print " | Number of primitives ....... " + str(self.number_of_primitives)
  1467. print " | Number of nodes ............ " + str(self.number_of_nodes)
  1468. print " | Number of areas ............ " + str(self.number_of_areas)
  1469. print " | Number of islands .......... " + str(self.number_of_islands)
  1470. print " | Number of holes ............ " + str(self.number_of_holes)
  1471. print " | Number of volumes .......... " + str(self.number_of_volumes)
  1472. STDSMetadataBase.print_info(self)
  1473. def print_shell_info(self):
  1474. """!Print information about this class in shell style"""
  1475. STDSMetadataBase.print_shell_info(self)
  1476. print "vector_register=" + str(self.get_vector_register())
  1477. print "points=" + str(self.get_number_of_points())
  1478. print "lines=" + str(self.get_number_of_lines())
  1479. print "boundaries=" + str(self.get_number_of_boundaries())
  1480. print "centroids=" + str(self.get_number_of_centroids())
  1481. print "faces=" + str(self.get_number_of_faces())
  1482. print "kernels=" + str(self.get_number_of_kernels())
  1483. print "primitives=" + str(self.get_number_of_primitives())
  1484. print "nodes=" + str(self.get_number_of_nodes())
  1485. print "areas=" + str(self.get_number_of_areas())
  1486. print "islands=" + str(self.get_number_of_islands())
  1487. print "holes=" + str(self.get_number_of_holes())
  1488. print "volumes=" + str(self.get_number_of_volumes())
  1489. ###############################################################################
  1490. if __name__ == "__main__":
  1491. import doctest
  1492. doctest.testmod()