SpatiaLite  5.0.0
Data Structures | Macros | Typedefs | Functions
gg_dxf.h File Reference

Geometry handling functions: DXF files. More...

Go to the source code of this file.

Data Structures

struct  gaia_dxf_extra_attr
 wrapper for DXF Extra Attribute object More...
 
struct  gaia_dxf_insert
 wrapper for DXF Insert object More...
 
struct  gaia_dxf_text
 wrapper for DXF Text object More...
 
struct  gaia_dxf_point
 wrapper for DXF Point object More...
 
struct  gaia_dxf_circle
 wrapper for DXF Circle object More...
 
struct  gaia_dxf_arc
 wrapper for DXF Arc object More...
 
struct  gaia_dxf_hole
 wrapper for DXF Polygon interior hole object More...
 
struct  gaia_dxf_polyline
 wrapper for DXF Polyline object could be a Linestring or a Polygon depending on the is_closed flag More...
 
struct  gaia_dxf_hatch_segm
 wrapper for DXF Pattern Segment object More...
 
struct  gaia_dxf_boundary_path
 wrapper for DXF Boundary Path object More...
 
struct  gaia_dxf_hatch
 wrapper for DXF Pattern Hatch object More...
 
struct  gaia_dxf_block
 wrapper for DXF Block object More...
 
struct  gaia_dxf_layer
 wrapper for DXF Layer object More...
 
struct  gaia_dxf_parser
 wrapper for DXF Parser object More...
 
struct  gaia_dxf_write
 wrapper for DXF Write object More...
 

Macros

#define GAIA_DXF_IMPORT_BY_LAYER   1
 import distinct layers
 
#define GAIA_DXF_IMPORT_MIXED   2
 import layers mixed altogether by type
 
#define GAIA_DXF_AUTO_2D_3D   3
 auto-selects 2D or 3D
 
#define GAIA_DXF_FORCE_2D   4
 always force 2D
 
#define GAIA_DXF_FORCE_3D   5
 always force 3D
 
#define GAIA_DXF_RING_NONE   6
 don't apply any special Ring handling
 
#define GAIA_DXF_RING_LINKED   7
 apply special "linked rings" handling
 
#define GAIA_DXF_RING_UNLINKED   8
 apply special "unlinked rings" handling
 
#define GAIA_DXF_V12   1000
 DXF version [Writer].
 

Typedefs

typedef struct gaia_dxf_extra_attr gaiaDxfExtraAttr
 wrapper for DXF Extra Attribute object
 
typedef gaiaDxfExtraAttrgaiaDxfExtraAttrPtr
 Typedef for DXF Extra Attribute object. More...
 
typedef struct gaia_dxf_insert gaiaDxfInsert
 wrapper for DXF Insert object
 
typedef gaiaDxfInsertgaiaDxfInsertPtr
 Typedef for DXF Insert object. More...
 
typedef struct gaia_dxf_text gaiaDxfText
 wrapper for DXF Text object
 
typedef gaiaDxfTextgaiaDxfTextPtr
 Typedef for DXF Text object. More...
 
typedef struct gaia_dxf_point gaiaDxfPoint
 wrapper for DXF Point object
 
typedef gaiaDxfPointgaiaDxfPointPtr
 Typedef for DXF Point object. More...
 
typedef struct gaia_dxf_circle gaiaDxfCircle
 wrapper for DXF Circle object
 
typedef gaiaDxfCirclegaiaDxfCirclePtr
 Typedef for DXF Circle object. More...
 
typedef struct gaia_dxf_arc gaiaDxfArc
 wrapper for DXF Arc object
 
typedef gaiaDxfArcgaiaDxfArcPtr
 Typedef for DXF Arc object. More...
 
typedef struct gaia_dxf_hole gaiaDxfHole
 wrapper for DXF Polygon interior hole object
 
typedef gaiaDxfHolegaiaDxfHolePtr
 Typedef for DXF Point object. More...
 
typedef struct gaia_dxf_polyline gaiaDxfPolyline
 wrapper for DXF Polyline object could be a Linestring or a Polygon depending on the is_closed flag
 
typedef gaiaDxfPolylinegaiaDxfPolylinePtr
 Typedef for DXF Polyline object. More...
 
typedef struct gaia_dxf_hatch_segm gaiaDxfHatchSegm
 wrapper for DXF Pattern Segment object
 
