vectorlib.dox 71 KB

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