[Gislite-admins] SF.net SVN: gislite: [11] trunk
Status: Planning
Brought to you by:
ctomasin
|
From: <cto...@us...> - 2007-09-03 21:20:20
|
Revision: 11
http://gislite.svn.sourceforge.net/gislite/?rev=11&view=rev
Author: ctomasin
Date: 2007-09-03 14:20:22 -0700 (Mon, 03 Sep 2007)
Log Message:
-----------
It didn't compile and now it does. Tried to understand why AsText(AsBinary(POINT())) desn't works.
Modified Paths:
--------------
trunk/Makefile
trunk/sqlfunc.c
trunk/wkgfunc.c
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2007-09-02 16:06:04 UTC (rev 10)
+++ trunk/Makefile 2007-09-03 21:20:22 UTC (rev 11)
@@ -3,7 +3,7 @@
ifeq ($(UNAME),Linux)
DYNAMIC = -shared
- OPTIONS = -lsqlite3 -lm -g
+ OPTIONS = -lsqlite3 -lm -g -O0
else
DYNAMIC= -fno-common -dynamiclib
OPTIONS=
@@ -16,7 +16,7 @@
gcc $(DYNAMIC) $(OPTIONS) -o $@ $(OBJS)
%.o : %.c
- gcc -Wall -O0 -D_GNU_SOURCE -c $<
+ gcc -Wall -O0 -g -D_GNU_SOURCE -c $<
clean :
Modified: trunk/sqlfunc.c
===================================================================
--- trunk/sqlfunc.c 2007-09-02 16:06:04 UTC (rev 10)
+++ trunk/sqlfunc.c 2007-09-03 21:20:22 UTC (rev 11)
@@ -112,7 +112,7 @@
//get blob from argv and fill structure from blob
pGeom = (WKBGeometry*)GeomFromBinary((unsigned char*) sqlite3_value_blob(argv[0]));
//return coordinate
- if(pGeom->point.wkbType == 3001)
+ if(pGeom->point.wkbType == (byte)wkbPoint)
sqlite3_result_double(context, pGeom->point.point.x);
else
sqlite3_result_error(context, messages[5], -1);
@@ -145,7 +145,7 @@
//get blob from argv and fill structure from blob
pGeom = (WKBGeometry*)GeomFromBinary((unsigned char*) sqlite3_value_blob(argv[0]));
//return coordinate
- if(pGeom->point.wkbType == 3001)
+ if(pGeom->point.wkbType == (byte)wkbPoint)
sqlite3_result_double(context, pGeom->point.point.y);
else
sqlite3_result_error(context, messages[5], -1);
@@ -177,7 +177,7 @@
//get blob from argv and fill structure from blob
pGeom = (WKBGeometry*)GeomFromBinary((unsigned char*) sqlite3_value_blob(argv[0]));
//return coordinate
- if(pGeom->point.wkbType == 3001)
+ if(pGeom->point.wkbType == (byte)wkbPoint)
sqlite3_result_double(context, pGeom->point.point.z);
else
sqlite3_result_error(context, messages[5], -1);
@@ -210,7 +210,7 @@
//get blob from argv and fill structure from blob
pGeom = (WKBGeometry*)GeomFromBinary((unsigned char*) sqlite3_value_blob(argv[0]));
//return coordinate
- if(pGeom->point.wkbType == 3001)
+ if(pGeom->point.wkbType == (byte)wkbPoint)
sqlite3_result_double(context, pGeom->point.point.m);
else
sqlite3_result_error(context, messages[5], -1);
Modified: trunk/wkgfunc.c
===================================================================
--- trunk/wkgfunc.c 2007-09-02 16:06:04 UTC (rev 10)
+++ trunk/wkgfunc.c 2007-09-03 21:20:22 UTC (rev 11)
@@ -50,7 +50,7 @@
* @return pointer to WKGeometry
*/
WKBGeometry* GeomFromText(char *pWKT){
- int len, i;
+ int len, i, num;
char *ppos;
char *pType;
char *pContent;
@@ -74,8 +74,8 @@
if(strncmp(pType, "POINT", 5)==0){
pGeom = (WKBGeometry*) sqlite3_malloc(sizeof(WKBPoint));
//fill geometry as point
- pGeom->point.byteOrder = (byte)'1';//little endian ... autoconf endianness
- pGeom->point.wkbType = (uint32)3001;
+ pGeom->point.byteOrder = (byte)wkbNDR;//little endian ... autoconf endianness
+ pGeom->point.wkbType = (uint32)wkbPoint;
if(sscanf(pContent+1, "%lf %lf %lf %lf",
&pGeom->point.point.x,
&pGeom->point.point.y,
@@ -91,23 +91,23 @@
//LINESTRING(1 1 1 1, 2 2 2 2, 3 3 3 3)
else if(strncmp(pWKT,"LINESTRING", 10)==0){
- //pContent points count
- len = strlen(pContent);
- num = 0;//init
- for(i=0; i<=len; ++i) if(pContent[i]==',') num++;
- //test search result
- if(num==0 || i>=len) return NULL;// "unrecognized content type"
- //points are 1 more than commas
- num++;//points
- //mallocate space enough for counted points and geom stuff
- pGeom = (WKBGeometry*)sqlite3_malloc(sizeof(Point)*num+sizeof(byte)+sizeof(uint32));
- pGeom->point.byteOrder = (byte)'1';//little endian ... autoconf endianness
- pGeom->point.wkbType = (uint32)3002;
- //parse pContent
- pContent[len] = '\0';//substitute last ) with string termination
- //scan pContent repeatedly parsing at ","
- for(i=0; i<num, (ppos = strsep(&pContent, ",")) != NULL; i++){
- if(*ppos != '\0'){
+ //pContent points count
+ len = strlen(pContent);
+ num = 0;//init
+ for(i=0; i<=len; ++i) if(pContent[i]==',') num++;
+ //test search result
+ if(num==0 || i>=len) return NULL;// "unrecognized content type"
+ //points are 1 more than commas
+ num++;//points
+ //mallocate space enough for counted points and geom stuff
+ pGeom = (WKBGeometry*)sqlite3_malloc(sizeof(Point)*num+sizeof(byte)+sizeof(uint32));
+ pGeom->point.byteOrder = (byte)'1';//little endian ... autoconf endianness
+ pGeom->point.wkbType = (uint32)wkbLineString;
+ //parse pContent
+ pContent[len] = '\0';//substitute last ) with string termination
+ //scan pContent repeatedly parsing at ","
+ for(i=0; i < num && (ppos = strsep(&pContent, ",")) != NULL; i++){
+ if(*ppos != '\0'){
/*
//fill geometry from token
sscanf(ppos+1, "%lf %lf %lf %lf",
@@ -117,6 +117,8 @@
&pGeom->linestring.points[i].m
);
*/
+ }
+ }
}
//POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))
@@ -153,18 +155,18 @@
//create string by wkbType
switch(pGeom->point.wkbType){
- case 3001: // wkbPoint
- //POINT(1.200000 1.300000 1.400000 1.500000)
- pWKT = sqlite3_mprintf("POINT(%lf %lf %lf %lf)"
+ case wkbPoint:
+ //POINT(1.200000 1.300000 1.400000 1.500000)
+ pWKT = sqlite3_mprintf("POINT(%lf %lf %lf %lf)"
, pGeom->point.point.x
, pGeom->point.point.y
, pGeom->point.point.z
, pGeom->point.point.m);
- break;
+ break;
- case 3002: // wkbLineString
- //LINESTRING(0 0, 10 10, 20 25, 50 60)
- break;
+ case wkbLineString:
+ //LINESTRING(0 0, 10 10, 20 25, 50 60)
+ break;
//POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))
//MULTIPOINT(0 0, 20 20, 60 60)
@@ -172,8 +174,8 @@
//MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((5 5,7 5,7 7,5 7, 5 5)))
//GEOMETRYCOLLECTION(POINT(10 10), POINT(30 30), LINESTRING(15 15, 20 20))
- default:
- pWKT = sqlite3_mprintf("Error: %s", messages[4]);
+ default:
+ pWKT = sqlite3_mprintf("Error: %s", messages[4]);
}
return pWKT;
@@ -194,7 +196,7 @@
WKBGeometry *pGeom;
//determining endianness from first byte
- if (pBin[0] == '0') bBigendian = 1; // Big endian
+ if (pBin[0] == (byte)wkbXDR) bBigendian = 1; // Big endian
else bBigendian = 0; // Little endian
//type
@@ -203,30 +205,30 @@
//set Geometry by wkbType
switch(wkbType){
- case 3001: // wkbPoint
- //alloc WKBGeometry for Point size
- pGeom = (WKBGeometry*) sqlite3_malloc(sizeof(WKBPoint));
- //assign order-first byte and type
- pGeom->point.byteOrder = pBin[0];
- pGeom->point.wkbType = wkbType;
- //read coordinates from blob into WKBGeometry
- size = sizeof(byte) + sizeof(uint32);
- memcpy(&pGeom->point.point.x, pBin+size, sizedbl);
- size += sizedbl;
- memcpy(&pGeom->point.point.y, pBin+size, sizedbl);
- size += sizedbl;
- memcpy(&pGeom->point.point.z, pBin+size, sizedbl);
- size += sizedbl;
- memcpy(&pGeom->point.point.m, pBin+size, sizedbl);
- //return filled pointer
- return pGeom;
- break;
+ case wkbPoint:
+ //alloc WKBGeometry for Point size
+ pGeom = (WKBGeometry*) sqlite3_malloc(sizeof(WKBPoint));
+ //assign order-first byte and type
+ pGeom->point.byteOrder = pBin[0];
+ pGeom->point.wkbType = wkbType;
+ //read coordinates from blob into WKBGeometry
+ size = sizeof(byte) + sizeof(uint32);
+ memcpy(&pGeom->point.point.x, pBin+size, sizedbl);
+ size += sizedbl;
+ memcpy(&pGeom->point.point.y, pBin+size, sizedbl);
+ size += sizedbl;
+ memcpy(&pGeom->point.point.z, pBin+size, sizedbl);
+ size += sizedbl;
+ memcpy(&pGeom->point.point.m, pBin+size, sizedbl);
+ //return filled pointer
+ return pGeom;
+ break;
- case 3002: // wkbLineString
- break;
+ case wkbLineString:
+ break;
default:
- return NULL;// "unable to convert from blob"
+ return NULL;// "unable to convert from blob"
}
return NULL;
@@ -246,32 +248,32 @@
//alloc by wkbType
switch(pGeom->point.wkbType){
- case 3001: // wkbPoint
- dim = sizeof(WKBPoint);
- pBuffer = (unsigned char*)sqlite3_malloc(dim);
- memset(pBuffer, 0, dim);
- pChar = pBuffer;
- //fill Geometry
- memcpy(pChar, (unsigned char*)&pGeom->point.byteOrder, sizeof(byte));
- pChar += sizeof(byte);
- memcpy(pChar, &pGeom->point.wkbType, sizeof(uint32));
- pChar += sizeof(uint32);
- memcpy(pChar, &pGeom->point.point.x, sizeof(double));
- pChar += sizeof(double);
- memcpy(pChar, &pGeom->point.point.y, sizeof(double));
- pChar += sizeof(double);
- memcpy(pChar, &pGeom->point.point.z, sizeof(double));
- pChar += sizeof(double);
- memcpy(pChar, &pGeom->point.point.m, sizeof(double));
- break;
+ case wkbPoint:
+ dim = sizeof(WKBPoint);
+ pBuffer = (unsigned char*)sqlite3_malloc(dim);
+ memset(pBuffer, 0, dim);
+ pChar = pBuffer;
+ //fill Geometry
+ memcpy(pChar, (unsigned char*)&pGeom->point.byteOrder, sizeof(byte));
+ pChar += sizeof(byte);
+ memcpy(pChar, &pGeom->point.wkbType, sizeof(uint32));
+ pChar += sizeof(uint32);
+ memcpy(pChar, &pGeom->point.point.x, sizeof(double));
+ pChar += sizeof(double);
+ memcpy(pChar, &pGeom->point.point.y, sizeof(double));
+ pChar += sizeof(double);
+ memcpy(pChar, &pGeom->point.point.z, sizeof(double));
+ pChar += sizeof(double);
+ memcpy(pChar, &pGeom->point.point.m, sizeof(double));
+ break;
- case 3002: // wkbLineString
- //sprintf(debug,"2");
- break;
+ case wkbLineString:
+ //sprintf(debug,"2");
+ break;
- default:
- pBuffer = NULL;// "unrecognized geometry type"
- //to be tested outside
+ default:
+ pBuffer = NULL;// "unrecognized geometry type"
+ //to be tested outside
}
return pBuffer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|