[Positioning] Add Point3D::Point3D(string)
This commit is contained in:
parent
ceb035ed19
commit
ccb57c86ec
|
@ -133,6 +133,8 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc $(SRC_DIR)/%.hh
|
|||
$(LD) $(LDFLAGS) -o $@ $^
|
||||
|
||||
# Dependencies
|
||||
$(OBJ_DIR)/point3d.o: \
|
||||
$(OBJ_DIR)/posexcept.o
|
||||
$(OBJ_DIR)/posutil.o: \
|
||||
$(OBJ_DIR)/posexcept.o
|
||||
$(OBJ_DIR)/owlps-positioning.o: \
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
#include "point3d.hh"
|
||||
#include "posexcept.hh"
|
||||
|
||||
#include <sstream>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
|
||||
/* *** Constructors *** */
|
||||
|
||||
|
||||
Point3D::Point3D(const string &source)
|
||||
{
|
||||
float pos[3] ;
|
||||
istringstream iss(source) ;
|
||||
|
||||
for (int i = 0 ; i < 2 ; ++i)
|
||||
{
|
||||
iss >> pos[i] ;
|
||||
if (iss.get() != ';')
|
||||
throw malformed_input_data(
|
||||
"Point3D(string): cannot extract coordinates!") ;
|
||||
}
|
||||
iss >> pos[2] ;
|
||||
|
||||
set_coordinates(pos) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Distance operations *** */
|
||||
|
@ -84,16 +109,16 @@ bool Point3D::operator<(const Point3D &source) const
|
|||
}
|
||||
|
||||
|
||||
Point3D::operator std::string(void) const
|
||||
Point3D::operator string(void) const
|
||||
{
|
||||
std::ostringstream oss ;
|
||||
ostringstream oss ;
|
||||
oss << *this ;
|
||||
return oss.str() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream &os, const Point3D &p)
|
||||
ostream& operator<<(ostream &os, const Point3D &p)
|
||||
{
|
||||
os << "(" << p.x << ";" << p.y << ";" << p.z << ")" ;
|
||||
return os ;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _OWLPS_POSITIONING_POINT3D_HH_
|
||||
#define _OWLPS_POSITIONING_POINT3D_HH_
|
||||
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#include <cmath>
|
||||
|
||||
|
@ -22,6 +23,8 @@ public:
|
|||
Point3D(const float source[3]):
|
||||
x(source[0]), y(source[1]), z(source[2]) {}
|
||||
|
||||
Point3D(const std::string &source) ;
|
||||
|
||||
virtual ~Point3D(void) {}
|
||||
|
||||
/** @name Read accessors */
|
||||
|
|
Loading…
Reference in New Issue