typedef gaiaDxfHatchSegmgaiaDxfHatchSegmPtr
 Typedef for DXF Hatch Segment object. More...
 
typedef struct gaia_dxf_boundary_path gaiaDxfBoundaryPath
 wrapper for DXF Boundary Path object
 
typedef gaiaDxfBoundaryPathgaiaDxfBoundaryPathPtr
 Typedef for DXF Boundary Path object. More...
 
typedef struct gaia_dxf_hatch gaiaDxfHatch
 wrapper for DXF Pattern Hatch object
 
typedef gaiaDxfHatchgaiaDxfHatchPtr
 Typedef for DXF Hatch object. More...
 
typedef struct gaia_dxf_block gaiaDxfBlock
 wrapper for DXF Block object
 
typedef gaiaDxfBlockgaiaDxfBlockPtr
 Typedef for DXF Block object. More...
 
typedef struct gaia_dxf_layer gaiaDxfLayer
 wrapper for DXF Layer object
 
typedef gaiaDxfLayergaiaDxfLayerPtr
 Typedef for DXF Layer object. More...
 
typedef struct gaia_dxf_parser gaiaDxfParser
 wrapper for DXF Parser object
 
typedef gaiaDxfParsergaiaDxfParserPtr
 Typedef for DXF Layer object. More...
 
typedef struct gaia_dxf_write gaiaDxfWriter
 wrapper for DXF Write object
 
typedef gaiaDxfWritergaiaDxfWriterPtr
 Typedef for DXF Writer object.
 

Functions

GAIAGEO_DECLARE gaiaDxfParserPtr gaiaCreateDxfParser (int srid, int force_dims, const char *prefix, const char *selected_layer, int special_rings)
 Creates a DXF Parser object. More...
 
GAIAGEO_DECLARE void gaiaDestroyDxfParser (gaiaDxfParserPtr parser)
 Destroying a DXF Parser object. More...
 
GAIAGEO_DECLARE int gaiaParseDxfFile (gaiaDxfParserPtr parser, const char *dxf_path)
 Parsing a DXF file. More...
 
GAIAGEO_DECLARE int gaiaParseDxfFile_r (const void *p_cache, gaiaDxfParserPtr parser, const char *dxf_path)
 Parsing a DXF file. More...
 
GAIAGEO_DECLARE int gaiaLoadFromDxfParser (sqlite3 *db_handle, gaiaDxfParserPtr parser, int mode, int append)
 Populating a DB so to permanently store all Geometries from a DXF Parser. More...
 
GAIAGEO_DECLARE int gaiaDxfWriterInit (gaiaDxfWriterPtr dxf, FILE *out, int precision, int version)
 Initializing a DXF Writer Object. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteHeader (gaiaDxfWriterPtr dxf, double minx, double miny, double minz, double maxx, double maxy, double maxz)
 Writing the DXF Header. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteFooter (gaiaDxfWriterPtr dxf)
 Writing a DXF Entities Section Header. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteTables (gaiaDxfWriterPtr dxf)
 Writing the DXF Tables Section Header. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteLayer (gaiaDxfWriterPtr dxf, const char *layer_name)
 Writing a DXF Table/Layer definition. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteEntities (gaiaDxfWriterPtr dxf)
 Writing a DXF Entities Section Header. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteEndSection (gaiaDxfWriterPtr dxf)
 Writing a DXF Entities Section Header. More...
 
GAIAGEO_DECLARE int gaiaDxfWritePoint (gaiaDxfWriterPtr dxf, const char *layer_name, double x, double y, double z)
 Writing a DXF Point Entity. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteText (gaiaDxfWriterPtr dxf, const char *layer_name, double x, double y, double z, const char *label, double text_height, double angle)
 Writing a DXF Text Entity. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteLine (gaiaDxfWriterPtr dxf, const char *layer_name, gaiaLinestringPtr line)
 Writing a DXF Polyline (opened) Entity. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteRing (gaiaDxfWriterPtr dxf, const char *layer_name, gaiaRingPtr ring)
 Writing a DXF Polyline (closed) Entity. More...
 
GAIAGEO_DECLARE int gaiaDxfWriteGeometry (gaiaDxfWriterPtr dxf, const char *layer_name, const char *label, double text_height, double text_rotation, gaiaGeomCollPtr geometry)
 Writing a DXF generic Entity. More...
 
