TsGeometry.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // Unit-Test TerraLib
21 #include "TsGeometry.h"
22 #include "../Config.h"
23 
24 // TerraLib
25 #include <terralib/Defines.h>
26 #include <terralib/common.h>
29 #include <terralib/geometry.h>
31 
32 // STL
33 #include <cstdio>
34 #include <cstdlib>
35 #include <cstring>
36 
38 
40 {
41 }
42 
44 {
45 }
46 
48 {
49 //#ifdef TE_COMPILE_ALL
50  te::gm::Point* pt2D = new te::gm::Point(2378);
51 
52  CPPUNIT_ASSERT(typeid(*pt2D) == typeid(te::gm::Point));
53  CPPUNIT_ASSERT(pt2D->getDimension() == te::gm::P);
54  CPPUNIT_ASSERT(pt2D->getCoordinateDimension() == 2);
55  CPPUNIT_ASSERT(pt2D->getGeometryType() == "Point");
56  CPPUNIT_ASSERT(pt2D->getGeomTypeId() == te::gm::PointType);
57  CPPUNIT_ASSERT(pt2D->getSRID() == 2378);
58 
59  delete pt2D;
60 
62 
63  CPPUNIT_ASSERT(typeid(*ptM) == typeid(te::gm::Point));
64  CPPUNIT_ASSERT(ptM->getDimension() == te::gm::P);
65  CPPUNIT_ASSERT(ptM->getCoordinateDimension() == 3);
66  CPPUNIT_ASSERT(ptM->getGeometryType() == "Point");
67  CPPUNIT_ASSERT(ptM->getGeomTypeId() == te::gm::PointMType);
68  CPPUNIT_ASSERT(ptM->getSRID() == 2378);
69 
70  delete ptM;
71 
73 
74  CPPUNIT_ASSERT(typeid(*ptZ) == typeid(te::gm::Point));
75  CPPUNIT_ASSERT(ptZ->getDimension() == te::gm::P);
76  CPPUNIT_ASSERT(ptZ->getCoordinateDimension() == 3);
77  CPPUNIT_ASSERT(ptZ->getGeometryType() == "Point");
78  CPPUNIT_ASSERT(ptZ->getGeomTypeId() == te::gm::PointZType);
79  CPPUNIT_ASSERT(ptZ->getSRID() == 2378);
80 
81  delete ptZ;
82 
84 
85  CPPUNIT_ASSERT(typeid(*ptZM) == typeid(te::gm::Point));
86  CPPUNIT_ASSERT(ptZM->getDimension() == te::gm::P);
87  CPPUNIT_ASSERT(ptZM->getCoordinateDimension() == 4);
88  CPPUNIT_ASSERT(ptZM->getGeometryType() == "Point");
89  CPPUNIT_ASSERT(ptZM->getGeomTypeId() == te::gm::PointZMType);
90  CPPUNIT_ASSERT(ptZM->getSRID() == 2378);
91 
92  delete ptZM;
93 
95 
96  CPPUNIT_ASSERT(typeid(*l2D) == typeid(te::gm::LineString));
97  CPPUNIT_ASSERT(l2D->getDimension() == te::gm::L);
98  CPPUNIT_ASSERT(l2D->getCoordinateDimension() == 2);
99  CPPUNIT_ASSERT(l2D->getGeometryType() == "LineString");
100  CPPUNIT_ASSERT(l2D->getGeomTypeId() == te::gm::LineStringType);
101  CPPUNIT_ASSERT(l2D->getSRID() == 2378);
102 
103  delete l2D;
104 
106 
107  CPPUNIT_ASSERT(typeid(*lM) == typeid(te::gm::LineString));
108  CPPUNIT_ASSERT(lM->getDimension() == te::gm::L);
109  CPPUNIT_ASSERT(lM->getCoordinateDimension() == 3);
110  CPPUNIT_ASSERT(lM->getGeometryType() == "LineString");
111  CPPUNIT_ASSERT(lM->getGeomTypeId() == te::gm::LineStringMType);
112  CPPUNIT_ASSERT(lM->getSRID() == 2378);
113 
114  delete lM;
115 
117 
118  CPPUNIT_ASSERT(typeid(*lZ) == typeid(te::gm::LineString));
119  CPPUNIT_ASSERT(lZ->getDimension() == te::gm::L);
120  CPPUNIT_ASSERT(lZ->getCoordinateDimension() == 3);
121  CPPUNIT_ASSERT(lZ->getGeometryType() == "LineString");
122  CPPUNIT_ASSERT(lZ->getGeomTypeId() == te::gm::LineStringZType);
123  CPPUNIT_ASSERT(lZ->getSRID() == 2378);
124 
125  delete lZ;
126 
128 
129  CPPUNIT_ASSERT(typeid(*lZM) == typeid(te::gm::LineString));
130  CPPUNIT_ASSERT(lZM->getDimension() == te::gm::L);
131  CPPUNIT_ASSERT(lZM->getCoordinateDimension() == 4);
132  CPPUNIT_ASSERT(lZM->getGeometryType() == "LineString");
133  CPPUNIT_ASSERT(lZM->getGeomTypeId() == te::gm::LineStringZMType);
134  CPPUNIT_ASSERT(lZM->getSRID() == 2378);
135 
136  delete lZM;
137 
138  te::gm::Polygon* pol2D = new te::gm::Polygon(0, te::gm::PolygonType, 2378);
139 
140  CPPUNIT_ASSERT(typeid(*pol2D) == typeid(te::gm::Polygon));
141  CPPUNIT_ASSERT(pol2D->getDimension() == te::gm::A);
142  CPPUNIT_ASSERT(pol2D->getCoordinateDimension() == 2);
143  CPPUNIT_ASSERT(pol2D->getGeometryType() == "Polygon");
144  CPPUNIT_ASSERT(pol2D->getGeomTypeId() == te::gm::PolygonType);
145  CPPUNIT_ASSERT(pol2D->getSRID() == 2378);
146 
147  delete pol2D;
148 
150 
151  CPPUNIT_ASSERT(typeid(*polM) == typeid(te::gm::Polygon));
152  CPPUNIT_ASSERT(polM->getDimension() == te::gm::A);
153  CPPUNIT_ASSERT(polM->getCoordinateDimension() == 3);
154  CPPUNIT_ASSERT(polM->getGeometryType() == "Polygon");
155  CPPUNIT_ASSERT(polM->getGeomTypeId() == te::gm::PolygonMType);
156  CPPUNIT_ASSERT(polM->getSRID() == 2378);
157 
158  delete polM;
159 
161 
162  CPPUNIT_ASSERT(typeid(*polZ) == typeid(te::gm::Polygon));
163  CPPUNIT_ASSERT(polZ->getDimension() == te::gm::A);
164  CPPUNIT_ASSERT(polZ->getCoordinateDimension() == 3);
165  CPPUNIT_ASSERT(polZ->getGeometryType() == "Polygon");
166  CPPUNIT_ASSERT(polZ->getGeomTypeId() == te::gm::PolygonZType);
167  CPPUNIT_ASSERT(polZ->getSRID() == 2378);
168 
169  delete polZ;
170 
172 
173  CPPUNIT_ASSERT(typeid(*polZM) == typeid(te::gm::Polygon));
174  CPPUNIT_ASSERT(polZM->getDimension() == te::gm::A);
175  CPPUNIT_ASSERT(polZM->getCoordinateDimension() == 4);
176  CPPUNIT_ASSERT(polZM->getGeometryType() == "Polygon");
177  CPPUNIT_ASSERT(polZM->getGeomTypeId() == te::gm::PolygonZMType);
178  CPPUNIT_ASSERT(polZM->getSRID() == 2378);
179 
180  delete polZM;
181 
183 
184  CPPUNIT_ASSERT(typeid(*gc2D) == typeid(te::gm::GeometryCollection));
185  CPPUNIT_ASSERT(gc2D->getDimension() == te::gm::P);
186  CPPUNIT_ASSERT(gc2D->getCoordinateDimension() == 2);
187  CPPUNIT_ASSERT(gc2D->getGeometryType() == "GeometryCollection");
188  CPPUNIT_ASSERT(gc2D->getGeomTypeId() == te::gm::GeometryCollectionType);
189  CPPUNIT_ASSERT(gc2D->getSRID() == 2378);
190 
191  delete gc2D;
192 
194 
195  CPPUNIT_ASSERT(typeid(*gcM) == typeid(te::gm::GeometryCollection));
196  CPPUNIT_ASSERT(gcM->getDimension() == te::gm::P);
197  CPPUNIT_ASSERT(gcM->getCoordinateDimension() == 3);
198  CPPUNIT_ASSERT(gcM->getGeometryType() == "GeometryCollection");
199  CPPUNIT_ASSERT(gcM->getGeomTypeId() == te::gm::GeometryCollectionMType);
200  CPPUNIT_ASSERT(gcM->getSRID() == 2378);
201 
202  delete gcM;
203 
205 
206  CPPUNIT_ASSERT(typeid(*gcZ) == typeid(te::gm::GeometryCollection));
207  CPPUNIT_ASSERT(gcZ->getDimension() == te::gm::P);
208  CPPUNIT_ASSERT(gcZ->getCoordinateDimension() == 3);
209  CPPUNIT_ASSERT(gcZ->getGeometryType() == "GeometryCollection");
210  CPPUNIT_ASSERT(gcZ->getGeomTypeId() == te::gm::GeometryCollectionZType);
211  CPPUNIT_ASSERT(gcZ->getSRID() == 2378);
212 
213  delete gcZ;
214 
216 
217  CPPUNIT_ASSERT(typeid(*gcZM) == typeid(te::gm::GeometryCollection));
218  CPPUNIT_ASSERT(gcZM->getDimension() == te::gm::P);
219  CPPUNIT_ASSERT(gcZM->getCoordinateDimension() == 4);
220  CPPUNIT_ASSERT(gcZM->getGeometryType() == "GeometryCollection");
221  CPPUNIT_ASSERT(gcZM->getGeomTypeId() == te::gm::GeometryCollectionZMType);
222  CPPUNIT_ASSERT(gcZM->getSRID() == 2378);
223 
224  delete gcZM;
225 
227 
228  CPPUNIT_ASSERT(typeid(*mpt2D) == typeid(te::gm::MultiPoint));
229  CPPUNIT_ASSERT(mpt2D->getDimension() == te::gm::P);
230  CPPUNIT_ASSERT(mpt2D->getCoordinateDimension() == 2);
231  CPPUNIT_ASSERT(mpt2D->getGeometryType() == "MultiPoint");
232  CPPUNIT_ASSERT(mpt2D->getGeomTypeId() == te::gm::MultiPointType);
233  CPPUNIT_ASSERT(mpt2D->getSRID() == 2378);
234 
235  delete mpt2D;
236 
238 
239  CPPUNIT_ASSERT(typeid(*mptM) == typeid(te::gm::MultiPoint));
240  CPPUNIT_ASSERT(mptM->getDimension() == te::gm::P);
241  CPPUNIT_ASSERT(mptM->getCoordinateDimension() == 3);
242  CPPUNIT_ASSERT(mptM->getGeometryType() == "MultiPoint");
243  CPPUNIT_ASSERT(mptM->getGeomTypeId() == te::gm::MultiPointMType);
244  CPPUNIT_ASSERT(mptM->getSRID() == 2378);
245 
246  delete mptM;
247 
249 
250  CPPUNIT_ASSERT(typeid(*mptZ) == typeid(te::gm::MultiPoint));
251  CPPUNIT_ASSERT(mptZ->getDimension() == te::gm::P);
252  CPPUNIT_ASSERT(mptZ->getCoordinateDimension() == 3);
253  CPPUNIT_ASSERT(mptZ->getGeometryType() == "MultiPoint");
254  CPPUNIT_ASSERT(mptZ->getGeomTypeId() == te::gm::MultiPointZType);
255  CPPUNIT_ASSERT(mptZ->getSRID() == 2378);
256 
257  delete mptZ;
258 
260 
261  CPPUNIT_ASSERT(typeid(*mptZM) == typeid(te::gm::MultiPoint));
262  CPPUNIT_ASSERT(mptZM->getDimension() == te::gm::P);
263  CPPUNIT_ASSERT(mptZM->getCoordinateDimension() == 4);
264  CPPUNIT_ASSERT(mptZM->getGeometryType() == "MultiPoint");
265  CPPUNIT_ASSERT(mptZM->getGeomTypeId() == te::gm::MultiPointZMType);
266  CPPUNIT_ASSERT(mptZM->getSRID() == 2378);
267 
268  delete mptZM;
269 
271 
272  CPPUNIT_ASSERT(typeid(*ml2D) == typeid(te::gm::MultiLineString));
273  CPPUNIT_ASSERT(ml2D->getDimension() == te::gm::L);
274  CPPUNIT_ASSERT(ml2D->getCoordinateDimension() == 2);
275  CPPUNIT_ASSERT(ml2D->getGeometryType() == "MultiLineString");
276  CPPUNIT_ASSERT(ml2D->getGeomTypeId() == te::gm::MultiLineStringType);
277  CPPUNIT_ASSERT(ml2D->getSRID() == 2378);
278 
279  delete ml2D;
280 
282 
283  CPPUNIT_ASSERT(typeid(*mlM) == typeid(te::gm::MultiLineString));
284  CPPUNIT_ASSERT(mlM->getDimension() == te::gm::L);
285  CPPUNIT_ASSERT(mlM->getCoordinateDimension() == 3);
286  CPPUNIT_ASSERT(mlM->getGeometryType() == "MultiLineString");
287  CPPUNIT_ASSERT(mlM->getGeomTypeId() == te::gm::MultiLineStringMType);
288  CPPUNIT_ASSERT(mlM->getSRID() == 2378);
289 
290  delete mlM;
291 
293 
294  CPPUNIT_ASSERT(typeid(*mlZ) == typeid(te::gm::MultiLineString));
295  CPPUNIT_ASSERT(mlZ->getDimension() == te::gm::L);
296  CPPUNIT_ASSERT(mlZ->getCoordinateDimension() == 3);
297  CPPUNIT_ASSERT(mlZ->getGeometryType() == "MultiLineString");
298  CPPUNIT_ASSERT(mlZ->getGeomTypeId() == te::gm::MultiLineStringZType);
299  CPPUNIT_ASSERT(mlZ->getSRID() == 2378);
300 
301  delete mlZ;
302 
304 
305  CPPUNIT_ASSERT(typeid(*mlZM) == typeid(te::gm::MultiLineString));
306  CPPUNIT_ASSERT(mlZM->getDimension() == te::gm::L);
307  CPPUNIT_ASSERT(mlZM->getCoordinateDimension() == 4);
308  CPPUNIT_ASSERT(mlZM->getGeometryType() == "MultiLineString");
309  CPPUNIT_ASSERT(mlZM->getGeomTypeId() == te::gm::MultiLineStringZMType);
310  CPPUNIT_ASSERT(mlZM->getSRID() == 2378);
311 
312  delete mlZM;
313 
315 
316  CPPUNIT_ASSERT(typeid(*mpoly2D) == typeid(te::gm::MultiPolygon));
317  CPPUNIT_ASSERT(mpoly2D->getDimension() == te::gm::A);
318  CPPUNIT_ASSERT(mpoly2D->getCoordinateDimension() == 2);
319  CPPUNIT_ASSERT(mpoly2D->getGeometryType() == "MultiPolygon");
320  CPPUNIT_ASSERT(mpoly2D->getGeomTypeId() == te::gm::MultiPolygonType);
321  CPPUNIT_ASSERT(mpoly2D->getSRID() == 2378);
322 
323  delete mpoly2D;
324 
326 
327  CPPUNIT_ASSERT(typeid(*mpolyM) == typeid(te::gm::MultiPolygon));
328  CPPUNIT_ASSERT(mpolyM->getDimension() == te::gm::A);
329  CPPUNIT_ASSERT(mpolyM->getCoordinateDimension() == 3);
330  CPPUNIT_ASSERT(mpolyM->getGeometryType() == "MultiPolygon");
331  CPPUNIT_ASSERT(mpolyM->getGeomTypeId() == te::gm::MultiPolygonMType);
332  CPPUNIT_ASSERT(mpolyM->getSRID() == 2378);
333 
334  delete mpolyM;
335 
337 
338  CPPUNIT_ASSERT(typeid(*mpolyZ) == typeid(te::gm::MultiPolygon));
339  CPPUNIT_ASSERT(mpolyZ->getDimension() == te::gm::A);
340  CPPUNIT_ASSERT(mpolyZ->getCoordinateDimension() == 3);
341  CPPUNIT_ASSERT(mpolyZ->getGeometryType() == "MultiPolygon");
342  CPPUNIT_ASSERT(mpolyZ->getGeomTypeId() == te::gm::MultiPolygonZType);
343  CPPUNIT_ASSERT(mpolyZ->getSRID() == 2378);
344 
345  delete mpolyZ;
346 
348 
349  CPPUNIT_ASSERT(typeid(*mpolyZM) == typeid(te::gm::MultiPolygon));
350  CPPUNIT_ASSERT(mpolyZM->getDimension() == te::gm::A);
351  CPPUNIT_ASSERT(mpolyZM->getCoordinateDimension() == 4);
352  CPPUNIT_ASSERT(mpolyZM->getGeometryType() == "MultiPolygon");
353  CPPUNIT_ASSERT(mpolyZM->getGeomTypeId() == te::gm::MultiPolygonZMType);
354  CPPUNIT_ASSERT(mpolyZM->getSRID() == 2378);
355 
356  delete mpolyZM;
357 
359 
360  CPPUNIT_ASSERT(typeid(*polyhedral2D) == typeid(te::gm::PolyhedralSurface));
361  CPPUNIT_ASSERT(polyhedral2D->getDimension() == te::gm::A);
362  CPPUNIT_ASSERT(polyhedral2D->getCoordinateDimension() == 2);
363  CPPUNIT_ASSERT(polyhedral2D->getGeometryType() == "PolyhedralSurface");
364  CPPUNIT_ASSERT(polyhedral2D->getGeomTypeId() == te::gm::PolyhedralSurfaceType);
365  CPPUNIT_ASSERT(polyhedral2D->getSRID() == 2378);
366 
367  delete polyhedral2D;
368 
370 
371  CPPUNIT_ASSERT(typeid(*polyhedralM) == typeid(te::gm::PolyhedralSurface));
372  CPPUNIT_ASSERT(polyhedralM->getDimension() == te::gm::A);
373  CPPUNIT_ASSERT(polyhedralM->getCoordinateDimension() == 3);
374  CPPUNIT_ASSERT(polyhedralM->getGeometryType() == "PolyhedralSurface");
375  CPPUNIT_ASSERT(polyhedralM->getGeomTypeId() == te::gm::PolyhedralSurfaceMType);
376  CPPUNIT_ASSERT(polyhedralM->getSRID() == 2378);
377 
378  delete polyhedralM;
379 
381 
382  CPPUNIT_ASSERT(typeid(*polyhedralZ) == typeid(te::gm::PolyhedralSurface));
383  CPPUNIT_ASSERT(polyhedralZ->getDimension() == te::gm::A);
384  CPPUNIT_ASSERT(polyhedralZ->getCoordinateDimension() == 3);
385  CPPUNIT_ASSERT(polyhedralZ->getGeometryType() == "PolyhedralSurface");
386  CPPUNIT_ASSERT(polyhedralZ->getGeomTypeId() == te::gm::PolyhedralSurfaceZType);
387  CPPUNIT_ASSERT(polyhedralZ->getSRID() == 2378);
388 
389  delete polyhedralZ;
390 
392 
393  CPPUNIT_ASSERT(typeid(*polyhedralZM) == typeid(te::gm::PolyhedralSurface));
394  CPPUNIT_ASSERT(polyhedralZM->getDimension() == te::gm::A);
395  CPPUNIT_ASSERT(polyhedralZM->getCoordinateDimension() == 4);
396  CPPUNIT_ASSERT(polyhedralZM->getGeometryType() == "PolyhedralSurface");
397  CPPUNIT_ASSERT(polyhedralZM->getGeomTypeId() == te::gm::PolyhedralSurfaceZMType);
398  CPPUNIT_ASSERT(polyhedralZM->getSRID() == 2378);
399 
400  delete polyhedralZM;
401 
402  te::gm::TIN* tin2D = new te::gm::TIN(0, te::gm::TINType, 2378);
403 
404  CPPUNIT_ASSERT(typeid(*tin2D) == typeid(te::gm::TIN));
405  CPPUNIT_ASSERT(tin2D->getDimension() == te::gm::A);
406  CPPUNIT_ASSERT(tin2D->getCoordinateDimension() == 2);
407  CPPUNIT_ASSERT(tin2D->getGeometryType() == "Tin");
408  CPPUNIT_ASSERT(tin2D->getGeomTypeId() == te::gm::TINType);
409  CPPUNIT_ASSERT(tin2D->getSRID() == 2378);
410 
411  delete tin2D;
412 
413  te::gm::TIN* tinM = new te::gm::TIN(0, te::gm::TINMType, 2378);
414 
415  CPPUNIT_ASSERT(typeid(*tinM) == typeid(te::gm::TIN));
416  CPPUNIT_ASSERT(tinM->getDimension() == te::gm::A);
417  CPPUNIT_ASSERT(tinM->getCoordinateDimension() == 3);
418  CPPUNIT_ASSERT(tinM->getGeometryType() == "Tin");
419  CPPUNIT_ASSERT(tinM->getGeomTypeId() == te::gm::TINMType);
420  CPPUNIT_ASSERT(tinM->getSRID() == 2378);
421 
422  delete tinM;
423 
424  te::gm::TIN* tinZ = new te::gm::TIN(0, te::gm::TINZType, 2378);
425 
426  CPPUNIT_ASSERT(typeid(*tinZ) == typeid(te::gm::TIN));
427  CPPUNIT_ASSERT(tinZ->getDimension() == te::gm::A);
428  CPPUNIT_ASSERT(tinZ->getCoordinateDimension() == 3);
429  CPPUNIT_ASSERT(tinZ->getGeometryType() == "Tin");
430  CPPUNIT_ASSERT(tinZ->getGeomTypeId() == te::gm::TINZType);
431  CPPUNIT_ASSERT(tinZ->getSRID() == 2378);
432 
433  delete tinZ;
434 
435  te::gm::TIN* tinZM = new te::gm::TIN(0, te::gm::TINZMType, 2378);
436 
437  CPPUNIT_ASSERT(typeid(*tinZM) == typeid(te::gm::TIN));
438  CPPUNIT_ASSERT(tinZM->getDimension() == te::gm::A);
439  CPPUNIT_ASSERT(tinZM->getCoordinateDimension() == 4);
440  CPPUNIT_ASSERT(tinZM->getGeometryType() == "Tin");
441  CPPUNIT_ASSERT(tinZM->getGeomTypeId() == te::gm::TINZMType);
442  CPPUNIT_ASSERT(tinZM->getSRID() == 2378);
443 
444  delete tinZM;
445 
447 
448  CPPUNIT_ASSERT(typeid(*tri2D) == typeid(te::gm::Triangle));
449  CPPUNIT_ASSERT(tri2D->getDimension() == te::gm::A);
450  CPPUNIT_ASSERT(tri2D->getCoordinateDimension() == 2);
451  CPPUNIT_ASSERT(tri2D->getGeometryType() == "Polygon");
452  CPPUNIT_ASSERT(tri2D->getGeomTypeId() == te::gm::TriangleType);
453  CPPUNIT_ASSERT(tri2D->getSRID() == 2378);
454 
455  delete tri2D;
456 
458 
459  CPPUNIT_ASSERT(typeid(*triM) == typeid(te::gm::Triangle));
460  CPPUNIT_ASSERT(triM->getDimension() == te::gm::A);
461  CPPUNIT_ASSERT(triM->getCoordinateDimension() == 3);
462  CPPUNIT_ASSERT(triM->getGeometryType() == "Polygon");
463  CPPUNIT_ASSERT(triM->getGeomTypeId() == te::gm::TriangleMType);
464  CPPUNIT_ASSERT(triM->getSRID() == 2378);
465 
466  delete triM;
467 
469 
470  CPPUNIT_ASSERT(typeid(*triZ) == typeid(te::gm::Triangle));
471  CPPUNIT_ASSERT(triZ->getDimension() == te::gm::A);
472  CPPUNIT_ASSERT(triZ->getCoordinateDimension() == 3);
473  CPPUNIT_ASSERT(triZ->getGeometryType() == "Polygon");
474  CPPUNIT_ASSERT(triZ->getGeomTypeId() == te::gm::TriangleZType);
475  CPPUNIT_ASSERT(triZ->getSRID() == 2378);
476 
477  delete triZ;
478 
480 
481  CPPUNIT_ASSERT(typeid(*triZM) == typeid(te::gm::Triangle));
482  CPPUNIT_ASSERT(triZM->getDimension() == te::gm::A);
483  CPPUNIT_ASSERT(triZM->getCoordinateDimension() == 4);
484  CPPUNIT_ASSERT(triZM->getGeometryType() == "Polygon");
485  CPPUNIT_ASSERT(triZM->getGeomTypeId() == te::gm::TriangleZMType);
486  CPPUNIT_ASSERT(triZM->getSRID() == 2378);
487 
488  delete triZM;
489 //#endif
490 }
491 
493 {
494 //#ifdef TE_COMPILE_ALL
495  te::gm::Point pt(27.3, 28.5, 4326);
496 
497  CPPUNIT_ASSERT(pt.getX() == 27.3);
498  CPPUNIT_ASSERT(pt.getY() == 28.5);
499  CPPUNIT_ASSERT(pt.getZ() == TE_DOUBLE_NOT_A_NUMBER);
500  CPPUNIT_ASSERT(pt.getM() == TE_DOUBLE_NOT_A_NUMBER);
501  CPPUNIT_ASSERT(pt.getDimension() == te::gm::P);
502  CPPUNIT_ASSERT(pt.getCoordinateDimension() == 2);
503  CPPUNIT_ASSERT(pt.getGeometryType() == "Point");
504  CPPUNIT_ASSERT(pt.getGeomTypeId() == te::gm::PointType);
505  CPPUNIT_ASSERT(pt.getSRID() == 4326);
506  pt.setSRID(4128);
507  CPPUNIT_ASSERT(pt.getSRID() == 4128);
508  pt.setSRID(4326);
509  CPPUNIT_ASSERT(pt.getSRID() == 4326);
510  //pt.transform(4128);
511  //CPPUNIT_ASSERT(pt.getSRID() == 4128);
512  std::unique_ptr<te::gm::Geometry> envelope(pt.getEnvelope());
513  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
514  CPPUNIT_ASSERT(pt.getMBR());
515  CPPUNIT_ASSERT(pt.getMBR()->m_llx == pt.getX());
516  CPPUNIT_ASSERT(pt.getMBR()->m_lly == pt.getY());
517  CPPUNIT_ASSERT(pt.getMBR()->m_urx == pt.getX());
518  CPPUNIT_ASSERT(pt.getMBR()->m_ury == pt.getY());
519  pt.setX(18.9);
520  pt.setY(9.81);
521  pt.computeMBR(false);
522  CPPUNIT_ASSERT(pt.getMBR()->m_llx == 18.9);
523  CPPUNIT_ASSERT(pt.getMBR()->m_lly == 9.81);
524  CPPUNIT_ASSERT(pt.getMBR()->m_urx == 18.9);
525  CPPUNIT_ASSERT(pt.getMBR()->m_ury == 9.81);
526  CPPUNIT_ASSERT(pt.asText() == "point(18.9 9.81)");
527 
528 // WKB test
529  {
530  size_t size = pt.getWkbSize();
531  CPPUNIT_ASSERT(size == 21);
532  char* wkb = new char[size];
534  char* hwkb = te::core::Binary2Hex(wkb, size);
535  delete [] wkb;
536  const char* validHWKB = "01010000006666666666E632401F85EB51B89E2340";
537  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
538  delete [] hwkb;
539  }
540 
541  {
542  size_t size = 0;
543  char* wkb = pt.asBinary(size);
544  CPPUNIT_ASSERT(size == 21);
545  char* hwkb = te::core::Binary2Hex(wkb, size);
546  delete [] wkb;
547  const char* validHWKB = "01010000006666666666E632401F85EB51B89E2340";
548  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
549  delete [] hwkb;
550  }
551 
552  CPPUNIT_ASSERT(pt.isEmpty() == false);
553  CPPUNIT_ASSERT(pt.isSimple() == true);
554  CPPUNIT_ASSERT(pt.isValid() == true);
555  CPPUNIT_ASSERT(pt.is3D() == false);
556  CPPUNIT_ASSERT(pt.isMeasured() == false);
557  std::unique_ptr<te::gm::Geometry> boundary(pt.getBoundary());
558 
559  CPPUNIT_ASSERT(pt.getNPoints() == 1);
560 
561  std::unique_ptr<te::gm::Geometry> pt_clone(static_cast<te::gm::Geometry*>(pt.clone()));
562  CPPUNIT_ASSERT(pt.equals((pt_clone.get())));
563  CPPUNIT_ASSERT(pt.disjoint(pt_clone.get()) == false);
564  CPPUNIT_ASSERT(pt.intersects(pt_clone.get()));
565  CPPUNIT_ASSERT(pt.touches(pt_clone.get()) == false);
566 //#endif
567 }
568 
570 {
571 //#ifdef TE_COMPILE_ALL
572  te::gm::Point pt(te::gm::PointZType, 4326, 0);
573  pt.setX(27.3);
574  pt.setY(28.5);
575  pt.setZ(99.9);
576 
577  CPPUNIT_ASSERT(pt.getX() == 27.3);
578  CPPUNIT_ASSERT(pt.getY() == 28.5);
579  CPPUNIT_ASSERT(pt.getZ() == 99.9);
580  CPPUNIT_ASSERT(pt.getM() == TE_DOUBLE_NOT_A_NUMBER);
581  CPPUNIT_ASSERT(pt.getDimension() == te::gm::P);
582  CPPUNIT_ASSERT(pt.getCoordinateDimension() == 3);
583  CPPUNIT_ASSERT(pt.getGeometryType() == "Point");
584  CPPUNIT_ASSERT(pt.getGeomTypeId() == te::gm::PointZType);
585  CPPUNIT_ASSERT(pt.getSRID() == 4326);
586  pt.setSRID(4128);
587  CPPUNIT_ASSERT(pt.getSRID() == 4128);
588  pt.setSRID(4326);
589  CPPUNIT_ASSERT(pt.getSRID() == 4326);
590  //pt.transform(4128);
591  //CPPUNIT_ASSERT(pt.getSRID() == 4128);
592  std::unique_ptr<te::gm::Geometry> envelope(pt.getEnvelope());
593  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
594  CPPUNIT_ASSERT(pt.getMBR());
595  CPPUNIT_ASSERT(pt.getMBR()->m_llx == pt.getX());
596  CPPUNIT_ASSERT(pt.getMBR()->m_lly == pt.getY());
597  CPPUNIT_ASSERT(pt.getMBR()->m_urx == pt.getX());
598  CPPUNIT_ASSERT(pt.getMBR()->m_ury == pt.getY());
599  pt.setX(18.9);
600  pt.setY(9.81);
601  pt.setZ(77.7);
602  pt.computeMBR(false);
603  CPPUNIT_ASSERT(pt.getMBR()->m_llx == 18.9);
604  CPPUNIT_ASSERT(pt.getMBR()->m_lly == 9.81);
605  CPPUNIT_ASSERT(pt.getMBR()->m_urx == 18.9);
606  CPPUNIT_ASSERT(pt.getMBR()->m_ury == 9.81);
607  CPPUNIT_ASSERT(pt.asText() == "point z(18.9 9.81 77.7)");
608 
609 // WKB test
610  {
611  size_t size = pt.getWkbSize();
612  CPPUNIT_ASSERT(size == 29);
613  char* wkb = new char[size];
615  char* hwkb = te::core::Binary2Hex(wkb, size);
616  delete [] wkb;
617  const char* validHWKB = "01E90300006666666666E632401F85EB51B89E2340CDCCCCCCCC6C5340";
618  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
619  delete [] hwkb;
620  }
621 
622  {
623  size_t size = 0;
624  char* wkb = pt.asBinary(size);
625  CPPUNIT_ASSERT(size == 29);
626  char* hwkb = te::core::Binary2Hex(wkb, size);
627  delete [] wkb;
628  const char* validHWKB = "01E90300006666666666E632401F85EB51B89E2340CDCCCCCCCC6C5340";
629  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
630  delete [] hwkb;
631  }
632 
633  CPPUNIT_ASSERT(pt.isEmpty() == false);
634  CPPUNIT_ASSERT(pt.isSimple() == true);
635  CPPUNIT_ASSERT(pt.isValid() == true);
636  CPPUNIT_ASSERT(pt.is3D() == true);
637  CPPUNIT_ASSERT(pt.isMeasured() == false);
638  std::unique_ptr<te::gm::Geometry> boundary(pt.getBoundary());
639  //boundary->getGeomTypeId() ==
640  CPPUNIT_ASSERT(pt.getNPoints() == 1);
641 
642  std::unique_ptr<te::gm::Geometry> pt_clone(static_cast<te::gm::Geometry*>(pt.clone()));
643  CPPUNIT_ASSERT(pt.equals((pt_clone.get())));
644  CPPUNIT_ASSERT(pt.disjoint(pt_clone.get()) == false);
645  CPPUNIT_ASSERT(pt.intersects(pt_clone.get()));
646  CPPUNIT_ASSERT(pt.touches(pt_clone.get()) == false);
647 //#endif
648 }
649 
651 {
652 //#ifdef TE_COMPILE_ALL
653  te::gm::Point pt(te::gm::PointMType, 4326, 0);
654  pt.setX(27.3);
655  pt.setY(28.5);
656  pt.setM(99.9);
657 
658  CPPUNIT_ASSERT(pt.getX() == 27.3);
659  CPPUNIT_ASSERT(pt.getY() == 28.5);
660  CPPUNIT_ASSERT(pt.getZ() == TE_DOUBLE_NOT_A_NUMBER);
661  CPPUNIT_ASSERT(pt.getM() == 99.9);
662  CPPUNIT_ASSERT(pt.getDimension() == te::gm::P);
663  CPPUNIT_ASSERT(pt.getCoordinateDimension() == 3);
664  CPPUNIT_ASSERT(pt.getGeometryType() == "Point");
665  CPPUNIT_ASSERT(pt.getGeomTypeId() == te::gm::PointMType);
666  CPPUNIT_ASSERT(pt.getSRID() == 4326);
667  pt.setSRID(4128);
668  CPPUNIT_ASSERT(pt.getSRID() == 4128);
669  pt.setSRID(4326);
670  CPPUNIT_ASSERT(pt.getSRID() == 4326);
671  //pt.transform(4128);
672  //CPPUNIT_ASSERT(pt.getSRID() == 4128);
673  std::unique_ptr<te::gm::Geometry> envelope(pt.getEnvelope());
674  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
675  CPPUNIT_ASSERT(pt.getMBR());
676  CPPUNIT_ASSERT(pt.getMBR()->m_llx == pt.getX());
677  CPPUNIT_ASSERT(pt.getMBR()->m_lly == pt.getY());
678  CPPUNIT_ASSERT(pt.getMBR()->m_urx == pt.getX());
679  CPPUNIT_ASSERT(pt.getMBR()->m_ury == pt.getY());
680  pt.setX(18.9);
681  pt.setY(9.81);
682  pt.setM(77.7);
683  pt.computeMBR(false);
684  CPPUNIT_ASSERT(pt.getMBR()->m_llx == 18.9);
685  CPPUNIT_ASSERT(pt.getMBR()->m_lly == 9.81);
686  CPPUNIT_ASSERT(pt.getMBR()->m_urx == 18.9);
687  CPPUNIT_ASSERT(pt.getMBR()->m_ury == 9.81);
688  CPPUNIT_ASSERT(pt.asText() == "point m(18.9 9.81 77.7)");
689 
690 // WKB test
691  {
692  size_t size = pt.getWkbSize();
693  CPPUNIT_ASSERT(size == 29);
694  char* wkb = new char[size];
696  char* hwkb = te::core::Binary2Hex(wkb, size);
697  delete [] wkb;
698  const char* validHWKB = "01D10700006666666666E632401F85EB51B89E2340CDCCCCCCCC6C5340";
699  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
700  delete [] hwkb;
701  }
702 
703  {
704  size_t size = 0;
705  char* wkb = pt.asBinary(size);
706  CPPUNIT_ASSERT(size == 29);
707  char* hwkb = te::core::Binary2Hex(wkb, size);
708  delete [] wkb;
709  const char* validHWKB = "01D10700006666666666E632401F85EB51B89E2340CDCCCCCCCC6C5340";
710  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
711  delete [] hwkb;
712  }
713 
714  CPPUNIT_ASSERT(pt.isEmpty() == false);
715  CPPUNIT_ASSERT(pt.isSimple() == true);
716  CPPUNIT_ASSERT(pt.isValid() == true);
717  CPPUNIT_ASSERT(pt.is3D() == false);
718  CPPUNIT_ASSERT(pt.isMeasured() == true);
719  std::unique_ptr<te::gm::Geometry> boundary(pt.getBoundary());
720  //boundary->getGeomTypeId() ==
721  CPPUNIT_ASSERT(pt.getNPoints() == 1);
722 
723  std::unique_ptr<te::gm::Geometry> pt_clone(static_cast<te::gm::Geometry*>(pt.clone()));
724  CPPUNIT_ASSERT(pt.equals(pt_clone.get()));
725  CPPUNIT_ASSERT(pt.disjoint(pt_clone.get()) == false);
726  CPPUNIT_ASSERT(pt.intersects(pt_clone.get()));
727  CPPUNIT_ASSERT(pt.touches(pt_clone.get()) == false);
728 //#endif
729 }
730 
732 {
733 //#ifdef TE_COMPILE_ALL
734  te::gm::Point pt(te::gm::PointZMType, 4326, 0);
735  pt.setX(27.3);
736  pt.setZ(28.5);
737  pt.setZ(99.9);
738  pt.setM(180.0);
739 
740  CPPUNIT_ASSERT(pt.getX() == 27.3);
741  CPPUNIT_ASSERT(pt.getY() == 28.5);
742  CPPUNIT_ASSERT(pt.getZ() == 99.9);
743  CPPUNIT_ASSERT(pt.getM() == 180.0);
744  CPPUNIT_ASSERT(pt.getDimension() == te::gm::P);
745  CPPUNIT_ASSERT(pt.getCoordinateDimension() == 4);
746  CPPUNIT_ASSERT(pt.getGeometryType() == "Point");
747  CPPUNIT_ASSERT(pt.getGeomTypeId() == te::gm::PointZMType);
748  CPPUNIT_ASSERT(pt.getSRID() == 4326);
749  pt.setSRID(4128);
750  CPPUNIT_ASSERT(pt.getSRID() == 4128);
751  pt.setSRID(4326);
752  CPPUNIT_ASSERT(pt.getSRID() == 4326);
753  //pt.transform(4128);
754  //CPPUNIT_ASSERT(pt.getSRID() == 4128);
755  std::unique_ptr<te::gm::Geometry> envelope(pt.getEnvelope());
756  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
757  CPPUNIT_ASSERT(pt.getMBR());
758  CPPUNIT_ASSERT(pt.getMBR()->m_llx == pt.getX());
759  CPPUNIT_ASSERT(pt.getMBR()->m_lly == pt.getY());
760  CPPUNIT_ASSERT(pt.getMBR()->m_urx == pt.getX());
761  CPPUNIT_ASSERT(pt.getMBR()->m_ury == pt.getY());
762  pt.setX(18.9);
763  pt.setY(9.81);
764  pt.setZ(77.7);
765  pt.setM(55.5);
766  pt.computeMBR(false);
767  CPPUNIT_ASSERT(pt.getMBR()->m_llx == 18.9);
768  CPPUNIT_ASSERT(pt.getMBR()->m_lly == 9.81);
769  CPPUNIT_ASSERT(pt.getMBR()->m_urx == 18.9);
770  CPPUNIT_ASSERT(pt.getMBR()->m_ury == 9.81);
771  CPPUNIT_ASSERT(pt.asText() == "point zm(18.9 9.81 77.7 55.5)");
772 
773 // WKB test
774  {
775  size_t size = pt.getWkbSize();
776  CPPUNIT_ASSERT(size == 37);
777  char* wkb = new char[size];
779  char* hwkb = te::core::Binary2Hex(wkb, size);
780  delete [] wkb;
781  const char* validHWKB = "01B90B00006666666666E632401F85EB51B89E2340CDCCCCCCCC6C53400000000000C04B40";
782  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
783  delete [] hwkb;
784  }
785 
786  {
787  size_t size = 0;
788  char* wkb = pt.asBinary(size);
789  CPPUNIT_ASSERT(size == 37);
790  char* hwkb = te::core::Binary2Hex(wkb, size);
791  delete [] wkb;
792  const char* validHWKB = "01B90B00006666666666E632401F85EB51B89E2340CDCCCCCCCC6C53400000000000C04B40";
793  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
794  delete [] hwkb;
795  }
796 
797  CPPUNIT_ASSERT(pt.isEmpty() == false);
798  CPPUNIT_ASSERT(pt.isSimple() == true);
799  CPPUNIT_ASSERT(pt.isValid() == true);
800  CPPUNIT_ASSERT(pt.is3D() == true);
801  CPPUNIT_ASSERT(pt.isMeasured() == true);
802  std::unique_ptr<te::gm::Geometry> boundary(pt.getBoundary());
803  CPPUNIT_ASSERT(pt.getNPoints() == 1);
804 
805  std::unique_ptr<te::gm::Geometry> pt_clone(static_cast<te::gm::Geometry*>(pt.clone()));
806  CPPUNIT_ASSERT(pt.equals(pt_clone.get()));
807  CPPUNIT_ASSERT(pt.disjoint(pt_clone.get()) == false);
808  CPPUNIT_ASSERT(pt.intersects(pt_clone.get()));
809  CPPUNIT_ASSERT(pt.touches(pt_clone.get()) == false);
810 //#endif
811 }
812 
814 {
815 //#ifdef TE_COMPILE_ALL
817  line.setPoint(0, 1.0, 1.5);
818  line.setPoint(1, 3.0, 3.3);
819  line.setPoint(2, 3.1, 2.1);
820 
821  CPPUNIT_ASSERT(line.getX(0) == 1.0);
822  CPPUNIT_ASSERT(line.getY(0) == 1.5);
823  CPPUNIT_ASSERT(line.getX(1) == 3.0);
824  CPPUNIT_ASSERT(line.getY(1) == 3.3);
825  CPPUNIT_ASSERT(line.getX(2) == 3.1);
826  CPPUNIT_ASSERT(line.getY(2) == 2.1);
827  CPPUNIT_ASSERT(line.getDimension() == te::gm::L);
828  CPPUNIT_ASSERT(line.getCoordinateDimension() == 2);
829  CPPUNIT_ASSERT(line.getGeometryType() == "LineString");
830  CPPUNIT_ASSERT(line.getGeomTypeId() == te::gm::LineStringType);
831  CPPUNIT_ASSERT(line.getSRID() == 4326);
832  line.setSRID(4128);
833  CPPUNIT_ASSERT(line.getSRID() == 4128);
834  line.setSRID(4326);
835  CPPUNIT_ASSERT(line.getSRID() == 4326);
836  //line.transform(4128);
837  //CPPUNIT_ASSERT(line.getSRID() == 4128);
838  std::unique_ptr<te::gm::Geometry> envelope(line.getEnvelope());
839  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
840  CPPUNIT_ASSERT(line.getMBR());
841  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
842  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
843  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
844  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(1));
845  line.setX(2, 18.9);
846  line.setY(2, 9.81);
847  line.computeMBR(false);
848  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
849  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
850  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
851  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(2));
852  CPPUNIT_ASSERT(line.asText() == "linestring(1 1.5,3 3.3,18.9 9.81)");
853 
854  // WKB test
855  {
856  size_t size = line.getWkbSize();
857  CPPUNIT_ASSERT(size == 57);
858  char* wkb = new char[size];
860  char* hwkb = te::core::Binary2Hex(wkb, size);
861  delete [] wkb;
862  const char* validHWKB = "010200000003000000000000000000F03F000000000000F83F00000000000008406666666666660A406666666666E632401F85EB51B89E2340";
863  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
864  delete [] hwkb;
865  }
866 
867  {
868  size_t size = 0;
869  char* wkb = line.asBinary(size);
870  CPPUNIT_ASSERT(size == 57);
871  char* hwkb = te::core::Binary2Hex(wkb, size);
872  delete [] wkb;
873  const char* validHWKB = "010200000003000000000000000000F03F000000000000F83F00000000000008406666666666660A406666666666E632401F85EB51B89E2340";
874  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
875  delete [] hwkb;
876  }
877 
878  CPPUNIT_ASSERT(line.isEmpty() == false);
879  CPPUNIT_ASSERT(line.isSimple() == true);
880  CPPUNIT_ASSERT(line.isValid() == true);
881  CPPUNIT_ASSERT(line.is3D() == false);
882  CPPUNIT_ASSERT(line.isMeasured() == false);
883  std::unique_ptr<te::gm::Geometry> boundary(line.getBoundary());
884  //boundary->getGeomTypeId() ==
885  CPPUNIT_ASSERT(line.getNPoints() == 3);
886 
887  std::unique_ptr<te::gm::Geometry> line_clone(static_cast<te::gm::Geometry*>(line.clone()));
888  CPPUNIT_ASSERT(line.equals(line_clone.get()));
889  CPPUNIT_ASSERT(line.disjoint(line_clone.get()) == false);
890  CPPUNIT_ASSERT(line.intersects(line_clone.get()));
891  CPPUNIT_ASSERT(line.touches(line_clone.get()) == false);
892 //#endif
893 }
894 
896 {
897 //#ifdef TE_COMPILE_ALL
899  line.setPointZ(0, 1.0, 1.5, 8.1);
900  line.setPointZ(1, 3.0, 3.3, 9.2);
901  line.setPointZ(2, 3.1, 2.1, 10.3);
902 
903  CPPUNIT_ASSERT(line.getX(0) == 1.0);
904  CPPUNIT_ASSERT(line.getY(0) == 1.5);
905  CPPUNIT_ASSERT(line.getZ(0) == 8.1);
906  CPPUNIT_ASSERT(line.getX(1) == 3.0);
907  CPPUNIT_ASSERT(line.getY(1) == 3.3);
908  CPPUNIT_ASSERT(line.getZ(1) == 9.2);
909  CPPUNIT_ASSERT(line.getX(2) == 3.1);
910  CPPUNIT_ASSERT(line.getY(2) == 2.1);
911  CPPUNIT_ASSERT(line.getZ(2) == 10.3);
912  CPPUNIT_ASSERT(line.getDimension() == te::gm::L);
913  CPPUNIT_ASSERT(line.getCoordinateDimension() == 3);
914  CPPUNIT_ASSERT(line.getGeometryType() == "LineString");
915  CPPUNIT_ASSERT(line.getGeomTypeId() == te::gm::LineStringZType);
916  CPPUNIT_ASSERT(line.getSRID() == 4326);
917  line.setSRID(4128);
918  CPPUNIT_ASSERT(line.getSRID() == 4128);
919  line.setSRID(4326);
920  CPPUNIT_ASSERT(line.getSRID() == 4326);
921  //line.transform(4128);
922  //CPPUNIT_ASSERT(line.getSRID() == 4128);
923  std::unique_ptr<te::gm::Geometry> envelope(line.getEnvelope());
924  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
925  CPPUNIT_ASSERT(line.getMBR());
926  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
927  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
928  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
929  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(1));
930  line.setX(2, 18.9);
931  line.setY(2, 9.81);
932  line.setZ(2, 19.81);
933  line.computeMBR(false);
934  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
935  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
936  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
937  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(2));
938  CPPUNIT_ASSERT(line.asText() == "linestring z(1 1.5 8.1,3 3.3 9.2,18.9 9.81 19.81)");
939 
940  // WKB test
941  {
942  size_t size = line.getWkbSize();
943  CPPUNIT_ASSERT(size == 81);
944  char* wkb = new char[size];
946  char* hwkb = te::core::Binary2Hex(wkb, size);
947  delete [] wkb;
948  const char* validHWKB = "01EA03000003000000000000000000F03F000000000000F83F333333333333204000000000000008406666666666660A4066666666666622406666666666E632401F85EB51B89E23408FC2F5285CCF3340";
949  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
950  delete [] hwkb;
951  }
952 
953  {
954  size_t size = 0;
955  char* wkb = line.asBinary(size);
956  CPPUNIT_ASSERT(size == 81);
957  char* hwkb = te::core::Binary2Hex(wkb, size);
958  delete [] wkb;
959  const char* validHWKB = "01EA03000003000000000000000000F03F000000000000F83F333333333333204000000000000008406666666666660A4066666666666622406666666666E632401F85EB51B89E23408FC2F5285CCF3340";
960  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
961  delete [] hwkb;
962  }
963 
964  CPPUNIT_ASSERT(line.isEmpty() == false);
965  CPPUNIT_ASSERT(line.isSimple() == true);
966  CPPUNIT_ASSERT(line.isValid() == true);
967  CPPUNIT_ASSERT(line.is3D() == true);
968  CPPUNIT_ASSERT(line.isMeasured() == false);
969  std::unique_ptr<te::gm::Geometry> boundary(line.getBoundary());
970  //boundary->getGeomTypeId() ==
971  CPPUNIT_ASSERT(line.getNPoints() == 3);
972 
973  std::unique_ptr<te::gm::Geometry> line_clone(static_cast<te::gm::Geometry*>(line.clone()));
974  CPPUNIT_ASSERT(line.equals(line_clone.get()));
975  CPPUNIT_ASSERT(line.disjoint(line_clone.get()) == false);
976  CPPUNIT_ASSERT(line.intersects(line_clone.get()));
977  CPPUNIT_ASSERT(line.touches(line_clone.get()) == false);
978 //#endif
979 }
980 
982 {
983 //#ifdef TE_COMPILE_ALL
985  line.setPointM(0, 1.0, 1.5, 8.1);
986  line.setPointM(1, 3.0, 3.3, 9.2);
987  line.setPointM(2, 3.1, 2.1, 10.3);
988 
989  CPPUNIT_ASSERT(line.getX(0) == 1.0);
990  CPPUNIT_ASSERT(line.getY(0) == 1.5);
991  CPPUNIT_ASSERT(line.getM(0) == 8.1);
992  CPPUNIT_ASSERT(line.getX(1) == 3.0);
993  CPPUNIT_ASSERT(line.getY(1) == 3.3);
994  CPPUNIT_ASSERT(line.getM(1) == 9.2);
995  CPPUNIT_ASSERT(line.getX(2) == 3.1);
996  CPPUNIT_ASSERT(line.getY(2) == 2.1);
997  CPPUNIT_ASSERT(line.getM(2) == 10.3);
998  CPPUNIT_ASSERT(line.getDimension() == te::gm::L);
999  CPPUNIT_ASSERT(line.getCoordinateDimension() == 3);
1000  CPPUNIT_ASSERT(line.getGeometryType() == "LineString");
1001  CPPUNIT_ASSERT(line.getGeomTypeId() == te::gm::LineStringMType);
1002  CPPUNIT_ASSERT(line.getSRID() == 4326);
1003  line.setSRID(4128);
1004  CPPUNIT_ASSERT(line.getSRID() == 4128);
1005  line.setSRID(4326);
1006  CPPUNIT_ASSERT(line.getSRID() == 4326);
1007  //line.transform(4128);
1008  //CPPUNIT_ASSERT(line.getSRID() == 4128);
1009  std::unique_ptr<te::gm::Geometry> envelope(line.getEnvelope());
1010  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
1011  CPPUNIT_ASSERT(line.getMBR());
1012  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
1013  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
1014  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
1015  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(1));
1016  line.setX(2, 18.9);
1017  line.setY(2, 9.81);
1018  line.setM(2, 19.81);
1019  line.computeMBR(false);
1020  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
1021  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
1022  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
1023  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(2));
1024  CPPUNIT_ASSERT(line.asText() == "linestring m(1 1.5 8.1,3 3.3 9.2,18.9 9.81 19.81)");
1025 
1026  // WKB test
1027  {
1028  size_t size = line.getWkbSize();
1029  CPPUNIT_ASSERT(size == 81);
1030  char* wkb = new char[size];
1032  char* hwkb = te::core::Binary2Hex(wkb, size);
1033  delete [] wkb;
1034  const char* validHWKB = "01D207000003000000000000000000F03F000000000000F83F333333333333204000000000000008406666666666660A4066666666666622406666666666E632401F85EB51B89E23408FC2F5285CCF3340";
1035  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
1036  delete [] hwkb;
1037  }
1038 
1039  {
1040  size_t size = 0;
1041  char* wkb = line.asBinary(size);
1042  CPPUNIT_ASSERT(size == 81);
1043  char* hwkb = te::core::Binary2Hex(wkb, size);
1044  delete [] wkb;
1045  const char* validHWKB = "01D207000003000000000000000000F03F000000000000F83F333333333333204000000000000008406666666666660A4066666666666622406666666666E632401F85EB51B89E23408FC2F5285CCF3340";
1046  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
1047  delete [] hwkb;
1048  }
1049 
1050  CPPUNIT_ASSERT(line.isEmpty() == false);
1051  CPPUNIT_ASSERT(line.isSimple() == true);
1052  CPPUNIT_ASSERT(line.isValid() == true);
1053  CPPUNIT_ASSERT(line.is3D() == false);
1054  CPPUNIT_ASSERT(line.isMeasured() == true);
1055  std::unique_ptr<te::gm::Geometry> boundary(line.getBoundary());
1056  //boundary->getGeomTypeId() ==
1057  CPPUNIT_ASSERT(line.getNPoints() == 3);
1058 
1059  std::unique_ptr<te::gm::Geometry> line_clone(static_cast<te::gm::Geometry*>(line.clone()));
1060  CPPUNIT_ASSERT(line.equals(line_clone.get()));
1061  CPPUNIT_ASSERT(line.disjoint(line_clone.get()) == false);
1062  CPPUNIT_ASSERT(line.intersects(line_clone.get()));
1063  CPPUNIT_ASSERT(line.touches(line_clone.get()) == false);
1064 //#endif
1065 }
1066 
1068 {
1069 //#ifdef TE_COMPILE_ALL
1071  line.setPointZM(0, 1.0, 1.5, 8.1, 21.3);
1072  line.setPointZM(1, 3.0, 3.3, 9.2, 98.4);
1073  line.setPointZM(2, 3.1, 2.1, 10.3, 63.7);
1074 
1075  CPPUNIT_ASSERT(line.getX(0) == 1.0);
1076  CPPUNIT_ASSERT(line.getY(0) == 1.5);
1077  CPPUNIT_ASSERT(line.getZ(0) == 8.1);
1078  CPPUNIT_ASSERT(line.getM(0) == 21.3);
1079  CPPUNIT_ASSERT(line.getX(1) == 3.0);
1080  CPPUNIT_ASSERT(line.getY(1) == 3.3);
1081  CPPUNIT_ASSERT(line.getZ(1) == 9.2);
1082  CPPUNIT_ASSERT(line.getM(1) == 98.4);
1083  CPPUNIT_ASSERT(line.getX(2) == 3.1);
1084  CPPUNIT_ASSERT(line.getY(2) == 2.1);
1085  CPPUNIT_ASSERT(line.getZ(2) == 10.3);
1086  CPPUNIT_ASSERT(line.getM(2) == 63.7);
1087  CPPUNIT_ASSERT(line.getDimension() == te::gm::L);
1088  CPPUNIT_ASSERT(line.getCoordinateDimension() == 4);
1089  CPPUNIT_ASSERT(line.getGeometryType() == "LineString");
1090  CPPUNIT_ASSERT(line.getGeomTypeId() == te::gm::LineStringZMType);
1091  CPPUNIT_ASSERT(line.getSRID() == 4326);
1092  line.setSRID(4128);
1093  CPPUNIT_ASSERT(line.getSRID() == 4128);
1094  line.setSRID(4326);
1095  CPPUNIT_ASSERT(line.getSRID() == 4326);
1096  //line.transform(4128);
1097  //CPPUNIT_ASSERT(line.getSRID() == 4128);
1098  std::unique_ptr<te::gm::Geometry> envelope(line.getEnvelope());
1099  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
1100  CPPUNIT_ASSERT(line.getMBR());
1101  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
1102  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
1103  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
1104  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(1));
1105  line.setX(2, 18.9);
1106  line.setY(2, 9.81);
1107  line.setZ(2, 19.81);
1108  line.setM(2, 43.5);
1109  line.computeMBR(false);
1110  CPPUNIT_ASSERT(line.getMBR()->m_llx == line.getX(0));
1111  CPPUNIT_ASSERT(line.getMBR()->m_lly == line.getY(0));
1112  CPPUNIT_ASSERT(line.getMBR()->m_urx == line.getX(2));
1113  CPPUNIT_ASSERT(line.getMBR()->m_ury == line.getY(2));
1114  CPPUNIT_ASSERT(line.asText() == "linestring zm(1 1.5 8.1 21.3,3 3.3 9.2 98.4,18.9 9.81 19.81 43.5)");
1115 
1116  // WKB test
1117  {
1118  size_t size = line.getWkbSize();
1119  CPPUNIT_ASSERT(size == 105);
1120  char* wkb = new char[size];
1122  char* hwkb = te::core::Binary2Hex(wkb, size);
1123  delete [] wkb;
1124  const char* validHWKB = "01BA0B000003000000000000000000F03F000000000000F83F3333333333332040CDCCCCCCCC4C354000000000000008406666666666660A4066666666666622409A999999999958406666666666E632401F85EB51B89E23408FC2F5285CCF33400000000000C04540";
1125  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
1126  delete [] hwkb;
1127  }
1128 
1129  {
1130  size_t size = 0;
1131  char* wkb = line.asBinary(size);
1132  CPPUNIT_ASSERT(size == 105);
1133  char* hwkb = te::core::Binary2Hex(wkb, size);
1134  delete [] wkb;
1135  const char* validHWKB = "01BA0B000003000000000000000000F03F000000000000F83F3333333333332040CDCCCCCCCC4C354000000000000008406666666666660A4066666666666622409A999999999958406666666666E632401F85EB51B89E23408FC2F5285CCF33400000000000C04540";
1136  CPPUNIT_ASSERT(strcmp(hwkb, validHWKB) == 0);
1137  delete [] hwkb;
1138  }
1139 
1140  CPPUNIT_ASSERT(line.isEmpty() == false);
1141  CPPUNIT_ASSERT(line.isSimple() == true);
1142  CPPUNIT_ASSERT(line.isValid() == true);
1143  CPPUNIT_ASSERT(line.is3D() == true);
1144  CPPUNIT_ASSERT(line.isMeasured() == true);
1145  std::unique_ptr<te::gm::Geometry> boundary(line.getBoundary());
1146  //boundary->getGeomTypeId() ==
1147  CPPUNIT_ASSERT(line.getNPoints() == 3);
1148 
1149  std::unique_ptr<te::gm::Geometry> line_clone(static_cast<te::gm::Geometry*>(line.clone()));
1150  CPPUNIT_ASSERT(line.equals(line_clone.get()));
1151  CPPUNIT_ASSERT(line.disjoint(line_clone.get()) == false);
1152  CPPUNIT_ASSERT(line.intersects(line_clone.get()));
1153  CPPUNIT_ASSERT(line.touches(line_clone.get()) == false);
1154 //#endif
1155 }
1156 
1158 {
1159 //#ifdef TE_COMPILE_ALL
1160  te::gm::Polygon poly(1000, te::gm::PolygonType, 4326, 0);
1161 
1162  CPPUNIT_ASSERT(poly.getExteriorRing() == 0);
1163  CPPUNIT_ASSERT(poly.getNumInteriorRings() == 999);
1164  CPPUNIT_ASSERT(poly.getNumRings() == 1000);
1165  poly.setNumRings(10);
1166  CPPUNIT_ASSERT(poly.getExteriorRing() == 0);
1167  CPPUNIT_ASSERT(poly.getNumInteriorRings() == 9);
1168  CPPUNIT_ASSERT(poly.getNumRings() == 10);
1169  CPPUNIT_ASSERT(poly.getInteriorRingN(1) == 0);
1170  CPPUNIT_ASSERT(poly.getRingN(9) == 0);
1171  CPPUNIT_ASSERT(poly[9] == 0);
1172  poly.setRingN(4, 0);
1173  poly.removeRingN(3);
1174  CPPUNIT_ASSERT(poly.getExteriorRing() == 0);
1175  CPPUNIT_ASSERT(poly.getNumInteriorRings() == 8);
1176  CPPUNIT_ASSERT(poly.getNumRings() == 9);
1177  poly.add(0);
1178  poly.push_back(0);
1179  CPPUNIT_ASSERT(poly.getExteriorRing() == 0);
1180  CPPUNIT_ASSERT(poly.getNumInteriorRings() == 10);
1181  CPPUNIT_ASSERT(poly.getNumRings() == 11);
1182  poly.clear();
1183  CPPUNIT_ASSERT(poly.getNumInteriorRings() == 0);
1184  CPPUNIT_ASSERT(poly.getNumRings() == 0);
1185  CPPUNIT_ASSERT(poly.getArea() == 0.0);
1186  std::unique_ptr<te::gm::Geometry> centroid1(poly.getCentroid());
1187  std::unique_ptr<te::gm::Coord2D> centroid2(poly.getCentroidCoord());
1188  std::unique_ptr<te::gm::Geometry> centroid3(poly.getPointOnSurface());
1189  std::unique_ptr<te::gm::Coord2D> centroid4(poly.getCoordOnSurface());
1190  CPPUNIT_ASSERT(poly.getDimension() == te::gm::A);
1191  CPPUNIT_ASSERT(poly.getCoordinateDimension() == 2);
1192  CPPUNIT_ASSERT(poly.getGeometryType() == "Polygon");
1193  CPPUNIT_ASSERT(poly.getGeomTypeId() == te::gm::PolygonType);
1194  CPPUNIT_ASSERT(poly.getSRID() == 4326);
1195  poly.setSRID(4128);
1196  CPPUNIT_ASSERT(poly.getSRID() == 4128);
1197  poly.setSRID(4326);
1198  CPPUNIT_ASSERT(poly.getSRID() == 4326);
1199  //poly.transform(4128);
1200  //CPPUNIT_ASSERT(poly.getSRID() == 4128);
1201  std::unique_ptr<te::gm::Geometry> envelope(poly.getEnvelope());
1202  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
1203  CPPUNIT_ASSERT(poly.getMBR());
1204  std::string polytext = poly.asText();
1205  CPPUNIT_ASSERT(poly.asText() == "polygon()");
1206 
1207 
1208  CPPUNIT_ASSERT(poly.isEmpty() == true);
1209  CPPUNIT_ASSERT(poly.isSimple() == true);
1210  CPPUNIT_ASSERT(poly.isValid() == true);
1211  CPPUNIT_ASSERT(poly.is3D() == false);
1212  CPPUNIT_ASSERT(poly.isMeasured() == false);
1213  std::unique_ptr<te::gm::Geometry> boundary(poly.getBoundary());
1214  /*size_t np = */poly.getNPoints();
1215  //CPPUNIT_ASSERT(poly.getNPoints() == 1);
1216 
1217  std::unique_ptr<te::gm::Geometry> clone(static_cast<te::gm::Geometry*>(poly.clone()));
1218  CPPUNIT_ASSERT(poly.equals(clone.get()));
1219  CPPUNIT_ASSERT(poly.disjoint(clone.get()) == false);
1220  CPPUNIT_ASSERT(poly.intersects(clone.get()));
1221  CPPUNIT_ASSERT(poly.touches(clone.get()));
1222 //#endif
1223 }
1224 
1226 {
1227 //#ifdef TE_COMPILE_ALL
1228 //#endif
1229 }
1230 
1232 {
1233 //#ifdef TE_COMPILE_ALL
1234 //#endif
1235 }
1236 
1238 {
1239 //#ifdef TE_COMPILE_ALL
1240 //#endif
1241 }
1242 
1244 {
1245 //#ifdef TE_COMPILE_ALL
1246 // load test data
1247  std::vector<WKBEntry> hwkbVec;
1248  loadGeometry(hwkbVec);
1249 
1250 // for each entry, test geometry basic methods
1251  std::cout << std::endl <<" Reading geom from wkt, transforming to New SRID and transforing back to the Orig SRID" << std::endl;
1252  for(size_t i = 0; i < hwkbVec.size(); ++i)
1253  {
1254  const WKBEntry& hwkb = hwkbVec[i];
1255 
1256 // converting WKT into a TL geometry
1257  std::unique_ptr<te::gm::Geometry> g(te::gm::WKTReader::read(hwkb.m_wkt.c_str()));
1258  CPPUNIT_ASSERT(g.get());
1259  g->setSRID(hwkb.m_srid);
1260  std::cout << std::endl;
1261  std::cout << " SRID= " << hwkb.m_srid << " asText= " << hwkb.m_wkt << std::endl;
1262 
1263 // transforming geom to new SRID=3031 (SRID 4128 is not found??) (SRID 4291 - does not change enough the coordinates)
1264  CPPUNIT_ASSERT_NO_THROW(g->transform(3031));
1265  std::string ustring1 = g->asText();
1266  std::cout << " New SRID= " << g->getSRID() << " asText= " << ustring1 << std::endl;
1267 
1268 // transforming back to the original SRID
1269  CPPUNIT_ASSERT_NO_THROW(g->transform(hwkb.m_srid ));
1270  std::string ustring2 = g->asText();
1271  std::cout << " Orig SRID= " << g->getSRID() << " asText= " << ustring2 << std::endl;
1272 
1273  CPPUNIT_ASSERT(g->asText() == te::common::Convert2LCase(hwkb.m_wkt));
1274  std::cout << std::endl;
1275  }
1276 
1277 //#endif
1278 }
1279 
1281 {
1282 //#ifdef TE_COMPILE_ALL
1283 // load test data
1284  std::vector<WKBEntry> hwkbVec;
1285  loadGeometry(hwkbVec);
1286 
1287 // for each entry, test conversion of geometry to text
1288  std::cout << std::endl << " Create a geom from wkt and check geom->asText()..." << std::endl;
1289  for(size_t i = 0; i < hwkbVec.size(); ++i)
1290  {
1291  const WKBEntry& hwkb = hwkbVec[i];
1292 
1293 // convert WKT into a TL geometry
1294  std::unique_ptr<te::gm::Geometry> g(te::gm::WKTReader::read(hwkb.m_wkt.c_str()));
1295  CPPUNIT_ASSERT(g.get());
1296  g->setSRID(hwkb.m_srid);
1297 
1298 // testing g->asText()
1299  std::cout << std::endl << " hwkb.m_wkt = " << hwkb.m_wkt << std::endl;
1300  std::cout << std::endl << " g->asText() = " << g->asText() << std::endl;
1301 
1302  CPPUNIT_ASSERT(g->asText() == te::common::Convert2LCase(hwkb.m_wkt));
1303  }
1304  std::cout << std::endl;
1305 //#endif
1306 }
1307 
1309 {
1310 //#ifdef TE_COMPILE_ALL
1311 // load test data
1312  std::vector<WKBEntry> hwkbVec;
1313  loadGeometry(hwkbVec);
1314 
1315 // for each entry, test geometry basic methods
1316  for(size_t i = 0; i < hwkbVec.size(); ++i)
1317  {
1318  const WKBEntry& hwkb = hwkbVec[i];
1319 
1320 // convert HWKB to WKB and read the WKB into a TL geometry
1321  std::unique_ptr<te::gm::Geometry> g(te::gm::WKBReader::read(te::core::Hex2Binary(hwkb.m_hwkb.c_str())));
1322  CPPUNIT_ASSERT(g.get());
1323  g->setSRID(hwkb.m_srid);
1324 
1325 // test geometry basic methods
1326  CPPUNIT_ASSERT(g->getDimension() == static_cast<te::gm::Dimensionality>(hwkb.m_dimensonality));
1327  CPPUNIT_ASSERT(g->getCoordinateDimension() == hwkb.m_ndims);
1328  CPPUNIT_ASSERT(te::common::Convert2UCase(g->getGeometryType()) == hwkb.m_geomType);
1329  CPPUNIT_ASSERT(g->getGeomTypeId() == static_cast<te::gm::GeomType>(hwkb.m_geomTypeId));
1330  CPPUNIT_ASSERT(g->getSRID() == hwkb.m_srid);
1331  std::unique_ptr<te::gm::Geometry> envelope(g->getEnvelope());
1332  CPPUNIT_ASSERT(envelope->getGeomTypeId() == te::gm::PolygonType);
1333  CPPUNIT_ASSERT(g->getMBR());
1334 
1335  std::cout << std::endl << g->asText() << std::endl;
1336  std::cout << "hwkb.m_wkt=" << hwkb.m_wkt << std::endl;
1337  size_t wkbSize;
1338  char* myWkb = g->asBinary(wkbSize);
1339  char* myHwkb = te::core::Binary2Hex(myWkb, wkbSize);
1340  delete [] myWkb;
1341  CPPUNIT_ASSERT(myHwkb == hwkb.m_hwkb);
1342  delete [] myHwkb;
1343 
1344  CPPUNIT_ASSERT(g->isEmpty() == false);
1345 
1346  if(g->getGeomTypeId() != te::gm::GeometryCollectionType)
1347  {
1348  CPPUNIT_ASSERT(g->isSimple() == true);
1349  CPPUNIT_ASSERT(g->isValid() == true);
1350  std::unique_ptr<te::gm::Geometry> boundary;
1351  CPPUNIT_ASSERT_NO_THROW(boundary.reset(g->getBoundary()));
1352  CPPUNIT_ASSERT(boundary.get());
1353  }
1354  CPPUNIT_ASSERT(g->is3D() == hwkb.m_is3D);
1355  CPPUNIT_ASSERT(g->isMeasured() == hwkb.m_isMeasured);
1356  }
1357 
1358 //#endif
1359 }
1360 
1362 {
1363 //#ifdef TE_COMPILE_ALL
1364 
1365 //#endif
1366 }
1367 
1368 void TsGeometry::loadGeometry(std::vector<WKBEntry>& hwkbVec) const
1369 {
1370  hwkbVec.clear();
1371 
1372  FILE* f = fopen( te::core::CharEncoding::fromUTF8(TERRALIB_DATA_DIR "/hwkb.csv").c_str(), "r");
1373 
1374  CPPUNIT_ASSERT(f != NULL);
1375 
1376  while(!feof(f))
1377  {
1378  std::vector<std::string> values;
1379  std::string value("");
1380 
1381  while(!feof(f))
1382  {
1383  char c = (char)(fgetc(f));
1384 
1385  if(c == '\n')
1386  {
1387  values.push_back(value);
1388  break;
1389  }
1390 
1391  if(c == ';')
1392  {
1393  values.push_back(value);
1394  value = "";
1395  }
1396  else
1397  value += c;
1398  }
1399 
1400  if(values.size() != 9)
1401  break;
1402 
1403  WKBEntry fe;
1404 
1405  fe.m_hwkb = values[0];
1406  fe.m_srid = atoi(values[1].c_str());
1407  fe.m_geomType = values[2];
1408  fe.m_dimensonality = atoi(values[3].c_str());
1409  fe.m_ndims = atoi(values[4].c_str());
1410  fe.m_wkt = values[5];
1411  fe.m_geomTypeId = atoi(values[6].c_str());
1412  fe.m_is3D = values[7] == "t";
1413  fe.m_isMeasured = values[8] == "t";
1414 
1415  hwkbVec.push_back(fe);
1416  }
1417 
1418  fclose(f);
1419 }
1420 
void setZ(std::size_t i, const double &z)
It sets the n-th z coordinate value.
const std::string & getGeometryType() const
The name of the Geometry subtype is: MultiLineString.
Dimensionality getDimension() const
Surfaces are 2-dimensional objects.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
Definition: CurvePolygon.h:153
void tcCreatePolygon()
Test Case: Creating a polygon.
Curve * getInteriorRingN(std::size_t i) const
It returns the n-th interior ring for this curve polygon as a curve.
virtual Dimensionality getDimension() const
For non-homogeneous collections this method will return the largest dimension of the contained object...
void add(Curve *ring)
It adds the ring to the curve polygon.
void push_back(Curve *ring)
It adds the curve to the curve polygon.
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
void tcCreatePoint()
Test Case: Creating a point object.
Definition: TsGeometry.cpp:492
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the linestring.
void setX(std::size_t i, const double &x)
It sets the n-th x coordinate value.
void setSRID(int srid) _NOEXCEPT_OP(true)
It sets the Spatial Reference System ID of the Point.
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
Dimensionality getDimension() const
MultiPoint is 0-dimensional.
std::string m_geomType
Definition: TsGeometry.h:145
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
Definition: StringUtils.h:202
void loadGeometry(std::vector< WKBEntry > &hwkbVec) const
Auxiliary method for reading geometry information from an ASCII file.
char * Hex2Binary(const char *hex)
It converts each pair of hex characters from a NULL-terminated string of hex characters into a binary...
Definition: HexUtils.h:469
void tcCreatePolygonZM()
Test Case: Creating a polygon with ZM values.
virtual te::dt::AbstractData * clone() const
It clones the linestring.
void computeMBR(bool cascade) const _NOEXCEPT_OP(true)
It computes the minimum bounding rectangle for the point.
std::size_t getNumInteriorRings() const
It returns the number of interior rings in this CurvePolygon.
const std::string & getGeometryType() const
It returns the name of the instantiable subtype of Geometry of which this geometric object is an inst...
Definition: TIN.cpp:43
virtual const std::string & getGeometryType() const
The name of the Geometry subtype is: GeometryCollection.
bool isMeasured() const _NOEXCEPT_OP(true)
It returns true if this geometric object has m coordinate values.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
Curve * getExteriorRing() const
It returns the exterior ring of this CurvePolygon.
double m_urx
Upper right corner x-coordinate.
void tcCreateLineStringZM()
Test Case: Creating a linestring with z and m value.
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
virtual bool disjoint(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object is spatially disjoint from rhs geometry.
void tcCreatePolygonZ()
Test Case: Creating a polygon with Z values.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:168
Dimensionality getDimension() const _NOEXCEPT_OP(true)
Points are 0-dimensional objects.
void tcCreateLineStringM()
Test Case: Creating a linestring with m value.
Definition: TsGeometry.cpp:981
void removeRingN(std::size_t i)
It removes the n-th ring in this CurvePolygon.
static std::string fromUTF8(const std::string &src)
Convert a string in UTF-8 to the current locale encoding.
virtual bool intersects(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object spatially intersects rhs geometry.
Proxy file for the real file terralib_defines.h.
virtual bool touches(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object spatially touches rhs geometry.
virtual bool isSimple() const _NOEXCEPT_OP(false)
It returns true if this geometric object has no anomalous points, such as self intersection or self t...
std::size_t getWkbSize() const _NOEXCEPT_OP(true)
It returns the size required by a WKB representation for this geometric object.
Dimensionality getDimension() const
MultiSurface is 2-dimenional.
An static class with global definitions.
void tcCreatePointZ()
Test Case: Creating a point with z value.
Definition: TsGeometry.cpp:569
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
unsigned int line
virtual te::dt::AbstractData * clone() const
It clones the linestring.
void setNumRings(std::size_t size)
It sets the number of rings in this curve polygon.
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
Definition: TIN.h:50
Test suite for the Vector Geometry Model.
Definition: TsGeometry.h:49
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
const std::string & getGeometryType() const
The name of the Geometry subtype is: MultiPolygon.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
double m_llx
Lower left corner x-coordinate.
Geometry * getEnvelope() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle (MBR) for the geometry.
std::size_t getNPoints() const
it returns the number of points (vertexes) in the geometry.
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
void tcBasicGeometryMethods()
Test Case: testing the basic geometry methods.
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Definition: Triangle.h:50
std::size_t getNPoints() const _NOEXCEPT_OP(true)
it returns the number of points (vertexes) in the geometry.
Definition: Point.h:261
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
A point with x and y coordinate values.
Definition: Point.h:50
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
virtual bool isValid() const _NOEXCEPT_OP(false)
It tells if the geometry is well formed.
virtual te::dt::AbstractData * clone() const
It clones the point.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
std::string asText() const _NOEXCEPT_OP(true)
It returns an string with the Well-Known Text Representation for the geometry.
void setM(const double &m)
It sets the Point m-coordinate value.
Definition: Point.h:187
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".
Dimensionality getDimension() const
MultiCurves are 1-dimensional.
virtual bool isEmpty() const _NOEXCEPT_OP(false)
It returns true if this geometric object is the empty Geometry.
Point * getPointOnSurface() const
It returns a point guaranteed to be on this surface.
virtual const std::string & getGeometryType() const
The name of the geometry subtype for PolyhedralSurface is: PolyhedralSurface.
void tcCreatePointM()
Test Case: Creating a point with m value.
Definition: TsGeometry.cpp:650
This file contains several utilities functions for dealing with HEX strings.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
A class for handling character enconding/decoding.
void setPointZ(std::size_t i, const double &x, const double &y, const double &z)
It sets the value of the specified point.
bool is3D() const _NOEXCEPT_OP(true)
It returns true if this geometric object has z coordinate values.
char * asBinary(std::size_t &size) const _NOEXCEPT_OP(false)
It serializes the geometric object to a Well-known Binary Representation (WKB).
void setUp()
Definition: TsGeometry.cpp:39
Coord2D * getCoordOnSurface() const
It returns a coordinate guaranteed to be on this surface.
void tcMisc()
Test Case: Creating several type of objects and testing some basic methods.
Definition: TsGeometry.cpp:47
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:166
double m_lly
Lower left corner y-coordinate.
void setM(std::size_t i, const double &m)
It sets the n-th m measure value.
double getArea() const
It returns the area of this surface, as measured in the spatial reference system of this surface...
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
void setPointZM(std::size_t i, const double &x, const double &y, const double &z, const double &m)
It sets the value of the specified point.
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:145
Test suite for the Vector Geometry Model.
double m_ury
Upper right corner y-coordinate.
Dimensionality getDimension() const
Curves are 1-dimensional objects.
const std::string & getGeometryType() const _NOEXCEPT_OP(true)
The name of instantiable subtype is: Point.
void tcCreatePointZM()
Test Case: Creating a point with z and m value.
Definition: TsGeometry.cpp:731
Coord2D * getCentroidCoord() const
It returns the mathematical centroid for this surface as a coordinate.
void tcCreatePolygonM()
Test Case: Creating a polygon with M values.
Point * getCentroid() const
It returns the mathematical centroid for this surface as a point.
void clear()
It deletes all the rings of the CurvePolygon and clear it.
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
virtual Geometry * getBoundary() const _NOEXCEPT_OP(false)
It returns the geometry boundary.
std::string m_hwkb
Definition: TsGeometry.h:143
const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:180
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
This file contains include headers for the TerraLib Common Runtime module.
void setPointM(std::size_t i, const double &x, const double &y, const double &m)
It sets the value of the specified point.
virtual const std::string & getGeometryType() const
It returns the name of the instantiable subtype of Geometry of which this geometric object is an inst...
const double & getM(std::size_t i) const
It returns the n-th m measure value.
void tcAsText()
Test Case: Reading (binary) geometries and getting the WKT.
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:159
void setY(std::size_t i, const double &y)
It sets the n-th y coordinate value.
This file contains include headers for the Vector Geometry model of TerraLib.
void tcSpatialRelationsMethods()
Test Case: testing the basic geometry methods.
const std::string & getGeometryType() const
The name of the instantiable subtype of geometry: MultiPoint.
void tcCreateLineStringZ()
Test Case: Creating a linestring with z value.
Definition: TsGeometry.cpp:895
It is a collection of other geometric objects.
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...
Definition: HexUtils.h:602
CPPUNIT_TEST_SUITE_REGISTRATION(TsGeometry)
std::string m_wkt
Definition: TsGeometry.h:148
void tearDown()
Definition: TsGeometry.cpp:43
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
void tcTransform()
Test Case: Reading WKT geometries and conveting to another proj SRID.
int getCoordinateDimension() const _NOEXCEPT_OP(true)
It returns the number of measurements or axes needed to describe a position in a coordinate system...
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
Definition: CurvePolygon.h:193
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB.
Definition: WKBReader.cpp:48
void setZ(const double &z)
It sets the Point z-coordinate value.
Definition: Point.h:173
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 setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.
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.
void tcCreateLineString()
Test Case: Creating a linestring object.
Definition: TsGeometry.cpp:813
const std::string & getGeometryType() const
The name of instantiable subtype is: LineString.