All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MetadataExtractor.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 terralib/metadata/MetadataExtractor.cpp
22  */
23 
24 // TerraLib
25 #include "../dataaccess/dataset/DataSet.h"
26 #include "../dataaccess/dataset/DataSetType.h"
27 #include "../dataaccess/utils/Utils.h"
28 #include "../geometry/Envelope.h"
29 #include "../geometry/GeometryProperty.h"
30 #include "Config.h"
31 #include "iso19115/CI_Citation.h"
32 #include "iso19115/MD_Metadata.h"
33 #include "MetadataExtractor.h"
34 
35 
36 // STL
37 #include <cassert>
38 #include <string>
39 
40 // Boost
41 #include <boost/lexical_cast.hpp>
42 #include <boost/date_time/gregorian/gregorian.hpp>
43 
45 {
46  assert(d);
47 
49  md->setStandardInfo("iso19115", "2003");
50  md->setDateStamp(boost::gregorian::day_clock::local_day());
51 
52  //const te::da::DataSetType* dst = d->getType();
53  //md->setFileId(boost::lexical_cast<std::string>(dst->getId()));
54 
55  //te::md::CI_Citation* ct = new te::md::CI_Citation(dst->getTitle(),boost::gregorian::day_clock::local_day(),te::md::CI_creation);
56  te::md::CI_Citation* ct = new te::md::CI_Citation("dst->getTitle()",boost::gregorian::day_clock::local_day(),te::md::CI_creation);
57 
59 
60  int pos = static_cast<int>(te::da::GetFirstPropertyPos(d, te::dt::GEOMETRY_TYPE));
61 
62  std::auto_ptr<te::gm::Geometry> g = d->getGeometry(pos);
63  std::auto_ptr<te::gm::Envelope> env = const_cast<te::da::DataSet*>(d)->getExtent(pos);
64  md->setReferenceSystem(g->getSRID());
65  id->addGeographicBBoxExt(env.get());
66 
67  return md;
68 }
69 
70 
void setReferenceSystem(int srid)
Sets the referency system.
void setStandardInfo(const std::string &sname, const std::string &sversion)
Sets the name of the metadata standard/profile used.
Provides a standardized method for citing a resource (dataset, feature, source, publication, etc.)
Definition: CI_Citation.h:53
Information required to identify a dataset.
To support the bibliographic information to reference the resource.
Configuration flags for the Metadata support of TerraLib.
TEMDEXPORT MD_Metadata * Extract(const te::da::DataSet *d)
Extract some metadata from a layer.
Root entity which defines metadata for a resource or resources.
Definition: MD_Metadata.h:58
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
void setDateStamp(const boost::gregorian::date &date)
Set metadata date stamp.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:481