GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
dig_structs.h
Go to the documentation of this file.
1/*!
2 \file include/grass/vect/dig_structs.h
3
4 \brief Data structures for \ref vectorlib
5
6 \author Written by Dave Gerdes (CERL) 5/1988
7 \author Updated to GRASS 5.7 by Radim Blazek (2001)
8 \author Updated to GRASS 7.0 by Markus Metz (2011)
9 \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
10 */
11#include <grass/config.h>
12
13#ifndef DIG___STRUCTS___
14#define DIG___STRUCTS___
15
16#include <stdio.h>
17
18#include <sys/types.h>
19
20#include <grass/dgl.h>
21#include <grass/shapefil.h>
22#include <grass/rbtree.h>
23#include <grass/rtree.h>
24#include <grass/dbmi.h>
25
26#include <ogr_api.h>
27
28#ifdef HAVE_POSTGRES
29#include <libpq-fe.h>
30#endif
31
32/*!
33 \brief plus_t size
34
35 3.10 changes plus_t to int. This assumes that any reasonable machine
36 will use 4 bytes to store an int. The diglib code is not guaranteed
37 to work if plus_t is changed to a type that is larger than an int.
38 */
39typedef int plus_t;
40
41/*!
42 \brief Used by sites lib
43 */
44struct site_att {
45 /*!
46 \brief Category number
47 */
48 int cat;
49 /*!
50 \brief Array of double attributes
51 */
52 double *dbl;
53 /*!
54 \brief Array of string attributes
55 */
56 char **str;
57};
58
59/*!
60 \brief Bounding box
61 */
62struct bound_box {
63 /*!
64 \brief North
65 */
66 double N;
67 /*!
68 \brief South
69 */
70 double S;
71 /*!
72 \brief East
73 */
74 double E;
75 /*!
76 \brief West
77 */
78 double W;
79 /*!
80 \brief Top
81 */
82 double T;
83 /*!
84 \brief Bottom
85 */
86 double B;
87};
88
89/*!
90 \brief File definition
91 */
92struct gvfile {
93 /*!
94 \brief File descriptor
95 */
97 /*!
98 \brief Pointer to beginning of the file in the memory
99 */
100 char *start;
101 /*!
102 \brief Current position set by dig_seek()
103 */
104 char *current;
105 /*!
106 \brief End of file in the memory (pointer to first byte after)
107 */
108 char *end;
109 /*!
110 \brief Size of the file loaded to memory
111 */
113 /*!
114 \brief Allocated space
115 */
117 /*!
118 \brief Is file loaded?
119
120 - 0 - not loaded
121 - 1 - loaded
122 */
124};
125
126/*!
127 \brief Layer (old: field) information
128 */
130 /*!
131 \brief Layer number
132 */
134 /*!
135 \brief Layer name (optional)
136 */
137 char *name;
138 /*!
139 \brief Name of DB driver ('sqlite', 'dbf', ...)
140 */
141 char *driver;
142 /*!
143 brief Name of database
144 */
145 char *database;
146 /*!
147 \brief Name of DB table
148 */
149 char *table;
150 /*!
151 \brief Name of key column (usually 'cat')
152 */
153 char *key;
154};
155
156/*!
157 \brief Database links
158 */
159struct dblinks {
160 /*!
161 \brief Pointer to the first field_info structure
162 */
164 /*!
165 \brief Number of allocated slots
166 */
168 /*!
169 \brief Number of available layers (old: fields)
170 */
172};
173
174/*!
175 \brief Portability info
176
177 Set by V1_open_new() or V1_open_old()
178 */
179struct Port_info {
180 /*!
181 \brief File byte order
182 */
184 /*!
185 \brief Size of `off_t` data type
186 */
188
189 /*!
190 \brief Conversion matrices between file and native byte order (double)
191 */
192 unsigned char dbl_cnvrt[PORT_DOUBLE];
193 /*!
194 \brief Conversion matrices between file and native byte order (float)
195 */
196 unsigned char flt_cnvrt[PORT_FLOAT];
197 /*!
198 \brief Conversion matrices between file and native byte order (long)
199 */
200 unsigned char lng_cnvrt[PORT_LONG];
201 /*!
202 \brief Conversion matrices between file and native byte order (int)
203 */
204 unsigned char int_cnvrt[PORT_INT];
205 /*!
206 \brief Conversion matrices between file and native byte order (short)
207 */
208 unsigned char shrt_cnvrt[PORT_SHORT];
209 /*!
210 \brief Conversion matrices between file and native byte order (off_t)
211 */
212 unsigned char off_t_cnvrt[PORT_OFF_T];
213 /*!
214 \brief Quick reading flag for double
215
216 Specify if native byte order of that type is the same
217 as byte order of vector file (TRUE) or not (FALSE)
218 */
220 /*!
221 \brief Quick reading flag for float
222
223 Specify if native byte order of that type is the same
224 as byte order of vector file (TRUE) or not (FALSE)
225 */
227 /*!
228 \brief Quick reading flag for long
229
230 Specify if native byte order of that type is the same
231 as byte order of vector file (TRUE) or not (FALSE)
232 */
234 /*!
235 \brief Quick reading flag for int
236
237 Specify if native byte order of that type is the same
238 as byte order of vector file (TRUE) or not (FALSE)
239 */
241 /*!
242 \brief Quick reading flag for short
243
244 Specify if native byte order of that type is the same
245 as byte order of vector file (TRUE) or not (FALSE)
246 */
248 /*!
249 \brief Quick reading flag for off_t
250
251 Specify if native byte order of that type is the same
252 as byte order of vector file (TRUE) or not (FALSE)
253 */
255};
256
257/*!
258 \brief List of dead lines in the file
259
260 \todo Implement it
261
262 The space can be reused, not yet used
263 */
264struct recycle {
265 char dummy;
266};
267
268/*! \brief Backward compatibility version info */
270 /*! \brief Current version (major) */
271 int major;
272 /*! \brief Current version (minor) */
273 int minor;
274 /*! \brief Earliest version that can use this data format (major) */
276 /*! \brief Earliest version that can use this data format (minor) */
278};
279
280/*!
281 \brief Vector map header data
282
283 Holds header data of vector map (see \ref vlibMap_info)
284 */
285struct dig_head {
286 /*!
287 \brief Organization name
288 */
290 /*!
291 \brief Map date
292 */
293 char *date;
294 /*!
295 \brief User name
296 */
298 /*!
299 \brief Map name
300 */
301 char *map_name;
302 /*!
303 \brief Source date
304 */
306 /*!
307 \brief Original scale
308 */
310 /*!
311 \brief Comments
312 */
313 char *comment;
314 int proj; /* projection */
315
316 /*!
317 \brief Zone (UTM only)
318 */
320 /*!
321 \brief Threshold for digitization
322 */
324
325 /* Programmers should NOT touch any thing below here */
326 /* Library takes care of everything for you */
327
328 /*! \brief Version info for coor file */
330
331 /*!
332 \brief 2D/3D vector data
333
334 - zero for 2D data
335 - non-zero for 3D data
336 */
338
339 /*!
340 \brief Coor file size
341 */
343 /*!
344 \brief Coor header size
345 */
347
348 /*!
349 \brief Portability information
350 */
352
353 /*!
354 \brief Offset of last read line
355 */
357
358 /*!
359 \brief Recycle dead line
360
361 \todo Not implemented yet
362 */
364};
365
366/*!
367 \brief Coor file info
368 */
369struct Coor_info {
370 /*!
371 \brief Total size (in bytes)
372 */
374 /*!
375 \brief Time of last modification
376 */
377 long mtime;
378};
379
380/*!
381 \brief Data structure used for building pseudo-topology
382
383 See Vect__build_sfa() (Format_info_ogr and Format_info_pg) for
384 implementation issues.
385 */
387 /*!
388 \brief Offset list
389
390 Array where feature/part info is stored for each feature in
391 GRASS. This is not used for GV_CENTROID. Because one feature may
392 contain more elements (geometry collection also recursively),
393 offset for one line may be stored in more records. First record
394 is FID, next records are part indexes if necessary.
395
396 Example 1:
397
398 5. ring in 3. polygon in 7. feature (multipolygon) of geometry
399 collection which has FID = 123 123 (feature 123: geometry
400 collection) 6 (7. feature in geometry collection: multiPolygon) 2
401 (3. polygon) 4 (5. ring in the polygon)
402
403 Example 2: geometry collection FID '1' containing one point, one
404 linestring and one polygon
405
406 \verbatim
407 Offset:
408
409 idx offset note
410 ----------------
411 0 1 FID
412 1 0 first part (point)
413
414 2 1 FID
415 3 1 second part (linestring)
416
417 4 1 FID
418 5 2 third part (polygon)
419 6 0 first ring of polygon
420
421 GRASS topology:
422
423 line idx
424 -----------------
425 1 0 point
426 2 2 line
427 3 4 boundary
428 4 1 centroid read from topo (idx == FID)
429
430 In PostGIS Topology mode the offset array is used for mapping
431 nodes.
432 \endverbatim
433 */
434 int *array;
435 /*!
436 \brief Number of items in offset list
437 */
439 /*!
440 \brief Space allocated for offset list
441 */
443};
444
445/*!
446 \brief Lines cache for reading feature (non-native formats)
447 */
449 /*!
450 \brief Lines array
451
452 Some simple features require more allocated lines (eg. polygon
453 with more rings, multipoint, or geometrycollection)
454
455 Line cache is also used for PostGIS Topology to store single
456 topological element (ctype == CACHE_FEATURE) or all elements
457 from the map (ctype == CACHE_MAP) to avoid random access which
458 is very costly.
459 */
460 struct line_pnts **lines;
461 /*!
462 \brief List of line types (GV_POINT, GV_LINE, ...)
463 */
465 /*!
466 \brief List of line cats (used only for PostGIS Topology access)
467 */
469 /*!
470 \brief Number of allocated lines in cache
471 */
473 /*!
474 \brief Number of lines which forms current feature
475 */
477 /*!
478 \brief Next line to be read from cache
479 */
481 /*!
482 \brief Feature id
483 */
484 long fid;
485 /*!
486 \brief Simple feature type (currently used only by PG format)
487 */
489 /*!
490 \brief Cache type
491
492 Currently used only by PostGIS Topology which allows caching the
493 whole map (CACHE_MAP) */
494 int ctype;
495};
496
497/*!
498 \brief Non-native format info (OGR)
499
500 \todo Structure size should not change depending on compilation I
501 think, do it better
502 */
504 /*!
505 \brief OGR driver name
506 */
508 /*!
509 \brief OGR datasource name
510 */
511 char *dsn;
512 /*!
513 \brief OGR layer name
514 */
516 /*!
517 \brief SQL where statement (to filter features)
518 */
519 char *where;
520 /*!
521 \brief Pointer to OGRDriver
522 */
524 /*!
525 \brief Pointer to OGRDataSource
526 */
528 /*!
529 \brief Pointer to OGRLayer
530 */
532
533 /*!
534 \brief Open DB driver when writing attributes
535
536 This driver is open by V2_open_new_ogr() and closed by
537 V1_close_ogr().
538 */
540
541 /*!
542 \brief Array of OGR DSN options
543 */
545 /*!
546 \brief Array of OGR layer options
547 */
549
550 /*!
551 \brief Lines cache for reading feature
552 */
554
555 /*!
556 \brief Cache to avoid repeated reading (level 2)
557
558 NULL if no feature is in cache
559 */
561
562 /*!
563 \brief Offset list used for building pseudo-topology
564 */
566
567 /*!
568 \brief Next line to be read
569
570 Used by V2_read_next_line_ogr()
571 */
573};
574
575/*!
576 \brief Non-native format info (PostGIS)
577 */
579 /*!
580 \brief Connection string
581 */
582 char *conninfo;
583 /*!
584 \brief Database name (derived from conninfo)
585 */
586 char *db_name;
587 /*!
588 \brief Schema name
589 */
591 /*!
592 \brief Table name
593 */
595 /*!
596 \brief SQL where statement (of filter features)
597 */
598 char *where;
599 /*!
600 \brief FID column
601 */
603 /*!
604 \brief Geometry column (simple feature access)
605 */
607 /*!
608 \brief Feature type (simple feature access)
609 */
611 /*!
612 \brief Coordinates dimension (2D or 3D)
613 */
615 /*!
616 \brief Spatial reference system id (see spatial_ref_sys
617 table)
618 */
619 int srid;
620
621 /*!
622 \brief Open DB driver when writing attributes
623
624 This driver is open by V2_open_new_pg() and closed by
625 V1_close_pg().
626 */
628 struct field_info *fi;
629
630 /*!
631 \brief Start/Finish transaction
632 */
634#ifdef HAVE_POSTGRES
635 /*!
636 \brief PGconn object (generated by PQconnectdb)
637 */
640#else
641 void *conn;
642 void *res;
643#endif
644 /*!
645 \brief Open cursor
646 */
649
650 /*!
651 \brief Next line to be read
652 */
654
655 /*!
656 \brief Lines cache for reading feature
657 */
659
660 /*!
661 \brief Offset list used for building pseudo-topology (simple
662 features access)
663 */
665
666 /* PostGIS topology support */
667 /*!
668 \brief TopoGeometry column (feature table)
669 */
671 /*!
672 \brief Topology schema name and id
673 */
676 /*!
677 \brief Topology format
678
679 TRUE to store only Topo-Geo data in DB otherwise GRASS-like
680 topology is also maintained in DB
681 */
683};
684
685/*!
686 \brief Non-native format info (currently only OGR is implemented)
687 */
689 /*!
690 \brief id?
691 */
692 int i;
693 /*!
694 \brief OGR info
695 */
697 /*!
698 \brief PostGIS info
699 */
701};
702
703/*!
704 \brief Category index
705 */
706struct Cat_index {
707 /*!
708 \brief Field (layer) number
709 */
710 int field;
711 /*!
712 \brief Number of items in cat array
713 */
715 /*!
716 \brief Allocated space in cat array
717 */
719 /*!
720 \brief Array of cats (cat, type, lines/area)
721 */
722 int (*cat)[3];
723 /*!
724 \brief Number of unique cats (not updated)
725 */
727 /*!
728 \brief Number of types in type
729 */
731 /*!
732 \brief Number of elements for each type
733
734 - GV_POINT
735 - GV_LINE
736 - GV_BOUNDARY
737 - GV_CENTROID
738 - GV_FACE
739 - GV_KERNEL
740 - GV_AREA
741 */
742 int type[7][2];
743 /*!
744 \brief Offset of the beginning of this index in cidx file
745 */
747};
748
749/*!
750 \brief Basic topology-related info
751
752 Holds basic topology-related information about vector map
753
754 Important note: you should NOT store non-topological information in
755 topological structures.
756 */
757struct Plus_head {
758 /*! \brief Backward compatibility version info */
759 struct {
760 /*! \brief Version info for topology file */
762 /*! \brief Version info for spatial index file */
764 /*! \brief Version info for category index file */
767
768 /*!
769 \brief 2D/3D vector data
770
771 - WITH_Z
772 - WITHOUT_Z
773 */
775 /*!
776 \brief 2D/3D spatial index
777
778 - WITH_Z
779 - WITHOUT_Z
780 */
782
783 /*!
784 \brief Offset size
785
786 Because Plus_head is available to all relevant
787 functions
788 */
790
791 /*** file header size ***/
792
793 /*!
794 \brief Topo header size
795 */
797 /*!
798 \brief Spatial index header size
799 */
801 /*!
802 \brief Category index header size
803 */
805
806 /*!
807 \brief Release memory occupied by support structures
808 (topo, spatial, category)
809 */
811
812 /*** portability info */
813
814 /*!
815 \brief Portability information
816 */
818 /*!
819 \brief Portability information for spatial index
820 */
822 /*!
823 \brief Portability information for category index
824 */
826 /*!
827 \brief Access mode
828
829 - GV_MODE_READ
830 - GV_MODE_WRITE
831 - GV_MODE_RW
832 */
833 int mode;
834
835 /*!
836 \brief Highest level of topology currently available
837
838 - GV_BUILD_NONE
839 - GV_BUILD_BASE
840 - GV_BUILD_AREAS
841 - GV_BUILD_ATTACH_ISLES
842 - GV_BUILD_CENTROIDS
843 - GV_BUILD_ALL
844 */
845 int built;
846 /*!
847 \brief Bounding box of features
848 */
850
851 /*** topology ***/
852 /*!
853 \brief Array of nodes
854 */
855 struct P_node **Node;
856 /*!
857 \brief Array of vector geometries
858 */
859 struct P_line **Line;
860 /*!
861 \brief Array of areas
862 */
863 struct P_area **Area;
864 /*!
865 \brief Array of isles
866 */
867 struct P_isle **Isle;
868
869 /* add here P_FACE, P_VOLUME, P_HOLE */
870
871 /*!
872 \brief Current number of points
873 */
875 /*!
876 \brief Current number of lines
877 */
879 /*!
880 \brief Current number of boundaries
881 */
883 /*!
884 \brief Current number of centroids
885 */
887 /*!
888 \brief Current number of faces
889 */
891 /*!
892 \brief Current number of kernels
893 */
895 /*!
896 \brief Current number of volume faces
897 */
899 /*!
900 \brief Current number of hole faces
901 */
903
904 /*!
905 \brief Current number of topological features derived from vector
906 geometries
907 */
908 /*!
909 \brief Current number of nodes
910 */
912 /*!
913 \brief Current number of edges
914 */
916 /*!
917 \brief Current number of lines
918 */
920 /*!
921 \brief Current number of areas
922 */
924 /*!
925 \brief Current number of isles
926 */
928 /*!
929 \brief Current number of faces
930 */
932 /*!
933 \brief Current number of volumes
934 */
936 /*!
937 \brief Current number of holes
938 */
940
941 /*!
942 \brief Number of allocated nodes
943
944 i.e. array size - 1
945 */
947 /*!
948 \brief Number of allocated edges
949
950 i.e. array size - 1
951 */
953 /*!
954 \brief Number of allocated lines
955
956 i.e. array size - 1
957 */
959 /*!
960 \brief Number of allocated areas
961
962 i.e. array size - 1
963 */
965 /*!
966 \brief Number of allocated isles
967
968 i.e. array size - 1
969 */
971 /*!
972 \brief Number of allocated faces
973
974 i.e. array size - 1
975 */
977 /*!
978 \brief Number of allocated volumes
979
980 i.e. array size - 1
981 */
983 /*!
984 \brief Number of allocated holes
985
986 i.e. array size - 1
987 */
989
990 /*!
991 \brief Offset of array of nodes in topo file
992 */
994 /*!
995 \brief Offset of array of edges in topo file
996 */
998 /*!
999 \brief Offset of array of vector geometries in topo file
1000 */
1002 /*!
1003 \brief Offset of array of areas in topo file
1004 */
1006 /*!
1007 \brief Offset of array of isles in topo file
1008 */
1010 /*!
1011 \brief Offset of array of volumes in topo file
1012 */
1014 /*!
1015 \brief Offset of array of holes in topo file
1016 */
1018
1019 /*** spatial index ***/
1020 /*!
1021 \brief Spatial index built?
1022
1023 Set to 1 if spatial index is available
1024 */
1026 /*!
1027 \brief Build new spatial index
1028
1029 Set to 1 if new spatial index will be generated
1030 */
1032 /*!
1033 \brief Build new spatial index in file
1034
1035 Set to 1 to build new indices in file
1036 */
1038
1039 /*!
1040 \brief Spatial index file pointer
1041 */
1043
1044 /*!
1045 \brief Offset of nodes in sidx file
1046 */
1048 /*!
1049 \brief Offset of lines in sidx file
1050 */
1052 /*!
1053 \brief Offset of areas in sidx file
1054 */
1056 /*!
1057 \brief Offset of isles in sidx file
1058 */
1060 /*!
1061 \brief Offset of faces in sidx file
1062 */
1064 /*!
1065 \brief Offset of volumes in sidx file
1066 */
1068 /*!
1069 \brief Offset of holes in sidx file
1070 */
1072
1073 /*!
1074 \brief Node spatial index
1075 */
1077 /*!
1078 \brief Line spatial index
1079 */
1081 /*!
1082 \brief Area spatial index
1083 */
1085 /*!
1086 \brief Isles spatial index
1087 */
1089 /*!
1090 \brief Faces spatial index
1091 */
1093 /*!
1094 \brief Volumes spatial index
1095 */
1097 /*!
1098 \brief Holes spatial index
1099 */
1101
1102 /*** category index ***/
1103 /*!
1104 \brief Update category index if vector is modified
1105
1106 By default, category index is not updated
1107 */
1109
1110 /*!
1111 \brief Number of category indexes (one for each field/layer)
1112 */
1114 /*!
1115 \brief Allocated space for category indexes
1116 */
1118 /*!
1119 \brief Array of category indexes
1120 */
1122 /*!
1123 \brief Category index to be updated
1124
1125 Set to 1 when cidx is created
1126 and reset to 0 whenever any line is changed
1127 */
1129
1130 /*!
1131 \brief Size of coor file
1132 */
1134 /*!
1135 \brief Time of last coor modification
1136 */
1138
1139 /*** level 2 ***/
1140 /*!
1141 \brief List of updated lines/nodes
1142
1143 Note: Vect_set_updated() must be called to maintain this list
1144 */
1145 struct {
1146 /*!
1147 \brief Indicates if the list of updated features is maintained
1148 */
1150
1151 /*!
1152 \brief Array of updated lines
1153
1154 List of lines and nodes updated (topo info for the line was
1155 changed) by last write/rewrite/delete operation.
1156 Lines/nodes in the list may be deleted (e.g. delete
1157 boundary: first added for delete area and then delete
1158 */
1160 /*!
1161 \brief Array of updated lines - offset
1162
1163 Negative value for dead (deleted) lines - used by Vect_restore_line()
1164 */
1166 /*!
1167 \brief Allocated array of lines
1168 */
1170 /*!
1171 \brief Number of updated lines
1172 */
1174 /*!
1175 \brief Array of updated nodes
1176 */
1178 /*!
1179 \brief Allocated array of nodes
1180 */
1182 /*!
1183 \brief number of updated nodes
1184 */
1187};
1188
1189/*!
1190 \brief Graph-related section (see \ref dglib)
1191 */
1193 /*!
1194 \brief Line type used to build the graph
1195 */
1197 /*!
1198 \brief Graph structure
1199 */
1201 /*!
1202 \brief Shortest path cache
1203 */
1205 /*!
1206 \brief Forward costs used for graph
1207
1208 dglGetEdge() is not supported for _DGL_V1)
1209 */
1211 /*!
1212 \brief backward costs used for graph
1213 */
1215 /*!
1216 \brief Node costs used for graph
1217 */
1218 double *node_costs;
1219 /*!
1220 \brief Edge and node costs multiplicator
1221 */
1223};
1224
1225/*! \brief
1226 Vector map info
1227
1228 Maintains all information about an individual open vector map. The
1229 structure must be passed to the most vector library routines.
1230 */
1231struct Map_info {
1232
1233 /*** common info for all formats ***/
1234
1235 /*!
1236 \brief Map format (native, ogr, postgis)
1237
1238 - GV_FORMAT_NATIVE
1239 - GV_FORMAT_OGR
1240 - GV_FORMAT_OGR_DIRECT
1241 - GV_FORMAT_POSTGIS
1242 */
1244
1245 /*!
1246 \brief Temporary map flag
1247 */
1249
1250 /*!
1251 \brief Array of DB links
1252 */
1254
1255 /*!
1256 \brief Plus info (topology, version, ...)
1257 */
1259
1260 /*!
1261 \brief Open indicator
1262
1263 Should be 0x5522AA22 (VECT_OPEN_CODE) if opened correctly
1264 or 0x22AA2255 (VECT_CLOSED_CODE) if closed
1265
1266 Anything else implies that structure has never been initialized
1267 */
1268 int open;
1269
1270 /* Open mode
1271
1272 - read (GV_MODE_READ),
1273 - write (GV_MODE_WRITE),
1274 - rw (GV_MODE_RW)
1275 */
1276 int mode;
1277
1278 /*!
1279 \brief Topology level
1280
1281 - 1 (without topo)
1282 - 2 (with 2D topology)
1283 - 3 (with 3D topology) - not yet implemented
1284 */
1286
1287 /*!
1288 \brief Open only header
1289
1290 Non-zero code to open only header of vector map
1291 */
1293
1294 /*!
1295 \brief Support files were updated
1296
1297 Non-zero code to indicate that support files were updated
1298 */
1300
1301 /*!
1302 \brief Map name (for 4.0)
1303 */
1304 char *name;
1305 /*!
1306 \brief Mapset name
1307 */
1308 char *mapset;
1309 /*!
1310 \brief Location name
1311
1312 Note: location and gisdbase is useful if changed (v.proj or external
1313 apps)
1314 */
1316 /*!
1317 \brief GISDBASE path
1318 */
1320
1321 /*!
1322 \brief Feature id for sequential access
1323
1324 Note: Line id starts with 1 - see Vect_read_next_line()
1325 */
1327
1328 /*!
1329 \brief Constraints for sequential feature access
1330 */
1331 struct {
1332 /*!
1333 \brief Non-zero value to enable region constraint
1334 */
1336 /*!
1337 \brief Region (bbox) constraint
1338 */
1339 struct bound_box box;
1340 /*!
1341 \brief Non-zero value to enable feature type constraint
1342 */
1344 /*!
1345 \brief Feature type constraint
1346 */
1347 int type;
1348 /*!
1349 \brief Non-zero value to enable field constraint
1350 */
1352 /*!
1353 \brief Field number constraint (see line_cats structure)
1354 */
1357
1358 /*!
1359 \brief ???
1360 */
1361 int proj;
1362
1363 /*!
1364 \brief History file
1365 */
1367
1368 /*!
1369 \brief Graph info (built for network analysis)
1370 */
1372
1373 /*!
1374 \brief Header info
1375 */
1377
1378 /*** format specific ***/
1379
1380 /*!
1381 \brief GV file pointer (native format only)
1382 */
1384
1385 /*!
1386 \brief Format info for non-native formats
1387 */
1389
1390 /* temporary solution for sites - to be removed ? */
1391
1392 /*!
1393 \brief Array of attributes loaded from db
1394
1395 \todo To be removed?
1396 */
1398 /*!
1399 \brief Number of attributes in site_att array
1400
1401 \todo To be removed?
1402 */
1404 /*!
1405 \brief Number of double attributes for one site
1406
1407 \todo To be removed
1408 */
1410 /*!
1411 \brief Number of string attributes for one site
1412
1413 \todo To be removed?
1414 */
1416};
1417
1418/*!
1419 \brief Topological feature - node
1420 */
1421struct P_node {
1422 /*!
1423 \brief X coordinate
1424 */
1425 double x;
1426 /*!
1427 \brief Y coordinate
1428 */
1429 double y;
1430 /*!
1431 \brief Z coordinate (used only for 3D data)
1432 */
1433 double z;
1434 /*!
1435 \brief Allocated space for lines
1436 */
1438 /*!
1439 \brief Number of attached lines (size of
1440 lines, angle)
1441
1442 If 0, then is degenerate node, for snapping ???
1443 */
1445 /*!
1446 \brief List of connected lines
1447
1448 Line id can be positive (for lines which starts at the node) or
1449 negative (for lines which ends at the node).
1450 */
1452 /*!
1453 \brief List of angles of connected lines
1454
1455 Angles for lines/boundaries are in radians between -PI and
1456 PI. Value for points or lines with identical points
1457 (degenerated) is set to -9. See dig_calc_begin_angle() and
1458 dig_calc_end_angle() for details.
1459 */
1460 float *angles;
1461};
1462
1463/*!
1464 \brief Line topology
1465 */
1466struct P_topo_l {
1467 /*!
1468 \brief Start node
1469 */
1471 /*!
1472 \brief End node
1473 */
1475};
1476
1477/*!
1478 \brief Boundary topology
1479 */
1480struct P_topo_b {
1481 /*!
1482 \brief Start node
1483 */
1485 /*!
1486 \brief End node
1487 */
1489 /*!
1490 \brief Area number to the left, negative for isle
1491 */
1493 /*!
1494 \brief Area number to the right, negative for isle
1495 */
1497};
1498
1499/*!
1500 \brief Centroid topology
1501 */
1502struct P_topo_c {
1503 /*!
1504 \brief Area number, negative for duplicate centroid
1505 */
1507};
1508
1509/*!
1510 \brief Face topology
1511 */
1512struct P_topo_f {
1513 /* TODO */
1514 /*!
1515 \brief Array of edges
1516 */
1518 /*!
1519 \brief Volume number to the left, negative for hole
1520 */
1522 /*!
1523 \brief Volume number to the right, negative for hole
1524 */
1526};
1527
1528/*!
1529 \brief Kernel topology
1530 */
1531struct P_topo_k {
1532 /*!
1533 \brief Volume number, negative for duplicate kernel
1534 */
1536};
1537
1538/*!
1539 \brief Vector geometry
1540 */
1541struct P_line {
1542 /*!
1543 \brief Line type
1544
1545 - GV_POINT
1546 - GV_LINE
1547 - GV_BOUNDARY
1548 - GV_CENTROID
1549 - GV_FACE
1550 - GV_KERNEL
1551 */
1552 char type;
1553 /*!
1554 \brief Offset in coor file for line
1555
1556 OGR-links: offset array index
1557 PG-links: node/edge id
1558 */
1560 /*!
1561 \brief Topology info
1562
1563 NULL for points
1564 */
1565 void *topo;
1566};
1567
1568/*!
1569 \brief Area (topology) info
1570 */
1571struct P_area {
1572 /*!
1573 \brief Number of boundary lines
1574 */
1576 /*!
1577 \brief Allocated space for lines
1578 */
1580 /*!
1581 \brief List of boundary lines
1582
1583 - negative means direction N2 to N1
1584 - lines are in clockwise order
1585 */
1587
1588 /********* Above this line is compatible with P_isle **********/
1589
1590 /*!
1591 \brief Number of first centroid within area
1592 */
1594 /*!
1595 \brief Number of islands inside
1596 */
1598 /*!
1599 \brief Allocated space for isles
1600 */
1602 /*!
1603 \brief 1st generation interior islands
1604 */
1606};
1607
1608/*!
1609 \brief Isle (topology) info
1610 */
1611struct P_isle {
1612 /*!
1613 \brief Number of boundary lines
1614 */
1616 /*!
1617 \brief Allocated space for lines
1618 */
1620 /*!
1621 \brief List of boundary lines
1622
1623 - negative means direction N2 to N1
1624 - lines are in counter clockwise order
1625 */
1627
1628 /********* Above this line is compatible with P_area **********/
1629
1630 /*!
1631 \brief Area it exists w/in, if any
1632 */
1634};
1635
1636/*!
1637 \brief Feature geometry info - coordinates
1638 */
1640 /*!
1641 \brief Array of X coordinates
1642 */
1643 double *x;
1644 /*!
1645 \brief Array of Y coordinates
1646 */
1647 double *y;
1648 /*!
1649 \brief Array of Z coordinates
1650 */
1651 double *z;
1652 /*!
1653 \brief Number of points
1654 */
1656 /*!
1657 \brief Allocated space for points
1658 */
1660};
1661
1662/*!
1663 \brief Feature category info
1664 */
1666 /*!
1667 \brief Array of layers (fields)
1668 */
1669 int *field;
1670 /*!
1671 \brief Array of categories
1672 */
1673 int *cat;
1674 /*!
1675 \brief Number of categories attached to element
1676 */
1678 /*!
1679 \brief Allocated space for categories
1680 */
1682};
1683
1684/*! \brief Category list */
1685struct cat_list {
1686 /*!
1687 \brief Category layer (field)
1688 */
1690 /*!
1691 \brief Array of minimum values
1692 */
1693 int *min;
1694 /*!
1695 \brief Array of maximum values
1696 */
1697 int *max;
1698 /*!
1699 \brief Number of ranges
1700 */
1702 /*!
1703 \brief Allocated space for ranges
1704 */
1706};
1707
1708/*!
1709 \brief List of bounding boxes with id
1710 */
1711struct boxlist {
1712 /*!
1713 \brief Array of ids
1714 */
1715 int *id;
1716 /*!
1717 \brief Array of bounding boxes
1718 */
1720 /*!
1721 \brief flag to indicate whether bounding boxes should be added
1722 */
1724 /*!
1725 \brief Number of items in the list
1726 */
1728 /*!
1729 \brief Allocated space for items
1730 */
1732};
1733
1734/*!
1735 \brief Vector array
1736
1737 Space allocated is size + 1
1738 */
1739struct varray {
1740 /*!
1741 \brief Array size
1742 */
1743 int size;
1744 /*!
1745 \brief Array
1746
1747 Where 'class' or new category
1748 or something like that is stored
1749 */
1750 int *c;
1751};
1752
1753/*!
1754 \brief Spatial index info
1755
1756 For use in modules
1757 */
1759 /*!
1760 \brief Pointer to the search tree (R*-Tree)
1761 */
1763 /*!
1764 \brief Name of file to store the search tree
1765 */
1766 char *name;
1767};
1768
1769#endif /* DIG___STRUCTS___ */
Main header of GRASS DataBase Management Interface.
SF_FeatureType
Simple feature types.
#define PORT_LONG
Definition dig_defines.h:47
#define PORT_SHORT
Definition dig_defines.h:49
#define PORT_DOUBLE
Sizes of types used in portable format (different names used in Vlib/ and diglib/ for the same thing)
Definition dig_defines.h:45
#define PORT_OFF_T
Definition dig_defines.h:51
#define PORT_FLOAT
Definition dig_defines.h:46
#define PORT_INT
Definition dig_defines.h:48
int plus_t
plus_t size
Definition dig_structs.h:39
Category index.
int n_types
Number of types in type.
int(* cat)[3]
Array of cats (cat, type, lines/area)
int a_cats
Allocated space in cat array.
int n_cats
Number of items in cat array.
off_t offset
Offset of the beginning of this index in cidx file.
int field
Field (layer) number.
int type[7][2]
Number of elements for each type.
int n_ucats
Number of unique cats (not updated)
Coor file info.
off_t size
Total size (in bytes)
long mtime
Time of last modification.
Lines cache for reading feature (non-native formats)
int ctype
Cache type.
int lines_next
Next line to be read from cache.
int * lines_types
List of line types (GV_POINT, GV_LINE, ...)
SF_FeatureType sf_type
Simple feature type (currently used only by PG format)
long fid
Feature id.
struct line_pnts ** lines
Lines array.
int lines_alloc
Number of allocated lines in cache.
int * lines_cats
List of line cats (used only for PostGIS Topology access)
int lines_num
Number of lines which forms current feature.
Data structure used for building pseudo-topology.
int * array
Offset list.
int array_alloc
Space allocated for offset list.
int array_num
Number of items in offset list.
Non-native format info (OGR)
char * dsn
OGR datasource name.
OGRSFDriverH driver
Pointer to OGRDriver.
OGRFeatureH feature_cache
Cache to avoid repeated reading (level 2)
char * driver_name
OGR driver name.
OGRDataSourceH ds
Pointer to OGRDataSource.
char * layer_name
OGR layer name.
int next_line
Next line to be read.
char * where
SQL where statement (to filter features)
dbDriver * dbdriver
Open DB driver when writing attributes.
OGRLayerH layer
Pointer to OGRLayer.
char ** layer_options
Array of OGR layer options.
struct Format_info_offset offset
Offset list used for building pseudo-topology.
struct Format_info_cache cache
Lines cache for reading feature.
char ** dsn_options
Array of OGR DSN options.
Non-native format info (PostGIS)
char * db_name
Database name (derived from conninfo)
char * fid_column
FID column.
char * schema_name
Schema name.
char * where
SQL where statement (of filter features)
dbDriver * dbdriver
Open DB driver when writing attributes.
PGconn * conn
PGconn object (generated by PQconnectdb)
char * toposchema_name
Topology schema name and id.
char * cursor_name
Open cursor.
int next_line
Next line to be read.
int coor_dim
Coordinates dimension (2D or 3D)
char * conninfo
Connection string.
PGresult * res
struct Format_info_cache cache
Lines cache for reading feature.
int inTransaction
Start/Finish transaction.
char * topogeom_column
TopoGeometry column (feature table)
int srid
Spatial reference system id (see spatial_ref_sys table)
struct Format_info_offset offset
Offset list used for building pseudo-topology (simple features access)
struct field_info * fi
char * geom_column
Geometry column (simple feature access)
int topo_geo_only
Topology format.
char * table_name
Table name.
SF_FeatureType feature_type
Feature type (simple feature access)
Non-native format info (currently only OGR is implemented)
struct Format_info_pg pg
PostGIS info.
struct Format_info_ogr ogr
OGR info.
Graph-related section (see GRASS Directed Graph Library)
dglSPCache_s spCache
Shortest path cache.
int line_type
Line type used to build the graph.
int cost_multip
Edge and node costs multiplicator.
double * edge_fcosts
Forward costs used for graph.
double * node_costs
Node costs used for graph.
dglGraph_s graph_s
Graph structure.
double * edge_bcosts
backward costs used for graph
Vector map info.
struct site_att * site_att
Array of attributes loaded from db.
char * mapset
Mapset name.
int temporary
Temporary map flag.
struct gvfile dig_fp
GV file pointer (native format only)
struct dig_head head
Header info.
int support_updated
Support files were updated.
int n_site_dbl
Number of double attributes for one site.
char * gisdbase
GISDBASE path.
int level
Topology level.
int proj
???
int n_site_att
Number of attributes in site_att array.
char * name
Map name (for 4.0)
int field
Field number constraint (see line_cats structure)
int field_flag
Non-zero value to enable field constraint.
FILE * hist_fp
History file.
plus_t next_line
Feature id for sequential access.
int type
Feature type constraint.
int n_site_str
Number of string attributes for one site.
int type_flag
Non-zero value to enable feature type constraint.
int open
Open indicator.
char * location
Location name.
int head_only
Open only header.
int format
Map format (native, ogr, postgis)
struct Map_info::@11 constraint
Constraints for sequential feature access.
struct dblinks * dblnk
Array of DB links.
int region_flag
Non-zero value to enable region constraint.
struct Format_info fInfo
Format info for non-native formats.
struct Graph_info dgraph
Graph info (built for network analysis)
struct Plus_head plus
Plus info (topology, version, ...)
Area (topology) info.
plus_t n_isles
Number of islands inside.
plus_t * isles
1st generation interior islands
plus_t n_lines
Number of boundary lines.
plus_t * lines
List of boundary lines.
plus_t alloc_lines
Allocated space for lines.
plus_t centroid
Number of first centroid within area.
plus_t alloc_isles
Allocated space for isles.
Isle (topology) info.
plus_t * lines
List of boundary lines.
plus_t n_lines
Number of boundary lines.
plus_t alloc_lines
Allocated space for lines.
plus_t area
Area it exists w/in, if any.
Vector geometry.
char type
Line type.
off_t offset
Offset in coor file for line.
void * topo
Topology info.
Topological feature - node.
plus_t alloc_lines
Allocated space for lines.
double x
X coordinate.
plus_t n_lines
Number of attached lines (size of lines, angle)
float * angles
List of angles of connected lines.
plus_t * lines
List of connected lines.
double z
Z coordinate (used only for 3D data)
double y
Y coordinate.
Boundary topology.
plus_t left
Area number to the left, negative for isle.
plus_t N1
Start node.
plus_t N2
End node.
plus_t right
Area number to the right, negative for isle.
Centroid topology.
plus_t area
Area number, negative for duplicate centroid.
Face topology.
plus_t left
Volume number to the left, negative for hole.
plus_t E[3]
Array of edges.
plus_t right
Volume number to the right, negative for hole.
Kernel topology.
plus_t volume
Volume number, negative for duplicate kernel.
Line topology.
plus_t N1
Start node.
plus_t N2
End node.
Basic topology-related info.
int do_uplist
Indicates if the list of updated features is maintained.
struct gvfile spidx_fp
Spatial index file pointer.
struct Cat_index * cidx
Array of category indexes.
off_t Hole_offset
Offset of array of holes in topo file.
plus_t n_klines
Current number of kernels.
int n_cidx
Number of category indexes (one for each field/layer)
int Spidx_built
Spatial index built?
plus_t alloc_lines
Number of allocated lines.
off_t Isle_offset
Offset of array of isles in topo file.
off_t Area_spidx_offset
Offset of areas in sidx file.
struct Port_info cidx_port
Portability information for category index.
plus_t alloc_faces
Number of allocated faces.
off_t Node_offset
Offset of array of nodes in topo file.
int with_z
2D/3D vector data
off_t coor_size
Size of coor file.
plus_t n_faces
Current number of faces.
off_t Isle_spidx_offset
Offset of isles in sidx file.
struct Plus_head::@9 version
Backward compatibility version info.
struct P_line ** Line
Array of vector geometries.
plus_t n_lines
Current number of lines.
off_t Hole_spidx_offset
Offset of holes in sidx file.
int Spidx_new
Build new spatial index.
off_t Volume_offset
Offset of array of volumes in topo file.
plus_t n_plines
Current number of points.
struct RTree * Isle_spidx
Isles spatial index.
off_t Face_spidx_offset
Offset of faces in sidx file.
int alloc_upnodes
Allocated array of nodes.
off_t Area_offset
Offset of array of areas in topo file.
int off_t_size
Offset size.
plus_t alloc_holes
Number of allocated holes.
struct RTree * Area_spidx
Area spatial index.
plus_t n_nodes
Current number of topological features derived from vector geometries.
plus_t n_volumes
Current number of volumes.
int n_upnodes
number of updated nodes
int Spidx_file
Build new spatial index in file.
plus_t alloc_volumes
Number of allocated volumes.
off_t Volume_spidx_offset
Offset of volumes in sidx file.
int * upnodes
Array of updated nodes.
plus_t alloc_areas
Number of allocated areas.
int a_cidx
Allocated space for category indexes.
struct RTree * Line_spidx
Line spatial index.
plus_t n_blines
Current number of boundaries.
struct P_area ** Area
Array of areas.
plus_t alloc_isles
Number of allocated isles.
long head_size
Topo header size.
struct RTree * Volume_spidx
Volumes spatial index.
int spidx_with_z
2D/3D spatial index
int release_support
Release memory occupied by support structures (topo, spatial, category)
plus_t n_clines
Current number of centroids.
int cidx_up_to_date
Category index to be updated.
struct Version_info cidx
Version info for category index file.
long spidx_head_size
Spatial index header size.
plus_t alloc_nodes
Number of allocated nodes.
struct Version_info topo
Version info for topology file.
int update_cidx
Update category index if vector is modified.
plus_t n_vfaces
Current number of volume faces.
plus_t n_isles
Current number of isles.
int alloc_uplines
Allocated array of lines.
plus_t alloc_edges
Number of allocated edges.
struct RTree * Face_spidx
Faces spatial index.
int * uplines
Array of updated lines.
struct Port_info spidx_port
Portability information for spatial index.
plus_t n_holes
Current number of holes.
plus_t n_hfaces
Current number of hole faces.
long cidx_head_size
Category index header size.
struct Plus_head::@10 uplist
List of updated lines/nodes.
long coor_mtime
Time of last coor modification.
off_t * uplines_offset
Array of updated lines - offset.
off_t Edge_offset
Offset of array of edges in topo file.
struct bound_box box
Bounding box of features.
plus_t n_edges
Current number of edges.
off_t Line_spidx_offset
Offset of lines in sidx file.
int n_uplines
Number of updated lines.
struct RTree * Node_spidx
Node spatial index.
struct P_isle ** Isle
Array of isles.
struct P_node ** Node
Array of nodes.
struct Port_info port
Portability information.
off_t Node_spidx_offset
Offset of nodes in sidx file.
int mode
Access mode.
struct RTree * Hole_spidx
Holes spatial index.
plus_t n_areas
Current number of areas.
int built
Highest level of topology currently available.
plus_t n_flines
Current number of faces.
off_t Line_offset
Offset of array of vector geometries in topo file.
plus_t n_llines
Current number of lines.
struct Version_info spidx
Version info for spatial index file.
Portability info.
unsigned char flt_cnvrt[PORT_FLOAT]
Conversion matrices between file and native byte order (float)
int flt_quick
Quick reading flag for float.
unsigned char lng_cnvrt[PORT_LONG]
Conversion matrices between file and native byte order (long)
int dbl_quick
Quick reading flag for double.
unsigned char off_t_cnvrt[PORT_OFF_T]
Conversion matrices between file and native byte order (off_t)
unsigned char int_cnvrt[PORT_INT]
Conversion matrices between file and native byte order (int)
int off_t_quick
Quick reading flag for off_t.
int lng_quick
Quick reading flag for long.
int int_quick
Quick reading flag for int.
unsigned char shrt_cnvrt[PORT_SHORT]
Conversion matrices between file and native byte order (short)
int off_t_size
Size of off_t data type.
unsigned char dbl_cnvrt[PORT_DOUBLE]
Conversion matrices between file and native byte order (double)
int shrt_quick
Quick reading flag for short.
int byte_order
File byte order.
Definition rtree.h:123
Backward compatibility version info.
int minor
Current version (minor)
int back_major
Earliest version that can use this data format (major)
int back_minor
Earliest version that can use this data format (minor)
int major
Current version (major)
Bounding box.
Definition dig_structs.h:62
double W
West.
Definition dig_structs.h:78
double T
Top.
Definition dig_structs.h:82
double S
South.
Definition dig_structs.h:70
double N
North.
Definition dig_structs.h:66
double E
East.
Definition dig_structs.h:74
double B
Bottom.
Definition dig_structs.h:86
List of bounding boxes with id.
int alloc_values
Allocated space for items.
int * id
Array of ids.
struct bound_box * box
Array of bounding boxes.
int n_values
Number of items in the list.
int have_boxes
flag to indicate whether bounding boxes should be added
Category list.
int alloc_ranges
Allocated space for ranges.
int n_ranges
Number of ranges.
int * min
Array of minimum values.
int * max
Array of maximum values.
int field
Category layer (field)
Vector map header data.
struct recycle * recycle
Recycle dead line.
char * date
Map date.
struct Version_info coor_version
Version info for coor file.
off_t last_offset
Offset of last read line.
long orig_scale
Original scale.
int plani_zone
Zone (UTM only)
double digit_thresh
Threshold for digitization.
char * organization
Organization name.
off_t size
Coor file size.
int with_z
2D/3D vector data
char * comment
Comments.
char * user_name
User name.
long head_size
Coor header size.
char * source_date
Source date.
char * map_name
Map name.
struct Port_info port
Portability information.
Layer (old: field) information.
char * table
Name of DB table.
char * driver
Name of DB driver ('sqlite', 'dbf', ...)
char * name
Layer name (optional)
char * database
char * key
Name of key column (usually 'cat')
int number
Layer number.
File definition.
Definition dig_structs.h:92
int loaded
Is file loaded?
char * end
End of file in the memory (pointer to first byte after)
char * start
Pointer to beginning of the file in the memory.
FILE * file
File descriptor.
Definition dig_structs.h:96
off_t alloc
Allocated space.
off_t size
Size of the file loaded to memory.
char * current
Current position set by dig_seek()
Feature category info.
int * field
Array of layers (fields)
int alloc_cats
Allocated space for categories.
int * cat
Array of categories.
int n_cats
Number of categories attached to element.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
int alloc_points
Allocated space for points.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.
List of dead lines in the file.
char dummy
Used by sites lib.
Definition dig_structs.h:44
int cat
Category number.
Definition dig_structs.h:48
char ** str
Array of string attributes.
Definition dig_structs.h:56
double * dbl
Array of double attributes.
Definition dig_structs.h:52
Spatial index info.
struct RTree * si_tree
Pointer to the search tree (R*-Tree)
char * name
Name of file to store the search tree.
Vector array.
int * c
Array.
int size
Array size.