GAIAGEO_DECLARE int gaiaExportDxf (gaiaDxfWriterPtr dxf, sqlite3 *db_handle, const char *sql, const char *layer_col_name, const char *geom_col_name, const char *label_col_name, const char *text_height_col_name, const char *text_rotation_col_name, gaiaGeomCollPtr geom_filter)
 Exporting a complex DXF file. More...
 

Detailed Description

Geometry handling functions: DXF files.

Typedef Documentation

◆ gaiaDxfArcPtr

Typedef for DXF Arc object.

See also
gaiaDxfArc

◆ gaiaDxfBlockPtr

Typedef for DXF Block object.

See also
gaiaDxfBlock

◆ gaiaDxfBoundaryPathPtr

Typedef for DXF Boundary Path object.

See also
gaiaDxfBoundaryPath

◆ gaiaDxfCirclePtr

Typedef for DXF Circle object.

See also
gaiaDxfCircle

◆ gaiaDxfExtraAttrPtr

Typedef for DXF Extra Attribute object.

See also
gaiaDxfExtraAttr

◆ gaiaDxfHatchPtr

Typedef for DXF Hatch object.

See also
gaiaDxfHatch

◆ gaiaDxfHatchSegmPtr

Typedef for DXF Hatch Segment object.

See also
gaiaDxfHatch

◆ gaiaDxfHolePtr

Typedef for DXF Point object.

See also
gaiaDxfHole

◆ gaiaDxfInsertPtr

Typedef for DXF Insert object.

See also
gaiaDxfText

◆ gaiaDxfLayerPtr

Typedef for DXF Layer object.

See also
gaiaDxfLayer

◆ gaiaDxfParserPtr

Typedef for DXF Layer object.

See also
gaiaDxfParser

◆ gaiaDxfPointPtr

Typedef for DXF Point object.

See also
gaiaDxfPoint

◆ gaiaDxfPolylinePtr

Typedef for DXF Polyline object.

See also
gaiaDxfPolyline

◆ gaiaDxfTextPtr

Typedef for DXF Text object.

See also
gaiaDxfText

Function Documentation

◆ gaiaCreateDxfParser()

GAIAGEO_DECLARE gaiaDxfParserPtr gaiaCreateDxfParser ( int  srid,
int  force_dims,
const char *  prefix,
const char *  selected_layer,
int  special_rings 
)

Creates a DXF Parser object.

Parameters
sridthe SRID value to be used for all Geometries
force_dimsshould be one of GAIA_DXF_AUTO_2D_3D, GAIA_DXF_FORCE_2D or GAIA_DXF_FORCE_3D
prefixan optional prefix to be used for DB target tables (could be NULL)
selected_layersif set, only the DXF Layer of corresponding name will be imported (could be NULL)
special_ringsrings handling: should be one of GAIA_DXF_RING_NONE, GAIA_DXF_RING_LINKED of GAIA_DXF_RING_UNLINKED
Returns
the pointer to a DXF Parser object
See also
gaiaDestroyDxfParser, gaiaParseDxfFile, gaiaLoadFromDxfParser
Note
the DXF Parser object corresponds to dynamically allocated memory: so you are responsible to destroy this object before or later by invoking gaiaDestroyDxfParser().

◆ gaiaDestroyDxfParser()

GAIAGEO_DECLARE void gaiaDestroyDxfParser ( gaiaDxfParserPtr  parser)

Destroying a DXF Parser object.

Parameters
parserpointer to DXF Parser object
See also
gaiaCreateDxfParser
Note
the pointer to the DXF Parser object to be finalized is expected to be the one returned by a previous call to gaiaCreateDxfParser.

◆ gaiaDxfWriteEndSection()

GAIAGEO_DECLARE int gaiaDxfWriteEndSection ( gaiaDxfWriterPtr  dxf)

Writing a DXF Entities Section Header.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteTables, gaiaDxfWriteEntities

◆ gaiaDxfWriteEntities()

GAIAGEO_DECLARE int gaiaDxfWriteEntities ( gaiaDxfWriterPtr  dxf)

Writing a DXF Entities Section Header.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteHeader, gaiaDxfWriteEndSection, gaiaDxfWritePoint, gaiaDxfWriteText, gaiaDxfWriteLine, gaiaDxfWriteRing, gaiaDxfWriteGeometry

◆ gaiaDxfWriteFooter()

GAIAGEO_DECLARE int gaiaDxfWriteFooter ( gaiaDxfWriterPtr  dxf)

