vectorlib.dox 65 KB

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