7#include "GisTopology.h"
14#include <QCoreApplication>
21#include "IException.h"
40 m_WKBreader(0), m_WKBwriter(0) {
102 QByteArray wkb_data =
wkb.toLatin1();
103 const unsigned char *footy =
reinterpret_cast<const unsigned char *
> (wkb_data.data());
104 GEOSGeometry *geom = GEOSWKBReader_readHEX(
wkbReader(), footy,
wkb.size());
106 GEOSGeometry *geom = GEOSWKBReader_readHEX(
wkbReader(),
107 reinterpret_cast<const unsigned char *
> (
wkb.toLatin1().data()),
111 QString mess =
"Unable convert the given WKB string [" +
wkb +
"] to a GEOSGeometry";
129 QByteArray wkt_data =
wkt.toLatin1();
130 const char *footy = wkt_data.data();
131 GEOSGeometry *geom = GEOSWKTReader_read(
wktReader(), footy);
133 QString mess =
"Unable convert the given WKT string [" +
wkt +
"] to a GEOSGeometry";
149 if (!geom)
return (0);
150 return (GEOSGeom_clone(geom));
164 const GEOSPreparedGeometry *ppgeom = GEOSPrepare(geom);
167 "Unable convert the given GEOSGeometry to a GEOSPreparedGeometry",
188 char *wkt_h = GEOSWKTWriter_write(
wktWriter(), geom);
189 QString thegeom = QString::fromLatin1(
reinterpret_cast<const char *
> (wkt_h));
215 unsigned char *wkt_h = GEOSWKBWriter_writeHEX(
wkbWriter(), geom, &length);
216 QString thegeom = QString::fromLatin1(
reinterpret_cast<const char *
> (wkt_h), length);
234 GEOSGeom_destroy(geom);
247 destroy(
const_cast<GEOSGeometry *
> (geom));
260 GEOSPreparedGeom_destroy(geom);
273 GEOSCoordSeq_destroy(sequence);
286 GEOSFree(
const_cast<char *
> (geos_text));
299 GEOSFree(
const_cast<unsigned char *
> (geos_text));
333 vsnprintf(buffer,
sizeof(buffer), fmt, ap);
350 vsnprintf(buffer,
sizeof(buffer), fmt, ap);
This class models GIS topology.
static GisTopology * instance()
Gets the singleton instance of this class.
Disposition
Enumeration to indicate whether the geometry should be preserved.
@ DestroyGeometry
Destroy the geometry.
GEOSGeometry * geomFromWKT(const QString &wkt)
Reads in the geometry from the given well-known text formatted string.
void geosFinish()
Shuts down the GEOS C API.
static void dieAtExit()
Exit termination routine.
void destroy(GEOSGeometry *geom) const
Destroys the given GEOS geometry.
QString wkt(const GEOSGeometry *geom, const Disposition &disp=PreserveGeometry)
Writes a well-known text string from the given geometry.
static GisTopology * m_gisfactory
A static member variable representing the GIS factory.
GEOSWKTWriter * wktWriter()
Accessor for the GEOS well-known text writer.
GEOSWKTReader * m_WKTreader
A GEOS library parser for well-known text format.
GEOSWKTWriter * m_WKTwriter
A GEOS library writer for well-known text format.
static void notice(const char *fmt,...)
A static method for handling errors.
GEOSGeometry * clone(const GEOSGeometry *geom) const
Clones the given GEOSGeometry pointer.
GEOSWKBReader * wkbReader()
Accessor for the GEOS well-known binary reader.
QString wkb(const GEOSGeometry *geom, const Disposition &disp=PreserveGeometry)
Writes a well-known binary string from the given geometry.
GEOSWKBReader * m_WKBreader
A GEOS library parser for well-known binary format.
void geosInit()
Initializes the GEOS C API.
~GisTopology()
Destroy the GisTopology object.
GEOSWKBWriter * wkbWriter()
Accessor for the GEOS well-known binary writer.
const GEOSPreparedGeometry * preparedGeometry(const GEOSGeometry *geom) const
Gets a GEOSPreparedGeometry from the given GEOSGeometry.
GEOSWKBWriter * m_WKBwriter
A GEOS library writer for well-known binary format.
GisTopology()
Private default constructor so that this class is only instatiated through the instance() method.
GEOSWKTReader * wktReader()
Accessor for the GEOS well-known text reader.
GEOSGeometry * geomFromWKB(const QString &wkb)
Reads in the geometry from the given well-known binary formatted string.
static void error(const char *fmt,...)
A static method for handling errors.
@ Programmer
This error is for when a programmer made an API call that was illegal.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.