examples/TIN/main.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 /*!
21  \file examples/dataaccess/main.cpp
22 
23  \brief A list of examples for the TerraLib TIN Module.
24 */
25 #include "TINExamples.h"
26 
27 // TerraLib
29 #include <terralib/core/plugin.h>
31 #include <terralib/core/uri/URI.h>
33 
35 
36 
43 
44 #include <terralib_buildconfig.h>
45 
46 // STL
47 #include "iostream"
48 
49 // Boost
50 #include <boost/filesystem.hpp>
51 
52 //TESTES *********
53 
56 
60 
66 #include <terralib/geometry/TIN.h>
68 
69 
72 
73 
76 
77 #include <geos.h>
78 #include <geos/triangulate/DelaunayTriangulationBuilder.h>
79 
80 
81 te::da::DataSet* create_ds_memory(const std::string& datasetName, te::da::DataSetType* datasettype, std::unique_ptr<geos::geom::Geometry> results)
82 {
83  te::mem::DataSet* ds = new te::mem::DataSet(datasettype);
84  te::mem::DataSetItem* dataSetItem = new te::mem::DataSetItem(ds);
85 
86  std::size_t ntri = results->getNumGeometries();
87  std::string gtype = results->getGeometryType();
88  int id_tri = 0;
89 
90  geos::geom::Geometry *gout = results->clone();
91  te::gm::GeometryCollection* tinout = dynamic_cast<te::gm::GeometryCollection*> (te::gm::GEOSReader::read(gout));
92  tinout->setSRID(results.get()->getSRID());
93  for (unsigned int tIdx = 0; tIdx < tinout->getNumGeometries(); ++tIdx)
94  {
95  te::mem::DataSetItem* dataSetItem = new te::mem::DataSetItem(ds);
96  std::vector<std::string> pt_value;
97  te::gm::Geometry* gout = tinout->getGeometryN(tIdx);
98  std::size_t n = gout->getNPoints();
99  te::gm::Polygon* gpol = dynamic_cast<te::gm::Polygon*>(gout);
100 
101  for (std::size_t i = 0; i < gpol->getNumRings(); ++i)
102  {
103  te::gm::Curve* c = gpol->getRingN(i);
104  te::gm::LinearRing* lr = dynamic_cast<te::gm::LinearRing*>(c);
105  for (std::size_t j = 0; j < lr->getNPoints(); ++j)
106  {
107  std::unique_ptr<te::gm::Point> p = lr->getPointN(j);
108  pt_value.push_back(p->toString());
109  }
110  }
111  dataSetItem->setInt32("TIN_ID", id_tri++);
112  dataSetItem->setString("Pt1", pt_value[0]);
113  dataSetItem->setString("Pt2", pt_value[1]);
114  dataSetItem->setString("Pt3", pt_value[2]);
115  dataSetItem->setGeometry("triangle", (te::gm::Geometry*)gout->clone());
116 
117  ds->add(dataSetItem);
118  }
119 
120  return ds;
121 }
122 
123 void SaveTIN_shp(std::string dir, std::string out, std::unique_ptr<geos::geom::Geometry> results)
124 {
125  std::unique_ptr<te::da::DataSetType> dt(new te::da::DataSetType(out));
126 
127  //Primary key
129  prop0->setAutoNumber(true);
134  prop4->setSRID(results.get()->getSRID());
135  dt->add(prop0);
136  dt->add(prop1);
137  dt->add(prop2);
138  dt->add(prop3);
139  dt->add(prop4);
140 
141  std::unique_ptr<te::da::DataSet> dataset(create_ds_memory(out, dt.get(), std::move(results)));
142 
143  std::string filename(dir);
144  filename.append(out);
145  filename.append(".shp");
146 
147  if (te::core::FileSystem::exists(filename))
148  {
150  }
151 
152  std::unique_ptr< te::da::DataSource > datasource = te::da::DataSourceFactory::make("OGR", ("file://" + filename) );
153  datasource->open();
154 
155  dataset->moveBeforeFirst();
156 
157  te::da::Create(datasource.get(), dt.get(), dataset.get());
158 
159  datasource->close();
160  dt.release();
161 
162 }
163 
164 void LoadIsolines(const std::string &filename,
165  te::gm::MultiPoint &mpt,
166  te::gm::MultiLineString &isolines,
167  std::string &geostype, std::string atributo)
168 {
169  int SRID = 4291;
170  double tol = 0.00018000000;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
171  double maxdist = 20.*tol;
172  double minedge = tol / 5.;
173 
174  std::unique_ptr<te::da::DataSource> datasource = te::da::DataSourceFactory::make("OGR", ("file://" + filename));
175  datasource->open();
176 
177  te::da::DataSourceTransactor* transactor = (datasource->getTransactor()).release();
178 
179  std::vector<std::string> datasetNames = datasource->getDataSetNames();
180 
181  te::da::DataSet* inDset = (datasource->getDataSet(datasetNames[0])).release();
182 
183  const std::size_t np = inDset->getNumProperties();
184  const std::size_t ng = inDset->size();
185 
186  //Lendo atributos do shape
187  std::vector<std::string>pnames;
188  std::vector<int> ptypes;
189  for (std::size_t i = 0; i != np; ++i)
190  {
191  pnames.push_back(inDset->getPropertyName(i));
192  ptypes.push_back(inDset->getPropertyDataType(i));
193  }
194 
195  te::gm::MultiLineString isolines_simp(0, te::gm::MultiLineStringZType, isolines.getSRID());
196 
197  std::size_t pos = 0;
198  while (inDset->moveNext())
199  {
200  std::unique_ptr<te::gm::Geometry> gin = inDset->getGeometry("OGR_GEOMETRY");
201  // std::cout << gin.get()->toString() <<std::endl;
202  geostype = gin.get()->getGeometryType();//g->getGeometryType();
203 
204  if (geostype == "MultiPoint")
205  {
206  te::gm::MultiPoint *g = dynamic_cast<te::gm::MultiPoint*>(gin.get());
207  std::size_t np = g->getNumGeometries();
208  double value = inDset->getDouble(atributo); //teste pegar da interface
209  for (std::size_t i = 0; i < np; ++i)
210  {
211  te::gm::Point *p = dynamic_cast<te::gm::Point*>(g->getGeometryN(i));
212  te::gm::Point pz(p->getX(), p->getY(), 0, te::gm::PointZType);
213  pz.setZ(value);
214  mpt.add(dynamic_cast<te::gm::Geometry*>(pz.clone()));
215  }
216  }
217  if (geostype == "LineString")
218  {
219  te::gm::LineString *l = dynamic_cast<te::gm::LineString*>(gin.get());
220  double value = inDset->getDouble(atributo); //teste pegar da interface
221  isolines.add(dynamic_cast<te::gm::Geometry*>(l->clone()));
222 
223  te::gm::LineString *ls = te::mnt::pointListSimplify(l, tol, maxdist, value);
224 
225  for (std::size_t j = 0; j < ls->getNPoints(); ++j)
226  {
227  mpt.add(ls->getPointN(j).release());
228  }
229  }
230  if (geostype == "MultiLineString")
231  {
232  te::gm::MultiLineString *g = dynamic_cast<te::gm::MultiLineString*>(gin.get());
233  std::size_t np = g->getNumGeometries();
234  double value = inDset->getDouble(atributo); //teste pegar da interface
235  for (std::size_t i = 0; i < np; ++i)
236  {
237  te::gm::LineString *l = dynamic_cast<te::gm::LineString*>(g->getGeometryN(i));
239  for (std::size_t il = 0; il < l->size(); il++)
240  {
241  lz->setPointZ(il, l->getX(il), l->getY(il), value);
242  }
243  isolines.add(dynamic_cast<te::gm::Geometry*>(lz));
244  l->setSRID(isolines.getSRID());
245  te::gm::LineString *ls = te::mnt::pointListSimplify(l, tol, maxdist, value);
246 
247  for (std::size_t j = 0; j < ls->getNPoints(); ++j)
248  {
249  mpt.add(ls->getPointN(j).release());
250  }
251 
252  isolines_simp.add(dynamic_cast<te::gm::Geometry*>(ls));
253  }
254  }
255 
256  }
257  delete inDset;
258  delete transactor;
259 
260 }
261 
262 void TesteGEOS()
263 {
264 
265 
266  int SRID = 4291;
267  double tol = 0.00018000000;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
268  double maxdist = 20.*tol;
269  double minedge = tol / 5.;
270 
271  const geos::geom::GeometryFactory *geomFact = te::gm::GEOSGeometryFactory::getGeomFactory();
274  std::string geostype;
275 
276  //Lendo shape das Isolinhas
277  std::string filename(TERRALIB_DATA_DIR "/mnt/Isolinhas.shp");
278 
279  LoadIsolines(filename, mpt, isolines_simp, geostype, "avg_z");
280  mpt.setSRID(SRID);
281  isolines_simp.setSRID(SRID);
282 
283  geos::triangulate::DelaunayTriangulationBuilder *tri = new geos::triangulate::DelaunayTriangulationBuilder();
284 
285  std::unique_ptr<geos::geom::Geometry> results;
286  geos::geom::MultiPoint* gin = te::gm::GEOSWriter::write(&mpt);
287  tri->setTolerance(minedge);
288  tri->setSites(*gin);
289 
290  std::string dirout(TERRALIB_DATA_DIR "/mnt/");
291  std::string fileout("Isolinhas_GEOS_TIN");
292 
293 
294  results = tri->getTriangles(*geomFact);
295  results.get()->setSRID(SRID);
296  SaveTIN_shp(dirout, fileout, std::move(results));
297 
298  results.release();
299  delete tri;
300 
301 }
302 ///******
303 
305 {
306  //Lendo shape das Isolinhas
307  std::string filename_iso(TERRALIB_DATA_DIR "/mnt/Isolinhas.shp");
308  std::string filename_pts(TERRALIB_DATA_DIR "/mnt/Pontos_cotados.shp");
309 
310  int SRID = 32723;
311  double tol = 20;// 0.00018000000;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
312  double maxdist = 20.*tol;
313  double minedge = tol / 5.;
314  std::string atributoz_iso("Avg_Z");
315  std::string atributoz_sample("Avg_Z");
316 
317  te::da::DataSourcePtr srcDsiso(te::da::DataSourceFactory::make("OGR", ("file://" + filename_iso)).release());
318  srcDsiso->open();
319 
320  std::string inDsetNameiso = "Isolinhas";
321  if (!srcDsiso->dataSetExists(inDsetNameiso))
322  {
323  std::cout << "Input dataset not found: " << inDsetNameiso << std::endl;
324  throw;
325  }
326 
327  std::unique_ptr<te::da::DataSetType> inDsetTypeiso(srcDsiso->getDataSetType(inDsetNameiso));
328 
329  te::da::DataSourcePtr srcDspts(te::da::DataSourceFactory::make("OGR", ("file://" + filename_pts)).release());
330  srcDspts->open();
331 
332  std::string inDsetNamepts = "Pontos_cotados";
333  if (!srcDspts->dataSetExists(inDsetNamepts))
334  {
335  std::cout << "Input dataset not found: " << inDsetNamepts << std::endl;
336  throw;
337  }
338 
339  std::unique_ptr<te::da::DataSetType> inDsetTypepts(srcDspts->getDataSetType(inDsetNamepts));
340 
341  std::string file_result = TERRALIB_DATA_DIR "/mnt/TIN.shp";
342 
343  if (te::core::FileSystem::exists(file_result))
344  {
345  te::core::FileSystem::remove(file_result);
346  }
347 
348  te::da::DataSourcePtr trgDs(te::da::DataSourceFactory::make("OGR",("file://" + file_result)).release());
349  trgDs->open();
350 
351  std::string outDS = "TIN";
352 
354 
355  Tin->setInput(srcDsiso, inDsetNameiso, std::move(inDsetTypeiso), te::mnt::Isolines);
356  Tin->setInput(srcDspts, inDsetNamepts, std::move(inDsetTypepts), te::mnt::Samples);
357  Tin->setOutput(trgDs, outDS);
358  Tin->setParams(tol, maxdist, minedge, atributoz_iso, atributoz_sample);
359  Tin->setSRID(SRID);
360 
361  bool result = Tin->run();
362 
363  trgDs->close();
364  srcDsiso->close();
365  srcDspts->close();
366 
367  delete Tin;
368 }
369 
371 {
372  std::string filename = TERRALIB_DATA_DIR "/mnt/TIN.shp";
373 
374  int SRID = 32723;
375  double tol = 2;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
376 
377  std::vector<double> val;
378  std::vector<double> gval;
379  for (double n = 1010; n <= 1180; n += 10)
380  val.push_back(n);
381 
382  te::da::DataSourcePtr srcDs(te::da::DataSourceFactory::make("OGR", ("file://" + filename)).release());
383  srcDs->open();
384 
385  std::string inDsetName = "TIN";
386  if (!srcDs->dataSetExists(inDsetName))
387  {
388  std::cout << "Input dataset not found: " << inDsetName << std::endl;
389  throw;
390  }
391 
392  std::unique_ptr<te::da::DataSet> inDset = srcDs->getDataSet(inDsetName);
393  std::unique_ptr<te::da::DataSetType> inDsetType(srcDs->getDataSetType(inDsetName));
394 
395  std::string file_result = TERRALIB_DATA_DIR "/mnt/TIN_iso.shp";
396  if (te::core::FileSystem::exists(file_result))
397  {
398  te::core::FileSystem::remove(file_result);
399  }
400 
401  te::da::DataSourcePtr trgDs(te::da::DataSourceFactory::make("OGR", ("file://" + file_result)).release());
402  trgDs->open();
403 
404  std::string outDS = "TIN_iso";
405 
407 
408  Tin->setInput(srcDs, inDsetName, std::move(inDsetType));
409  Tin->setOutput(trgDs, outDS);
410  Tin->setSRID(SRID);
411  Tin->setParams(val, gval, tol);
412 
413  bool result = Tin->run();
414 
415  trgDs->close();
416  srcDs->close();
417 
418  delete Tin;
419 
420 }
421 
423 {
424  std::string filename = TERRALIB_DATA_DIR "/mnt/TIN.shp";
425 
426  int SRID = 32723;
427  double tol = 2;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
428  double resx = 30, resy = 30;
429 
430  te::da::DataSourcePtr srcDs(te::da::DataSourceFactory::make("OGR", ("file://" + filename)).release());
431  srcDs->open();
432 
433  std::string inDsetName = "TIN";
434  if (!srcDs->dataSetExists(inDsetName))
435  {
436  std::cout << "Input dataset not found: " << inDsetName << std::endl;
437  throw;
438  }
439 
440  std::unique_ptr<te::da::DataSet> inDset = srcDs->getDataSet(inDsetName);
441  std::unique_ptr<te::da::DataSetType> inDsetType(srcDs->getDataSetType(inDsetName));
442 
443  boost::filesystem::path uri(TERRALIB_DATA_DIR "/mnt/TIN_GRD_quint1.tif");
444  std::string dsName = "TIN_GRD_quint";
445 
446  if (te::core::FileSystem::exists(uri.string()))
447  {
448  te::core::FileSystem::remove(uri.string());
449  }
450 
451 
452  te::da::DataSourcePtr dsOGR(te::da::DataSourceFactory::make("GDAL", ("file://" + uri.string())).release());
453 
454  dsOGR->open();
455  if (dsOGR->dataSetExists(dsName))
456  {
457  std::cout << "There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again.";
458  throw;
459  }
460 
462  std::map<std::string, std::string> options;// = te::core::Expand(dsOGR->getConnectionInfo().query());
463  options["URI"] = uri.string();
464 
465  Tin->setInput(srcDs, inDsetName, std::move(inDsetType));
466  Tin->setOutput(options);
467  Tin->setSRID(SRID);
468  Tin->setParams(resx, resy, te::mnt::Quintico);
469 
470  bool result = Tin->run();
471 
472  srcDs->close();
473  dsOGR->close();
474  delete Tin;
475 }
476 
477 
479 {
480  std::string filename_iso(TERRALIB_DATA_DIR "/mnt/Isolinhas.shp");
481  std::string filename_pts(TERRALIB_DATA_DIR "/mnt/Pontos_cotados.shp");
482  std::string atributoz_iso("Avg_Z");
483  std::string atributoz_sample("Avg_Z");
484 
485  int SRID = 32723;
486  double tol = 2;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
487  double resx = 30, resy = 30;
488 
489  te::da::DataSourcePtr srcDsiso(te::da::DataSourceFactory::make("OGR", ("file://" + filename_iso)).release());
490  srcDsiso->open();
491 
492  std::string inDsetNameiso = "Isolinhas";
493  if (!srcDsiso->dataSetExists(inDsetNameiso))
494  {
495  std::cout << "Input dataset not found: " << inDsetNameiso << std::endl;
496  throw;
497  }
498 
499  std::unique_ptr<te::da::DataSet> inDsetiso = srcDsiso->getDataSet(inDsetNameiso);
500  std::unique_ptr<te::da::DataSetType> inDsetTypeiso(srcDsiso->getDataSetType(inDsetNameiso));
501 
502  te::da::DataSourcePtr srcDspts(te::da::DataSourceFactory::make("OGR", ("file://" + filename_pts)).release());
503  srcDspts->open();
504 
505  std::string inDsetNamepts = "Pontos_cotados";
506  if (!srcDspts->dataSetExists(inDsetNamepts))
507  {
508  std::cout << "Input dataset not found: " << inDsetNamepts << std::endl;
509  throw;
510  }
511 
512  std::unique_ptr<te::da::DataSet> inDsetpts = srcDspts->getDataSet(inDsetNamepts);
513  std::unique_ptr<te::da::DataSetType> inDsetTypepts(srcDspts->getDataSetType(inDsetNamepts));
514 
515  boost::filesystem::path uri(TERRALIB_DATA_DIR "/mnt/IsoPts_GRD.tif");
516  std::string dsName = "IsoPts_GRD";
517 
518  if (te::core::FileSystem::exists(uri.string()))
519  {
520  te::core::FileSystem::remove(uri.string());
521  }
522 
523  te::da::DataSourcePtr dsOGR(te::da::DataSourceFactory::make("GDAL", ("file://" + uri.string())).release());
524 
525  dsOGR->open();
526  if (dsOGR->dataSetExists(dsName))
527  {
528  std::cout << "There is already a dataset with the requested name in the output data source. Remove it or select a new name and try again.";
529  throw;
530  }
531  double raio = 2308.;
532  int pow = 2;
533 
535  std::map<std::string, std::string> options;// = te::core::Expand(dsOGR->getConnectionInfo().query());
536  options["URI"] = uri.string();
537 
538  grid->setInput(srcDsiso, inDsetNameiso, srcDsiso->getDataSetType(inDsetNameiso), te::mnt::Isolines);
539  grid->setInput(srcDspts, inDsetNamepts, srcDspts->getDataSetType(inDsetNamepts), te::mnt::Samples);
540  grid->setOutput(options);
541  grid->setSRID(SRID);
542  grid->setParams(atributoz_iso, atributoz_sample, resx, resy, te::mnt::Media, raio, pow);
543  bool result = grid->run();
544 
545  srcDsiso->close();
546  srcDspts->close();
547  dsOGR->close();
548 
549  delete grid;
550 }
551 
553 {
554  std::string filename = TERRALIB_DATA_DIR "/mnt/TIN_GRD_quint1.tif";
555 
556  int SRID = 32723;
557  double tol = 2;// 20.;//Pegar da interface (double)SGinfo->Scale()*0.4 / 1000.*multfactor;
558  double m_min = 980;
559  double m_max = 1200;
560  double m_dummy = std::numeric_limits<double>::max();
561  bool m_hasDummy = false;
562 
563  std::vector<double> val;
564  std::vector<double> gval;
565  for (double n = m_min; n <= m_max; n += 20)
566  val.push_back(n);
567 
568  te::da::DataSourcePtr srcDs(te::da::DataSourceFactory::make("GDAL", ("file://" + filename)).release());
569  srcDs->open();
570 
571  std::string inDsetName = "TIN_GRD_quint1.tif";
572  std::unique_ptr<te::da::DataSetType> inDsetType(srcDs->getDataSetType(inDsetName));
573 
574  std::string file_result = TERRALIB_DATA_DIR "/mnt/TIN_GRD_quint1_iso.shp";
575  if (te::core::FileSystem::exists(file_result))
576  {
577  te::core::FileSystem::remove(file_result);
578  }
579 
580  te::da::DataSourcePtr trgDs(te::da::DataSourceFactory::make("OGR", ("file://" + file_result)).release());
581  trgDs->open();
582 
583  std::string outDS = "TIN_GRD_quint1_iso";
584 
586 
587  ci->setInput(srcDs, inDsetName, std::move(inDsetType));
588  ci->setOutput(trgDs, outDS);
589  ci->setParams(val, gval, m_max, m_min, m_dummy, m_hasDummy);
590  std::unique_ptr<te::rst::Raster> raster = ci->getPrepareRaster();
591  bool result = ci->run(std::move(raster));
592 
593  delete ci;
594 
595  trgDs->close();
596  srcDs->close();
597 }
598 
599 
600 int main(int /*argc*/, char** /*argv*/)
601 {
602  try
603  {
604  // Initialize the Terralib support
606 
607  LoadModules();
608 
609  //TesteGEOS();
610 
611  GenerateTIN();
612 
613  GenerateIso();
614 
615  CalculateGrid();
616 
617  CreateIsolines();
618 
620 
622  }
623  catch(const std::exception& e)
624  {
625  std::cout << std::endl << "An exception has occurred: " << e.what() << std::endl;
626  return EXIT_FAILURE;
627  }
628  catch(...)
629  {
630  std::cout << std::endl << "An unexpected exception has occurred!" << std::endl;
631  return EXIT_FAILURE;
632  }
633 
634  return EXIT_SUCCESS;
635 }
virtual std::vector< std::string > getDataSetNames()=0
It It gets the dataset names available in the data source.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType, InputType type)
It sets the Datasource that is being used to generate TIN.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType)
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
Definition: CurvePolygon.h:153
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
void setParams(std::vector< double > &val, std::vector< double > &gval, double tol)
te::da::DataSet * create_ds_memory(const std::string &datasetName, te::da::DataSetType *datasettype, std::unique_ptr< geos::geom::Geometry > results)
Class to generate isolines from TIN.
This file contains a class to generate isolines from a TIN. Adapted from SPRING.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
void CreateIsolines()
Geometric property.
The global factory used by TerraLib in order to create GEOS geometries.
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
Include files for Core Plugin Library.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
bool run()
Calculate GRID \ return true or false.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
Definition: FileSystem.cpp:142
An atomic property like an integer or double.
boost::shared_ptr< DataSource > DataSourcePtr
void TINCalculateGrid()
A class that models the description of a dataset.
Definition: DataSetType.h:72
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
virtual te::dt::AbstractData * clone() const
It clones the linestring.
bool run()
Method that generates a regular Grid from a given TIN.
It models a property definition.
A point with x and y coordinate values.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
void GenerateTIN()
Examples on how to access/manipulate a specified DatasOURCE.
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsname)
It sets the Datasource that is being used to save TIN.
static te::dt::Date ds(2010, 01, 01)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
void setSRID(int srid)
Definition: Tin.cpp:177
Utility functions for MNT support.
virtual std::size_t size() const =0
It returns the collection size, if it is known.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void setParams(std::vector< double > &nval, std::vector< double > &gval, double vmax, double vmin, double dummy, bool hasDummy)
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
static PluginManager & instance()
Access the singleton.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
void setParams(const std::string &attriso, const std::string &attrpt, double resx, double resy, Interpolator gt, double rad, int pow)
It sets the parameters that is being used to save TIN.
An Envelope defines a 2D rectangular region.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
static bool remove(const std::string &path)
Removes a file or directory from a given path in UTF-8.
Definition: FileSystem.cpp:166
void finalize()
It finalizes the TerraLib Platform.
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
static TerraLib & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
Definition: Point.h:50
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
TEDATAACCESSEXPORT void Create(DataSource *ds, DataSetType *dt, DataSet *d, std::size_t limit=0)
It creates the dataset definition in a data source and then fill it with data from the input dataset...
Class to calculate grid from TIN.
TEMNTEXPORT te::gm::LineString * pointListSimplify(te::gm::LineString *ls, double snap, double maxdist, double Zvalue)
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
void TesteGEOS()
A class for handling system files and paths.
void DataSet()
static te::dt::TimeDuration dt(20, 30, 50, 11)
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsname)
A factory for data sources.
Geometric property.
This file contains a class to generate TIN. Adapted from SPRING.
void GenerateIso()
te::gm::Polygon * p
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
virtual AbstractData * clone() const =0
It returns a clone of this object.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
The type for string types: FIXED_STRING, VAR_STRING or STRING.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
void setPointZ(std::size_t i, const double &x, const double &y, const double &z)
It sets the value of the specified point.
Utility functions for the data access module.
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.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Class to generate TIN.
Definition: TINGeneration.h:37
A class that converts a TerraLib geometry to a GEOS geometry.
void initialize()
It initializes the TerraLib Platform.
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
void SaveTIN_shp(std::string dir, std::string out, std::unique_ptr< geos::geom::Geometry > results)
MultiLineString is a MultiCurve whose elements are LineStrings.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
A dataset is the unit of information manipulated by the data access module of TerraLib.
This file contains a class to calculate retangular grid from Samples. Adapted from SPRING...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry collection and all its parts.
This file contains a class to calculate a grid from a TIN. Adapted from SPRING.
bool run()
Generate TIN \ return true or false.
bool run(std::unique_ptr< te::rst::Raster > raster)
This file contains utility functions used to manipulate data from a URI.
void add(Geometry *g)
It adds the geometry into the collection.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType)
It sets the Datasource that is being used to generate TIN.
An atomic property like an integer or double.
void setOutput(std::map< std::string, std::string > &dsinfo)
It sets the Datasource that is being used to save TIN.
void setSRID(int srid)
It sets the Spatial Reference System ID of the linestring.
virtual std::size_t getNPoints() const _NOEXCEPT_OP(true)=0
it returns the number of points (vertexes) in the geometry.
A class for representing an Uniform Resource Identifier (URI).
std::unique_ptr< te::rst::Raster > getPrepareRaster()
void setParams(double resx, double resy, Interpolator gt)
It sets the parameters that is being used to save TIN.
LineString is a curve with linear interpolation between points.
void LoadIsolines(const std::string &filename, te::gm::MultiPoint &mpt, te::gm::MultiLineString &isolines, std::string &geostype, std::string atributo)
void setOutput(std::map< std::string, std::string > &dsinfo)
It sets the Datasource that is being used to save TIN.
void setInput(te::da::DataSourcePtr inRasterDsrc, std::string inRasterName, std::unique_ptr< te::da::DataSetType > inDsetType)
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType, InputType type)
It sets the Datasource that is being used to generate TIN.
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property.
void clear()
Stop and unload all plugins, then clear the internal list of plugins.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
It is a collection of other geometric objects.
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsname)
void CalculateGrid()
void LoadModules()
Load terralib modules.
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
void setParams(const double &tolerance, const double &maxdist, const double &minedgesize, const std::string &atrz_iso, const std::string &atrz_pt)
It sets the parameters to generate TIN.
int main(int, char **)
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
Definition: CurvePolygon.h:193
void setZ(const double &z)
It sets the Point z-coordinate value.
Definition: Point.h:173
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
Definition: LineString.h:262