* www.telogis.com
*
*/
-#include "wktparse.h"
#include <string.h>
#include <stdio.h>
+
#include "liblwgeom.h"
+#include "wktparse.h"
/*
//To get byte order
typedef struct tag_tuple tuple;
struct tag_outputstate{
- byte* pos;
+ uchar* pos;
};
typedef struct tag_outputstate output_state;
void alloc_geomertycollection(void);
void alloc_counter(void);
void alloc_empty(void);
-byte* make_lwgeom(void);
-byte strhex_readbyte(const char* in);
-byte read_wkb_byte(const char** in);
-void read_wkb_bytes(const char** in,byte* out, int cnt);
+uchar* make_lwgeom(void);
+uchar strhex_readbyte(const char* in);
+uchar read_wkb_byte(const char** in);
+void read_wkb_bytes(const char** in,uchar* out, int cnt);
int4 read_wkb_int(const char** in);
double read_wbk_double(const char** in,int convert_from_int);
void read_wkb_point(const char** b);
void read_collection2(const char** b);
void parse_wkb(const char** b);
void alloc_wkb(const char* parser);
-byte* parse_it(const char* geometry,allocator allocfunc,report_error errfunc);
-byte* parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc);
-byte* parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc);
+uchar* parse_it(const char* geometry,allocator allocfunc,report_error errfunc);
+uchar* parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc);
+uchar* parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc);
void
set_srid(double d_srid)
val |=0x80;
}
- *out->pos++ = (byte)val;
+ *out->pos++ = (uchar)val;
the_geom.alloc_size-=3;
}
else{
void
write_type(tuple* this,output_state* out)
{
- byte type=0;
+ uchar type=0;
//Empty handler - switch back
if ( this->uu.nn.type == 0xff )
}
-byte *
+uchar *
make_lwgeom()
{
- byte* out_c;
+ uchar* out_c;
output_state out;
tuple* cur;
- out_c = (byte*)local_malloc(the_geom.alloc_size);
+ out_c = (uchar*)local_malloc(the_geom.alloc_size);
out.pos = out_c;
cur = the_geom.first ;
puts '{'+a.join(",")+'}'
*/
-static const byte to_hex[] = {
+static const uchar to_hex[] = {
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255};
-byte
+uchar
strhex_readbyte(const char* in)
{
if ( *in == 0 ){
return to_hex[(int)*in]<<4 | to_hex[(int)*(in+1)];
}
-byte
+uchar
read_wkb_byte(const char** in)
{
- byte ret = strhex_readbyte(*in);
+ uchar ret = strhex_readbyte(*in);
(*in)+=2;
return ret;
}
int swap_order;
void
-read_wkb_bytes(const char** in,byte* out, int cnt)
+read_wkb_bytes(const char** in,uchar* out, int cnt)
{
if ( ! swap_order ){
while(cnt--) *out++ = read_wkb_byte(in);
read_wkb_int(const char** in)
{
int4 ret;
- read_wkb_bytes(in,(byte*)&ret,4);
+ read_wkb_bytes(in,(uchar*)&ret,4);
return ret;
}
double ret;
if ( ! convert_from_int){
- read_wkb_bytes(in,(byte*)&ret,8);
+ read_wkb_bytes(in,(uchar*)&ret,8);
return ret;
}else{
ret = read_wkb_int(in);
parse_wkb(const char** b)
{
int4 type;
- byte xdr = read_wkb_byte(b);
+ uchar xdr = read_wkb_byte(b);
int4 localsrid;
swap_order=0;
/*
Parse a string and return a LW_GEOM
*/
-byte *
+uchar *
parse_it(const char* geometry,allocator allocfunc,report_error errfunc)
{
return make_lwgeom();
}
-byte *
+uchar *
parse_lwg(const char* geometry,allocator allocfunc,report_error errfunc)
{
the_geom.lwgi=0;
return parse_it(geometry,allocfunc,errfunc);
}
-byte *
+uchar *
parse_lwgi(const char* geometry,allocator allocfunc,report_error errfunc)
{
the_geom.lwgi=1;
*/
-#include "wktparse.h"
#include <string.h>
#include <math.h>
#include <stdio.h>
//#include <netinet/ip.h>
#include "liblwgeom.h"
+#include "wktparse.h"
+
//-- Typedefs ----------------------------------------------
typedef unsigned long int4;
-typedef byte* (*outfunc)(byte*,int);
-typedef byte* (*outwkbfunc)(byte*);
+typedef uchar* (*outfunc)(uchar*,int);
+typedef uchar* (*outwkbfunc)(uchar*);
//-- Prototypes --------------------------------------------
void write_str(const char* str);
void write_double(double val);
void write_int(int i);
-int4 read_int(byte** geom);
-double read_double(byte** geom);
-byte* output_point(byte* geom,int supress);
-byte* output_single(byte* geom,int supress);
-byte* output_collection(byte* geom,outfunc func,int supress);
-byte* output_collection_2(byte* geom,int suppress);
-byte* output_multipoint(byte* geom,int suppress);
-
-void write_wkb_hex_bytes(byte* ptr, unsigned int cnt, size_t size);
-void write_wkb_bin_bytes(byte* ptr, unsigned int cnt, size_t size);
-void write_wkb_bin_flip_bytes(byte* ptr, unsigned int cnt, size_t size);
-void write_wkb_hex_flip_bytes(byte* ptr, unsigned int cnt, size_t size);
+int4 read_int(uchar** geom);
+double read_double(uchar** geom);
+uchar* output_point(uchar* geom,int supress);
+uchar* output_single(uchar* geom,int supress);
+uchar* output_collection(uchar* geom,outfunc func,int supress);
+uchar* output_collection_2(uchar* geom,int suppress);
+uchar* output_multipoint(uchar* geom,int suppress);
+
+void write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size);
+void write_wkb_bin_bytes(uchar* ptr, unsigned int cnt, size_t size);
+void write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size);
+void write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size);
void write_wkb_int(int i);
-byte* output_wkb_collection(byte* geom,outwkbfunc func);
-byte* output_wkb_collection_2(byte* geom);
-byte* output_wkb_point(byte* geom);
-byte* output_wkb(byte* geom);
+uchar* output_wkb_collection(uchar* geom,outwkbfunc func);
+uchar* output_wkb_collection_2(uchar* geom);
+uchar* output_wkb_point(uchar* geom);
+uchar* output_wkb(uchar* geom);
//-- Globals -----------------------------------------------
static int len;
static int lwgi;
//static int flipbytes;
-static byte endianbyte;
-void (*write_wkb_bytes)(byte* ptr,unsigned int cnt,size_t size);
+static uchar endianbyte;
+void (*write_wkb_bytes)(uchar* ptr,unsigned int cnt,size_t size);
//----------------------------------------------------------
}
int4
-read_int(byte** geom)
+read_int(uchar** geom)
{
int4 ret;
#ifdef SHRINK_INTS
double round(double);
-double read_double(byte** geom){
+double read_double(uchar** geom){
if (lwgi){
double ret = *((int4*)*geom);
ret /= 0xb60b60;
}
}
-byte *
-output_point(byte* geom,int supress)
+uchar *
+output_point(uchar* geom,int supress)
{
int i;
return geom;
}
-byte *
-output_single(byte* geom,int supress)
+uchar *
+output_single(uchar* geom,int supress)
{
write_str("(");
geom=output_point(geom,supress);
return geom;
}
-byte *
-output_collection(byte* geom,outfunc func,int supress)
+uchar *
+output_collection(uchar* geom,outfunc func,int supress)
{
int cnt = read_int(&geom);
if ( cnt == 0 ){
return geom;
}
-byte *
-output_collection_2(byte* geom,int suppress)
+uchar *
+output_collection_2(uchar* geom,int suppress)
{
return output_collection(geom,output_point,suppress);
}
-byte *output_wkt(byte* geom, int supress);
+uchar *output_wkt(uchar* geom, int supress);
/* special case for multipoint to supress extra brackets */
-byte *output_multipoint(byte* geom,int suppress){
+uchar *output_multipoint(uchar* geom,int suppress){
unsigned type = *geom & 0x0f;
if ( type == POINTTYPE )
// Suppress=0 // write TYPE, M, coords
// Suppress=1 // write TYPE, coords
// Suppress=2 // write only coords
-byte *
-output_wkt(byte* geom, int supress)
+uchar *
+output_wkt(uchar* geom, int supress)
{
unsigned type=*geom++;
}
char *
-unparse_WKT(byte* serialized, allocator alloc, freeor free)
+unparse_WKT(uchar* serialized, allocator alloc, freeor free)
{
if (serialized==NULL)
/* Write HEX bytes flipping */
void
-write_wkb_hex_flip_bytes(byte* ptr, unsigned int cnt, size_t size)
+write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
{
unsigned int bc; // byte count
/* Write HEX bytes w/out flipping */
void
-write_wkb_hex_bytes(byte* ptr, unsigned int cnt, size_t size)
+write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size)
{
unsigned int bc; // byte count
/* Write BIN bytes flipping */
void
-write_wkb_bin_flip_bytes(byte* ptr, unsigned int cnt, size_t size)
+write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
{
unsigned int bc; // byte count
/* Write BIN bytes w/out flipping */
void
-write_wkb_bin_bytes(byte* ptr, unsigned int cnt, size_t size)
+write_wkb_bin_bytes(uchar* ptr, unsigned int cnt, size_t size)
{
unsigned int bc; // byte count
}
}
-byte *
-output_wkb_point(byte* geom)
+uchar *
+output_wkb_point(uchar* geom)
{
if ( lwgi ){
write_wkb_bytes(geom,dims,4);
void
write_wkb_int(int i){
- write_wkb_bytes((byte*)&i,1,4);
+ write_wkb_bytes((uchar*)&i,1,4);
}
-byte *
-output_wkb_collection(byte* geom,outwkbfunc func)
+uchar *
+output_wkb_collection(uchar* geom,outwkbfunc func)
{
int cnt = read_int(&geom);
#ifdef PGIS_DEBUG
return geom;
}
-byte *
-output_wkb_collection_2(byte* geom){
+uchar *
+output_wkb_collection_2(uchar* geom){
return output_wkb_collection(geom,output_wkb_point);
}
-byte *
-output_wkb(byte* geom)
+uchar *
+output_wkb(uchar* geom)
{
unsigned char type=*geom++;
int4 wkbtype;
}
char *
-unparse_WKB(byte* serialized, allocator alloc, freeor free, char endian, size_t *outsize, byte hex)
+unparse_WKB(uchar* serialized, allocator alloc, freeor free, char endian, size_t *outsize, uchar hex)
{
#ifdef PGIS_DEBUG
lwnotice("unparse_WKB(%p,...) called", serialized);
/******************************************************************
* $Log$
+ * Revision 1.18 2005/02/21 16:16:14 strk
+ * Changed byte to uchar to avoid clashes with win32 headers.
+ *
* Revision 1.17 2005/02/07 13:21:10 strk
* Replaced DEBUG* macros with PGIS_DEBUG*, to avoid clashes with postgresql DEBUG
*