GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-38f5cf43d1
geos_to_wktb.c File Reference

Vector library - GEOS powered WKT and WKB export. More...

#include <stdbool.h>
#include <stdlib.h>
#include <grass/vector.h>
#include <grass/glocale.h>
Include dependency graph for geos_to_wktb.c:

Go to the source code of this file.

Functions

unsigned char * Vect_read_area_to_wkb (struct Map_info *Map, int area, size_t *size)
 Read vector area and return it as Well Known Binary (WKB) unsigned char array. More...
 
char * Vect_read_area_to_wkt (struct Map_info *Map, int area)
 Read vector area and return it as Well Known Text (WKT) unsigned char array. More...
 
char * Vect_read_area_to_wkt2 (struct Map_info *Map, int area, bool trim)
 Read vector area and return it as Well Known Text (WKT) unsigned char array. More...
 
unsigned char * Vect_read_line_to_wkb (struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line, size_t *size, int *error)
 Read a Well Known Binary (WKB) representation of a given feature id. More...
 
unsigned char * Vect_line_to_wkb (const struct line_pnts *points, int type, int with_z, size_t *size)
 Create a Well Known Binary (WKB) representation of given feature type from points. More...
 
char * Vect_line_to_wkt (const struct line_pnts *points, int type, bool with_z)
 Create a Well Known Text (WKT) representation of given feature type from points. More...
 
char * Vect_line_to_wkt2 (const struct line_pnts *points, int type, bool with_z, bool trim)
 Create a Well Known Text (WKT) representation of given feature type from points. More...
 

Detailed Description

Vector library - GEOS powered WKT and WKB export.

Higher level functions for reading/writing/manipulating vectors.

(C) 2015 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
Soeren Gebbert <soerengebbert googlemail.com>

Definition in file geos_to_wktb.c.

Function Documentation

◆ Vect_line_to_wkb()

unsigned char* Vect_line_to_wkb ( const struct line_pnts points,
int  type,
int  with_z,
size_t *  size 
)

Create a Well Known Binary (WKB) representation of given feature type from points.

This function is not thread safe, it uses static variables for speedup.

Supported feature types:

  • GV_POINT -> POINT
  • GV_CENTROID -> POINT
  • GV_LINE -> LINESTRING
  • GV_BOUNDARY -> LINEARRING
Parameters
pointspointer to line_pnts structure
typefeature type (see supported types)
with_zSet to 1 if the feature is 3d, 0 otherwise
sizeThe size of the returned byte array
Returns
pointer to string (allocated)
NULL on error

Definition at line 223 of file geos_to_wktb.c.

◆ Vect_line_to_wkt()

char* Vect_line_to_wkt ( const struct line_pnts points,
int  type,
bool  with_z 
)

Create a Well Known Text (WKT) representation of given feature type from points.

Calls Vect_line_to_wkt2() with trim set to false.

Definition at line 259 of file geos_to_wktb.c.

◆ Vect_line_to_wkt2()

char* Vect_line_to_wkt2 ( const struct line_pnts points,
int  type,
bool  with_z,
bool  trim 
)

Create a Well Known Text (WKT) representation of given feature type from points.

This function is not thread safe, it uses static variables for speedup.

Supported types:

  • GV_POINT -> POINT
  • GV_CENTROID -> POINT
  • GV_LINE -> LINESTRING
  • GV_BOUNDARY -> LINEARRING
Parameters
pointspointer to line_pnts structure
typefeature type (see supported types)
with_zSet to true if the feature is 3d, false otherwise
trimSet the number trimming option on, With trim set to true, the writer will strip trailing 0's from the output coordinates.
Returns
pointer to char array
NULL on error

Definition at line 285 of file geos_to_wktb.c.

◆ Vect_read_area_to_wkb()

unsigned char* Vect_read_area_to_wkb ( struct Map_info Map,
int  area,
size_t *  size 
)

Read vector area and return it as Well Known Binary (WKB) unsigned char array.

Parameters
Mappointer to Map_info structure
areaarea id
sizeThe size of the returned unsigned char array
Returns
pointer to unsigned char array
NULL on error

Definition at line 34 of file geos_to_wktb.c.

References init(), NULL, and Vect_read_area_geos().

◆ Vect_read_area_to_wkt()

char* Vect_read_area_to_wkt ( struct Map_info Map,
int  area 
)

Read vector area and return it as Well Known Text (WKT) unsigned char array.

Calls Vect_read_area_to_wkt2() with trim set to false.

Definition at line 71 of file geos_to_wktb.c.

References Vect_read_area_to_wkt2().

◆ Vect_read_area_to_wkt2()

char* Vect_read_area_to_wkt2 ( struct Map_info Map,
int  area,
bool  trim 
)

Read vector area and return it as Well Known Text (WKT) unsigned char array.

Parameters
Mappointer to Map_info structure
areaarea id
sizeThe size of the returned unsigned char array
trimSet the number trimming option on, With trim set to true, the writer will strip trailing 0's from the output coordinates.
Returns
pointer to string (allocated)
NULL on error

Definition at line 89 of file geos_to_wktb.c.

References G_store(), init(), NULL, and Vect_read_area_geos().

Referenced by Vect_read_area_to_wkt().

◆ Vect_read_line_to_wkb()

unsigned char* Vect_read_line_to_wkb ( struct Map_info Map,
struct line_pnts line_p,
struct line_cats line_c,
int  line,
size_t *  size,
int *  error 
)

Read a Well Known Binary (WKB) representation of a given feature id.

This function reads a specific feature and converts it into a WKB representation. line_pnts and line_cats structures can be provided to store the result of the read operation. That is meaningful in case the category values of the feature are needed. This function is not thread safe, it uses static variables for speedup.

Supported feature types:

  • GV_POINT -> POINT
  • GV_CENTROID -> POINT
  • GV_LINE -> LINESTRING
  • GV_BOUNDARY -> LINEARRING
Parameters
Mappointer to Map_info structure
line_ppointer to line_pnts structure to use, or NULL
line_cpointer to line_cats structure to use, or NULL
lineThe id of the feature to read
sizeThe size of the returned unsigned char array
Returns
pointer to unsigned char array
NULL on error

Definition at line 146 of file geos_to_wktb.c.