/home/martin/workspace/OpenStreetNav/src/wkb/WKBInterface.cpp
Go to the documentation of this file.
00001 /*
00002  * WKBInterface.cpp
00003  *
00004  *  Created on: Nov 26, 2011
00005  *      Author: martin
00006  */
00007 
00008 #include "WKBInterface.h"
00009 #include <sstream>
00010 #include <algorithm>
00011 #include <geos/geom/Coordinate.h>
00012 #include <geos/geom/Point.h>
00013 #include <geos/geom/Geometry.h>
00014 
00015 namespace wkb
00016 {
00017 
00018 WKBInterface::WKBInterface()
00019 {
00020 }
00021 
00022 WKBInterface::~WKBInterface()
00023 {
00024 }
00025 
00026 WKBInterface* WKBInterface::inst = NULL;
00027 
00028 WKBInterface& WKBInterface::get_instance()
00029 {
00030     if (inst == NULL)
00031     {
00032         inst = new WKBInterface();
00033     }
00034     return *inst;
00035 }
00036 
00037 std::vector<char> WKBInterface::point_to_wkb(const geo::Point& p)
00038 {
00039     std::ostringstream stream;
00040     geos::geom::Coordinate coord;
00041     coord.x = p.lon;
00042     coord.y = p.lat;
00043     geos::geom::Geometry* pt = fct.createPoint(coord);
00044     wr.write(*pt, stream);
00045     fct.destroyGeometry(pt);
00046     std::string const& str(stream.str());
00047     std::vector<char> out;
00048     out.reserve(str.length());
00049     std::copy(str.begin(), str.end(), std::back_inserter(out));
00050     return out;
00051 }
00052 
00053 } /* namespace wkb */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines