GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
simple_features.c File Reference

Vector library - OGC Simple Features Access. More...

#include <stdio.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include "pg_local_proto.h"
#include <ogr_api.h>
Include dependency graph for simple_features.c:

Go to the source code of this file.

Functions

SF_FeatureType Vect_sfa_get_line_type (const struct line_pnts *Points, int type, int with_z)
 Get SF type of given vector feature. More...
 
int Vect_sfa_get_type (SF_FeatureType sftype)
 Get relevant GV type. More...
 
int Vect_sfa_check_line_type (const struct line_pnts *Points, int type, SF_FeatureType sftype, int with_z)
 Check SF type. More...
 
int Vect_sfa_line_dimension (int type)
 Get geometry dimension. More...
 
char * Vect_sfa_line_geometry_type (const struct line_pnts *Points, int type)
 Get geometry type (string) More...
 
int Vect_sfa_line_astext (const struct line_pnts *Points, int type, int with_z, int precision, FILE *file)
 Export geometry to Well-Known Text. More...
 
int Vect_sfa_is_line_simple (const struct line_pnts *Points UNUSED, int type UNUSED, int with_z UNUSED)
 Check if feature is simple. More...
 
int Vect_sfa_is_line_closed (const struct line_pnts *Points, int type, int with_z)
 Check if feature is closed. More...
 
int Vect_sfa_get_num_features (struct Map_info *Map)
 Get number of simple features. More...
 

Detailed Description

Vector library - OGC Simple Features Access.

Higher level functions for reading/writing/manipulating vectors.

Note: In progress! Currently on GV_POINT, GV_LINE, GV_BOUNDARY are supported.

Todo:
  • Vect_sfa_line_is_simple()
  • Vect_sfa_line_srid()
  • Vect_sfa_line_envelope()
  • Vect_sfa_line_asbinary()
  • Vect_sfa_line_is_empty()
  • Vect_sfa_line_is_3d()
  • Vect_sfa_line_is_measured()
  • Vect_sfa_line_boundary()

Reference: http://www.opengeospatial.org/standards/sfa

(C) 2009, 2011-2013 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Martin Landa <landa.martin gmail.com>

Definition in file simple_features.c.

Function Documentation

◆ Vect_sfa_check_line_type()

int Vect_sfa_check_line_type ( const struct line_pnts Points,
int  type,
SF_FeatureType  sftype,
int  with_z 
)

Check SF type.

E.g. if type is GV_LINE with two or more segments and the start node is identical with the end node, and sftype is SF_LINEARRING, functions returns 1, otherwise 0.

Parameters
Pointspointer to line_pnts structure
typefeature type (GV_POINT, GV_LINE, ...)
sftypeSF type to be checked (SF_POINT, SF_LINE, ...)
with_znon-zero value for 3D data
Returns
1 if type is sftype
0 type differs from sftype

Definition at line 114 of file simple_features.c.

◆ Vect_sfa_get_line_type()

SF_FeatureType Vect_sfa_get_line_type ( const struct line_pnts Points,
int  type,
int  with_z 
)

Get SF type of given vector feature.

List of supported feature types:

  • GV_POINT -> SF_POINT
  • GV_LINE -> SF_LINESTRING
  • GV_LINE (closed) -> SF_LINEARRING
  • GV_BOUNDARY -> SF_POLYGON
Parameters
Pointspointer to line_pnts structure
typefeature type (see supported types above)
with_zWITH_Z for 3D data
Returns
SF type identificator (see list of supported types)
-1 on error

Definition at line 64 of file simple_features.c.

◆ Vect_sfa_get_num_features()

int Vect_sfa_get_num_features ( struct Map_info Map)

◆ Vect_sfa_get_type()

int Vect_sfa_get_type ( SF_FeatureType  sftype)

Get relevant GV type.

Parameters
Mappointer to Map_info structure
typeSF geometry type (SF_POINT, SF_LINESTRING, ...)
Returns
GV type
-1 on error

Definition at line 79 of file simple_features.c.

References GV_BOUNDARY, GV_LINE, GV_POINT, SF_LINEARRING, SF_LINESTRING, SF_LINESTRING25D, SF_POINT, SF_POINT25D, SF_POLYGON, and SF_POLYGON25D.

◆ Vect_sfa_is_line_closed()

int Vect_sfa_is_line_closed ( const struct line_pnts Points,
int  type,
int  with_z 
)

Check if feature is closed.

Parameters
Pointspointer to line_pnts structure
typefeature type (GV_LINE or GV_BOUNDARY)
Returns
1 feature closed
0 feature not closed
-1 feature type not supported (GV_POINT, GV_CENTROID, ...)

Definition at line 271 of file simple_features.c.

◆ Vect_sfa_is_line_simple()

int Vect_sfa_is_line_simple ( const struct line_pnts *Points  UNUSED,
int type  UNUSED,
int with_z  UNUSED 
)

Check if feature is simple.

Parameters
Pointspointer to line_pnts structure
typefeature type (GV_POINT, GV_LINE, ...)
Returns
1 feature simple
0 feature not simple
-1 feature type not supported (GV_POINT, GV_CENTROID, ...)
Note
Implementation is pending, now always returns 0

Definition at line 248 of file simple_features.c.

◆ Vect_sfa_line_astext()

int Vect_sfa_line_astext ( const struct line_pnts Points,
int  type,
int  with_z,
int  precision,
FILE *  file 
)

Export geometry to Well-Known Text.

Parameters
Pointspointer to line_pnts structure
typefeature type
with_znon-zero value for 3D data
precisionfloating number precision
[out]filefile where to write the output
Returns
0 on success
-1 unsupported feature type

Definition at line 188 of file simple_features.c.

◆ Vect_sfa_line_dimension()

int Vect_sfa_line_dimension ( int  type)

Get geometry dimension.

Parameters
Pointspointer to line_pnts structure
typefeature type (GV_POINT, GV_LINE, ...)
Returns
0 for GV_POINT
1 for GV_LINE
2 for GV_BOUNDARY
-1 unsupported feature type

Definition at line 131 of file simple_features.c.

◆ Vect_sfa_line_geometry_type()

char* Vect_sfa_line_geometry_type ( const struct line_pnts Points,
int  type 
)

Get geometry type (string)

Supported types:

  • GV_POINT -> SF_POINT -> "POINT"
  • GV_LINE -> SF_LINESTRING -> "LINESTRING"
  • GV_LINE (closed) -> SF_LINEARRING -> "LINEARRING"
  • GV_BOUNDARY (closed) -> SF_POLYGON -> "POLYGON"

Note: Allocated string should be freed by G_free().

Parameters
Pointspointer to line_pnts structure (feature geometry)
typefeature type (see supported types above)
Returns
geometry type string
NULL unsupported feature type

Definition at line 160 of file simple_features.c.