Update of /cvsroot/playerstage/code/player/client_libs/libplayerc++
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20455/client_libs/libplayerc++
Modified Files:
Makefile.am playerc++.cc playerc++.h
Added Files:
vectormapproxy.cc
Log Message:
added vectormap interface
added postgis vectormap driver
Thanks to Ben Morelli for these changes
--- NEW FILE: vectormapproxy.cc ---
/*
* Player - One Hell of a Robot Server
* Copyright (C) 2000-2003
* Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/********************************************************************
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
********************************************************************/
/*
* $Id: vectormapproxy.cc,v 1.1 2007/08/20 19:42:47 thjc Exp $
*/
#include "playerc++.h"
#include "string.h"
using namespace std;
using namespace PlayerCc;
// Constructor
VectorMapProxy::VectorMapProxy(PlayerClient *aPc, uint aIndex) :
ClientProxy(aPc, aIndex),
mDevice(NULL)
{
Subscribe(aIndex);
mInfo = &(mDevice->info);
map_info_cached = false;
}
// Destructor
VectorMapProxy::~VectorMapProxy()
{
Unsubscribe();
}
// Subscribe
void VectorMapProxy::Subscribe(uint aIndex)
{
scoped_lock_t lock(mPc->mMutex);
mDevice = playerc_vectormap_create(mClient, aIndex);
if (NULL==mDevice)
throw PlayerError("VectorMapProxy::VectorMapProxy()", "could not create");
if (0 != playerc_vectormap_subscribe(mDevice, PLAYER_OPEN_MODE))
throw PlayerError("VectorMapProxy::VectorMapProxy()", "could not
subscribe");
}
// Unsubscribe
void VectorMapProxy::Unsubscribe()
{
assert(NULL!=mDevice);
scoped_lock_t lock(mPc->mMutex);
playerc_vectormap_unsubscribe(mDevice);
playerc_vectormap_destroy(mDevice);
mDevice = NULL;
}
void VectorMapProxy::GetMapInfo()
{
playerc_vectormap_get_map_info(mDevice);
map_info_cached = true;
}
int VectorMapProxy::GetLayerCount() const
{
if (map_info_cached)
return mDevice->layers_count;
else
return -1;
}
vector<string> VectorMapProxy::GetLayerNames() const
{
vector<string> names;
int layerCount = GetLayerCount();
if (layerCount < 1)
return names;
for (int i=0; i<layerCount; ++i)
{
names.push_back(string(mDevice->layers[i]->info.name));
}
return names;
}
void VectorMapProxy::GetLayerData(unsigned layer_index)
{
if (map_info_cached)
playerc_vectormap_get_layer_data(mDevice, layer_index);
}
int VectorMapProxy::GetFeatureCount(unsigned layer_index) const
{
int layerCount = GetLayerCount();
if (layerCount < 1)
return -1;
return mDevice->layers[layer_index]->features_count;
}
ostream&
std::operator << (ostream &os, const VectorMapProxy &c)
{
os << "#VectorMap (" << c.GetInterface() << ":" << c.GetIndex() << ")" <<
endl;
os << "#Layer Number\tName\tFeature Count" << endl;
int layerCount = c.GetLayerCount();
vector<string> names = c.GetLayerNames();
for (int i=0; i<layerCount; ++i)
{
os << i << "\t" << names[i] << "\t" << c.GetFeatureCount(i) << endl;
}
os << "Total " << layerCount << " layers\n";
return os;
}
Index: playerc++.h
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/playerc++.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -d -r1.95 -r1.96
*** playerc++.h 6 Aug 2007 06:30:49 -0000 1.95
--- playerc++.h 20 Aug 2007 19:42:47 -0000 1.96
***************
*** 2344,2347 ****
--- 2344,2378 ----
/**
+ * The @p VectorMapProxy class is used to interface to a vectormap.
+ */
+ class VectorMapProxy : public ClientProxy
+ {
+
+ private:
+
+ // Subscribe
+ void Subscribe(uint aIndex);
+ // Unsubscribe
+ void Unsubscribe();
+
+ // libplayerc data structure
+ playerc_vectormap_t *mDevice;
+
+ bool map_info_cached;
+ public:
+ // Constructor
+ VectorMapProxy(PlayerClient *aPc, uint aIndex=0);
+ // Destructor
+ ~VectorMapProxy();
+
+ void GetMapInfo();
+ void GetLayerData(unsigned layer_index);
+
+ int GetLayerCount() const;
+ std::vector<std::string> GetLayerNames() const;
+ int GetFeatureCount(unsigned layer_index) const;
+ };
+
+ /**
The @p WiFiProxy class controls a @ref interface_wifi device. */
class WiFiProxy: public ClientProxy
***************
*** 2440,2443 ****
--- 2471,2475 ----
std::ostream& operator << (std::ostream& os, const player_bbox3d_t& c);
std::ostream& operator << (std::ostream& os, const player_segment_t& c);
+ std::ostream& operator << (std::ostream& os, const player_extent2d_t& c);
std::ostream& operator << (std::ostream& os, const playerc_device_info_t&
c);
***************
*** 2473,2476 ****
--- 2505,2509 ----
std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechProxy&
c);
std::ostream& operator << (std::ostream& os, const
PlayerCc::SpeechRecognitionProxy& c);
+ std::ostream& operator << (std::ostream& os, const
PlayerCc::VectorMapProxy& c);
//std::ostream& operator << (std::ostream& os, const
PlayerCc::WafeformProxy& c);
std::ostream& operator << (std::ostream& os, const PlayerCc::WiFiProxy& c);
Index: Makefile.am
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/Makefile.am,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** Makefile.am 17 Jun 2007 00:14:27 -0000 1.47
--- Makefile.am 20 Aug 2007 19:42:47 -0000 1.48
***************
*** 63,66 ****
--- 63,67 ----
speechproxy.cc \
speechrecognitionproxy.cc \
+ vectormapproxy.cc \
wifiproxy.cc \
wsnproxy.cc
Index: playerc++.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/playerc++.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** playerc++.cc 10 Jul 2007 09:01:50 -0000 1.17
--- playerc++.cc 20 Aug 2007 19:42:47 -0000 1.18
***************
*** 185,189 ****
}
-
std::ostream&
std::operator << (std::ostream& os, const player_segment_t& c)
--- 185,188 ----
***************
*** 195,198 ****
--- 194,205 ----
std::ostream&
+ std::operator << (std::ostream& os, const player_extent2d_t& c)
+ {
+ os << "extent: (" << c.x0 << "," << c.y0 << ") - ("
+ << c.x1 << "," << c.y1 << ")";
+ return os;
+ }
+
+ std::ostream&
std::operator << (std::ostream& os, const playerc_device_info_t& c)
{
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit