vectorlib.dox 65 KB

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