vectorlib.dox 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339
  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 (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</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 with_z)</td></tr>
  543. <tr><td>x,y</td><td>D</td><td>2</td><td>Coordinate pair</td></tr>
  544. <tr><td>z</td><td>D</td><td>1</td><td>Only for with_z</td></tr>
  545. </table>
  546. See \ref P_node data structure.
  547. <b>Lines</b>
  548. For each line (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</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>First 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>Second 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 (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</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 (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</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: 1, lines: 1, areas: 0, isles: 0)
  595. + N1/L1
  596. \endverbatim
  597. %Node N1 (see \ref P_Node)
  598. \verbatim
  599. node = 1, n_lines = 1, xyz = 631286.707172, 225105.223577, 0.000000
  600. line = 1, type = 1, angle = -9.000000
  601. \endverbatim
  602. Line L1 (see \ref P_Line)
  603. \verbatim
  604. line = 1, type = 1, offset = 18 n1 = 1, n2 = 1, left/area = 0, right = 0
  605. \endverbatim
  606. <b>Lines</b>
  607. \verbatim
  608. One line (nodes: 2, lines: 1, areas: 0, isles: 0)
  609. +----L1----+
  610. N1 N2
  611. \endverbatim
  612. %Node N1 (see \ref P_Node)
  613. \verbatim
  614. node = 1, n_lines = 1, xyz = 634624.746450, 223557.302231, 0.000000
  615. line = 1, type = 2, angle = -0.436257
  616. \endverbatim
  617. %Node N2 (see \ref P_Node)
  618. \verbatim
  619. node = 2, n_lines = 1, xyz = 638677.484787, 221667.849899, 0.000000
  620. line = -1, type = 2, angle = 2.705335
  621. \endverbatim
  622. Line L1 (see \ref P_Line)
  623. \verbatim
  624. line = 1, type = 2, offset = 18 n1 = 1, n2 = 2, left/area = 0, right = 0
  625. \endverbatim
  626. <b>Areas without holes</b>
  627. \verbatim
  628. Two lines (nodes: 1, lines: 2, areas: 1, isles: 1)
  629. +N1
  630. / \
  631. / \
  632. / \
  633. / +L2 \
  634. / \
  635. -------L1------
  636. \endverbatim
  637. %Node N1 (see \ref P_Node)
  638. \verbatim
  639. node = 1, n_lines = 2, xyz = 635720.081136, 225063.387424, 0.000000
  640. line = 1, type = 4, angle = -2.245537
  641. line = -1, type = 4, angle = -0.842926
  642. \endverbatim
  643. Line L1 (see \ref P_Line)
  644. \verbatim
  645. line = 1, type = 4, offset = 18 n1 = 1, n2 = 1, left/area = 1, right = -1
  646. \endverbatim
  647. Line L2 (see \ref P_Line)
  648. \verbatim
  649. line = 2, type = 8, offset = 87 n1 = 2, n2 = 2, left/area = 1, right = 0
  650. \endverbatim
  651. Area A1 (see \ref P_Area)
  652. \verbatim
  653. area = 1, n_lines = 1, n_isles = 0 centroid = 2
  654. line = -1
  655. \endverbatim
  656. Isle I1 (see \ref P_Isle)
  657. \verbatim
  658. isle = 1, n_lines = 1 area = 0
  659. line = 1
  660. \endverbatim
  661. <b>Areas with holes</b>
  662. \verbatim
  663. Three lines (nodes: 2, lines: 3, areas: 2, isles: 2)
  664. +N1
  665. / \
  666. / \
  667. / \
  668. / \
  669. / +L2 \
  670. / \
  671. / +N2 \
  672. / /\ \
  673. / / \ \
  674. / / \ \
  675. / ---L3-- \
  676. / \
  677. ------------L1-------------
  678. \endverbatim
  679. %Node N1 (see \ref P_Node)
  680. \verbatim
  681. node = 1, n_lines = 2, xyz = 635720.081136, 225063.387424, 0.000000
  682. line = 1, type = 4, angle = -2.245537
  683. line = -1, type = 4, angle = -0.842926
  684. \endverbatim
  685. %Node N2 (see \ref P_Node)
  686. \verbatim
  687. node = 3, n_lines = 2, xyz = 636788.032454, 223173.935091, 0.000000
  688. line = 3, type = 4, angle = -2.245537
  689. line = -3, type = 4, angle = -0.866302
  690. \endverbatim
  691. Line L1 (see \ref P_Line)
  692. \verbatim
  693. line = 1, type = 4, offset = 18 n1 = 1, n2 = 1, left/area = 1, right = -1
  694. \endverbatim
  695. Line L2 (see \ref P_Line)
  696. \verbatim
  697. line = 2, type = 8, offset = 87 n1 = 2, n2 = 2, left/area = 1, right = 0
  698. \endverbatim
  699. Line L3 (see \ref P_Line)
  700. \verbatim
  701. line = 3, type = 4, offset = 197 n1 = 3, n2 = 3, left/area = 2, right = -2
  702. \endverbatim
  703. Area A1 (see \ref P_Area)
  704. \verbatim
  705. area = 1, n_lines = 1, n_isles = 1 centroid = 2
  706. line = -1
  707. isle = 2
  708. \endverbatim
  709. Area A2 (see \ref P_Area)
  710. \verbatim
  711. area = 2, n_lines = 1, n_isles = 0 centroid = 0
  712. line = -3
  713. \endverbatim
  714. Isle I1 (see \ref P_Isle)
  715. \verbatim
  716. isle = 1, n_lines = 1 area = 0
  717. line = 1
  718. \endverbatim
  719. Isle I2 (see \ref P_Isle)
  720. \verbatim
  721. isle = 2, n_lines = 1 area = 1
  722. line = 3
  723. \endverbatim
  724. <b>Example 1</b>
  725. A polygon may be formed by many boundaries (several connected primitives).
  726. One boundary is shared by adjacent areas.
  727. \verbatim
  728. +--1--+--5--+
  729. | | |
  730. 2 A 4 B 6
  731. | | |
  732. +--3--+--7--+
  733. 1,2,3,4,5,6,7 = 7 boundaries (primitives)
  734. A,B = 2 areas
  735. A+B = 1 isle
  736. \endverbatim
  737. <b>Example 2</b>
  738. This is handled correctly in GRASS: A can be filled, B filled differently.
  739. \verbatim
  740. +---------+
  741. | A |
  742. +-----+ |
  743. | B | |
  744. +-----+ |
  745. | |
  746. +---------+
  747. A, B = 2 areas
  748. A+B = 1 isle
  749. \endverbatim
  750. In GRASS, whenever an 'inner' ring touches the boundary of an outside
  751. area, even in one point, it is no longer an 'inner' ring (isle in
  752. GRASS topology), it is simply another area. A, B above can never be
  753. exported from GRASS as polygon A with inner ring B because there are
  754. only 2 areas A and B and one island formed by A and B together.
  755. <b>Example 3</b>
  756. This is handled correctly in GRASS: Areas A1, A2, and A3 can be filled differently.
  757. \verbatim
  758. +---------------------+
  759. | A1 |
  760. + +------+------+ |
  761. | | A2 | A3 | |
  762. + +------+------+ |
  763. | I1 |
  764. +---------------------+
  765. A1,A2,A3 = 3 areas
  766. A1,A2+A3 = 2 isles
  767. \endverbatim
  768. In GRASS, whenever an 'inner' ring does not touch the boundary of an
  769. outside area, also not in one point, it is an 'inner' ring (isle). The
  770. areas A2 and A3 form a single isle I1 located within area A1. The size
  771. of isle I1 is substracted from the size of area A1 when calculating
  772. the size of area A1. Any centroids falling into isle I1 are excluded
  773. when searching for a centroid that can be attached to area A1. A1
  774. above can be exported from GRASS as polygon A1 with inner ring I1.
  775. <b>Example 4</b>
  776. <tt>v.in.ogr/v.clean</tt> can identify dangles and change the type
  777. from boundary to line (in TIGER data for example). Distinction
  778. between line and boundary isn't important only for dangles. Example:
  779. \verbatim
  780. +-----+-----+
  781. | . |
  782. | . |
  783. +.....+.....+
  784. | . |
  785. | x . |
  786. +-----+-----+
  787. ---- road + boundary of one parcel => type boundary
  788. .... road => type line
  789. x parcel centroid (identifies whole area)
  790. \endverbatim
  791. Because lines are not used to build areas, we have only one
  792. area/centroid, instead of 4 which would be necessary in TIGER.
  793. \subsection vlibTopoMemory Topology memory management
  794. Topology is generated for all kinds of vector types. Memory is not
  795. released by default. The programmer can force the library to release
  796. the memory by using Vect_set_release_support(). But: The programmer
  797. cannot run Vect_set_release_support() in mid process because all
  798. vectors are needed in the spatial index, which is needed to build topology.
  799. Topology is also necessary for points in case of a vector network
  800. because the graph is built using topology information about lines
  801. and points.
  802. The topology structure does not only store the topology but also
  803. the 'line' bounding box and line offset in coor file (index).
  804. The existing spatial index is using line ID in 'topology' structure
  805. to identify lines in 'coor' file. Currently it is not possible to build
  806. spatial index without topology.
  807. \section vlibSpidx Vector library spatial index management
  808. Spatial index (based on R*-tree) is created with topology, see \ref
  809. RTree data structure.
  810. Spatial index occupies a lot of memory but it is necessary for
  811. topology building. Also, it takes some time to release the memory
  812. occupied by spatial index (see dig_spidx_free()). The spatial index can
  813. also be built in file to save memory by setting the environment variable
  814. GRASS_VECTOR_LOWMEM.
  815. The function building topology - Vect_build() - is usually called at
  816. the end of modules (before Vect_close()) so it is faster to call
  817. <tt>exit()</tt> and operating system releases all the memory much
  818. faster. By default the memory is not released.
  819. It is possible to call Vect_set_release_support() before Vect_close()
  820. to enforce memory release, but it takes some time on large files.
  821. The spatial index is stored in file and not loaded for old vectors that
  822. are not updated, saving a lot of memory. Spatial queries are done in
  823. file.
  824. Currently most of the modules do not release the memory occupied for
  825. spatial index and work like this (pseudocode):
  826. \code
  827. int main
  828. {
  829. Vect_open_new();
  830. /* writing new vector */
  831. Vect_build();
  832. Vect_close(); /* memory is not released */
  833. }
  834. \endcode
  835. In general it is possible to free the memory with Vect_set_release_support()
  836. such as:
  837. \code
  838. int main
  839. {
  840. Vect_open_new();
  841. /* writing new vector */
  842. Vect_build();
  843. Vect_set_release_support();
  844. Vect_close(); /* memory is released */
  845. }
  846. \endcode
  847. but it takes a bit longer.
  848. It makes sense to release the spatial index if it is used only at the beginning
  849. of a module or in permanently running programs like QGIS. Note that this
  850. applies only when creating a new vector or updating an old vector.
  851. For example:
  852. \code
  853. int main
  854. {
  855. Vect_open_update();
  856. /* select features using spatial index, e.g. Vect_select_lines_by_box() */
  857. Vect_set_release_support();
  858. Vect_close(); /* memory is released */
  859. /* do some processing which needs memory */
  860. }
  861. \endcode
  862. See also \ref spatial_index data structure.
  863. \subsection vlibSidxFileFormat Sidx file format specification
  864. Spatial index file ('sidx') is read by Vect_open_sidx().
  865. \subsubsection vlibSidxFileHead Header
  866. Note: <tt>plus</tt> is instance of \ref Plus_head structure.
  867. <table border="1" style="border-collapse: collapse" cellpadding="5">
  868. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  869. <tr><td>plus->spidx_Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  870. <tr><td>plus->spidx_Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  871. <tr><td>plus->spidx_Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  872. <tr><td>plus->spidx_Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  873. <tr><td>plus->spidx_port->byte_order</td><td>C</td><td>1</td><td>little or big endian
  874. flag; files are written in machine native order but
  875. files in both little and big endian order may be
  876. readl; zero for little endian</td></tr>
  877. <tr><td>plus->spidx_port.off_t_size</td><td>C</td><td>1</td><td>off_t size (LFS)</td></tr>
  878. <tr><td>plus->spidx_head_size</td><td>L</td><td>1</td><td>header size</td></tr>
  879. <tr><td>plus->spidx_with_z</td><td>C</td><td>1</td><td>2D/3D vector data</td></tr>
  880. <tr><td>ndims</td><td>C</td><td>1</td><td>Number of dimensions</td></tr>
  881. <tr><td>nsides</td><td>C</td><td>1</td><td>Number of sides</td></tr>
  882. <tr><td>nodesize</td><td>I</td><td>1</td><td>%Node size</td></tr>
  883. <tr><td>nodecard</td><td>I</td><td>1</td><td>%Node card (?)</td></tr>
  884. <tr><td>leafcard</td><td>I</td><td>1</td><td>Leaf card (?)</td></tr>
  885. <tr><td>min_node_fill</td><td>I</td><td>1</td><td>Minimum node fill (?)</td></tr>
  886. <tr><td>min_leaf_fill</td><td>I</td><td>1</td><td>Minimum leaf fill (?)</td></tr>
  887. <tr><td>plus->Node_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  888. <tr><td>plus->Node_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  889. <tr><td>plus->Node_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  890. <tr><td>plus->Node_spidx_offset</td><td>O</td><td>1</td><td>%Node offset</td></tr>
  891. <tr><td>plus->Line_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  892. <tr><td>plus->Line_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  893. <tr><td>plus->Line_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  894. <tr><td>plus->Line_spidx_offset</td><td>O</td><td>1</td><td>Line offset</td></tr>
  895. <tr><td>plus->Area_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  896. <tr><td>plus->Area_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  897. <tr><td>plus->Area_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  898. <tr><td>plus->Area_spidx_offset</td><td>O</td><td>1</td><td>Area offset</td></tr>
  899. <tr><td>plus->Isle_spidx->n_nodes</td><td>I</td><td>1</td><td>Number of nodes</td></tr>
  900. <tr><td>plus->Isle_spidx->n_leafs</td><td>I</td><td>1</td><td>Number of leafs</td></tr>
  901. <tr><td>plus->Isle_spidx->n_levels</td><td>I</td><td>1</td><td>Number of levels</td></tr>
  902. <tr><td>plus->Isle_spidx_offset</td><td>O</td><td>1</td><td>Isle offset</td></tr>
  903. <tr><td>plus->Face_spidx_offset</td><td>O</td><td>1</td><td>Face offset</td></tr>
  904. <tr><td>plus->Volume_spidx_offset</td><td>O</td><td>1</td><td>Volume offset</td></tr>
  905. <tr><td>plus->Hole_spidx_offset</td><td>O</td><td>1</td><td>Hole offset</td></tr>
  906. <tr><td>plus->coor_size</td><td>O</td><td>1</td><td>Coor file size</td></tr>
  907. </table>
  908. \section vlibCidx Vector library category index management
  909. The category index (stored in the cidx file) improves the performance
  910. of all selections by cats/attributes (SQL, e.g. <tt>d.vect
  911. cats=27591</tt>, <tt>v.extract list=20000-21000</tt>). This avoids
  912. that all selections have to be made by looping through all vector
  913. lines. Category index is also essential for simple feature
  914. representation of GRASS vectors.
  915. Category index is created for each field. In memory, it is stored in
  916. \ref Cat_index data structure.
  917. Category index is built with topology, but it is <b>not updated</b> if
  918. vector is edited on level 2. Category index is stored in 'cidx' file,
  919. 'cat' array is written/read by one call of dig__fwrite_port_I() or
  920. dig__fread_port_I().
  921. Stored values can be retrieved either by index in 'cat' array (if all
  922. features of given field are required) or by category value (one or few
  923. features), always by <tt>Vect_cidx_*()</tt> functions.
  924. To create category index, it will be necessary to rebuild topology for
  925. all existing vectors. This is an opportunity to make (hopefully) last
  926. changes in 'topo', 'cidx' formats.
  927. \subsection vlibCidxFileFormat Cidx file format specification
  928. Category index file ('cidx') is read by Vect_cidx_open().
  929. \subsubsection vlibCidxFileHead Header
  930. Note: <tt>plus</tt> is instance of \ref Plus_head structure.
  931. <table border="1" style="border-collapse: collapse" cellpadding="5">
  932. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  933. <tr><td>plus->cpidx_Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  934. <tr><td>plus->cpidx_Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  935. <tr><td>plus->cpidx_Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  936. <tr><td>plus->cpidx_Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  937. <tr><td>plus->cidx_port->byte_order</td><td>C</td><td>1</td><td>little or big endian
  938. flag; files are written in machine native order but
  939. files in both little and big endian order may be
  940. readl; zero for little endian</td></tr>
  941. <tr><td>plus->cidx_head_size</td><td>L</td><td>1</td><td>cidx head size</td></tr>
  942. <tr><td>plus->n_cidx</td><td>I</td><td>1</td><td>number of fields</td></tr>
  943. <tr><td>field</td><td>I</td><td>n_cidx</td><td>field number</td></tr>
  944. <tr><td>n_cats</td><td>I</td><td>n_cidx</td><td>number of categories</td></tr>
  945. <tr><td>n_ucats</td><td>I</td><td>n_cidx</td><td>number of unique categories</td></tr>
  946. <tr><td>n_types</td><td>I</td><td>n_cidx</td><td>number of feature types</td></tr>
  947. <tr><td>rtype</td><td>I</td><td>n_cidx * n_types</td><td>Feature type</td></tr>
  948. <tr><td>type[t]</td><td>I</td><td>n_cidx * n_types</td><td>Number of items</td></tr>
  949. </table>
  950. \section vlibTin Vector TINs
  951. TINs are simply created as 2D/3D vector polygons consisting of
  952. 3 vertices. See Vect_tin_get_z().
  953. \section vlibOgrIface OGR interface
  954. \subsection vLibPseudoTopo Pseudo-topology
  955. Reduced topology: each boundary is attached to one area only,
  956. i.e. smoothing, simplification, removing small areas etc. will not
  957. work properly for adjacent areas or areas within areas.
  958. Full topology is only available for native GRASS vectors or can only
  959. be built after all polygons are converted to areas and cleaned as done
  960. by <tt>v.in.ogr</tt>.
  961. \subsection vlibFrmtFileFormat Frmt file format specification
  962. Frmt is a plain text file which contains basic information about
  963. external format of linked vector map. Each line contains key, value
  964. pairs separated by comma.
  965. OGR specific format is described by:
  966. - FORMAT - ogr
  967. - DSN - OGR datasource name
  968. - LAYER - OGR layer name
  969. Example:
  970. \verbatim
  971. FORMAT: ogr
  972. DSN: /path/to/shapefiles
  973. LAYER: cities
  974. \endverbatim
  975. OGR layer can be linked via <tt>v.external</tt> command. When linking
  976. OGR layer pseudo-topology ('topo') is built including spatial index
  977. file ('sidx') and category index file ('cidx'). Additionally also
  978. feature index file (see \ref vlibFidxFileFormat) is created.
  979. \subsection vlibFidxFileFormat Fidx file format specification
  980. Note: <tt>finfo</tt> is an instance of \ref Format_info structure.
  981. <table border="1" style="border-collapse: collapse" cellpadding="5">
  982. <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Number</b></td><td><b>Description</b></td></tr>
  983. <tr><td>Version_Major </td><td>C</td><td>1</td><td>file version (major)</td></tr>
  984. <tr><td>Version_Minor </td><td>C</td><td>1</td><td>file version (minor)</td></tr>
  985. <tr><td>Back_Major</td><td>C</td><td>1</td><td>supported from GRASS version (major)</td></tr>
  986. <tr><td>Back_Minor</td><td>C</td><td>1</td><td>supported from GRASS version (minor)</td></tr>
  987. <tr><td>byte_order</td><td>C</td><td>1</td><td>little or big endian
  988. flag; files are written in machine native order but
  989. files in both little and big endian order may be
  990. readl; zero for little endian</td></tr>
  991. <tr><td>length</td><td>L</td><td>1</td><td>header size</td></tr>
  992. <tr><td>fInfo.ogr.offset_num</td><td>I</td><td>1</td><td>number of records</td></tr>
  993. <tr><td>fInfo.ogr.offset</td><td>I</td><td>offset_num</td><td>offsets</td></tr>
  994. </table>
  995. \section vlibDglib DGLib (Directed Graph Library)
  996. \ref dglib or DGLib (Micarelli 2002, http://grass.osgeo.org/dglib/)
  997. provides functionality for vector network analysis. This library
  998. released under GPL is hosted by the GRASS project (within the GRASS
  999. source code). As a stand-alone library it may also be used by other
  1000. software projects.
  1001. The Directed Graph Library library provides functionality to assign
  1002. costs to lines and/or nodes. That means that costs can be accumulated
  1003. while traveling along polylines. The user can assign individual costs
  1004. to all lines and/or nodes of a vector map and later calculate least costly
  1005. path connections based on the accumulated costs. Applications are
  1006. transport analysis, connectivity and more. Implemented applications
  1007. cover shortest/fastest path, traveling salesman (round trip), allocation of
  1008. sources (creation of subnetworks), minimum Steiner trees (star-like
  1009. connections), and iso-distances (from centers).
  1010. For details, please read Blazek et al. 2002 (see below).
  1011. Related vector functions are:
  1012. Vect_graph_add_edge(),
  1013. Vect_graph_init(),
  1014. Vect_graph_set_node_costs(),
  1015. Vect_graph_shortest_path(),
  1016. Vect_net_build_graph(),
  1017. Vect_net_nearest_nodes(),
  1018. Vect_net_shortest_path(), and
  1019. Vect_net_shortest_path_coor().
  1020. \section vlibAscii Vector ASCII Format Specifications
  1021. The GRASS ASCII vector map format may contain a mix of primitives
  1022. including points, lines, boundaries, centroids, faces, and
  1023. kernels. The format may also contain a header with various metadata
  1024. (see example below).
  1025. Vector map can be converted to the ASCII representation at user level
  1026. by <tt>v.out.ascii format=standard</tt> command.
  1027. See \ref vlibAsciiFn for list of related functions.
  1028. The header is similar as the head file of vector binary format (see
  1029. \ref vlibHeadFileFormat) but contains bounding box also. Keywords are:
  1030. \verbatim
  1031. ORGANIZATION
  1032. DIGIT DATE
  1033. DIGIT NAME
  1034. MAP NAME
  1035. MAP DATE
  1036. MAP SCALE
  1037. OTHER INFO
  1038. ZONE
  1039. WEST EDGE
  1040. EAST EDGE
  1041. SOUTH EDGE
  1042. NORTH EDGE
  1043. MAP THRESH
  1044. \endverbatim
  1045. Example:
  1046. \verbatim
  1047. ORGANIZATION: NC OneMap
  1048. DIGIT DATE:
  1049. DIGIT NAME: helena
  1050. MAP NAME: North Carolina selected bridges (points map)
  1051. MAP DATE: Mon Nov 6 15:32:39 2006
  1052. MAP SCALE: 1
  1053. OTHER INFO:
  1054. ZONE: 0
  1055. MAP THRESH: 0.000000
  1056. \endverbatim
  1057. The body begins with the row:
  1058. \verbatim
  1059. VERTI:
  1060. \endverbatim
  1061. followed by records of primitives:
  1062. \verbatim
  1063. TYPE NUMBER_OF_COORDINATES [NUMBER_OF_CATEGORIES]
  1064. X Y [Z]
  1065. ....
  1066. X Y [Z]
  1067. [ LAYER CATEGORY]
  1068. ....
  1069. [ LAYER CATEGORY]
  1070. \endverbatim
  1071. Everything above in <tt>[]</tt> is optional.
  1072. The primitive codes are as follows:
  1073. - 'P': point
  1074. - 'L': line
  1075. - 'B': boundary
  1076. - 'C': centroid
  1077. - 'F': face (3D boundary)
  1078. - 'K': kernel (3D centroid)
  1079. - 'A': area (boundary) - better use 'B'; kept only for backward
  1080. compatibility
  1081. The coordinates are listed following the initial line containing the
  1082. primitive code, the total number of vectors in the series, and (optionally)
  1083. the number of categories (1 for a single layer, higher for multiple layers).
  1084. Below that 1 or several lines follow to indicate the layer number and
  1085. the category number (ID).
  1086. The order of coordinates is
  1087. \verbatim
  1088. X Y [Z]
  1089. \endverbatim
  1090. Note: The points are stored as y, x (i.e., east, north), which is the
  1091. reserve of the way GRASS usually represents geographic coordinates.
  1092. Example:
  1093. \verbatim
  1094. P 1 1
  1095. 375171.4992779 317756.72097616
  1096. 1 1
  1097. B 5
  1098. 637740 219580
  1099. 639530 219580
  1100. 639530 221230
  1101. 637740 221230
  1102. 637740 219580
  1103. C 1 1
  1104. 638635 220405
  1105. 1 2
  1106. \endverbatim
  1107. In this example, the first vector feature is a point with category
  1108. number 1. The second vector feature is a boundary composed by 5
  1109. points. The third feature is a centroid with category number 2. The
  1110. boundary and the centroid form an area with category number 2. All
  1111. vector feature mentioned above are located in layer 1.
  1112. \section vlibFunc List of vector library functions
  1113. The vector library provides the GRASS programmer with routines to
  1114. process vector data. The routines in the vector library are presented
  1115. in functional groupings, rather than in alphabetical order. The order
  1116. of presentation will, it is hoped, provide better understanding of how
  1117. the library is to be used, as well as show the interrelationships
  1118. among the various routines. Note that a good way to understand how to
  1119. use these routines is to look at the source code for GRASS modules
  1120. which use them.
  1121. Note: All routines start with one of following prefixes Vect_, V1_,
  1122. V2_ or dig_. To avoid name conficts, programmers should not create
  1123. variables or routines in their own modules which use this prefix.
  1124. The Vect_*() functions are the programmer's API for GRASS vector
  1125. programming. The programmer should use only routines with this prefix.
  1126. - \subpage vlibArea
  1127. - \subpage vlibArray
  1128. - \subpage vlibBox
  1129. - \subpage vlibBreakLines
  1130. - \subpage vlibBreakPolygons
  1131. - \subpage vlibBridges
  1132. - \subpage vlibBuffer
  1133. - \subpage vlibBuild
  1134. - \subpage vlibBuildNat
  1135. - \subpage vlibBuildOgr
  1136. - \subpage vlibCats
  1137. - \subpage vlibCindex
  1138. - \subpage vlibCleanNodes
  1139. - \subpage vlibClose
  1140. - \subpage vlibConstraint
  1141. - \subpage vlibDangles
  1142. - \subpage vlibDbcolumns
  1143. - \subpage vlibError
  1144. - \subpage vlibField
  1145. - \subpage vlibFind
  1146. - \subpage vlibGraph
  1147. - \subpage vlibHeader
  1148. - \subpage vlibHist
  1149. - \subpage vlibInitHead
  1150. - \subpage vlibIntersect
  1151. - \subpage vlibLegalVname
  1152. - \subpage vlibLevel
  1153. - \subpage vlibLevelTwo
  1154. - \subpage vlibLine
  1155. - \subpage vlibList
  1156. - \subpage vlibMap
  1157. - \subpage vlibNet
  1158. - \subpage vlibOpen
  1159. - \subpage vlibOverlay
  1160. - \subpage vlibVpoly
  1161. - \subpage vlibRead
  1162. - \subpage vlibRemoveAreas
  1163. - \subpage vlibRemoveDuplicates
  1164. - \subpage vlibRewind
  1165. - \subpage vlibSelect
  1166. - \subpage vlibSindex
  1167. - \subpage vlibSnap
  1168. - \subpage vlibTin
  1169. - \subpage vlibType
  1170. - \subpage vlibDelete
  1171. - \subpage vlibWrite
  1172. - \subpage vlibAsciiFn
  1173. - \subpage vlibSFAFn
  1174. - \subpage vlibGeosFn
  1175. \section vlibArea Vector area functions
  1176. - Vect_get_area_area()
  1177. - Vect_get_area_boundaries()
  1178. - Vect_get_area_centroid()
  1179. - Vect_get_area_isle()
  1180. - Vect_get_area_num_isles()
  1181. - Vect_area_perimeter()
  1182. - Vect_get_area_points()
  1183. - Vect_get_isle_area()
  1184. - Vect_get_isle_boundaries()
  1185. - Vect_get_isle_points()
  1186. - Vect_point_in_area()
  1187. \section vlibArray Vector array functions
  1188. - Vect_new_varray()
  1189. - Vect_set_varray_from_cat_list()
  1190. - Vect_set_varray_from_cat_string()
  1191. - Vect_set_varray_from_db()
  1192. \section vlibBox Vector bounding box functions
  1193. - Vect_box_copy()
  1194. - Vect_box_clip()
  1195. - Vect_box_extend()
  1196. - Vect_box_overlap()
  1197. - Vect_get_area_box()
  1198. - Vect_get_isle_box()
  1199. - Vect_get_line_box()
  1200. - Vect_get_map_box()
  1201. - Vect_point_in_box()
  1202. - Vect_region_box()
  1203. \section vlibBreakLines Vector break lines functions
  1204. - Vect_break_lines()
  1205. - Vect_break_lines_list()
  1206. \section vlibBreakPolygons Vector break polygons functions
  1207. - Vect_break_polygons()
  1208. \section vlibBridges Vector bridges functions
  1209. - Vect_chtype_bridges()
  1210. - Vect_remove_bridges()
  1211. \section vlibBuffer Vector buffer functions
  1212. - Vect_line_buffer()
  1213. - Vect_line_parallel()
  1214. \section vlibBuild Vector build functions
  1215. - Vect_build()
  1216. - Vect_build_partial()
  1217. - Vect_get_built()
  1218. - Vect_build_sidx_from_topo()
  1219. - Vect_build_sidx()
  1220. - Vect_save_sidx()
  1221. - Vect_save_topo()
  1222. - Vect_sidx_dump()
  1223. - Vect_topo_dump()
  1224. \subsection vlibBuildNat Vector build (native) functions
  1225. - Vect_attach_centroids()
  1226. - Vect_attach_isle()
  1227. - Vect_attach_isles()
  1228. - Vect_build_line_area()
  1229. - Vect_build_nat()
  1230. - Vect_isle_find_area()
  1231. \subsection vlibBuildOgr Vector build (OGR) functions
  1232. - Vect_build_ogr()
  1233. \section vlibCats Vector categories functions
  1234. - Vect_array_to_cat_list()
  1235. - Vect_cat_del()
  1236. - Vect_cat_get()
  1237. - Vect_cat_in_array()
  1238. - Vect_cat_in_cat_list()
  1239. - Vect_cat_set()
  1240. - Vect_destroy_cat_list()
  1241. - Vect_destroy_cats_struct()
  1242. - Vect_field_cat_del()
  1243. - Vect_get_area_cats()
  1244. - Vect_get_area_cat()
  1245. - Vect_get_line_cat()
  1246. - Vect_new_cat_list()
  1247. - Vect_new_cats_struct()
  1248. - Vect_reset_cats()
  1249. - Vect_str_to_cat_list()
  1250. \section vlibCindex Vector category index functions
  1251. (note: vector layer is historically called "field")
  1252. - Vect_cidx_dump()
  1253. - Vect_cidx_find_next()
  1254. - Vect_cidx_find_all()
  1255. - Vect_cidx_get_cat_by_index()
  1256. - Vect_cidx_get_field_index()
  1257. - Vect_cidx_get_field_number()
  1258. - Vect_cidx_get_num_cats_by_index()
  1259. - Vect_cidx_get_num_fields()
  1260. - Vect_cidx_get_num_types_by_index()
  1261. - Vect_cidx_get_num_unique_cats_by_index()
  1262. - Vect_cidx_get_type_count()
  1263. - Vect_cidx_get_type_count_by_index()
  1264. - Vect_cidx_open()
  1265. - Vect_cidx_save()
  1266. - Vect_set_category_index_update()
  1267. \section vlibCleanNodes Vector clean nodes functions
  1268. - Vect_clean_small_angles_at_nodes()
  1269. \section vlibClose Vector close functions
  1270. - Vect_close()
  1271. \section vlibConstraint Vector constraint functions
  1272. - Vect_get_constraint_box()
  1273. - Vect_remove_constraints()
  1274. - Vect_set_constraint_region()
  1275. - Vect_set_constraint_type()
  1276. \section vlibDangles Vector dangles functions
  1277. - Vect_chtype_dangles()
  1278. - Vect_remove_dangles()
  1279. - Vect_select_dangles()
  1280. \section vlibDbcolumns Vector dbcolumns functions
  1281. - Vect_get_column_names()
  1282. - Vect_get_column_names_types()
  1283. - Vect_get_column_types()
  1284. \section vlibError Vector error functions
  1285. - Vect_get_fatal_error()
  1286. - Vect_set_fatal_error()
  1287. \section vlibField Vector field functions
  1288. (note: vector layer is historically called "field")
  1289. - Vect_add_dblink()
  1290. - Vect_check_dblink()
  1291. - Vect_default_field_info()
  1292. - Vect_get_dblink()
  1293. - Vect_get_field()
  1294. - Vect_get_field_by_name()
  1295. - Vect_map_add_dblink()
  1296. - Vect_map_check_dblink()
  1297. - Vect_map_del_dblink()
  1298. - Vect_new_dblinks_struct()
  1299. - Vect_read_dblinks()
  1300. - Vect_reset_dblinks()
  1301. - Vect_set_db_updated()
  1302. - Vect_subst_var()
  1303. - Vect_write_dblinks()
  1304. \section vlibFind Vector find functions
  1305. - Vect_find_area()
  1306. - Vect_find_island()
  1307. - Vect_find_line()
  1308. - Vect_find_line_list()
  1309. - Vect_find_node()
  1310. \section vlibGraph Vector graph functions
  1311. - Vect_graph_add_edge()
  1312. - Vect_graph_build()
  1313. - Vect_graph_init()
  1314. - Vect_graph_set_node_costs()
  1315. - Vect_graph_shortest_path()
  1316. \section vlibHeader Vector header functions
  1317. - Vect_get_comment()
  1318. - Vect_get_constraint_box()
  1319. - Vect_get_date()
  1320. - Vect_get_full_name()
  1321. - Vect_get_map_date()
  1322. - Vect_get_map_name()
  1323. - Vect_get_mapset()
  1324. - Vect_get_name()
  1325. - Vect_get_organization()
  1326. - Vect_get_person()
  1327. - Vect_get_proj()
  1328. - Vect_get_proj_name()
  1329. - Vect_get_scale()
  1330. - Vect_get_thresh()
  1331. - Vect_get_zone()
  1332. - Vect_is_3d()
  1333. - Vect_print_header()
  1334. - Vect_read_header()
  1335. - Vect_set_comment()
  1336. - Vect_set_date()
  1337. - Vect_set_map_date()
  1338. - Vect_set_map_name()
  1339. - Vect_set_organization()
  1340. - Vect_set_person()
  1341. - Vect_set_scale()
  1342. - Vect_set_thresh()
  1343. - Vect_set_zone()
  1344. - Vect_write_header()
  1345. \section vlibHist Vector history functions
  1346. - Vect_hist_command()
  1347. - Vect_hist_copy()
  1348. - Vect_hist_read()
  1349. - Vect_hist_rewind()
  1350. - Vect_hist_write()
  1351. \section vlibInitHead Vector header functions
  1352. - Vect_copy_head_data()
  1353. \section vlibIntersect Vector intersection functions
  1354. - Vect_line_check_intersection()
  1355. - Vect_line_intersection()
  1356. - Vect_segment_intersection()
  1357. \section vlibLegalVname Vector valid map name functions
  1358. - Vect_check_input_output_name()
  1359. - Vect_legal_filename()
  1360. \section vlibLevel Vector level functions
  1361. - Vect_level()
  1362. \section vlibLevelTwo Vector topological (level 2) functions
  1363. - Vect_get_centroid_area()
  1364. - Vect_get_line_areas()
  1365. - Vect_get_line_nodes()
  1366. - Vect_get_node_coor()
  1367. - Vect_get_node_line()
  1368. - Vect_get_node_line_angle()
  1369. - Vect_get_node_n_lines()
  1370. - Vect_get_num_areas()
  1371. - Vect_get_num_dblinks()
  1372. - Vect_get_num_faces()
  1373. - Vect_get_num_islands()
  1374. - Vect_get_num_lines()
  1375. - Vect_get_num_nodes()
  1376. - Vect_get_num_primitives()
  1377. - Vect_get_num_updated_lines()
  1378. - Vect_get_num_updated_nodes()
  1379. - Vect_get_updated_line()
  1380. - Vect_get_updated_node()
  1381. - Vect_set_release_support()
  1382. \section vlibLine Vector feature functions
  1383. - Vect_append_point()
  1384. - Vect_append_points()
  1385. - Vect_copy_pnts_to_xyz()
  1386. - Vect_copy_xyz_to_pnts()
  1387. - Vect_destroy_line_struct()
  1388. - Vect_get_num_line_points()
  1389. - Vect_line_box()
  1390. - Vect_line_delete_point()
  1391. - Vect_line_distance()
  1392. - Vect_line_geodesic_length()
  1393. - Vect_line_get_point()
  1394. - Vect_line_insert_point()
  1395. - Vect_line_length()
  1396. - Vect_line_prune()
  1397. - Vect_line_prune_thresh()
  1398. - Vect_line_reverse()
  1399. - Vect_line_segment()
  1400. - Vect_new_line_struct()
  1401. - Vect_point_on_line()
  1402. - Vect_points_distance()
  1403. - Vect_reset_line()
  1404. \section vlibList Vector list functions
  1405. - Vect_destroy_list()
  1406. - Vect_list_append()
  1407. - Vect_list_append_list()
  1408. - Vect_list_delete()
  1409. - Vect_list_delete_list()
  1410. - Vect_new_list()
  1411. - Vect_reset_list()
  1412. - Vect_val_in_list()
  1413. - Vect_destroy_boxlist()
  1414. - Vect_boxlist_append()
  1415. - Vect_boxlist_append_boxlist()
  1416. - Vect_boxlist_delete()
  1417. - Vect_boxlist_delete_boxlist()
  1418. - Vect_new_boxlist()
  1419. - Vect_reset_boxlist()
  1420. - Vect_val_in_boxlist()
  1421. \section vlibMap Vector map functions
  1422. - Vect_copy()
  1423. - Vect_copy_map_lines()
  1424. - Vect_copy_table()
  1425. - Vect_copy_table_by_cats()
  1426. - Vect_copy_tables()
  1427. - Vect_delete()
  1428. - Vect_rename()
  1429. \section vlibMergeLines Vector merge line functions
  1430. - Vect_merge_lines()
  1431. \section vlibNet Vector network functions
  1432. - Vect_net_build_graph()
  1433. - Vect_net_get_line_cost()
  1434. - Vect_net_get_node_cost()
  1435. - Vect_net_nearest_nodes()
  1436. - Vect_net_shortest_path()
  1437. - Vect_net_shortest_path_coor()
  1438. \section vlibOpen Vector open functions
  1439. - Vect_coor_info()
  1440. - Vect_maptype_info()
  1441. - Vect_maptype()
  1442. - Vect_open_new()
  1443. - Vect__open_old()
  1444. - Vect_open_old()
  1445. - Vect_open_old_head()
  1446. - Vect_open_sidx()
  1447. - Vect_open_topo()
  1448. - Vect_open_update()
  1449. - Vect_open_update_head()
  1450. - Vect_set_open_level()
  1451. \section vlibOverlay Vector overlay functions
  1452. - Vect_overlay()
  1453. - Vect_overlay_str_to_operator()
  1454. \section vlibVpoly Vector polygon functions
  1455. - Vect_find_poly_centroid()
  1456. - Vect_get_point_in_area()
  1457. - Vect_point_in_area_outer_ring()
  1458. - Vect_point_in_island()
  1459. - Vect_get_point_in_poly()
  1460. - Vect_get_point_in_poly_isl()
  1461. \section vlibRead Vector read functions
  1462. \subsection vlibread1_2 Level 1 and 2
  1463. - Vect_read_next_line()
  1464. \subsection vlibRead2 Level 2 only
  1465. - Vect_area_alive()
  1466. - Vect_isle_alive()
  1467. - Vect_line_alive()
  1468. - Vect_node_alive()
  1469. - Vect_read_line()
  1470. \section vlibRemoveAreas Vector remove areas functions
  1471. - Vect_remove_small_areas()
  1472. \section vlibRemoveDuplicates Vector remove duplicates functions
  1473. - Vect_line_check_duplicate()
  1474. - Vect_remove_duplicates()
  1475. \section vlibRewind Vector rewind functions
  1476. - Vect_rewind()
  1477. \section vlibSelect Vector select functions
  1478. - Vect_select_areas_by_box()
  1479. - Vect_select_areas_by_polygon()
  1480. - Vect_select_isles_by_box()
  1481. - Vect_select_lines_by_box()
  1482. - Vect_select_lines_by_polygon()
  1483. - Vect_select_nodes_by_box()
  1484. \section vlibSindex Vector spatial index functions
  1485. - Vect_spatial_index_add_item()
  1486. - Vect_spatial_index_del_item()
  1487. - Vect_spatial_index_destroy()
  1488. - Vect_spatial_index_init()
  1489. - Vect_spatial_index_select()
  1490. \section vlibSnap Vector snap functions
  1491. - Vect_snap_lines()
  1492. - Vect_snap_lines_list()
  1493. \section vlibTin Vector TIN functions
  1494. - Vect_tin_get_z()
  1495. \section vlibType Vector type option functions
  1496. - Vect_option_to_types()
  1497. \section vlibDelete Vector delete functions
  1498. \subsection vlibDelete2 Level 2 only
  1499. - Vect_delete_line()
  1500. \section vlibWrite Vector write functions
  1501. \subsection vlibWrite1_2 Level 1 and 2
  1502. - Vect_write_line()
  1503. \subsection vlibWrite2 Level 2 only
  1504. - Vect_rewrite_line()
  1505. \subsection vlibAsciiFn Vector ASCII functions
  1506. - Vect_read_ascii()
  1507. - Vect_read_ascii_head()
  1508. - Vect_write_ascii()
  1509. - Vect_write_ascii_head()
  1510. \subsection vlibSFAFn Vector Simple Feature Access API
  1511. Functions from GRASS Simple Feature API (in progress, incomplete).
  1512. - Vect_sfa_get_line_type()
  1513. - Vect_sfa_check_line_type()
  1514. - Vect_sfa_line_dimension()
  1515. - Vect_sfa_line_geometry_type()
  1516. - Vect_sfa_line_astext()
  1517. - Vect_sfa_is_line_simple()
  1518. - Vect_sfa_is_line_closed()
  1519. \section vlibGeosFn Vector GEOS functions
  1520. Note: The functions are available only if GRASS is compiled with
  1521. <tt>--with-geos</tt> switch.
  1522. - Vect_read_line_geos()
  1523. - Vect_read_area_geos()
  1524. - Vect_line_to_geos()
  1525. - Vect_get_area_points_geos()
  1526. - Vect_get_isle_points_geos()
  1527. \section vlibAuthors Authors
  1528. - Radim Blazek (vector architecture) <radim.blazek gmail.com>
  1529. - Roberto Micarelli (DGLib) <mi.ro iol.it>
  1530. Updates for GRASS 7:
  1531. - Markus Metz (file-based spatial index, vector topology)
  1532. - Martin Landa (GEOS support, direct OGR read access) <landa.martin gmail.com>
  1533. \section vlibReferences References
  1534. Text based on: R. Blazek, M. Neteler, and R. Micarelli. The new GRASS 5.1
  1535. vector architecture. In Open source GIS - GRASS users conference 2002,
  1536. Trento, Italy, 11-13 September 2002. University of Trento, Italy, 2002.
  1537. <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>
  1538. \section vlibSeealso See Also
  1539. - \ref dglib
  1540. - \ref dbmilib
  1541. - \ref veditlib
  1542. */