vectorlib_files.dox 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*! \page vlibFormat Vector format description
  2. by GRASS Development Team (http://grass.osgeo.org)
  3. \tableofcontents
  4. \section vlibDirectoryStructure Directory structure
  5. Vector map is stored in a number of data files. Vector map directory
  6. structure and file names were changed in GRASS 6 with respect to
  7. previous GRASS versions. All vector files for one vector map are
  8. stored in one directory:
  9. \verbatim
  10. $MAPSET/vector/vector_name/
  11. \endverbatim
  12. This directory contains these files:
  13. - <b>coor</b> - binary file, coordinates [former dig/ file] (see \ref vlibCoorFileFormat)
  14. - <b>topo</b> - binary file, topology [former dig_plus/ file] (see \ref vlibTopoFileFormat)
  15. - <b>sidx</b> - binary file, spatial index (see \ref vlibSidxFileFormat)
  16. - <b>cidx</b> - binary file, category index (see \ref vlibCidxFileFormat)
  17. - <b>head</b> - text file, header information [former part of dig/ file] (see \ref vlibHeadFileFormat)
  18. - <b>dbln</b> - text file, link(s) to attribute table(s) (see \ref vlibDblnFileFormat)
  19. - <b>hist</b> - text file, vector map change history
  20. - <b>frmt</b> - text file, format description (external formats only)
  21. - <b>fidx</b> - binary file, feature index (OGR format only)
  22. \section vlibHeadFileFormat Header file format specification
  23. The header contains meta information, a description of the
  24. vector map and many other information. The file is an unordered list
  25. of key/value entries. The <i>key</i> is a string separated from
  26. <i>value</i> by a colon and optional whitespace.
  27. Keywords are:
  28. - ORGANIZATION - organization that digitized the data
  29. - DIGIT DATE - date the data was digitized
  30. - DIGIT NAME - person who digitized the data
  31. - MAP NAME - title of the original source map
  32. - MAP DATE - date of the original source map
  33. - MAP SCALE - scale of the original source map
  34. - OTHER INFO - other comments about the map
  35. - ZONE - zone of the map (e.g., UTM zone)
  36. - MAP THRESH - digitizing threshold
  37. This information holds \ref dig_head data structure.
  38. \section vlibDblnFileFormat DB link file format specification
  39. Each vector maps has its own DBMI settings stored in the
  40. '$MAPSET/vector/vector_name/dbln' text file. For each pair <em>vector map +
  41. layer</em>, all of <em>table, key column, database, driver</em> must be
  42. defined in a new row. This definition must be written to
  43. '$MAPSET/vector/vector_name/dbln' text file. Each row in the 'dbln'
  44. file contains names separated by spaces in following order ([ ] -
  45. optional):
  46. \verbatim
  47. map[@mapset] layer table [key [database [driver]]]
  48. \endverbatim
  49. If key, database or driver are omitted (on second and higher row only)
  50. the last definition is used. When reading a vector map from another
  51. mapset (if mapset is specified along with map name), definitions in
  52. the related "dbln" file may overwrite the DBMI definition in the
  53. current mapset. This means that the map-wise definition is always
  54. "stronger".
  55. Wild cards <b>*</b> and <b>?</b> may be used in map and mapset names.
  56. Variables $GISDBASE, $LOCATION_NAME, $MAPSET, and $MAP may be used in
  57. table, key, database and driver names (function
  58. Vect_subst_var()). Note that $MAPSET is not the current mapset but
  59. mapset of the map the rule is defined for.
  60. Note that vector features in GRASS vector maps may have attributes in
  61. different tables or may be without attributes. Boundaries form areas
  62. but it may happen that some boundaries are not closed (such boundaries
  63. would not appear in polygon layer). Boundaries may have
  64. attributes. All types may be mixed in one vector map.
  65. The link to the table is permanent and it is stored in 'dbln' file in
  66. vector directory. Tables are considered to be a part of the vector and
  67. the command <tt>g.remove</tt>, for example, deletes linked tables of
  68. the vector. Attributes must be joined with geometry.
  69. Information about database links holds \ref dblinks data structure.
  70. <b>Examples:</b>
  71. Examples are written mostly for the DBF driver, where database is full
  72. path to the directory with dbf files and table name is the name of dbf
  73. file without .dbf extension:
  74. \verbatim
  75. * 1 mytable id $GISDBASE/$LOCATION_NAME/$MAPSET/vector/$MAP dbf
  76. \endverbatim
  77. This definition says that entities with category of layer 1 are linked
  78. to dbf tables with names "mytable.dbf" saved in vector directories of
  79. each map. The attribute column containing the category numbers is
  80. called "id".
  81. \verbatim
  82. * 1 $MAP id $GISDBASE/$LOCATION_NAME/$MAPSET/dbf dbf
  83. \endverbatim
  84. Similar as above but all dbf files are in one directory dbf/ in mapset
  85. and names of dbf files are $MAP.dbf
  86. \verbatim
  87. water* 1 rivers id /home/grass/dbf dbf
  88. water* 2 lakes lakeid /home/guser/mydb
  89. trans* 1 roads key basedb odbc
  90. trans* 5 rails
  91. \endverbatim
  92. These definitions define more layers (called "field" in the API) for
  93. one vector map i.e. in one vector map may be more features linked to
  94. more attribute tables. Definitions on first 2 rows are applied for
  95. example on maps water1, water2, ... so that more maps may share one
  96. table.
  97. \verbatim
  98. water@PERMANENT 1 myrivers id /home/guser/mydbf dbf
  99. \endverbatim
  100. This definion overwrites the definition saved in PERMANENT/VAR and
  101. links the water map from PERMANENT mapset to the user's table.
  102. Modules should be written so that connections to databases for each
  103. vector layer are independent. It should be possible to read attributes
  104. of an input vector map from one database and write to some other and
  105. even with some other driver (should not be a problem).
  106. There are open questions, however. For one, how does one distinguish when
  107. new tables should be written and when not? For example, definitions:
  108. \verbatim
  109. river 1 river id water odbc
  110. river.backup* 1 NONE
  111. \endverbatim
  112. could be used to say that tables should not be copied for backups of
  113. map river because table is stored in a reliable RDBMS.
  114. \section vlibCoorFileFormat Coor file format specification
  115. In the coor file the following is stored: 'line' (element) type,
  116. number of attributes and layer number for each category. Coordinates
  117. in binary file are stored as double (8 bytes). See \ref Coor_info data
  118. structure.
  119. \subsection vlibCoorFileHead Header
  120. <table border="1" style="border-collapse: collapse" cellpadding="5">
  121. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  122. <tr><td>Version_Major</td> <td>C</td> <td>1</td> <td>file version (major)</td></tr>
  123. <tr><td>Version_Minor</td> <td>C</td> <td>1</td> <td>file version (minor)</td></tr>
  124. <tr><td>Back_Major</td> <td>C</td> <td>1</td> <td>supported from GRASS version (major)</td></tr>
  125. <tr><td>Back_Minor</td> <td>C</td> <td>1</td> <td>supported from GRASS version (minor)</td></tr>
  126. <tr><td>byte_order</td> <td>C</td> <td>1</td> <td>little or big endian flag</td></tr>
  127. <tr><td>head_size</td> <td>L</td> <td>1</td> <td>header size of coor file</td></tr>
  128. <tr><td>with_z</td> <td>C</td> <td>1</td> <td>2D or 3D flag; zero for 2D</td></tr>
  129. <tr><td>size</td> <td>L</td> <td>1</td> <td>coor file size</td></tr>
  130. </table>
  131. \subsection vlibCoorFileBody Body
  132. The body consists of line records:
  133. <table border="1" style="border-collapse: collapse" cellpadding="5">
  134. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  135. <tr><td>record header</td><td>C</td><td>1</td><td>
  136. - 0. bit: 1 - alive, 0 - dead line
  137. - 1. bit: 1 - categories, 0 - no categories
  138. - 2.-3. bit: type - one of: GV_POINT, GV_LINE, GV_BOUNDARY, GV_CENTROID, GV_FACE, GV_KERNEL
  139. - 4.-7. bit: reserved, not used
  140. </td></tr>
  141. <tr><td>ncats</td><td>I</td><td>1</td><td>number of categories
  142. (written only if categories exist) </td></tr>
  143. <tr><td>field</td><td>I</td><td>ncats</td><td>field identifier,
  144. distinguishes between more categories append to one feature (written
  145. only if categories exist; field is called "layer" at user
  146. level)</td></tr>
  147. <tr><td>cat</td><td>I</td><td>ncats</td><td>category value (written
  148. only if categories exist)</td></tr>
  149. <tr><td>ncoor</td><td>I</td><td>1</td><td>written for GV_LINES and GV_BOUNDARIES
  150. only</td></tr>
  151. <tr><td>x</td><td>D</td><td>ncoor</td><td>x coordinate</td></tr>
  152. <tr><td>y</td><td>D</td><td>ncoor</td><td>y coordinate</td></tr>
  153. <tr><td>z</td><td>D</td><td>ncoor</td><td>z coordinate; present if
  154. with_z in head is set to 1</td></tr> </table>
  155. Types used in coor file:
  156. <table border="1" style="border-collapse: collapse" cellpadding="5">
  157. <tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Size in Bytes</b></td></tr>
  158. <tr><td>D</td><td>Double</td><td>8</td></tr>
  159. <tr><td>L</td><td>Long </td><td>4</td></tr>
  160. <tr><td>I</td><td>Int </td><td>4</td></tr>
  161. <tr><td>S</td><td>Short </td><td>4</td></tr>
  162. <tr><td>C</td><td>Char </td><td>1</td></tr>
  163. </table>
  164. */