source: grass/trunk/include/vect/dig_structs.h

Last change on this file was 70262, checked in by martinl, 8 years ago

v.external: implement where statement option (requires distclean)

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