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.h utils.c
Added Files:
dev_vectormap.c
Log Message:
added vectormap interface
added postgis vectormap driver
Thanks to Ben Morelli for these changes
--- NEW FILE: dev_vectormap.c ---
/*
* libplayerc : a Player client library
* Copyright (C) Andrew Howard 2002-2003
*
* 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.
*
*/
/*
* Player - One Hell of a Robot Server
* Copyright (C) Andrew Howard 2003
*
*
* 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
*/
/***************************************************************************
* Desc: Map device proxy
* Author: Benjamin Morelli
* Date: July 2007
* CVS: $Id: dev_vectormap.c,v 1.1 2007/08/20 19:42:47 thjc Exp $
**************************************************************************/
#if HAVE_CONFIG_H
#include <config.h>
#endif
/*#if HAVE_ZLIB_H
#include <zlib.h>
#endif*/
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "playerc.h"
#include "error.h"
#include <libplayerxdr/playerxdr.h>
// Create a new vectormap proxy
playerc_vectormap_t *playerc_vectormap_create(playerc_client_t *client, int
index)
{
playerc_vectormap_t *device = NULL;
device = malloc(sizeof(playerc_vectormap_t));
memset(device, 0, sizeof(playerc_vectormap_t));
playerc_device_init(&device->info, client, PLAYER_VECTORMAP_CODE, index,
(playerc_putmsg_fn_t) NULL);
return device;
}
// Destroy a vectormap proxy
void playerc_vectormap_destroy(playerc_vectormap_t *device)
{
playerc_device_term(&device->info);
playerc_vectormap_cleanup(device);
free(device);
}
// Subscribe to the vectormap device
int playerc_vectormap_subscribe(playerc_vectormap_t *device, int access)
{
#ifdef HAVE_GEOS
initGEOS(printf,printf);
#endif
return playerc_device_subscribe(&device->info, access);
}
// Un-subscribe from the vectormap device
int playerc_vectormap_unsubscribe(playerc_vectormap_t *device)
{
#ifdef HAVE_GEOS
finishGEOS();
#endif
return playerc_device_unsubscribe(&device->info);
}
// Get vectormap meta-data
int playerc_vectormap_get_map_info(playerc_vectormap_t* device)
{
int ii;
player_vectormap_info_t info_req;
memset(&info_req, 0, sizeof(info_req));
// try to get map info
if (playerc_client_request(
device->info.client,
&device->info,
PLAYER_VECTORMAP_REQ_GET_MAP_INFO,
NULL,
&info_req,
sizeof(player_vectormap_info_t)) < 0)
{
PLAYERC_ERR("failed to get vectormap info");
return -1;
}
playerc_vectormap_cleanup(device);
device->srid = info_req.srid;
device->extent = info_req.extent;
device->layers_count = info_req.layers_count;
// allocate mem for array of layers and memset to 0
device->layers = calloc(device->layers_count,
sizeof(player_vectormap_layer_data_t*));
if (!device->layers)
{
PLAYERC_ERR("calloc failed. failed to get vectormap info");
return -1;
}
for (ii=0; ii<device->layers_count; ++ii)
{
device->layers[ii] = malloc(sizeof(player_vectormap_layer_data_t));
device->layers[ii]->info = info_req.layers[ii].info;
}
return 0;
}
// get layer info
int playerc_vectormap_get_layer_info(playerc_vectormap_t *device, unsigned
layer_index)
{
player_vectormap_layer_info_t info_req = device->layers[layer_index]->info;
if (playerc_client_request(
device->info.client,
&device->info,
PLAYER_VECTORMAP_REQ_GET_LAYER_INFO,
&info_req,
&info_req,
sizeof(info_req)) < 0)
{
PLAYERC_ERR("failed to get layer info");
return -1;
}
device->layers[layer_index]->info = info_req;
return 0;
}
// Get layer data
int playerc_vectormap_get_layer_data(playerc_vectormap_t *device, unsigned
layer_index)
{
player_vectormap_layer_data_t data_req;
memset(&data_req, 0, sizeof(data_req));
player_vectormap_layer_info_t layer_info = device->layers[layer_index]->info;
data_req.info = layer_info;
if (playerc_client_request(
device->info.client,
&device->info,
PLAYER_VECTORMAP_REQ_GET_LAYER_DATA,
&data_req,
&data_req,
sizeof(data_req)) < 0)
{
PLAYERC_ERR("failed to get layer data");
return -1;
}
memset(device->layers[layer_index], 0, sizeof(player_vectormap_layer_data_t));
data_req.info = layer_info;
memcpy(device->layers[layer_index], &data_req, sizeof(data_req));
return 0;
}
GEOSGeom playerc_vectormap_get_feature_data(playerc_vectormap_t *device,
unsigned layer_index, unsigned feature_index)
{
int i;
#ifdef HAVE_GEOS
/*printf("%p %d\n", device->layers[layer_index]->features[feature_index].wkb,
device->layers[layer_index]->features[feature_index].wkb_count);
for(i = 0; i <
device->layers[layer_index]->features[feature_index].wkb_count; i++)
printf("%02x", device->layers[layer_index]->features[feature_index].wkb[i]);
printf("\n");*/
return GEOSGeomFromWKB_buf(
device->layers[layer_index]->features[feature_index].wkb,
device->layers[layer_index]->features[feature_index].wkb_count
);
#else
return NULL;
#endif
}
void playerc_vectormap_cleanup(playerc_vectormap_t *device)
{
unsigned ii;
if (device->layers)
{
for (ii=0; ii<device->layers_count; ++ii)
{
player_vectormap_layer_data_t_cleanup(device->layers[ii]);
}
free(device->layers);
}
device->srid = -1;
device->layers_count = 0;
memset(&device->extent, 0, sizeof(player_extent2d_t));
}
Index: utils.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/utils.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** utils.c 6 Aug 2007 00:41:22 -0000 1.29
--- utils.c 20 Aug 2007 19:42:47 -0000 1.30
***************
*** 55,59 ****
}
!
// Get the name for a given device code.
const char *playerc_lookup_name(int code)
--- 55,59 ----
}
! /*
// Get the name for a given device code.
const char *playerc_lookup_name(int code)
***************
*** 194,197 ****
return -1;
}
!
--- 194,197 ----
return -1;
}
! */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/Makefile.am,v
retrieving revision 1.97
retrieving revision 1.98
diff -C2 -d -r1.97 -r1.98
*** Makefile.am 9 Jun 2007 03:57:10 -0000 1.97
--- Makefile.am 20 Aug 2007 19:42:47 -0000 1.98
***************
*** 37,41 ****
dev_gripper.c \
dev_health.c \
! dev_imu.c \
dev_ir.c \
dev_laser.c \
--- 37,41 ----
dev_gripper.c \
dev_health.c \
! dev_imu.c \
dev_ir.c \
dev_laser.c \
***************
*** 46,50 ****
dev_opaque.c \
dev_planner.c \
! dev_pointcloud3d.c \
dev_position1d.c \
dev_position2d.c \
--- 46,50 ----
dev_opaque.c \
dev_planner.c \
! dev_pointcloud3d.c \
dev_position1d.c \
dev_position2d.c \
***************
*** 58,63 ****
dev_speech.c \
dev_speech_recognition.c \
dev_wifi.c \
! dev_wsn.c
#dev_joystick.c
--- 58,64 ----
dev_speech.c \
dev_speech_recognition.c \
+ dev_vectormap.c \
dev_wifi.c \
! dev_wsn.c
#dev_joystick.c
***************
*** 71,74 ****
--- 72,80 ----
libplayerc_la_LIBADD += $(top_builddir)/libplayerjpeg/*.lo
endif
+ if HAVE_GEOS
+ libplayerc_la_LIBADD += $(GEOS_LIBS)
+ endif
+
+
libplayerc_includedir = $(includedir)/player-2.0/libplayerc
Index: playerc.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/playerc.h,v
retrieving revision 1.227
retrieving revision 1.228
diff -C2 -d -r1.227 -r1.228
*** playerc.h 11 Aug 2007 00:21:28 -0000 1.227
--- playerc.h 20 Aug 2007 19:42:47 -0000 1.228
***************
*** 51,54 ****
--- 51,62 ----
#include <sys/types.h>
#include <netinet/in.h>
+ #include <config.h>
+
+ #ifdef HAVE_GEOS
+ #include <geos_c.h>
+ #else
+ typedef void * GEOSGeom;
+ #endif
+
// Get the message structures from Player
***************
*** 335,342 ****
/** Get the name for a given interface code. */
! const char *playerc_lookup_name(int code);
/** Get the interface code for a given name. */
! int playerc_lookup_code(const char *name);
/** Add new entries to the XDR function table. */
--- 343,350 ----
/** Get the name for a given interface code. */
! //const char *playerc_lookup_name(int code);
/** Get the interface code for a given name. */
! //int playerc_lookup_code(const char *name);
/** Add new entries to the XDR function table. */
***************
*** 2112,2116 ****
} playerc_map_t;
-
/** @brief Convert from a cell position to a map index.
*/
--- 2120,2123 ----
***************
*** 2138,2141 ****
--- 2145,2199 ----
/**************************************************************************/
+ /** @ingroup playerc_proxies
+ * @defgroup playerc_proxy_vectormap vectormap
+
+ The vectormap proxy provides an interface to a map of geometric features.
+
+ @{ */
+
+ /** @brief Vectormap proxy. */
+ typedef struct
+ {
+ /** Device info; must be at the start of all device structures. */
+ playerc_device_t info;
+ /** Spatial reference identifier. Use '0' if you are not using spatial
references. */
+ uint32_t srid;
+ /** Boundary area. */
+ player_extent2d_t extent;
+ /** The number of layers. */
+ uint32_t layers_count;
+ /** Layer data. */
+ player_vectormap_layer_data_t** layers;
+ } playerc_vectormap_t;
+
+ /** @brief Create a vectormap proxy. */
+ playerc_vectormap_t *playerc_vectormap_create(playerc_client_t *client, int
index);
+
+ /** @brief Destroy a vectormap proxy. */
+ void playerc_vectormap_destroy(playerc_vectormap_t *device);
+
+ /** @brief Subscribe to the vectormap device. */
+ int playerc_vectormap_subscribe(playerc_vectormap_t *device, int access);
+
+ /** @brief Un-subscribe from the vectormap device. */
+ int playerc_vectormap_unsubscribe(playerc_vectormap_t *device);
+
+ /** @brief Get the vectormap metadata, which is stored in the proxy. */
+ int playerc_vectormap_get_map_info(playerc_vectormap_t* device);
+
+ /** @brief Get the layer info by index. Must only be used after a successfull
call to playerc_vectormap_get_map_info. */
+ int playerc_vectormap_get_layer_info(playerc_vectormap_t *device, unsigned
layer_index);
+
+ /** @brief Get the layer data by index. Must only be used after a successfull
call to playerc_vectormap_get_layer_info. */
+ int playerc_vectormap_get_layer_data(playerc_vectormap_t *device, unsigned
layer_index);
+
+ /** @brief Clean up the dynamically allocated memory for the vectormap. */
+ void playerc_vectormap_cleanup(playerc_vectormap_t *device);
+
+ /** @brief Get an individual feature as a geos geometry. Must only be used
after a successful call to playerc_vectormap_get_layer_data. */
+ GEOSGeom playerc_vectormap_get_feature_data(playerc_vectormap_t *device,
unsigned layer_index, unsigned feature_index);
+
+ /** @} */
+
/***************************************************************************/
/** @ingroup playerc_proxies
-------------------------------------------------------------------------
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