[Gislite-admins] SF.net SVN: gislite: [7] trunk
Status: Planning
Brought to you by:
ctomasin
|
From: <cto...@us...> - 2007-08-24 15:21:05
|
Revision: 7
http://gislite.svn.sourceforge.net/gislite/?rev=7&view=rev
Author: ctomasin
Date: 2007-08-24 08:20:12 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
Some modifies
Added the Makefile used in Linux system to compile gislite.so.
Project compile but functionalities has not been tested due to a lack of time.
Modified Paths:
--------------
trunk/sqlfunc.c
trunk/wkg.h
trunk/wkgfunc.c
trunk/wkgfunc.h
Added Paths:
-----------
trunk/Makefile
Added: trunk/Makefile
===================================================================
--- trunk/Makefile (rev 0)
+++ trunk/Makefile 2007-08-24 15:20:12 UTC (rev 7)
@@ -0,0 +1,12 @@
+NAME = gislite.so
+SOURCES = wkgfunc.c sqlfunc.c
+OBJS = $(SOURCES:%.c=%.o)
+$(NAME) : $(OBJS)
+ gcc -shared -lsqlite3 -lm -g -o $@ $(OBJS)
+
+%.o : %.c
+ gcc -Wall -O0 -D_GNU_SOURCE -c $<
+
+
+clean :
+ rm -f $(NAME) $(OBJS)
Modified: trunk/sqlfunc.c
===================================================================
--- trunk/sqlfunc.c 2007-08-24 13:57:30 UTC (rev 6)
+++ trunk/sqlfunc.c 2007-08-24 15:20:12 UTC (rev 7)
@@ -3,6 +3,12 @@
* Functions used from SQL interface
* */
+#include <stdio.h>
+#include <string.h>
+#include <sqlite3ext.h>
+#include "wkgfunc.h"
+SQLITE_EXTENSION_INIT1
+
/**
* SQL function toWKT(b)
* Returns a WKT openGis Geometry representation from a sqlite blob b.
@@ -14,7 +20,7 @@
*
* @return string geometry as well-known text
*/
-static void toWKT(
+static void ToWKT(
sqlite3_context *context,
int argc,
sqlite3_value **argv
@@ -33,10 +39,10 @@
pBlob = (unsigned char*) sqlite3_value_blob(argv[0]);
//fill structure from blob
error = 0;
- error = FromBinary(pBlob, &Geom);
+ error = fromBinary(pBlob, &Geom);
if(error) sqlite3_result_error(context, messages[error], -1);
//convert to string
- pString = AsText(&Geom);
+ pString = asText(&Geom);
break;
default:
sqlite3_result_error(context, messages[4], -1);
@@ -46,7 +52,7 @@
sqlite3_result_text(context, pString, -1, SQLITE_TRANSIENT);
//free AsText allocated memory
- free(pString);
+ sqlite3_free(pString);
}
/**
@@ -59,7 +65,7 @@
*
* @return blob well-known binary to sqlite by its own function
*/
-static void toWKB(
+static void ToWKB(
sqlite3_context *context,
int argc,
sqlite3_value **argv
@@ -75,10 +81,10 @@
pBuf = (char*)sqlite3_value_text(argv[0]);
error = 0;
- error = FromText(pBuf, &Geom);
+ error = fromText(pBuf, &Geom);
if(error) sqlite3_result_error(context, messages[error], -1);
//fill char array
- pBin = AsBinary(&Geom);
+ pBin = asBinary(&Geom);
//double tmp;
//memcpy(&tmp, pBin+sizeof(byte)+sizeof(uint32)+sizeof(double),sizeof(double));
//sprintf(debug,"bin: %lf",tmp);
@@ -114,7 +120,7 @@
//only if value type is BLOB
if( sqlite3_value_type(argv[0]) == SQLITE_BLOB){
//get blob from argv and fill structure from blob
- FromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
+ fromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
//return coordinate
if(Geom.point.wkbType == 3001)
sqlite3_result_double(context, Geom.point.point.x);
@@ -147,7 +153,7 @@
//only if value type is BLOB
if( sqlite3_value_type(argv[0]) == SQLITE_BLOB){
//get blob from argv and fill structure from blob
- FromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
+ fromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
//return coordinate
if(Geom.point.wkbType == 3001)
sqlite3_result_double(context, Geom.point.point.y);
@@ -179,7 +185,7 @@
//only if value type is BLOB
if( sqlite3_value_type(argv[0]) == SQLITE_BLOB){
//get blob from argv and fill structure from blob
- FromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
+ fromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
//return coordinate
if(Geom.point.wkbType == 3001)
sqlite3_result_double(context, Geom.point.point.z);
@@ -212,7 +218,7 @@
//only if value type is BLOB
if( sqlite3_value_type(argv[0]) == SQLITE_BLOB){
//get blob from argv and fill structure from blob
- FromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
+ fromBinary((unsigned char*) sqlite3_value_blob(argv[0]), &Geom);
//return coordinate
if(Geom.point.wkbType == 3001)
sqlite3_result_double(context, Geom.point.point.m);
@@ -228,7 +234,7 @@
* SQL function StartPoint(g)
* Returns the start Point of a WKBGeometry LineString g.
* Ex:
- * sqlite> SELECT AsText(StartPoint(GeomFromBinary(BLOB_LINE))) FROM testGeom WHERE INDEX=1;
+ * sqlite> SELECT AsText(StartPoint(GeomfromBinary(BLOB_LINE))) FROM testGeom WHERE INDEX=1;
* sqlite> POINT(1.1 1.2 1.3 4.4)
*
* @param g WKBGeometry structure containing LineString
@@ -241,7 +247,7 @@
* SQL function EndPoint(g)
* Returns the end Point of a LineString.
* Ex:
- * sqlite> SELECT AsText(EndPoint(GeomFromBinary(BLOB_LINE))) FROM testGeom WHERE INDEX=1;
+ * sqlite> SELECT AsText(EndPoint(GeomfromBinary(BLOB_LINE))) FROM testGeom WHERE INDEX=1;
* sqlite> POINT(5.1 5.2 5.3 4.4)
*
* @param g WKBGeometry structure containing LineString
@@ -254,7 +260,7 @@
* SQL function Length(g)
* Returns the length of the LineString geometry g as double.
* Ex:
- * sqlite> SELECT Length(GeomFromBinary(BLOB_LINE)) FROM testGeom WHERE INDEX=1;
+ * sqlite> SELECT Length(GeomfromBinary(BLOB_LINE)) FROM testGeom WHERE INDEX=1;
* sqlite> 5.8926358638273
*
* @param g WKBGeometry structure containing LineString
@@ -267,7 +273,7 @@
* SQL function NumPoints(g)
* Returns the number of points in the WKBGeometry LineString g.
* Ex:
- * sqlite> SELECT NumPoints(GeomFromBinary(BLOB_LINE)) FROM testGeom WHERE INDEX=1;
+ * sqlite> SELECT NumPoints(GeomfromBinary(BLOB_LINE)) FROM testGeom WHERE INDEX=1;
* sqlite> 12
*
* @param g WKBGeometry structure containing LineString
@@ -280,7 +286,7 @@
* SQL function PointN(g, n)
* Returns the n-th point in the WKBGeometry Linestring g. Point numbers begin at 0.
* Ex:
- * sqlite> SELECT AsText(PointN(GeomFromBinary(BLOB_LINE),10)) FROM testGeom WHERE INDEX=1;
+ * sqlite> SELECT AsText(PointN(GeomfromBinary(BLOB_LINE),10)) FROM testGeom WHERE INDEX=1;
* sqlite> POINT(1.1 1.2 0.0 0.0)
*
* @param g WKBGeometry structure containing LineString
@@ -295,7 +301,7 @@
* Returns 1 if the WKBGeometry LineString g is closed and is simple.
* Returns 0 if ls is not a ring, and -1 if it is NULL.
* Ex:
- * sqlite> SELECT IsRing(GeomFromBinary(BLOB_LINE)) FROM testGeom WHERE INDEX=1;
+ * sqlite> SELECT IsRing(GeomfromBinary(BLOB_LINE)) FROM testGeom WHERE INDEX=1;
* sqlite> 1
*
* @param g WKBGeometry structure containing LineString
@@ -314,8 +320,8 @@
const sqlite3_api_routines *pApi
){
SQLITE_EXTENSION_INIT2(pApi)
- sqlite3_create_function(db, "toWKT", 1, SQLITE_ANY, 0, toWKT, 0, 0);
- sqlite3_create_function(db, "toWKB", 1, SQLITE_ANY, 0, toWKB, 0, 0);
+ sqlite3_create_function(db, "toWKT", 1, SQLITE_ANY, 0, ToWKT, 0, 0);
+ sqlite3_create_function(db, "toWKB", 1, SQLITE_ANY, 0, ToWKB, 0, 0);
sqlite3_create_function(db, "X", 1, SQLITE_ANY, 0, X, 0, 0);
sqlite3_create_function(db, "Y", 1, SQLITE_ANY, 0, Y, 0, 0);
sqlite3_create_function(db, "Z", 1, SQLITE_ANY, 0, Z, 0, 0);
Modified: trunk/wkg.h
===================================================================
--- trunk/wkg.h 2007-08-24 13:57:30 UTC (rev 6)
+++ trunk/wkg.h 2007-08-24 15:20:12 UTC (rev 7)
@@ -5,7 +5,8 @@
* as in: OGC 06-103r3 (8.2.8)
* expressed as C structures
*/
-
+#ifndef WKG_H
+#define WKG_H
//postGIS: 3d geometries are encoded as in OGR by adding WKBZOFFSET to the type.
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
@@ -104,3 +105,4 @@
WKBGeometryCollection collection;
};
}WKBGeometry;
+#endif
Modified: trunk/wkgfunc.c
===================================================================
--- trunk/wkgfunc.c 2007-08-24 13:57:30 UTC (rev 6)
+++ trunk/wkgfunc.c 2007-08-24 15:20:12 UTC (rev 7)
@@ -5,24 +5,21 @@
#include <stdio.h>
#include <string.h>
-//#include <stdlib.h>
-#include <sqlite3ext.h>
-#include "wkg.h"
#include "wkgfunc.h"
+#include <sqlite3ext.h> // needed by portable sqlite-specific functions
-SQLITE_EXTENSION_INIT1
+SQLITE_EXTENSION_INIT1 // needed by portable sqlite-specific functions
-char *messages[5] = {
- "ok" // 0
- ,"unrecognized text type" // 1
- ,"parse error" // 2
- ,"unrecognized geometry type" // 3
- ,"unable to convert from blob" // 4
- ,"unable to convert from blob" // 5
-
+//char debug[50];
+char *messages[6] = {
+ "ok" // 0
+ ,"unrecognized text type" // 1
+ ,"parse error" // 2
+ ,"unrecognized geometry type" // 3
+ ,"unable to convert from blob" // 4
+ ,"geometry is not a point" // 5
};
-//char debug[50];
void swap_char(char *a,char *b){
char c;
@@ -49,7 +46,7 @@
*
* @return integer error code
*/
-int FromText(char *pWKT, WKBGeometry *pGeom){
+int fromText(char *pWKT, WKBGeometry *pGeom){
int len, i;
char *pType;
char *pContent;
@@ -118,8 +115,8 @@
*
* @return as pWKT
*/
-char* AsText(WKBGeometry *pGeom){
- int len, i;
+char* asText(WKBGeometry *pGeom){
+ int len;
char *pWKT;
//char *sBuffer;
@@ -159,7 +156,7 @@
*
* @return integer error code
*/
-int FromBinary(unsigned char *pBin, WKBGeometry *pGeom){
+int fromBinary(unsigned char *pBin, WKBGeometry *pGeom){
int bBigendian;
uint32 wkbType;
int size, sizedbl=sizeof(double);
@@ -205,8 +202,8 @@
*
* @return pointer to unsigned char to be filled
*/
-unsigned char* AsBinary(WKBGeometry* pGeom){
- int dim, i;
+unsigned char* asBinary(WKBGeometry* pGeom){
+ int dim;
unsigned char *pBuffer;
unsigned char *pChar;
Modified: trunk/wkgfunc.h
===================================================================
--- trunk/wkgfunc.h 2007-08-24 13:57:30 UTC (rev 6)
+++ trunk/wkgfunc.h 2007-08-24 15:20:12 UTC (rev 7)
@@ -1,3 +1,5 @@
+#ifndef WKGGFUNC_H
+#define WKGFUNC_H
#include "wkg.h"
void swap_char(char *a,char *b);
@@ -6,11 +8,13 @@
void flip_endian_int32(char *i);
-int FromText(char *pWKT, WKBGeometry *pGeom);
+int fromText(char *pWKT, WKBGeometry *pGeom);
-char* AsText(WKBGeometry *pGeom);
+char* asText(WKBGeometry *pGeom);
-int FromBinary(unsigned char *pBin, WKBGeometry *pGeom);
+int fromBinary(unsigned char *pBin, WKBGeometry *pGeom);
-unsigned char* AsBinary(WKBGeometry* pGeom);
+unsigned char* asBinary(WKBGeometry* pGeom);
+extern char *messages[];
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|