vectorlib.dox 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463
  1. /*! \page vectorlib GRASS Vector Library
  2. by GRASS Development Team (http://grass.osgeo.org)
  3. <b>Table of contents</b>
  4. - \subpage vlibBackground
  5. - \subpage vlibIntro
  6. - \subpage vlibVectorMap
  7. - \subpage vlibVectorLevels
  8. - \subpage vlibDirectoryStructure
  9. - \subpage vlibHeadFileFormat
  10. - \subpage vlibCategoriesLayers
  11. - \subpage vlibAttributes
  12. - \subpage vlibDblnFileFormat
  13. - \subpage vlibs
  14. - \subpage vlibHistory
  15. - \subpage vlibStructures
  16. - \subpage vlibGeometry
  17. - \subpage vlibFeatureTypes
  18. - \subpage vlibCoorFileFormat
  19. - \subpage vlibCoorFileHead
  20. - \subpage vlibCoorFileBody
  21. - \subpage vlibTopoManagement
  22. - \subpage vlibTopoFileFormat
  23. - \subpage vlibTopoFileHead
  24. - \subpage vlibTopoFileBody
  25. - \subpage vlibTopoLevels
  26. - \subpage vlibTopoExamples
  27. - \subpage vlibTopoMemory
  28. - \subpage vlibSpidx
  29. - \subpage vlibSidxFileFormat
  30. - \subpage vlibCidx
  31. - \subpage vlibCidxFileFormat
  32. - \subpage vlibCidxFileHead
  33. - \subpage vlibTin
  34. - \subpage vlibOgrIface
  35. - \subpage vlibFrmtFileFormat
  36. - \subpage vlibFidxFileFormat
  37. - \subpage vlibDglib
  38. - \subpage vlibAscii
  39. - \subpage vlibFunc
  40. - \subpage vlibAuthors
  41. - \subpage vlibReferences
  42. - \subpage vlibSeealso
  43. \section vlibBackground Background
  44. Generally, the vector data model is used to describe geographic
  45. phenomena which may be represented by geometric entities like
  46. <em>points</em>, <em>lines</em>, and <em>areas</em>. The GRASS vector
  47. data model includes the description of <em>topology</em>, where
  48. besides the coordinates describing the location of the primitives
  49. (points, lines, boundaries, centroids, faces, kernels, and volumes),
  50. their spatial relations are also stored. In general, topological GIS
  51. requires a data structure where the common boundary between two
  52. adjacent areas is stored as a single line, simplifying the vector data
  53. maintenance.
  54. \section vlibIntro Introduction
  55. The GRASS 6/7 vector format is very similar to the previous GRASS 4.x
  56. (5.0/5.3) vector format.
  57. This description covers the new GRASS 6/7 vector library architecture.
  58. This new architecture overcomes the vector limitations of GRASS
  59. 4.x-5.4.x by extending the vector support with attributes stored in
  60. the external relational databases, and by new 3D capabilities. Besides
  61. internal file based storage the geometry may alternatively be stored
  62. in a PostGIS database (accessible via OGR interface). This enables
  63. users to maintain large data sets with simultaneous write
  64. access. External GIS formats such as SHAPE-files may be used directly,
  65. without requiring format conversion. All vector data accessed through
  66. the OGR interface have only pseudo-topology and only a limited subset
  67. of vector operations can be performed.
  68. The current implementation includes:
  69. - <em>multi-layer</em>: features in one vector map may represent more
  70. layers and may be linked to more external tables (see \ref
  71. vlibCategoriesLayers)
  72. - <em>2D and 3D vector geometry</em> with full topology support for 2D and
  73. partial topology support for 3D (see \ref vlibTopoManagement)
  74. - <em>multi-format</em>: external data formats supported (SHAPE-file,
  75. OGR sources etc.)
  76. - <em>portability</em>: platform independent internal format, read- and
  77. writable on 32bit, 64bit etc. computer architectures
  78. - integrated \ref vlibDglib - support for vector network analysis
  79. - <em>spatial index</em>: based on R-tree method for fast vector
  80. geometry access (see \ref vlibSpidx)
  81. - <em>multi-attribute</em>: attributes saved in external Relational
  82. Database Management System (RDBMS) connected through DBMI
  83. library and drivers (see \ref vlibAttributes)
  84. \subsection vlibVectorMap Vector map definition (native format)
  85. GRASS vector maps are stored in an <em>arc-node</em> representation,
  86. consisting of curves called arcs. An arc is stored as a series of
  87. x,y,z coordinate pairs. The two endpoints of an arc are called
  88. <em>nodes</em>. Two consecutive x,y,z pairs define an arc segment. The
  89. user specifies the type of input to GRASS; GRASS doesn't decide. GRASS
  90. supports feature type definition which allows for multiple types to
  91. co-exist in the same map. A centroid is assigned to the area it is
  92. within/inside (geometrically). An area is defined by one or more
  93. boundaries that form a losed ring. The category to which an area belongs
  94. is stored with the centroid. Such centroids are stored in the same binary
  95. 'coor' file with other primitives. Each element may have none, one or
  96. more categories (cats). More cats can be distinguished by field number
  97. (field, called "layer" at user level). Single and multi-category
  98. support on modules level are implemented. The z coordinate is optional
  99. and both 2D and 3D files may be written.
  100. The following <em>vector feature types (primitives)</em> are defined
  101. by the vector library (and holds by the coor file; see also \ref
  102. vlibFeatureTypes):
  103. - point: a point (2D or 3D) - GV_POINT
  104. - line: a directed sequence of connected vertices with two endpoints
  105. called nodes (2D or 3D) - GV_LINE
  106. - boundary: the border line to describe an area (2D only) - GV_BOUNDARY
  107. - centroid: a point within a closed boundary(ies) to describe an area
  108. (2D only) - GV_CENTROID
  109. - face: a 3D boundary (not implemented yet) - GV_FACE
  110. - kernel: a 3D centroid in a volume - GV_KERNEL
  111. From vector feature types mentioned above are derived:
  112. - area: the topological composition of a closed ring of boundary(ies)
  113. and optionally a centroid (2D only, 3D coordinates supported but
  114. ignored) - GV_AREA
  115. - isle: an area within area, not touching the boundaries of the outer
  116. area (2D only, 3D coordinates supported but ignored)
  117. - volume: a 3D corpus, the topological composition of faces and
  118. kernel (not implemented yet) - GV_VOLUME
  119. - hole: a volume within volume, 3D equivalent to isle within area (not
  120. implemented yet)
  121. Note that all lines and boundaries can consist of multiple segments.
  122. Area topology also holds information about isles. <em>Isles</em> are
  123. located within an area, not touching the boundaries of the outer
  124. area. Isles consist of one or more areas and are used internally by
  125. the vector library to maintain correct topology of areas.
  126. \subsubsection vlibVectorLevels Levels of read access
  127. There are two levels of read access to the vector data:
  128. - <i>Level One</i> provides simple access to the vector feature
  129. information. There is no access to topology information at this
  130. level.
  131. - <i>Level Two</i> provides full access to all the information
  132. including topology information. This level requires more from the
  133. programmer, more memory, and longer startup time. Without this level,
  134. areas are not available.
  135. The level of access is retured by Vect_open_old().
  136. <b>Example for sequential read access without topology:</b>
  137. \code
  138. int main
  139. {
  140. int type, ltype;
  141. struct Map_info Map;
  142. struct line_pnts *Points;
  143. struct line_cat *Cats;
  144. const char *name, *mapset;
  145. /* set open level to 1: no topology */
  146. Vect_set_open_level(1);
  147. if (Vect_open_old(&Map, name, mapset) < 1)
  148. G_fatal_error(_("Failed to open vector '%s'"), name);
  149. /* rewind vector file */
  150. Vect_rewind(&Map);
  151. Points = Vect_new_line_struct();
  152. Cats = Vect_new_cats_struct();
  153. while ((ltype = Vect_read_next_line(&Map, Points, Cats) > 0) {
  154. /* check for desired type */
  155. if (!(ltype & type))
  156. continue;
  157. /* process the feature */
  158. }
  159. exit(EXIT_SUCCESS);
  160. }
  161. \endcode
  162. <b>Example for random read access with topology:</b>
  163. \code
  164. int main
  165. {
  166. int line, nlines, type, ltype;
  167. struct Map_info Map;
  168. struct line_pnts *Points;
  169. struct line_cat *Cats;
  170. const char *name, *mapset;
  171. if (Vect_open_old(&Map, name, mapset) < 2)
  172. G_fatal_error(_("Failed to open vector '%s'"), name);
  173. Points = Vect_new_line_struct();
  174. Cats = Vect_new_cats_struct();
  175. nlines = Vect_get_num_lines(&Map);
  176. for (line = 1; line <= nlines; line++) {
  177. /* check for desired type */
  178. if (!(Vect_get_line_type(&Map, line) & type))
  179. continue;
  180. Vect_read_line(&Map, points, cats, line);
  181. /* process the feature */
  182. }
  183. exit(EXIT_SUCCESS);
  184. }
  185. \endcode
  186. <b>Example for working with areas (requires topology):</b>
  187. \code
  188. int main
  189. {
  190. int area, nareas;
  191. struct Map_info Map;
  192. struct line_cat *Cats;
  193. const char *name, *mapset;
  194. if (Vect_open_old(&Map, name, mapset) < 2)
  195. G_fatal_error(_("Failed to open vector '%s'"), name);
  196. Points = Vect_new_line_struct();
  197. Cats = Vect_new_cats_struct();
  198. nareas = Vect_get_num_areas(&Map);
  199. for (area = 1; area <= nareas; area++) {
  200. /* process the area */
  201. /* example: get area categories */
  202. if (Vect_get_area_cats(&Map, area, Cats) == -1)
  203. G_message(_("No catagory available for area %d"), area);
  204. }
  205. exit(EXIT_SUCCESS);
  206. }
  207. \endcode
  208. <em>Note:</em> Higher level of access are planned, so when checking
  209. success return codes for a particular level of access (when calling
  210. Vect_open_old() for example), the programmer should use >= instead of
  211. == for compatibility with future releases.
  212. An existing vector map can be opened for reading by Vect_open_old().
  213. A new vector map can be created (or open for writing) by
  214. Vect_open_new(). Vect_open_old() attempts to open a vector map at the
  215. highest possible level of access. It will return the number of the
  216. level at which the map was opened. Vect_open_new() always opens at level 1
  217. only. If you require that a vector map be opened at a lower level
  218. (e.g. one), you can call the routine <tt>Vect_set_open_level(1)</tt>;
  219. Vect_open_old() will then either open at level one or fail. If you
  220. instead require the highest level access possible, you should not use
  221. Vect_set_open_level(), but instead check the return value of
  222. Vect_open_old() to make sure it is greater than or equal to the lowest
  223. level at which you need access. This allows for future levels to work
  224. without need for module change.
  225. \subsubsection vlibDirectoryStructure Directory structure
  226. Vector map is stored in a number of data files. Vector map directory
  227. structure and file names were changed in GRASS 6 with respect to
  228. previous GRASS versions. All vector files for one vector map are
  229. stored in one directory:
  230. \verbatim
  231. $MAPSET/vector/vector_name/
  232. \endverbatim
  233. This directory contains these files:
  234. - <b>coor</b> - binary file, coordinates [former dig/ file] (see \ref vlibCoorFileFormat)
  235. - <b>topo</b> - binary file, topology [former dig_plus/ file] (see \ref vlibTopoFileFormat)
  236. - <b>sidx</b> - binary file, spatial index (see \ref vlibSidxFileFormat)
  237. - <b>cidx</b> - binary file, category index (see \ref vlibCidxFileFormat)
  238. - <b>head</b> - text file, header information [former part of dig/ file] (see \ref vlibHeadFileFormat)
  239. - <b>dbln</b> - text file, link(s) to attribute table(s) (see \ref vlibDblnFileFormat)
  240. - <b>hist</b> - text file, vector map change history
  241. - <b>frmt</b> - text file, format description (external formats only)
  242. - <b>fidx</b> - binary file, feature index (OGR format only)
  243. \subsubsection vlibHeadFileFormat Header file format specification
  244. The header contains meta information, a description of the
  245. vector map and many other information. The file is an unordered list
  246. of key/value entries. The <i>key</i> is a string separated from
  247. <i>value</i> by a colon and optional whitespace.
  248. Keywords are:
  249. - ORGANIZATION - organization that digitized the data
  250. - DIGIT DATE - date the data was digitized
  251. - DIGIT NAME - person who digitized the data
  252. - MAP NAME - title of the original source map
  253. - MAP DATE - date of the original source map
  254. - MAP SCALE - scale of the original source map
  255. - OTHER INFO - other comments about the map
  256. - ZONE - zone of the map (e.g., UTM zone)
  257. - MAP THRESH - digitizing threshold
  258. This information holds \ref dig_head data structure.
  259. \subsection vlibCategoriesLayers Categories and Layers
  260. <i>Note: "layer" was called "field" in earlier version.</i>
  261. In GRASS, a "category" or "category number" is a vector feature ID
  262. used to link geometry to attributes which are stored in one or several
  263. (external) database table(s). This category number is stored into the
  264. vector geometry as well as a "cat" column (integer type) in each
  265. attribute database table. The category number is used to lookup an
  266. attribute assigned to a vector object. At user level, category numbers
  267. can be assigned to vector objects with the <tt>v.category</tt> command.
  268. In order to assign multiple attributes in different tables to vector
  269. objects, each map can hold multiple category numbers. This is achieved
  270. by assigning more than one "layer" to the map (<tt>v.db.connect</tt>
  271. command). The layer number determines which table to be used for
  272. attribute queries. For example, a cadastrial vector area map can be
  273. assigned on layer 1 to an attribute table containing landuse
  274. descriptions which are maintained by department A while layer 2 is
  275. assigned to an attribute table containing owner descriptions which are
  276. maintained by department B.
  277. Each vector feature inside a vector map has zero, one or more
  278. &lt;layer,category&gt; tuple(s). A user can (but not must) create
  279. attribute tables which are referenced by the layer, and rows which are
  280. essentially referenced by the &lt;layer,category&gt; pair.
  281. %Categories start with 1 (category '0' is allowed for OGR
  282. layers). %Categories do not have to be continuous.
  283. Information about categories holds \ref line_cats data structure.
  284. \subsection vlibAttributes Attributes
  285. The old GRASS 4.x 'dig_cats' files are not used any more and vectors'
  286. attributes are stored in external database. Connection with the
  287. database is done through drivers based on \ref dbmilib. Records in a
  288. table are linked to vector entities by layer and category number. The
  289. layer identifies table and the category identifies record. I.e., for
  290. any unique combination
  291. \verbatim
  292. map+mapset+layer+category
  293. \endverbatim
  294. there exists one unique combination
  295. \verbatim
  296. driver+database+table+row
  297. \endverbatim
  298. The general DBMI settings are defined in the '$MAPSET/VAR' text file
  299. (maintained with <tt>db.connect</tt> command at user level).
  300. \subsection vlibDblnFileFormat DB link file format specification
  301. Each vector maps has its own DBMI settings stored in the
  302. '$MAPSET/vector/vector_name/dbln' text file. For each pair <em>vector map +
  303. layer</em>, all of <em>table, key column, database, driver</em> must be
  304. defined in a new row. This definition must be written to
  305. '$MAPSET/vector/vector_name/dbln' text file. Each row in the 'dbln'
  306. file contains names separated by spaces in following order ([ ] -
  307. optional):
  308. \verbatim
  309. map[@mapset] layer table [key [database [driver]]]
  310. \endverbatim
  311. If key, database or driver are omitted (on second and higher row only)
  312. the last definition is used. When reading a vector map from another
  313. mapset (if mapset is specified along with map name), definitions in
  314. the related "dbln" file may overwrite the DBMI definition in the
  315. current mapset. This means that the map-wise definition is always
  316. "stronger".
  317. Wild cards <b>*</b> and <b>?</b> may be used in map and mapset names.
  318. Variables $GISDBASE, $LOCATION_NAME, $MAPSET, and $MAP may be used in
  319. table, key, database and driver names (function
  320. Vect_subst_var()). Note that $MAPSET is not the current mapset but
  321. mapset of the map the rule is defined for.
  322. Note that vector features in GRASS vector maps may have attributes in
  323. different tables or may be without attributes. Boundaries form areas
  324. but it may happen that some boundaries are not closed (such boundaries
  325. would not appear in polygon layer). Boundaries may have
  326. attributes. All types may be mixed in one vector map.
  327. The link to the table is permanent and it is stored in 'dbln' file in
  328. vector directory. Tables are considered to be a part of the vector and
  329. the command <tt>g.remove</tt>, for example, deletes linked tables of
  330. the vector. Attributes must be joined with geometry.
  331. Information about database links holds \ref dblinks data structure.
  332. <b>Examples:</b>
  333. Examples are written mostly for the DBF driver, where database is full
  334. path to the directory with dbf files and table name is the name of dbf
  335. file without .dbf extension:
  336. \verbatim
  337. * 1 mytable id $GISDBASE/$LOCATION_NAME/$MAPSET/vector/$MAP dbf
  338. \endverbatim
  339. This definition says that entities with category of layer 1 are linked
  340. to dbf tables with names "mytable.dbf" saved in vector directories of
  341. each map. The attribute column containing the category numbers is
  342. called "id".
  343. \verbatim
  344. * 1 $MAP id $GISDBASE/$LOCATION_NAME/$MAPSET/dbf dbf
  345. \endverbatim
  346. Similar as above but all dbf files are in one directory dbf/ in mapset
  347. and names of dbf files are $MAP.dbf
  348. \verbatim
  349. water* 1 rivers id /home/grass/dbf dbf
  350. water* 2 lakes lakeid /home/guser/mydb
  351. trans* 1 roads key basedb odbc
  352. trans* 5 rails
  353. \endverbatim
  354. These definitions define more layers (called "field" in the API) for
  355. one vector map i.e. in one vector map may be more features linked to
  356. more attribute tables. Definitions on first 2 rows are applied for
  357. example on maps water1, water2, ... so that more maps may share one
  358. table.
  359. \verbatim
  360. water@PERMANENT 1 myrivers id /home/guser/mydbf dbf
  361. \endverbatim
  362. This definion overwrites the definition saved in PERMANENT/VAR and
  363. links the water map from PERMANENT mapset to the user's table.
  364. Modules should be written so that connections to databases for each
  365. vector layer are independent. It should be possible to read attributes
  366. of an input vector map from one database and write to some other and
  367. even with some other driver (should not be a problem).
  368. There are open questions, however. For one, how does one distinguish when
  369. new tables should be written and when not? For example, definitions:
  370. \verbatim
  371. river 1 river id water odbc
  372. river.backup* 1 NONE
  373. \endverbatim
  374. could be used to say that tables should not be copied for backups of
  375. map river because table is stored in a reliable RDBMS.
  376. \section vlibs Vector libraries
  377. Besides internal library functions there are two main libraries:
  378. - Vlib (Vector library), see \ref vlibIntro
  379. - DGLib (Directed Graph Library), see \ref vlibDglib
  380. For historical reasons, there are two internal libraries:
  381. - diglib (with dig_*() functions), GRASS 3.x/4.x
  382. - Vlib (with V1_*(), V2_*() and Vect_*() functions), since GRASS 4.x
  383. (except for the 5.7 interim version)
  384. The vector library was introduced in GRASS 4.0 to hide internal vector
  385. files' formats and structures. In GRASS 6/7, everything is accessed via
  386. Vect_*() functions, for example:
  387. Old 4.x code:
  388. \code
  389. xx = Map.Att[Map.Area[area_num].att].x;
  390. \endcode
  391. New 6.x/7.x functions:
  392. \code
  393. centroid = Vect_get_area_centroid(Map, area_num);
  394. Vect_read_line(Map, line_p, NULL, centroid);
  395. Vect_line_get_point(line_p, 0, &xx, NULL, NULL);
  396. \endcode
  397. In GRASS 6/7, all internal, mostly non-topological vector functions are
  398. hidden from the modules' API (mainly dig_*(), V1_*() and V2_*()
  399. functions). All available Vect_*() functions are topological vector
  400. functions.
  401. The following include file contains definitions and structures
  402. required by some of the routines in this library. The programmer
  403. should therefore include this file in any code that uses the vector
  404. library:
  405. \code
  406. #include <grass/vector.h>
  407. \endcode
  408. <i>Note: For details please read Blazek et al. 2002 (see below) as
  409. well as the references in this document.</i>
  410. \subsection vlibHistory Historical notes
  411. The vector library in GRASS 4.0 changed significantly from the
  412. <em>Digit Library</em> (diglib) used in GRASS 3.1. Below is an
  413. overview of why the changes were made.
  414. The Digit Library was a collage of subroutines created for developing
  415. the map development programs. Few of these subroutines were actually
  416. designed as a user access library. They required individuals to assume
  417. too much responsibility and control over what happened to the data
  418. file. Thus when it came time to change vector data file formats for
  419. GRASS 4.0, many modules also required modification. The two different
  420. access levels for 3.0 vector files provided very different ways of
  421. calling the library; they offered little consistency for the user.
  422. The Digit Library was originally designed to only have one file open
  423. for read or write at a time. Although it was possible in some cases to
  424. get around this, one restriction was the global head structure. Since
  425. there was only one instance of this, there could only be one copy of
  426. that information, and thus, only one open vector file.
  427. The solution to these problems was to design a new user library as an
  428. interface to the vector data files. This new library was designed to
  429. provide a simple consistent interface, which hides as much of the
  430. details of the data format as possible. It also could be extended for
  431. future enhancements without the need to change existing programs.
  432. The new vector library in GRASS 4 provided routines for opening,
  433. closing, reading, and writing vector files, as well as several support
  434. functions. The Digit Library has been replaced, so that all existing
  435. modules was converted to use the new library. Those routines that
  436. existed in the Digit Library and were not affected by these changes
  437. continue to exist in unmodified form, and were included in the vector
  438. library. Most of the commonly used routines have been discarded, and
  439. replaced by the new vector routines.
  440. Instead the global head structure was used own local version of
  441. it. The structure that replaced structure head is structure \ref
  442. dig_head. There were still two levels of interface to the vector files
  443. (future releases may include more). Level one provided access only to
  444. arc (i.e. polyline) information and to the type of line (AREA, LINE,
  445. DOT). Level two provided access to polygons (areas), attributes, and
  446. network topology.
  447. \section vlibStructures Vector library data structures
  448. All data structure used by the vector library are defined in
  449. include/vect/dig_structs.h. See the list bellow:
  450. Major:
  451. - \ref Map_info
  452. - \ref Plus_head
  453. - \ref dig_head
  454. Supporting:
  455. - \ref bound_box
  456. - \ref gvfile
  457. - \ref Port_info
  458. - \ref Coor_info
  459. - \ref spatial_index
  460. Format-related:
  461. - \ref Format_info
  462. - \ref Format_info_ogr
  463. DB-related:
  464. - \ref field_info
  465. - \ref dblinks
  466. Geometry-related:
  467. - \ref line_pnts
  468. Category-related:
  469. - \ref line_cats
  470. - \ref cat_list
  471. - \ref Cat_index
  472. Topology-related:
  473. - \ref P_node
  474. - \ref P_line
  475. - \ref P_area
  476. - \ref P_isle
  477. Misc:
  478. - \ref ilist
  479. - \ref varray
  480. Obsolete:
  481. - \ref site_att
  482. - \ref recycle
  483. \section vlibGeometry Vector library feature geometry
  484. \subsection vlibFeatureTypes Feature types
  485. Feature types are defined in include/vect_dig_defines.h, see the list bellow:
  486. - GV_POINT
  487. - GV_LINE
  488. - GV_BOUNDARY
  489. - GV_CENTROID
  490. - GV_FACE
  491. - GV_KERNEL
  492. - GV_AREA
  493. - GV_VOLUME
  494. - GV_POINTS (GV_POINT | GV_CENTROID)
  495. - GV_LINES (GV_LINE | GV_BOUNDARY)
  496. Face and kernel are 3D equivalents of boundary and centroid, but there
  497. is no support (yet) for 3D topology (volumes). Faces are used in a
  498. couple of modules including NVIZ to visualize 3D buildings and other
  499. volumetric figures.
  500. \subsection vlibCoorFileFormat Coor file format specification
  501. In the coor file the following is stored: 'line' (element) type,
  502. number of attributes and layer number for each category. Coordinates
  503. in binary file are stored as double (8 bytes). See \ref Coor_info data
  504. structure.
  505. \subsubsection vlibCoorFileHead Header
  506. <table border="1" style="border-collapse: collapse" cellpadding="5">
  507. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  508. <tr><td>Version_Major</td> <td>C</td> <td>1</td> <td>file version (major)</td></tr>
  509. <tr><td>Version_Minor</td> <td>C</td> <td>1</td> <td>file version (minor)</td></tr>
  510. <tr><td>Back_Major</td> <td>C</td> <td>1</td> <td>supported from GRASS version (major)</td></tr>
  511. <tr><td>Back_Minor</td> <td>C</td> <td>1</td> <td>supported from GRASS version (minor)</td></tr>
  512. <tr><td>byte_order</td> <td>C</td> <td>1</td> <td>little or big endian flag</td></tr>
  513. <tr><td>head_size</td> <td>L</td> <td>1</td> <td>header size of coor file</td></tr>
  514. <tr><td>with_z</td> <td>C</td> <td>1</td> <td>2D or 3D flag; zero for 2D</td></tr>
  515. <tr><td>size</td> <td>L</td> <td>1</td> <td>coor file size</td></tr>
  516. </table>
  517. \subsubsection vlibCoorFileBody Body
  518. The body consists of line records:
  519. <table border="1" style="border-collapse: collapse" cellpadding="5">
  520. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  521. <tr><td>record header</td><td>C</td><td>1</td><td>
  522. - 0. bit: 1 - alive, 0 - dead line
  523. - 1. bit: 1 - categories, 0 - no categories
  524. - 2.-3. bit: type - one of: GV_POINT, GV_LINE, GV_BOUNDARY, GV_CENTROID, GV_FACE, GV_KERNEL
  525. - 4.-7. bit: reserved, not used
  526. </td></tr>
  527. <tr><td>ncats</td><td>I</td><td>1</td><td>number of categories
  528. (written only if categories exist) </td></tr>
  529. <tr><td>field</td><td>I</td><td>ncats</td><td>field identifier,
  530. distinguishes between more categories append to one feature (written
  531. only if categories exist; field is called "layer" at user
  532. level)</td></tr>
  533. <tr><td>cat</td><td>I</td><td>ncats</td><td>category value (written
  534. only if categories exist)</td></tr>
  535. <tr><td>ncoor</td><td>I</td><td>1</td><td>written for GV_LINES and GV_BOUNDARIES
  536. only</td></tr>
  537. <tr><td>x</td><td>D</td><td>ncoor</td><td>x coordinate</td></tr>
  538. <tr><td>y</td><td>D</td><td>ncoor</td><td>y coordinate</td></tr>
  539. <tr><td>z</td><td>D</td><td>ncoor</td><td>z coordinate; present if
  540. with_z in head is set to 1</td></tr> </table>
  541. Types used in coor file:
  542. <table border="1" style="border-collapse: collapse" cellpadding="5">
  543. <tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Size in Bytes</b></td></tr>
  544. <tr><td>D</td><td>Double</td><td>8</td></tr>
  545. <tr><td>L</td><td>Long </td><td>4</td></tr>
  546. <tr><td>I</td><td>Int </td><td>4</td></tr>
  547. <tr><td>S</td><td>Short </td><td>4</td></tr>
  548. <tr><td>C</td><td>Char </td><td>1</td></tr>
  549. </table>
  550. \section vlibTopoManagement Vector library topology management
  551. Topology general characteristics:
  552. - geometry and attributes are stored separately
  553. (don't read both if it is not necessary - usually it is not)
  554. - the format is topological (areas build from boundaries)
  555. - currently only 2D topology is supported
  556. Topology is written for native GRASS vector format; in case of
  557. linked OGR sources (see <tt>v.external</tt> module), only
  558. pseudo-topology (boundaries constructed from polygons) is written.
  559. The following rules apply to the vector data:
  560. - Boundaries should not cross each other (i.e., boundaries which would
  561. cross must be split at their intersection to form distict boundaries).
  562. On the contrary, lines can cross each other, e.g. bridges over rivers.
  563. - Lines and boundaries share nodes only if their endpoints are identical.
  564. Lines or boundaries can be forced to share a common node by snapping
  565. them together. This is particulary important since nodes
  566. are not represented in the coor file, but only implicitly as
  567. endpoints of lines and boundaries.
  568. - Common area boundaries should appear only once (i.e., should not be
  569. double digitized).
  570. - Areas must be explicitly closed. This means that it must be possible
  571. to complete each area by following one or more boundaries that are
  572. connected by common nodes, and that such tracings result in closed
  573. areas.
  574. - It is recommended that area features and linear features be placed
  575. in separate layers. However if area features and linear features
  576. must appear in one layer, common boundaries should be digitized only
  577. once. For example, a boundary that is also a line (e.g., a road which
  578. is also a field boundary), should be digitized as a boundary to
  579. complete the area(s), and a boundary which is functionally also a line
  580. should be labeled as a line by a distinct category number.
  581. Vector map topology can be cleaned at user level by <tt>v.clean</tt>
  582. command.
  583. \subsection vlibTopoFileFormat Topo file format specification
  584. Topo file is read by Vect_open_topo().
  585. \subsubsection vlibTopoFileHead Header
  586. <i>Note:</i> <tt>plus</tt> is an instance of \ref Plus_head data structure.
  587. <table border="1" style="border-collapse: collapse" cellpadding="5">
  588. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  589. <tr><td>plus->Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  590. <tr><td>plus->Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  591. <tr><td>plus->Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  592. <tr><td>plus->Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  593. <tr><td>plus->port->byte_order</td><td>C</td><td>1</td><td>little or big endian
  594. flag; files are written in machine native order but
  595. files in both little and big endian order may be
  596. readl; zero for little endian</td></tr>
  597. <tr><td>plus->head_size</td><td>L</td><td>1</td><td>header size</td></tr>
  598. <tr><td>plus->with_z</td><td>C</td><td>1</td><td>2D or 3D flag; zero for 2D</td></tr>
  599. <tr><td>plus->box</td><td>D</td><td>6</td><td>Bounding box coordinates (N,S,E,W,T,B)</td></tr>
  600. <tr><td>plus->n_nodes, plus->n_lines, etc.</td><td>I</td><td>7</td><td>Number of
  601. nodes, edges, lines, areas, isles, volumes and holes</td></tr>
  602. <tr><td>plus->n_plines, plus->n_llines, etc.</td><td>I</td><td>7</td><td>Number of
  603. points, lines, boundaries, centroids, faces and kernels</td></tr>
  604. <tr><td>plus->Node_offset, plus->Edge_offset,
  605. etc.</td><td>L</td><td>7</td><td>Offset value for nodes, edges, lines,
  606. areas, isles, volumes and holes</td></tr>
  607. <tr><td>plus->coor_size</td><td>L</td><td>1</td><td>File size</td></tr>
  608. </table>
  609. \subsubsection vlibTopoFileBody Body (nodes, lines, areas, isles)
  610. <b>Nodes</b>
  611. For each node (plus->n_nodes):
  612. <table border="1" style="border-collapse: collapse" cellpadding="5">
  613. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  614. <tr><td>n_lines</td><td>I</td><td>1</td><td>Number of lines (0 for dead node)</td></tr>
  615. <tr><td>lines</td><td>I</td><td>n_lines</td><td>Line ids (negative id for line which ends at the node)</td></tr>
  616. <tr><td>angles</td><td>D</td><td>n_lines</td><td>Angle value</td></tr>
  617. <tr><td>n_edges</td><td>I</td><td>1</td><td>Reserved for edges (only for <tt>with_z</tt>)</td></tr>
  618. <tr><td>x,y</td><td>D</td><td>2</td><td>Coordinate pair (2D)</td></tr>
  619. <tr><td>z</td><td>D</td><td>1</td><td>Only for <tt>with_z</tt> (3D)</td></tr>
  620. </table>
  621. See \ref P_node data structure.
  622. <b>Lines</b>
  623. For each line (plus->n_lines):
  624. <table border="1" style="border-collapse: collapse" cellpadding="5">
  625. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  626. <tr><td>feature type</td><td>C</td><td>1</td><td>0 for dead line</td></tr>
  627. <tr><td>offset</td><td>L</td><td>1</td><td>Line offset</td></tr>
  628. <tr><td>N1</td><td>I</td><td>1</td><td>Start node id (only if feature type is GV_LINE or GV_BOUNDARY)</td></tr>
  629. <tr><td>N2</td><td>I</td><td>1</td><td>End node id (only if feature type is GV_LINE or GV_BOUNDARY)</td></tr>
  630. <tr><td>left</td><td>I</td><td>1</td><td>Left area id for feature type GV_BOUNDARY / Area id for feature type GV_CENTROID</td></tr>
  631. <tr><td>right</td><td>I</td><td>1</td><td>Right area id (for feature type GV_BOUNDARY)</td></tr>
  632. <tr><td>vol</td><td>I</td><td>1</td><td>Reserved for kernel (volume number, for feature type GV_KERNEL)</td></tr>
  633. </table>
  634. See \ref P_line data structure.
  635. <b>Areas</b>
  636. For each area (plus->n_areas):
  637. <table border="1" style="border-collapse: collapse" cellpadding="5">
  638. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  639. <tr><td>n_lines</td><td>I</td><td>1</td><td>number of boundaries</td></tr>
  640. <tr><td>lines</td><td>I</td><td>n_lines</td><td>Line ids forming exterior boundary (clockwise order, negative id for backward direction)</td></tr>
  641. <tr><td>n_isles</td><td>I</td><td>1</td><td>Number of isles</td></tr>
  642. <tr><td>isles</td><td>I</td><td>n_isles</td><td>Isle ids</td></tr>
  643. <tr><td>centroid</td><td>I</td><td>1</td><td>Centroid id</td></tr>
  644. </table>
  645. See \ref P_area data structure.
  646. <b>Isles</b>
  647. For each isle (plus->n_isle):
  648. <table border="1" style="border-collapse: collapse" cellpadding="5">
  649. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  650. <tr><td>n_lines</td><td>I</td><td>1</td><td>number of boundaries</td></tr>
  651. <tr><td>lines</td><td>I</td><td>n_lines</td><td>Line ids forming exterior boundary (counter-clockwise order, negative id for backward direction)</td></tr>
  652. <tr><td>area</td><td>I</td><td>1</td><td>Outer area id</td></tr>
  653. </table>
  654. See \ref P_isle data structure.
  655. \subsection vlibTopoLevels Topology levels
  656. The vector library defines more <i>topology levels</i> (only for level
  657. of access 2):
  658. - GV_BUILD_NONE
  659. - GV_BUILD_BASE
  660. - GV_BUILD_AREAS
  661. - GV_BUILD_ATTACH_ISLES
  662. - GV_BUILD_CENTROIDS
  663. - GV_BUILD_ALL
  664. <i>Note:</i> Only the geometry type GV_BOUNDARY is used to build
  665. areas. The geometry type GV_LINE cannot form an area.
  666. \subsection vlibTopoExamples Topology examples
  667. <b>Points</b>
  668. \verbatim
  669. One point (nodes: 0, lines: 1, areas: 0, isles: 0)
  670. + N1/L1
  671. \endverbatim
  672. Line L1 (see \ref P_line)
  673. \verbatim
  674. line = 1, type = 1 (GV_POINT)
  675. \endverbatim
  676. <b>Lines</b>
  677. \verbatim
  678. One line (nodes: 2, lines: 1, areas: 0, isles: 0)
  679. +----L1----+
  680. N1 N2
  681. \endverbatim
  682. %Node N1 (see \ref P_node)
  683. \verbatim
  684. node = 1, n_lines = 1, xyz = 634624.746450, 223557.302231, 0.000000
  685. line = 1, type = 2 (GV_LINE), angle = -0.436257
  686. \endverbatim
  687. %Node N2 (see \ref P_node)
  688. \verbatim
  689. node = 2, n_lines = 1, xyz = 638677.484787, 221667.849899, 0.000000
  690. line = -1, type = 2 (GV_LINE), angle = 2.705335
  691. \endverbatim
  692. Line L1 (see \ref P_line)
  693. \verbatim
  694. line = 1, type = 2 (GV_LINE), n1 = 1, n2 = 2
  695. \endverbatim
  696. <b>Areas without holes</b>
  697. \verbatim
  698. Two lines (nodes: 1, lines: 2, areas: 1, isles: 1)
  699. +N1
  700. / \
  701. / \
  702. / \
  703. / +L2 \
  704. / \
  705. -------L1------
  706. \endverbatim
  707. %Node N1 (see \ref P_node)
  708. \verbatim
  709. node = 1, n_lines = 2, xyz = 635720.081136, 225063.387424, 0.000000
  710. line = 1, type = 4 (GV_BOUNDARY), angle = -2.245537
  711. line = -1, type = 4 (GV_BOUNDARY), angle = -0.842926
  712. \endverbatim
  713. Line L1 (see \ref P_line)
  714. \verbatim
  715. line = 1, type = 4 (GV_BOUNDARY), n1 = 1, n2 = 1, left = 1, right = -1
  716. \endverbatim
  717. Line L2 (see \ref P_line)
  718. \verbatim
  719. line = 2, type = 8 (GV_CENTROID), area = 1
  720. \endverbatim
  721. Area A1 (see \ref P_area)
  722. \verbatim
  723. area = 1, n_lines = 1, n_isles = 0 centroid = 2
  724. line = -1
  725. \endverbatim
  726. Isle I1 (see \ref P_isle)
  727. \verbatim
  728. isle = 1, n_lines = 1 area = 0
  729. line = 1
  730. \endverbatim
  731. <b>Areas with holes</b>
  732. \verbatim
  733. Three lines (nodes: 2, lines: 3, areas: 2, isles: 2)
  734. +N1
  735. / \
  736. / \
  737. / \
  738. / \
  739. / +L2 \
  740. / \
  741. / +N2 \
  742. / /\ \
  743. / / \ \
  744. / / \ \
  745. / ---L3-- \
  746. / \
  747. ------------L1-------------
  748. \endverbatim
  749. %Node N1 (see \ref P_node)
  750. \verbatim
  751. node = 1, n_lines = 2, xyz = 635720.081136, 225063.387424, 0.000000
  752. line = 1, type = 4 (GV_BOUNDARY), angle = -2.245537
  753. line = -1, type = 4 (GV_BOUNDARY), angle = -0.842926
  754. \endverbatim
  755. %Node N2 (see \ref P_node)
  756. \verbatim
  757. node = 2, n_lines = 2, xyz = 636788.032454, 223173.935091, 0.000000
  758. line = 3, type = 4 (GV_BOUNDARY), angle = -2.245537
  759. line = -3, type = 4 (GV_BOUNDARY), angle = -0.866302
  760. \endverbatim
  761. Line L1 (see \ref P_line)
  762. \verbatim
  763. line = 1, type = 4 (GV_BOUNDARY), n1 = 1, n2 = 1, left = 1, right = -1
  764. \endverbatim
  765. Line L2 (see \ref P_line)
  766. \verbatim
  767. line = 2, type = 8 (GV_CENTROID), area = 1
  768. \endverbatim
  769. Line L3 (see \ref P_line)
  770. \verbatim
  771. line = 3, type = 4 (GV_BOUNDARY), n1 = 3, n2 = 3, left = 2, right = -2
  772. \endverbatim
  773. Area A1 (see \ref P_area)
  774. \verbatim
  775. area = 1, n_lines = 1, n_isles = 1 centroid = 2
  776. line = -1
  777. isle = 2
  778. \endverbatim
  779. Area A2 (see \ref P_area)
  780. \verbatim
  781. area = 2, n_lines = 1, n_isles = 0 centroid = 0
  782. line = -3
  783. \endverbatim
  784. Isle I1 (see \ref P_isle)
  785. \verbatim
  786. isle = 1, n_lines = 1 area = 0
  787. line = 1
  788. \endverbatim
  789. Isle I2 (see \ref P_isle)
  790. \verbatim
  791. isle = 2, n_lines = 1 area = 1
  792. line = 3
  793. \endverbatim
  794. <b>Example 1</b>
  795. A polygon may be formed by many boundaries (several connected primitives).
  796. One boundary is shared by adjacent areas.
  797. \verbatim
  798. +--1--+--5--+
  799. | | |
  800. 2 A 4 B 6
  801. | | |
  802. +--3--+--7--+
  803. 1,2,3,4,5,6,7 = 7 boundaries (primitives)
  804. A,B = 2 areas
  805. A+B = 1 isle
  806. \endverbatim
  807. <b>Example 2</b>
  808. This is handled correctly in GRASS: A can be filled, B filled differently.
  809. \verbatim
  810. +---------+
  811. | A |
  812. +-----+ |
  813. | B | |
  814. +-----+ |
  815. | |
  816. +---------+
  817. A, B = 2 areas
  818. A+B = 1 isle
  819. \endverbatim
  820. In GRASS, whenever an 'inner' ring touches the boundary of an outside
  821. area, even in one point, it is no longer an 'inner' ring (isle in
  822. GRASS topology), it is simply another area. A, B above can never be
  823. exported from GRASS as polygon A with inner ring B because there are
  824. only 2 areas A and B and one island formed by A and B together.
  825. <b>Example 3</b>
  826. This is handled correctly in GRASS: Areas A1, A2, and A3 can be filled differently.
  827. \verbatim
  828. +---------------------+
  829. | A1 |
  830. + +------+------+ |
  831. | | A2 | A3 | |
  832. + +------+------+ |
  833. | I1 |
  834. +---------------------+
  835. A1,A2,A3 = 3 areas
  836. A1,A2+A3 = 2 isles
  837. \endverbatim
  838. In GRASS, whenever an 'inner' ring does not touch the boundary of an
  839. outside area, also not in one point, it is an 'inner' ring (isle). The
  840. areas A2 and A3 form a single isle I1 located within area A1. The size
  841. of isle I1 is substracted from the size of area A1 when calculating
  842. the size of area A1. Any centroids falling into isle I1 are excluded
  843. when searching for a centroid that can be attached to area A1. A1
  844. above can be exported from GRASS as polygon A1 with inner ring I1.
  845. <b>Example 4</b>
  846. <tt>v.in.ogr/v.clean</tt> can identify dangles and change the type
  847. from boundary to line (in TIGER data for example). Distinction
  848. between line and boundary isn't important only for dangles. Example:
  849. \verbatim
  850. +-----+-----+
  851. | . |
  852. | . |
  853. +.....+.....+
  854. | . |
  855. | x . |
  856. +-----+-----+
  857. ---- road + boundary of one parcel => type boundary
  858. .... road => type line
  859. x parcel centroid (identifies whole area)
  860. \endverbatim
  861. Because lines are not used to build areas, we have only one
  862. area/centroid, instead of 4 which would be necessary in TIGER.
  863. \subsection vlibTopoMemory Topology memory management
  864. Topology is generated for all kinds of vector types. Memory is not
  865. released by default. The programmer can force the library to release
  866. the memory by using Vect_set_release_support(). But: The programmer
  867. cannot run Vect_set_release_support() in mid process because all
  868. vectors are needed in the spatial index, which is needed to build topology.
  869. Topology is also necessary for points in case of a vector network
  870. because the graph is built using topology information about lines
  871. and points.
  872. The topology structure does not only store the topology but also
  873. the 'line' bounding box and line offset in coor file (index).
  874. The existing spatial index is using line ID in 'topology' structure
  875. to identify lines in 'coor' file. Currently it is not possible to build
  876. spatial index without topology.
  877. \section vlibSpidx Vector library spatial index management
  878. Spatial index (based on R*-tree) is created with topology, see \ref
  879. RTree data structure.
  880. Spatial index occupies a lot of memory but it is necessary for
  881. topology building. Also, it takes some time to release the memory
  882. occupied by spatial index (see dig_spidx_free()). The spatial index can
  883. also be built in file to save memory by setting the environment variable
  884. GRASS_VECTOR_LOWMEM.
  885. The function building topology - Vect_build() - is usually called at
  886. the end of modules (before Vect_close()) so it is faster to call
  887. <tt>exit()</tt> and operating system releases all the memory much
  888. faster. By default the memory is not released.
  889. It is possible to call Vect_set_release_support() before Vect_close()
  890. to enforce memory release, but it takes some time on large files.
  891. The spatial index is stored in file and not loaded for old vectors that
  892. are not updated, saving a lot of memory. Spatial queries are done in
  893. file.
  894. Currently most of the modules do not release the memory occupied for
  895. spatial index and work like this (pseudocode):
  896. \code
  897. int main
  898. {
  899. Vect_open_new();
  900. /* writing new vector */
  901. Vect_build();
  902. Vect_close(); /* memory is not released */
  903. }
  904. \endcode
  905. In general it is possible to free the memory with Vect_set_release_support()
  906. such as:
  907. \code
  908. int main
  909. {
  910. Vect_open_new();
  911. /* writing new vector */
  912. Vect_build();
  913. Vect_set_release_support();
  914. Vect_close(); /* memory is released */
  915. }
  916. \endcode
  917. but it takes a bit longer.
  918. It makes sense to release the spatial index if it is used only at the beginning
  919. of a module or in permanently running programs like QGIS. Note that this
  920. applies only when creating a new vector or updating an old vector.
  921. For example:
  922. \code
  923. int main
  924. {
  925. Vect_open_update();
  926. /* select features using spatial index, e.g. Vect_select_lines_by_box() */
  927. Vect_set_release_support();
  928. Vect_close(); /* memory is released */
  929. /* do some processing which needs memory */
  930. }
  931. \endcode
  932. See also \ref spatial_index data structure.
  933. \subsection vlibSidxFileFormat Sidx file format specification
  934. Spatial index file ('sidx') is read by Vect_open_sidx().
  935. \subsubsection vlibSidxFileHead Header
  936. Note: <tt>plus</tt> is instance of \ref Plus_head structure.
  937. <table border="1" style="border-collapse: collapse" cellpadding="5">
  938. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  939. <tr><td>plus->spidx_Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  940. <tr><td>plus->spidx_Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  941. <tr><td>plus->spidx_Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  942. <tr><td>plus->spidx_Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  943. <tr><td>plus->spidx_port->byte_order</td><td>C</td><td>1</td><td>little or big endian
  944. flag; files are written in machine native order but
  945. files in both little and big endian order may be
  946. readl; zero for little endian</td></tr>
  947. <tr><td>plus->spidx_port.off_t_size</td><td>C</td><td>1</td><td>off_t size (LFS)</td></tr>
  948. <tr><td>plus->spidx_head_size</td><td>L</td><td>1</td><td>header size</td></tr>
  949. <tr><td>plus->spidx_with_z</td><td>C</td><td>1</td><td>2D/3D vector data</td></tr>
  950. <tr><td>ndims</td><td>C</td><td>1</td><td>Number of dimensions</td></tr>
  951. <tr><td>nsides</td><td>C</td><td>1</td><td>Number of sides</td></tr>
  952. <tr><td>nodesize</td><td>I</td><td>1</td><td>%Node size</td></tr>
  953. <tr><td>nodecard</td><td>I</td><td>1</td><td>%Node card (?)</td></tr>
  954. <tr><td>leafcard</td><td>I</td><td>1</td><td>Leaf card (?)</td></tr>
  955. <tr><td>min_node_fill</td><td>I</td><td>1</td><td>Minimum node fill (?)</td></tr>
  956. <tr><td>min_leaf_fill</td><td>I</td><td>1</td><td>Minimum leaf fill (?)</td></tr>
  957. <tr><td>plus->Node_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  958. <tr><td>plus->Node_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  959. <tr><td>plus->Node_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  960. <tr><td>plus->Node_spidx_offset</td><td>O</td><td>1</td><td>%Node offset</td></tr>
  961. <tr><td>plus->Line_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  962. <tr><td>plus->Line_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  963. <tr><td>plus->Line_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  964. <tr><td>plus->Line_spidx_offset</td><td>O</td><td>1</td><td>Line offset</td></tr>
  965. <tr><td>plus->Area_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  966. <tr><td>plus->Area_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  967. <tr><td>plus->Area_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  968. <tr><td>plus->Area_spidx_offset</td><td>O</td><td>1</td><td>Area offset</td></tr>
  969. <tr><td>plus->Isle_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  970. <tr><td>plus->Isle_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  971. <tr><td>plus->Isle_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  972. <tr><td>plus->Isle_spidx_offset</td><td>O</td><td>1</td><td>Isle offset</td></tr>
  973. <tr><td>plus->Face_spidx_offset</td><td>O</td><td>1</td><td>Face offset</td></tr>
  974. <tr><td>plus->Volume_spidx_offset</td><td>O</td><td>1</td><td>Volume offset</td></tr>
  975. <tr><td>plus->Hole_spidx_offset</td><td>O</td><td>1</td><td>Hole offset</td></tr>
  976. <tr><td>plus->coor_size</td><td>O</td><td>1</td><td>Coor file size</td></tr>
  977. </table>
  978. \section vlibCidx Vector library category index management
  979. The category index (stored in the cidx file) improves the performance
  980. of all selections by cats/attributes (SQL, e.g. <tt>d.vect
  981. cats=27591</tt>, <tt>v.extract list=20000-21000</tt>). This avoids
  982. that all selections have to be made by looping through all vector
  983. lines. Category index is also essential for simple feature
  984. representation of GRASS vectors.
  985. Category index is created for each field. In memory, it is stored in
  986. \ref Cat_index data structure.
  987. Category index is built with topology, but it is <b>not updated</b> if
  988. vector is edited on level 2. Category index is stored in 'cidx' file,
  989. 'cat' array is written/read by one call of dig__fwrite_port_I() or
  990. dig__fread_port_I().
  991. Stored values can be retrieved either by index in 'cat' array (if all
  992. features of given field are required) or by category value (one or few
  993. features), always by <tt>Vect_cidx_*()</tt> functions.
  994. To create category index, it will be necessary to rebuild topology for
  995. all existing vectors. This is an opportunity to make (hopefully) last
  996. changes in 'topo', 'cidx' formats.
  997. \subsection vlibCidxFileFormat Cidx file format specification
  998. Category index file ('cidx') is read by Vect_cidx_open().
  999. \subsubsection vlibCidxFileHead Header
  1000. Note: <tt>plus</tt> is instance of \ref Plus_head structure.
  1001. <table border="1" style="border-collapse: collapse" cellpadding="5">
  1002. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  1003. <tr><td>plus->cpidx_Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  1004. <tr><td>plus->cpidx_Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  1005. <tr><td>plus->cpidx_Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  1006. <tr><td>plus->cpidx_Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  1007. <tr><td>plus->cidx_port->byte_order</td><td>C</td><td>1</td><td>little or big endian
  1008. flag; files are written in machine native order but
  1009. files in both little and big endian order may be
  1010. readl; zero for little endian</td></tr>
  1011. <tr><td>plus->cidx_head_size</td><td>L</td><td>1</td><td>cidx head size</td></tr>
  1012. <tr><td>plus->n_cidx</td><td>I</td><td>1</td><td>number of fields</td></tr>
  1013. <tr><td>field</td><td>I</td><td>n_cidx</td><td>field number</td></tr>
  1014. <tr><td>n_cats</td><td>I</td><td>n_cidx</td><td>number of categories</td></tr>
  1015. <tr><td>n_ucats</td><td>I</td><td>n_cidx</td><td>number of unique categories</td></tr>
  1016. <tr><td>n_types</td><td>I</td><td>n_cidx</td><td>number of feature types</td></tr>
  1017. <tr><td>rtype</td><td>I</td><td>n_cidx * n_types</td><td>Feature type</td></tr>
  1018. <tr><td>type[t]</td><td>I</td><td>n_cidx * n_types</td><td>Number of items</td></tr>
  1019. </table>
  1020. \section vlibTin Vector TINs
  1021. TINs are simply created as 2D/3D vector polygons consisting of
  1022. 3 vertices. See Vect_tin_get_z().
  1023. \section vlibOgrIface OGR interface
  1024. \subsection vLibPseudoTopo Pseudo-topology
  1025. Reduced topology: each boundary is attached to one area only,
  1026. i.e. smoothing, simplification, removing small areas etc. will not
  1027. work properly for adjacent areas or areas within areas.
  1028. Full topology is only available for native GRASS vectors or can only
  1029. be built after all polygons are converted to areas and cleaned as done
  1030. by <tt>v.in.ogr</tt>.
  1031. \subsection vlibFrmtFileFormat Frmt file format specification
  1032. Frmt is a plain text file which contains basic information about
  1033. external format of linked vector map. Each line contains key, value
  1034. pairs separated by comma.
  1035. OGR specific format is described by:
  1036. - FORMAT - ogr
  1037. - DSN - OGR datasource name
  1038. - LAYER - OGR layer name
  1039. Example:
  1040. \verbatim
  1041. FORMAT: ogr
  1042. DSN: /path/to/shapefiles
  1043. LAYER: cities
  1044. \endverbatim
  1045. OGR layer can be linked via <tt>v.external</tt> command. When linking
  1046. OGR layer pseudo-topology ('topo') is built including spatial index
  1047. file ('sidx') and category index file ('cidx'). Additionally also
  1048. feature index file (see \ref vlibFidxFileFormat) is created.
  1049. \subsection vlibFidxFileFormat Fidx file format specification
  1050. Note: <tt>finfo</tt> is an instance of \ref Format_info structure.
  1051. <table border="1" style="border-collapse: collapse" cellpadding="5">
  1052. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  1053. <tr><td>Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  1054. <tr><td>Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  1055. <tr><td>Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  1056. <tr><td>Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  1057. <tr><td>byte_order</td><td>C</td><td>1</td><td>little or big endian
  1058. flag; files are written in machine native order but
  1059. files in both little and big endian order may be
  1060. readl; zero for little endian</td></tr>
  1061. <tr><td>length</td><td>L</td><td>1</td><td>header size</td></tr>
  1062. <tr><td>fInfo.ogr.offset_num</td><td>I</td><td>1</td><td>number of records</td></tr>
  1063. <tr><td>fInfo.ogr.offset</td><td>I</td><td>offset_num</td><td>offsets</td></tr>
  1064. </table>
  1065. \section vlibDglib DGLib (Directed Graph Library)
  1066. \ref dglib or DGLib (Micarelli 2002, http://grass.osgeo.org/dglib/)
  1067. provides functionality for vector network analysis. This library
  1068. released under GPL is hosted by the GRASS project (within the GRASS
  1069. source code). As a stand-alone library it may also be used by other
  1070. software projects.
  1071. The Directed Graph Library library provides functionality to assign
  1072. costs to lines and/or nodes. That means that costs can be accumulated
  1073. while traveling along polylines. The user can assign individual costs
  1074. to all lines and/or nodes of a vector map and later calculate least costly
  1075. path connections based on the accumulated costs. Applications are
  1076. transport analysis, connectivity and more. Implemented applications
  1077. cover shortest/fastest path, traveling salesman (round trip), allocation of
  1078. sources (creation of subnetworks), minimum Steiner trees (star-like
  1079. connections), and iso-distances (from centers).
  1080. For details, please read Blazek et al. 2002 (see below).
  1081. Related vector functions are:
  1082. Vect_graph_add_edge(),
  1083. Vect_graph_init(),
  1084. Vect_graph_set_node_costs(),
  1085. Vect_graph_shortest_path(),
  1086. Vect_net_build_graph(),
  1087. Vect_net_nearest_nodes(),
  1088. Vect_net_shortest_path(), and
  1089. Vect_net_shortest_path_coor().
  1090. \section vlibAscii Vector ASCII Format Specifications
  1091. The GRASS ASCII vector map format may contain a mix of primitives
  1092. including points, lines, boundaries, centroids, faces, and
  1093. kernels. The format may also contain a header with various metadata
  1094. (see example below).
  1095. Vector map can be converted to the ASCII representation at user level
  1096. by <tt>v.out.ascii format=standard</tt> command.
  1097. See \ref vlibAsciiFn for list of related functions.
  1098. The header is similar as the head file of vector binary format (see
  1099. \ref vlibHeadFileFormat) but contains bounding box also. Keywords are:
  1100. \verbatim
  1101. ORGANIZATION
  1102. DIGIT DATE
  1103. DIGIT NAME
  1104. MAP NAME
  1105. MAP DATE
  1106. MAP SCALE
  1107. OTHER INFO
  1108. ZONE
  1109. WEST EDGE
  1110. EAST EDGE
  1111. SOUTH EDGE
  1112. NORTH EDGE
  1113. MAP THRESH
  1114. \endverbatim
  1115. Example:
  1116. \verbatim
  1117. ORGANIZATION: NC OneMap
  1118. DIGIT DATE:
  1119. DIGIT NAME: helena
  1120. MAP NAME: North Carolina selected bridges (points map)
  1121. MAP DATE: Mon Nov 6 15:32:39 2006
  1122. MAP SCALE: 1
  1123. OTHER INFO:
  1124. ZONE: 0
  1125. MAP THRESH: 0.000000
  1126. \endverbatim
  1127. The body begins with the row:
  1128. \verbatim
  1129. VERTI:
  1130. \endverbatim
  1131. followed by records of primitives:
  1132. \verbatim
  1133. TYPE NUMBER_OF_COORDINATES [NUMBER_OF_CATEGORIES]
  1134. X Y [Z]
  1135. ....
  1136. X Y [Z]
  1137. [ LAYER CATEGORY]
  1138. ....
  1139. [ LAYER CATEGORY]
  1140. \endverbatim
  1141. Everything above in <tt>[]</tt> is optional.
  1142. The primitive codes are as follows:
  1143. - 'P': point
  1144. - 'L': line
  1145. - 'B': boundary
  1146. - 'C': centroid
  1147. - 'F': face (3D boundary)
  1148. - 'K': kernel (3D centroid)
  1149. - 'A': area (boundary) - better use 'B'; kept only for backward
  1150. compatibility
  1151. The coordinates are listed following the initial line containing the
  1152. primitive code, the total number of vectors in the series, and (optionally)
  1153. the number of categories (1 for a single layer, higher for multiple layers).
  1154. Below that 1 or several lines follow to indicate the layer number and
  1155. the category number (ID).
  1156. The order of coordinates is
  1157. \verbatim
  1158. X Y [Z]
  1159. \endverbatim
  1160. Note: The points are stored as y, x (i.e., east, north), which is the
  1161. reserve of the way GRASS usually represents geographic coordinates.
  1162. Example:
  1163. \verbatim
  1164. P 1 1
  1165. 375171.4992779 317756.72097616
  1166. 1 1
  1167. B 5
  1168. 637740 219580
  1169. 639530 219580
  1170. 639530 221230
  1171. 637740 221230
  1172. 637740 219580
  1173. C 1 1
  1174. 638635 220405
  1175. 1 2
  1176. \endverbatim
  1177. In this example, the first vector feature is a point with category
  1178. number 1. The second vector feature is a boundary composed by 5
  1179. points. The third feature is a centroid with category number 2. The
  1180. boundary and the centroid form an area with category number 2. All
  1181. vector feature mentioned above are located in layer 1.
  1182. \section vlibFunc List of vector library functions
  1183. The vector library provides the GRASS programmer with routines to
  1184. process vector data. The routines in the vector library are presented
  1185. in functional groupings, rather than in alphabetical order. The order
  1186. of presentation will, it is hoped, provide better understanding of how
  1187. the library is to be used, as well as show the interrelationships
  1188. among the various routines. Note that a good way to understand how to
  1189. use these routines is to look at the source code for GRASS modules
  1190. which use them.
  1191. Note: All routines start with one of following prefixes Vect_, V1_,
  1192. V2_ or dig_. To avoid name conficts, programmers should not create
  1193. variables or routines in their own modules which use this prefix.
  1194. The Vect_*() functions are the programmer's API for GRASS vector
  1195. programming. The programmer should use only routines with this prefix.
  1196. - \subpage vlibArea
  1197. - \subpage vlibArray
  1198. - \subpage vlibBox
  1199. - \subpage vlibBreakLines
  1200. - \subpage vlibBreakPolygons
  1201. - \subpage vlibBridges
  1202. - \subpage vlibBuffer
  1203. - \subpage vlibBuild
  1204. - \subpage vlibBuildNat
  1205. - \subpage vlibBuildOgr
  1206. - \subpage vlibCats
  1207. - \subpage vlibCindex
  1208. - \subpage vlibCleanNodes
  1209. - \subpage vlibClose
  1210. - \subpage vlibConstraint
  1211. - \subpage vlibDangles
  1212. - \subpage vlibDbcolumns
  1213. - \subpage vlibError
  1214. - \subpage vlibField
  1215. - \subpage vlibFind
  1216. - \subpage vlibGraph
  1217. - \subpage vlibHeader
  1218. - \subpage vlibHist
  1219. - \subpage vlibInitHead
  1220. - \subpage vlibIntersect
  1221. - \subpage vlibLegalVname
  1222. - \subpage vlibLevel
  1223. - \subpage vlibLevelTwo
  1224. - \subpage vlibLine
  1225. - \subpage vlibList
  1226. - \subpage vlibMap
  1227. - \subpage vlibNet
  1228. - \subpage vlibOpen
  1229. - \subpage vlibOverlay
  1230. - \subpage vlibVpoly
  1231. - \subpage vlibRead
  1232. - \subpage vlibRemoveAreas
  1233. - \subpage vlibRemoveDuplicates
  1234. - \subpage vlibRewind
  1235. - \subpage vlibSelect
  1236. - \subpage vlibSindex
  1237. - \subpage vlibSnap
  1238. - \subpage vlibTin
  1239. - \subpage vlibType
  1240. - \subpage vlibDelete
  1241. - \subpage vlibWrite
  1242. - \subpage vlibAsciiFn
  1243. - \subpage vlibSFAFn
  1244. - \subpage vlibGeosFn
  1245. - \subpage vlibPgFn
  1246. \section vlibArea Vector area functions
  1247. - Vect_get_area_area()
  1248. - Vect_get_area_boundaries()
  1249. - Vect_get_area_centroid()
  1250. - Vect_get_area_isle()
  1251. - Vect_get_area_num_isles()
  1252. - Vect_area_perimeter()
  1253. - Vect_get_area_points()
  1254. - Vect_get_isle_area()
  1255. - Vect_get_isle_boundaries()
  1256. - Vect_get_isle_points()
  1257. - Vect_point_in_area()
  1258. \section vlibArray Vector array functions
  1259. - Vect_new_varray()
  1260. - Vect_set_varray_from_cat_list()
  1261. - Vect_set_varray_from_cat_string()
  1262. - Vect_set_varray_from_db()
  1263. \section vlibBox Vector bounding box functions
  1264. - Vect_box_copy()
  1265. - Vect_box_clip()
  1266. - Vect_box_extend()
  1267. - Vect_box_overlap()
  1268. - Vect_get_area_box()
  1269. - Vect_get_isle_box()
  1270. - Vect_get_line_box()
  1271. - Vect_get_map_box()
  1272. - Vect_point_in_box()
  1273. - Vect_region_box()
  1274. \section vlibBreakLines Vector break lines functions
  1275. - Vect_break_lines()
  1276. - Vect_break_lines_list()
  1277. \section vlibBreakPolygons Vector break polygons functions
  1278. - Vect_break_polygons()
  1279. \section vlibBridges Vector bridges functions
  1280. - Vect_chtype_bridges()
  1281. - Vect_remove_bridges()
  1282. \section vlibBuffer Vector buffer functions
  1283. - Vect_line_buffer()
  1284. - Vect_line_parallel()
  1285. \section vlibBuild Vector build functions
  1286. - Vect_build()
  1287. - Vect_build_partial()
  1288. - Vect_get_built()
  1289. - Vect_build_sidx_from_topo()
  1290. - Vect_build_sidx()
  1291. - Vect_save_sidx()
  1292. - Vect_save_topo()
  1293. - Vect_sidx_dump()
  1294. - Vect_topo_dump()
  1295. \subsection vlibBuildNat Vector build (native) functions
  1296. - Vect_attach_centroids()
  1297. - Vect_attach_isle()
  1298. - Vect_attach_isles()
  1299. - Vect_build_line_area()
  1300. - Vect_build_nat()
  1301. - Vect_isle_find_area()
  1302. \subsection vlibBuildOgr Vector build (OGR) functions
  1303. - Vect_build_ogr()
  1304. \section vlibCats Vector categories functions
  1305. - Vect_array_to_cat_list()
  1306. - Vect_cat_del()
  1307. - Vect_cat_get()
  1308. - Vect_cat_in_array()
  1309. - Vect_cat_in_cat_list()
  1310. - Vect_cat_set()
  1311. - Vect_destroy_cat_list()
  1312. - Vect_destroy_cats_struct()
  1313. - Vect_field_cat_del()
  1314. - Vect_get_area_cats()
  1315. - Vect_get_area_cat()
  1316. - Vect_get_line_cat()
  1317. - Vect_new_cat_list()
  1318. - Vect_new_cats_struct()
  1319. - Vect_reset_cats()
  1320. - Vect_str_to_cat_list()
  1321. \section vlibCindex Vector category index functions
  1322. (note: vector layer is historically called "field")
  1323. - Vect_cidx_dump()
  1324. - Vect_cidx_find_next()
  1325. - Vect_cidx_find_all()
  1326. - Vect_cidx_get_cat_by_index()
  1327. - Vect_cidx_get_field_index()
  1328. - Vect_cidx_get_field_number()
  1329. - Vect_cidx_get_num_cats_by_index()
  1330. - Vect_cidx_get_num_fields()
  1331. - Vect_cidx_get_num_types_by_index()
  1332. - Vect_cidx_get_num_unique_cats_by_index()
  1333. - Vect_cidx_get_type_count()
  1334. - Vect_cidx_get_type_count_by_index()
  1335. - Vect_cidx_open()
  1336. - Vect_cidx_save()
  1337. - Vect_set_category_index_update()
  1338. \section vlibCleanNodes Vector clean nodes functions
  1339. - Vect_clean_small_angles_at_nodes()
  1340. \section vlibClose Vector close functions
  1341. - Vect_close()
  1342. \section vlibConstraint Vector constraint functions
  1343. - Vect_get_constraint_box()
  1344. - Vect_remove_constraints()
  1345. - Vect_set_constraint_region()
  1346. - Vect_set_constraint_type()
  1347. \section vlibDangles Vector dangles functions
  1348. - Vect_chtype_dangles()
  1349. - Vect_remove_dangles()
  1350. - Vect_select_dangles()
  1351. \section vlibDbcolumns Vector dbcolumns functions
  1352. - Vect_get_column_names()
  1353. - Vect_get_column_names_types()
  1354. - Vect_get_column_types()
  1355. \section vlibError Vector error functions
  1356. - Vect_get_fatal_error()
  1357. - Vect_set_fatal_error()
  1358. \section vlibField Vector field functions
  1359. (note: vector layer is historically called "field")
  1360. - Vect_add_dblink()
  1361. - Vect_check_dblink()
  1362. - Vect_default_field_info()
  1363. - Vect_get_dblink()
  1364. - Vect_get_field()
  1365. - Vect_get_field_by_name()
  1366. - Vect_map_add_dblink()
  1367. - Vect_map_check_dblink()
  1368. - Vect_map_del_dblink()
  1369. - Vect_new_dblinks_struct()
  1370. - Vect_read_dblinks()
  1371. - Vect_reset_dblinks()
  1372. - Vect_set_db_updated()
  1373. - Vect_subst_var()
  1374. - Vect_write_dblinks()
  1375. \section vlibFind Vector find functions
  1376. - Vect_find_area()
  1377. - Vect_find_island()
  1378. - Vect_find_line()
  1379. - Vect_find_line_list()
  1380. - Vect_find_node()
  1381. \section vlibGraph Vector graph functions
  1382. - Vect_graph_add_edge()
  1383. - Vect_graph_build()
  1384. - Vect_graph_init()
  1385. - Vect_graph_set_node_costs()
  1386. - Vect_graph_shortest_path()
  1387. \section vlibHeader Vector header functions
  1388. - Vect_get_comment()
  1389. - Vect_get_constraint_box()
  1390. - Vect_get_date()
  1391. - Vect_get_full_name()
  1392. - Vect_get_map_date()
  1393. - Vect_get_map_name()
  1394. - Vect_get_mapset()
  1395. - Vect_get_name()
  1396. - Vect_get_organization()
  1397. - Vect_get_person()
  1398. - Vect_get_proj()
  1399. - Vect_get_proj_name()
  1400. - Vect_get_scale()
  1401. - Vect_get_thresh()
  1402. - Vect_get_zone()
  1403. - Vect_is_3d()
  1404. - Vect_print_header()
  1405. - Vect_read_header()
  1406. - Vect_set_comment()
  1407. - Vect_set_date()
  1408. - Vect_set_map_date()
  1409. - Vect_set_map_name()
  1410. - Vect_set_organization()
  1411. - Vect_set_person()
  1412. - Vect_set_scale()
  1413. - Vect_set_thresh()
  1414. - Vect_set_zone()
  1415. - Vect_write_header()
  1416. \section vlibHist Vector history functions
  1417. - Vect_hist_command()
  1418. - Vect_hist_copy()
  1419. - Vect_hist_read()
  1420. - Vect_hist_rewind()
  1421. - Vect_hist_write()
  1422. \section vlibInitHead Vector header functions
  1423. - Vect_copy_head_data()
  1424. \section vlibIntersect Vector intersection functions
  1425. - Vect_line_check_intersection()
  1426. - Vect_line_intersection()
  1427. - Vect_segment_intersection()
  1428. \section vlibLegalVname Vector valid map name functions
  1429. - Vect_check_input_output_name()
  1430. - Vect_legal_filename()
  1431. \section vlibLevel Vector level functions
  1432. - Vect_level()
  1433. \section vlibLevelTwo Vector topological (level 2) functions
  1434. - Vect_get_centroid_area()
  1435. - Vect_get_line_areas()
  1436. - Vect_get_line_nodes()
  1437. - Vect_get_node_coor()
  1438. - Vect_get_node_line()
  1439. - Vect_get_node_line_angle()
  1440. - Vect_get_node_n_lines()
  1441. - Vect_get_num_areas()
  1442. - Vect_get_num_dblinks()
  1443. - Vect_get_num_faces()
  1444. - Vect_get_num_islands()
  1445. - Vect_get_num_lines()
  1446. - Vect_get_num_nodes()
  1447. - Vect_get_num_primitives()
  1448. - Vect_get_num_updated_lines()
  1449. - Vect_get_num_updated_nodes()
  1450. - Vect_get_updated_line()
  1451. - Vect_get_updated_node()
  1452. - Vect_set_release_support()
  1453. \section vlibLine Vector feature functions
  1454. - Vect_append_point()
  1455. - Vect_append_points()
  1456. - Vect_copy_pnts_to_xyz()
  1457. - Vect_copy_xyz_to_pnts()
  1458. - Vect_destroy_line_struct()
  1459. - Vect_get_num_line_points()
  1460. - Vect_line_box()
  1461. - Vect_line_delete_point()
  1462. - Vect_line_distance()
  1463. - Vect_line_geodesic_length()
  1464. - Vect_line_get_point()
  1465. - Vect_line_insert_point()
  1466. - Vect_line_length()
  1467. - Vect_line_prune()
  1468. - Vect_line_prune_thresh()
  1469. - Vect_line_reverse()
  1470. - Vect_line_segment()
  1471. - Vect_new_line_struct()
  1472. - Vect_point_on_line()
  1473. - Vect_points_distance()
  1474. - Vect_reset_line()
  1475. \section vlibList Vector list functions
  1476. - Vect_destroy_list()
  1477. - Vect_list_append()
  1478. - Vect_list_append_list()
  1479. - Vect_list_delete()
  1480. - Vect_list_delete_list()
  1481. - Vect_new_list()
  1482. - Vect_reset_list()
  1483. - Vect_val_in_list()
  1484. - Vect_destroy_boxlist()
  1485. - Vect_boxlist_append()
  1486. - Vect_boxlist_append_boxlist()
  1487. - Vect_boxlist_delete()
  1488. - Vect_boxlist_delete_boxlist()
  1489. - Vect_new_boxlist()
  1490. - Vect_reset_boxlist()
  1491. - Vect_val_in_boxlist()
  1492. \section vlibMap Vector map functions
  1493. - Vect_copy()
  1494. - Vect_copy_map_lines()
  1495. - Vect_copy_table()
  1496. - Vect_copy_table_by_cats()
  1497. - Vect_copy_tables()
  1498. - Vect_delete()
  1499. - Vect_rename()
  1500. \section vlibMergeLines Vector merge line functions
  1501. - Vect_merge_lines()
  1502. \section vlibNet Vector network functions
  1503. - Vect_net_build_graph()
  1504. - Vect_net_get_line_cost()
  1505. - Vect_net_get_node_cost()
  1506. - Vect_net_nearest_nodes()
  1507. - Vect_net_shortest_path()
  1508. - Vect_net_shortest_path_coor()
  1509. \section vlibOpen Vector open functions
  1510. - Vect_coor_info()
  1511. - Vect_maptype_info()
  1512. - Vect_maptype()
  1513. - Vect_open_new()
  1514. - Vect__open_old()
  1515. - Vect_open_old()
  1516. - Vect_open_old_head()
  1517. - Vect_open_sidx()
  1518. - Vect_open_topo()
  1519. - Vect_open_update()
  1520. - Vect_open_update_head()
  1521. - Vect_set_open_level()
  1522. \section vlibOverlay Vector overlay functions
  1523. - Vect_overlay()
  1524. - Vect_overlay_str_to_operator()
  1525. \section vlibVpoly Vector polygon functions
  1526. - Vect_find_poly_centroid()
  1527. - Vect_get_point_in_area()
  1528. - Vect_point_in_area_outer_ring()
  1529. - Vect_point_in_island()
  1530. - Vect_get_point_in_poly()
  1531. - Vect_get_point_in_poly_isl()
  1532. \section vlibRead Vector read functions
  1533. \subsection vlibread1_2 Level 1 and 2
  1534. - Vect_read_next_line()
  1535. \subsection vlibRead2 Level 2 only
  1536. - Vect_area_alive()
  1537. - Vect_isle_alive()
  1538. - Vect_line_alive()
  1539. - Vect_node_alive()
  1540. - Vect_read_line()
  1541. \section vlibRemoveAreas Vector remove areas functions
  1542. - Vect_remove_small_areas()
  1543. \section vlibRemoveDuplicates Vector remove duplicates functions
  1544. - Vect_line_check_duplicate()
  1545. - Vect_remove_duplicates()
  1546. \section vlibRewind Vector rewind functions
  1547. - Vect_rewind()
  1548. \section vlibSelect Vector select functions
  1549. - Vect_select_areas_by_box()
  1550. - Vect_select_areas_by_polygon()
  1551. - Vect_select_isles_by_box()
  1552. - Vect_select_lines_by_box()
  1553. - Vect_select_lines_by_polygon()
  1554. - Vect_select_nodes_by_box()
  1555. \section vlibSindex Vector spatial index functions
  1556. - Vect_spatial_index_add_item()
  1557. - Vect_spatial_index_del_item()
  1558. - Vect_spatial_index_destroy()
  1559. - Vect_spatial_index_init()
  1560. - Vect_spatial_index_select()
  1561. \section vlibSnap Vector snap functions
  1562. - Vect_snap_lines()
  1563. - Vect_snap_lines_list()
  1564. \section vlibTin Vector TIN functions
  1565. - Vect_tin_get_z()
  1566. \section vlibType Vector type option functions
  1567. - Vect_option_to_types()
  1568. \section vlibDelete Vector delete functions
  1569. \subsection vlibDelete2 Level 2 only
  1570. - Vect_delete_line()
  1571. \section vlibWrite Vector write functions
  1572. \subsection vlibWrite1_2 Level 1 and 2
  1573. - Vect_write_line()
  1574. \subsection vlibWrite2 Level 2 only
  1575. - Vect_rewrite_line()
  1576. \subsection vlibAsciiFn Vector ASCII functions
  1577. - Vect_read_ascii()
  1578. - Vect_read_ascii_head()
  1579. - Vect_write_ascii()
  1580. - Vect_write_ascii_head()
  1581. \subsection vlibSFAFn Vector Simple Feature Access API
  1582. Functions from GRASS Simple Feature API (in progress, incomplete).
  1583. - Vect_sfa_get_line_type()
  1584. - Vect_sfa_check_line_type()
  1585. - Vect_sfa_line_dimension()
  1586. - Vect_sfa_line_geometry_type()
  1587. - Vect_sfa_line_astext()
  1588. - Vect_sfa_is_line_simple()
  1589. - Vect_sfa_is_line_closed()
  1590. \section vlibGeosFn Vector GEOS functions
  1591. Note: The functions are available only if GRASS is compiled with
  1592. <tt>--with-geos</tt> switch.
  1593. - Vect_read_line_geos()
  1594. - Vect_read_area_geos()
  1595. - Vect_line_to_geos()
  1596. - Vect_get_area_points_geos()
  1597. - Vect_get_isle_points_geos()
  1598. \section vlibPgFn Vector PostgreSQL/PostGIS functions
  1599. Note: The functions are available only if GRASS is compiled with
  1600. <tt>--with-postgres</tt> switch.
  1601. - Vect_open_topo_pg()
  1602. - Vect_build_pg()
  1603. (For internal use only)
  1604. - V1_open_old_pg(), V2_open_old_pg() called by Vect_open_old()
  1605. - V1_open_new_pg(), V2_open_new_pg() called by Vect_open_new()
  1606. - V1_rewind_pg(), V2_rewind_pg() called by Vect_rewind()
  1607. - V1_close_pg(), V2_close_pg() called by Vect_close()
  1608. - V1_read_line_pg(), V2_read_line_pg() called by Vect_read_line()
  1609. - V1_read_next_line_pg(), V2_read_next_line_pg() called by Vect_read_next_line()
  1610. - V1_delete_line_pg(), V2_delete_line_sfa() called by Vect_delete_line()
  1611. - V1_write_line_pg(), V2_write_line_pg() called by Vect_write_line()
  1612. - V1_rewrite_line_pg(), V2_rewrite_line_sfa() called by Vect_rewrite_line()
  1613. - V2_write_area_pg(), see <tt>v.out.postgis</tt> for implementation issues
  1614. \section vlibAuthors Authors
  1615. - Radim Blazek (vector architecture) <radim.blazek gmail.com>
  1616. - Roberto Micarelli (DGLib) <mi.ro iol.it>
  1617. Updates for GRASS 7:
  1618. - Markus Metz (file-based spatial index, vector topology)
  1619. - Martin Landa (GEOS support, direct OGR read access, PostgreSQL/PostGIS support) <landa.martin gmail.com>
  1620. \section vlibReferences References
  1621. Text based on: R. Blazek, M. Neteler, and R. Micarelli. The new GRASS 5.1
  1622. vector architecture. In Open source GIS - GRASS users conference 2002,
  1623. Trento, Italy, 11-13 September 2002. University of Trento, Italy, 2002.
  1624. <a href="http://www.ing.unitn.it/~grass/conferences/GRASS2002/proceedings/proceedings/pdfs/Blazek_Radim.pdf">http://www.ing.unitn.it/~grass/conferences/GRASS2002/proceedings/proceedings/pdfs/Blazek_Radim.pdf</a>
  1625. \section vlibSeealso See Also
  1626. - \ref dglib
  1627. - \ref dbmilib
  1628. - \ref veditlib
  1629. */