00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "gis.h"
00019 #include "Vect.h"
00020 #include <stdlib.h>
00021
00022
00023
00030 int
00031 Vect_get_num_nodes (struct Map_info *map)
00032 {
00033 return (map->plus.n_nodes);
00034 }
00035
00042 int
00043 Vect_get_num_primitives (struct Map_info *map, int type)
00044 {
00045 int num = 0;
00046
00047 if ( type & GV_POINT ) num += map->plus.n_plines;
00048 if ( type & GV_LINE ) num += map->plus.n_llines;
00049 if ( type & GV_BOUNDARY ) num += map->plus.n_blines;
00050 if ( type & GV_CENTROID ) num += map->plus.n_clines;
00051 if ( type & GV_FACE ) num += map->plus.n_flines;
00052 if ( type & GV_KERNEL ) num += map->plus.n_klines;
00053
00054 return num;
00055 }
00056
00063 int
00064 Vect_get_num_lines (struct Map_info *map)
00065 {
00066 return (map->plus.n_lines);
00067 }
00068
00075 int
00076 Vect_get_num_areas (struct Map_info *map)
00077 {
00078 return (map->plus.n_areas);
00079 }
00080
00087 int
00088 Vect_get_num_islands (struct Map_info *map)
00089 {
00090 return (map->plus.n_isles);
00091 }
00092
00099 int
00100 Vect_get_num_dblinks (struct Map_info *map)
00101 {
00102 return (map->dblnk->n_fields);
00103 }
00104
00111 int
00112 Vect_get_num_updated_lines (struct Map_info *map)
00113 {
00114 return (map->plus.n_uplines);
00115 }
00116
00123 int
00124 Vect_get_updated_line (struct Map_info *map, int idx)
00125 {
00126 return (map->plus.uplines[idx]);
00127 }
00128
00135 int
00136 Vect_get_num_updated_nodes (struct Map_info *map)
00137 {
00138 return (map->plus.n_upnodes);
00139 }
00140
00147 int
00148 Vect_get_updated_node (struct Map_info *map, int idx)
00149 {
00150 return (map->plus.upnodes[idx]);
00151 }
00152
00159 int
00160 Vect_get_node_coor (struct Map_info *map, int num, double *x, double *y, double *z)
00161 {
00162 P_NODE *Node;
00163
00164 Node = map->plus.Node[num];
00165 *x = Node->x;
00166 *y = Node->y;
00167
00168 if ( z != NULL )
00169 *z = Node->z;
00170
00171 return (0);
00172 }
00173
00180 int
00181 Vect_get_line_nodes ( struct Map_info *Map, int line, int *n1, int *n2)
00182 {
00183
00184 if ( Map->level < 2 )
00185 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00186
00187 if ( n1 != NULL )
00188 *n1 = Map->plus.Line[line]->N1;
00189
00190 if ( n2 != NULL )
00191 *n2 = Map->plus.Line[line]->N2;
00192
00193 return 1;
00194 }
00195
00202 int
00203 Vect_get_line_areas ( struct Map_info *Map, int line, int *left, int *right)
00204 {
00205
00206 if ( Map->level < 2 )
00207 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00208
00209 if ( left != NULL )
00210 *left = Map->plus.Line[line]->left;
00211
00212 if ( right != NULL )
00213 *right = Map->plus.Line[line]->right;
00214
00215 return 1;
00216 }
00217
00224 int
00225 Vect_get_node_n_lines ( struct Map_info *Map, int node )
00226 {
00227
00228 if ( Map->level < 2 )
00229 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00230
00231 return ( Map->plus.Node[node]->n_lines );
00232
00233 }
00234
00243 int
00244 Vect_get_node_line ( struct Map_info *Map, int node, int line )
00245 {
00246 if ( Map->level < 2 )
00247 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00248
00249 return ( Map->plus.Node[node]->lines[line] );
00250 }
00251
00260 float
00261 Vect_get_node_line_angle ( struct Map_info *Map, int node, int line )
00262 {
00263 if ( Map->level < 2 )
00264 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00265
00266 return ( Map->plus.Node[node]->angles[line] );
00267 }
00268
00275 int
00276 Vect_get_centroid_area ( struct Map_info *Map, int centroid )
00277 {
00278 if ( Map->level < 2 )
00279 G_fatal_error ("Map %s@%s is not open on level >= 2\n", Map->name, Map->mapset);
00280
00281 return ( Map->plus.Line[centroid]->left );
00282 }