22 #include "../Config.h" 66 wkb2size = g2->getWKBSize();
68 assert(wkb1size == wkb2size);
70 char* wkb2 = new char[wkb2size];
73 assert(memcmp(wkb1, wkb2) == 0);
80 std::vector<WKBEntry> hwkbVec;
83 for(
size_t i = 0; i < hwkbVec.size(); ++i)
91 std::size_t wkb1size = 0;
93 char* wkb1 =
new char[wkb1size];
98 CPPUNIT_ASSERT(g2->
equals(g1));
103 CPPUNIT_ASSERT(wkb1size == wkb2size);
105 char* wkb2 =
new char[wkb2size];
109 CPPUNIT_ASSERT(strcmp(hwkb1, hwkb2) == 0);
110 CPPUNIT_ASSERT(memcmp(wkb1, wkb2, wkb2size) == 0);
115 CPPUNIT_ASSERT(geomRead);
116 CPPUNIT_ASSERT(geomRead->
equals(g1));
118 char* wkb1Read =
new char [size1];
120 CPPUNIT_ASSERT(memcmp(wkb1, wkb1Read, size1) == 0);
122 const char* validHWKB = hwkb.
m_hwkb.c_str();
123 CPPUNIT_ASSERT(strcmp(hwkb1, validHWKB) == 0);
130 delete g1;
delete g2;
delete geomRead;
141 std::vector<std::string> wktGeom;
143 loadWKT(
"/data/wkt_geom.txt", wktGeom);
144 for(
size_t i = 0; i < wktGeom.size(); ++i)
146 std::string rr_wkt = wktGeom[i];
152 std::size_t wkb1size = 0;
154 char* wkb1 =
new char[wkb1size];
160 CPPUNIT_ASSERT(g1->
equals(tl_geom_from_geos));
167 CPPUNIT_ASSERT(geomRead->equals(g1));
169 CPPUNIT_ASSERT(g2->equals(g1));
171 size_t size1 = geomRead->getWkbSize();
172 char* wkb1Read =
new char [size1];
174 CPPUNIT_ASSERT(memcmp(wkb1Read, wkb1, size1) == 0);
176 std::size_t wkb2size = g2->getWkbSize();
177 char* wkb2 =
new char[wkb2size];
179 CPPUNIT_ASSERT(wkb1size == wkb2size);
180 CPPUNIT_ASSERT(memcmp(wkb1, wkb2, wkb2size) == 0);
185 CPPUNIT_ASSERT(strcmp(hwkb1, hwkb2) == 0);
192 delete g1;
delete g2;
delete geomRead;
203 std::vector<WKBEntry> hwkbVec;
207 for(
size_t i = 0; i < hwkbVec.size(); ++i)
213 CPPUNIT_ASSERT(g.get());
218 CPPUNIT_ASSERT(g->getCoordinateDimension() == hwkb.
m_ndims);
221 CPPUNIT_ASSERT(g->getSRID() == hwkb.
m_srid);
224 std::unique_ptr<te::gm::Geometry> envelope(g->getEnvelope());
226 CPPUNIT_ASSERT(g->getMBR());
227 std::cout << hwkb.
m_wkt << std::endl;
228 std::string ustring = g->asText();
231 char* myWkb = g->asBinary(wkbSize);
234 CPPUNIT_ASSERT(myHwkb == hwkb.
m_hwkb);
237 CPPUNIT_ASSERT(g->isEmpty() ==
false);
241 CPPUNIT_ASSERT(g->isSimple() ==
true);
242 CPPUNIT_ASSERT(g->isValid() ==
true);
243 std::unique_ptr<te::gm::Geometry> boundary;
244 CPPUNIT_ASSERT_NO_THROW(boundary.reset(g->getBoundary()));
245 CPPUNIT_ASSERT(boundary.get());
247 CPPUNIT_ASSERT(g->is3D() == hwkb.
m_is3D);
258 FILE* f = fopen( TERRALIB_DATA_DIR
"/hwkb.csv",
"r");
260 CPPUNIT_ASSERT(f != NULL);
264 std::vector<std::string> values;
265 std::string value(
"");
269 char c = (char)(fgetc(f));
273 values.push_back(value);
279 values.push_back(value);
286 if(values.size() != 9)
292 fe.
m_srid = atoi(values[1].c_str());
295 fe.
m_ndims = atoi(values[4].c_str());
296 fe.
m_wkt = values[5];
298 fe.
m_is3D = values[7] ==
"t";
301 hwkbVec.push_back(fe);
313 CPPUNIT_ASSERT(f != NULL);
317 std::vector<std::string> values;
318 std::string value(
"");
322 char c = (char)(fgetc(f));
326 geom_wkt.push_back(value);
340 std::string filename = TERRALIB_DATA_DIR + filewkt;
343 CPPUNIT_ASSERT(f != NULL);
347 std::vector<std::string> values;
348 std::string value(
"");
352 char c = (char)(fgetc(f));
356 geom_wkt.push_back(value);
void loadWKT(std::vector< std::string > &geom_wkt) const
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
char * Hex2Binary(const char *hex)
It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary...
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
static std::string fromUTF8(const std::string &src)
Convert a string in UTF-8 to the current locale encoding.
std::size_t getWkbSize() const _NOEXCEPT_OP(true)
It returns the size required by a WKB representation for this geometric object.
An static class with global definitions.
void tcBasicGeometryMethods()
Test Case: testing the basic geometry methods.
Test suite for the geometry WKB Reader.
Test suite for the WKBReader class.
Dimensionality
From Wikipedia: "in mathematics, the dimension of an object is an intrinsic property, independent of the space in which the object may happen to be embedded".
This file contains several utilities functions for dealing with HEX strings.
A class for handling character enconding/decoding.
static geos::geom::Geometry * write(const Geometry *teGeom)
It reads a TerraLib geometry and make a GEOS geometry.
A class that converts a GEOS geometry to a TerraLib geometry.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void loadGeometry(std::vector< WKBEntry > &hwkbVec) const
Auxiliary method for reading geometry information from an ASCII file.
A class that converts a TerraLib geometry to a GEOS geometry.
void tcCreateGeomFromWKTAndApplyReadTests()
Test Case: Creating basic Geom from WKT and apply read test.
void tcCreateGeometriesAndApplyReadTests()
Test Case: Creating basic Geom and apply read test.
virtual void setSRID(int srid) _NOEXCEPT_OP(true)=0
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
This file contains include headers for the TerraLib Common Runtime module.
This file contains include headers for the Vector Geometry model of TerraLib.
char * Binary2Hex(const char *s, std::size_t size)
Each char from the array of characters in binary format is converted into a pair of hex characters...
CPPUNIT_TEST_SUITE_REGISTRATION(TsWKBReader)
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB.
virtual bool equals(const Geometry *const rhs, const bool exact=false) const _NOEXCEPT_OP(false)
It returns true if the geometry object is spatially equal to rhs geometry.
void getWkb(char *wkb, te::common::MachineByteOrder byteOrder) const _NOEXCEPT_OP(false)
It serializes the geometry to a WKB representation into the specified buffer.
static Geometry * read(const char *wkt)
It returns a valid Geometry from a given WKT.