GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71793
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
simple_features.c File Reference

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

#include <stdio.h>
#include <grass/vector.h>
#include <grass/glocale.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, int type, int with_z)
 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 (const 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

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 113 of file simple_features.c.

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.

Referenced by Vect_sfa_is_line_simple(), Vect_sfa_line_astext(), and Vect_sfa_line_geometry_type().

int Vect_sfa_get_num_features ( const struct Map_info Map)

Get number of simple features.

For native format or PostGIS Topology returns -1

Parameters
Mapvector map
Returns
number of features
-1 on error

Definition at line 293 of file simple_features.c.

References _, Format_info_pg::conn, DB_SQL_MAX, Map_info::fInfo, Map_info::format, G_fatal_error(), G_warning(), GV_FORMAT_OGR, GV_FORMAT_OGR_DIRECT, GV_FORMAT_POSTGIS, Format_info_ogr::layer, Format_info::ogr, Format_info::pg, Format_info_pg::schema_name, Format_info_pg::table_name, Format_info_pg::toposchema_name, TRUE, and Vect_get_full_name().

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 78 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.

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 265 of file simple_features.c.

References GV_LINES, Vect_get_num_line_points(), line_pnts::x, line_pnts::y, and line_pnts::z.

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

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, ...)

Definition at line 244 of file simple_features.c.

References Vect_sfa_get_line_type().

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 187 of file simple_features.c.

References _, G_warning(), line_pnts::n_points, SF_LINEARRING, SF_LINESTRING, SF_POINT, SF_POLYGON, and Vect_sfa_get_line_type().

Referenced by Vect_write_ascii().

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 130 of file simple_features.c.

References GV_BOUNDARY, GV_LINE, and GV_POINT.

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 159 of file simple_features.c.

References G_store(), NULL, SF_LINEARRING, SF_LINESTRING, SF_POINT, SF_POLYGON, and Vect_sfa_get_line_type().