Writing a DXF Entities Section Header.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteHeader

◆ gaiaDxfWriteGeometry()

GAIAGEO_DECLARE int gaiaDxfWriteGeometry ( gaiaDxfWriterPtr  dxf,
const char *  layer_name,
const char *  label,
double  text_height,
double  text_rotation,
gaiaGeomCollPtr  geometry 
)

Writing a DXF generic Entity.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
layer_namename of the corresponding layer
linepointer to the internal Ring to be exported into the DXF
labeltext string containing the label value (could be NULL)
text_heightonly for Text Labels: ingnored in any other case.
text_rotationonly for Text Labels: ingnored in any other case.
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteEntities, gaiaDxfWriteEndSection, gaiaDxfWritePoint, gaiaDxfWriteText, gaiaDxfWriteLine, gaiaDxfWriteRing

◆ gaiaDxfWriteHeader()

GAIAGEO_DECLARE int gaiaDxfWriteHeader ( gaiaDxfWriterPtr  dxf,
double  minx,
double  miny,
double  minz,
double  maxx,
double  maxy,
double  maxz 
)

Writing the DXF Header.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
minxthe minimum X coordinate contained within the DXF
minxthe minimum Y coordinate contained within the DXF
minxthe minimum Z coordinate contained within the DXF
minxthe maximum X coordinate contained within the DXF
minxthe maximum Y coordinate contained within the DXF
minxthe maximum Z coordinate contained within the DXF
Returns
0 on failure, any other value on success
See also
gaiaDxfWriterInit, gaiaDxfWriteFooter, gaiaDxfWriteTables, gaiaDxfWriteEntities

◆ gaiaDxfWriteLayer()

GAIAGEO_DECLARE int gaiaDxfWriteLayer ( gaiaDxfWriterPtr  dxf,
const char *  layer_name 
)

Writing a DXF Table/Layer definition.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
layer_namename of the layer
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteTables, gaiaDxfWriteEndSection

◆ gaiaDxfWriteLine()

GAIAGEO_DECLARE int gaiaDxfWriteLine ( gaiaDxfWriterPtr  dxf,
const char *  layer_name,
gaiaLinestringPtr  line 
)

Writing a DXF Polyline (opened) Entity.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
layer_namename of the corresponding layer
linepointer to the internal Linestring to be exported into the DXF
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteEntities, gaiaDxfWriteEndSection, gaiaDxfWritePoint, gaiaDxfWriteText, gaiaDxfWriteRing, gaiaDxfWriteGeometry

◆ gaiaDxfWritePoint()

GAIAGEO_DECLARE int gaiaDxfWritePoint ( gaiaDxfWriterPtr  dxf,
const char *  layer_name,
double  x,
double  y,
double  z 
)

Writing a DXF Point Entity.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
layer_namename of the corresponding layer
xX coordinate value
yY coordinate value
zZ coordinate value
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteEntities, gaiaDxfWriteEndSection, gaiaDxfWriteText, gaiaDxfWriteLine, gaiaDxfWriteRing, gaiaDxfWriteGeometry

◆ gaiaDxfWriteRing()

GAIAGEO_DECLARE int gaiaDxfWriteRing ( gaiaDxfWriterPtr  dxf,
const char *  layer_name,
gaiaRingPtr  ring 
)

Writing a DXF Polyline (closed) Entity.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
layer_namename of the corresponding layer
linepointer to the internal Ring to be exported into the DXF
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteEntities, gaiaDxfWriteEndSection, gaiaDxfWritePoint, gaiaDxfWriteText, gaiaDxfWriteLine, gaiaDxfWriteGeometry

◆ gaiaDxfWriterInit()

GAIAGEO_DECLARE int gaiaDxfWriterInit ( gaiaDxfWriterPtr  dxf,
FILE *  out,
int  precision,
int  version 
)

Initializing a DXF Writer Object.

Parameters
writerpointer to the gaiaDxfWriter object to be initialized
outfile handle to DXF output file
precisionnumber of decimal digits for any coordinate
versioncurrently always expected to be GAIA_DXF_V12
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteHeader, gaiaExportDxf

◆ gaiaDxfWriteTables()

GAIAGEO_DECLARE int gaiaDxfWriteTables ( gaiaDxfWriterPtr  dxf)

Writing the DXF Tables Section Header.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteHeader, gaiaDxfWriteEndSection

◆ gaiaDxfWriteText()

