All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointPlacement.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2011 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/serialization/se/PointPlacement.cpp
22 
23  \brief Support for PointPlacement serialization.
24 */
25 
26 // TerraLib
27 #include "../../se/PointPlacement.h"
28 #include "../../xml/Reader.h"
29 #include "../../xml/Writer.h"
30 #include "AnchorPoint.h"
31 #include "Displacement.h"
32 #include "ParameterValue.h"
33 #include "PointPlacement.h"
34 #include "Utils.h"
35 
36 // STL
37 #include <cassert>
38 #include <memory>
39 
41 {
42  assert(reader.getNodeType() == te::xml::START_ELEMENT);
43  assert(reader.getElementLocalName() == "PointPlacement");
44 
45  reader.next();
46 
47  std::auto_ptr<te::se::PointPlacement> pp(new te::se::PointPlacement);
48 
49  // AnchorPoint
50  if(reader.getElementLocalName() == "AnchorPoint")
51  pp->setAnchorPoint(ReadAnchorPoint(reader));
52 
53  // Displacement
54  if(reader.getElementLocalName() == "Displacement")
55  pp->setDisplacement(ReadDisplacement(reader));
56 
57  // Rotation
58  if(reader.getElementLocalName() == "Rotation")
59  {
60  reader.next();
61  pp->setRotation(ReadParameterValue(reader));
62  }
63 
64  assert(reader.getNodeType() == te::xml::END_ELEMENT);
65  reader.next();
66 
67  return pp.release();
68 }
69 
71 {
72  if(pp == 0)
73  return;
74 
75  writer.writeStartElement("se:PointPlacement");
76 
77  Save(pp->getAnchorPoint(), writer);
78  Save(pp->getDisplacement(), writer);
79  WriteParameterValuePtrHelper("se:Rotation", pp->getRotation(), writer);
80 
81  writer.writeEndElement("se:PointPlacement");
82 }
A PointPlacement specifies how a text label should be rendered relative to a geometric point...
TESERIALIZATIONEXPORT te::se::ParameterValue * ReadParameterValue(te::xml::Reader &reader)
Utility methods for Symbology serialization.
TEDATAACCESSEXPORT void Save(const std::string &fileName)
Definition: Serializer.cpp:191
A PointPlacement specifies how a text label should be rendered relative to a geometric point...
This class models a XML reader object.
Definition: Reader.h:55
void WriteParameterValuePtrHelper(const std::string &elementName, const te::se::ParameterValue *p, te::xml::Writer &writer)
Definition: Utils.cpp:46
virtual bool next()=0
It gets the next event to be read.
TESERIALIZATIONEXPORT te::se::AnchorPoint * ReadAnchorPoint(te::xml::Reader &reader)
Definition: AnchorPoint.cpp:38
virtual void writeStartElement(const std::string &qName)
Definition: Writer.cpp:44
const Displacement * getDisplacement() const
virtual void writeEndElement(const std::string &qName)
Definition: Writer.cpp:156
TESERIALIZATIONEXPORT void Save(const te::fe::Filter *filter, te::xml::Writer &writer)
Definition: Filter.cpp:54
const ParameterValue * getRotation() const
Support for Displacement serialization.
TESERIALIZATIONEXPORT te::se::PointPlacement * ReadPointPlacement(te::xml::Reader &reader)
const AnchorPoint * getAnchorPoint() const
TESERIALIZATIONEXPORT te::se::Displacement * ReadDisplacement(te::xml::Reader &reader)
Support for AnchorPoint serialization.
virtual NodeType getNodeType() const =0
It return the type of node read.
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
This class models a XML writer object.
Definition: Writer.h:52