vectorlib.dox 65 KB

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