GAIAGEO_DECLARE int gaiaDxfWriteText ( gaiaDxfWriterPtr  dxf,
const char *  layer_name,
double  x,
double  y,
double  z,
const char *  label,
double  text_height,
double  angle 
)

Writing a DXF Text Entity.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
layer_namename of the corresponding layer
xX coordinate value
yY coordinate value
zZ coordinate value
labeltext string containing the label value
text_heightheight of the text in map units
angletext rotation angle
Returns
0 on failure, any other value on success
See also
gaiaDxfWriteEntities, gaiaDxfWriteEndSection, gaiaDxfWritePoint, gaiaDxfWriteLine, gaiaDxfWriteRing, gaiaDxfWriteGeometry

◆ gaiaExportDxf()

GAIAGEO_DECLARE int gaiaExportDxf ( gaiaDxfWriterPtr  dxf,
sqlite3 *  db_handle,
const char *  sql,
const char *  layer_col_name,
const char *  geom_col_name,
const char *  label_col_name,
const char *  text_height_col_name,
const char *  text_rotation_col_name,
gaiaGeomCollPtr  geom_filter 
)

Exporting a complex DXF file.

Parameters
dxfpointer to a properly initialized gaiaDxfWriter object
db_hanldehandle to the current DB connection
sqla text string defining the SQL query to be used for extracting all geometries/entities to be exported into the output DXF
layer_col_namename of the SQL resultset column containing the Layer name
geom_col_namename of the SQL resultset column containing Geometries
label_col_namename of the SQL resultset column containing Label values (could be NULL)
text_height_col_namename of the SQL resultset column containing Text Height values (could be NULL)
text_rotation_col_namename of the SQL resultset column containing Text Rotation values (could be NULL)
geom_filteran optional arbitrary Geometry to be used as a Spatial Filter (could be NULL)
Returns
0 on failure; the total count of exported entities on success
See also
gaiaDxfWriterInit

◆ gaiaLoadFromDxfParser()

GAIAGEO_DECLARE int gaiaLoadFromDxfParser ( sqlite3 *  db_handle,
gaiaDxfParserPtr  parser,
int  mode,
int  append 
)

Populating a DB so to permanently store all Geometries from a DXF Parser.

Parameters
db_handlehandle to a valid DB connection
parserpointer to DXF Parser object
modeshould be one of GAIA_DXF_IMPORT_BY_LAYER or GAIA_DXF_IMPORT_MIXED
appendboolean flag: if set and some required DB table already exists will attempt to append further rows into the existing table. otherwise an error will be returned.
Returns
0 on failure, any other value on success
See also
gaiaCreateDxfParser, gaiaDestroyDxfParser, gaiaParseDxfFile
Note
the pointer to the DXF Parser object is expected to be the one returned by a previous call to gaiaCreateDxfParser and previously used for a succesfull call to gaiaParseDxfFile

◆ gaiaParseDxfFile()

GAIAGEO_DECLARE int gaiaParseDxfFile ( gaiaDxfParserPtr  parser,
const char *  dxf_path 
)

Parsing a DXF file.

Parameters
parserpointer to DXF Parser object
dxf_pathpathname of the DXF external file to be parsed
Returns
0 on failure, any other value on success
See also
gaiaParseDxfFile_r, gaiaCreateDxfParser, gaiaDestroyDxfParser, gaiaLoadFromDxfParser
Note
the pointer to the DXF Parser object is expected to be the one returned by a previous call to gaiaCreateDxfParser. A DXF Parser object can be used only a single time to parse a DXF file.
not reentrant and thread unsafe.

◆ gaiaParseDxfFile_r()

GAIAGEO_DECLARE int gaiaParseDxfFile_r ( const void *  p_cache,
gaiaDxfParserPtr  parser,
const char *  dxf_path 
)

Parsing a DXF file.

Parameters
p_cachea memory pointer returned by spatialite_alloc_connection()
parserpointer to DXF Parser object
dxf_pathpathname of the DXF external file to be parsed
Returns
0 on failure, any other value on success
See also
gaiaParseDxfFile, gaiaCreateDxfParser, gaiaDestroyDxfParser, gaiaLoadFromDxfParser
Note
the pointer to the DXF Parser object is expected to be the one returned by a previous call to gaiaCreateDxfParser. A DXF Parser object can be used only a single time to parse a DXF file.
reentrant and thread-safe.