[Gislite-admins] SF.net SVN: gislite: [10] trunk
Status: Planning
Brought to you by:
ctomasin
|
From: <oci...@us...> - 2007-09-02 16:06:10
|
Revision: 10
http://gislite.svn.sourceforge.net/gislite/?rev=10&view=rev
Author: ocinemod
Date: 2007-09-02 09:06:04 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
Starting LineString part of GeomFromText() in wkgfunc.c
Modified Paths:
--------------
trunk/Makefile
trunk/sqlfunc.c
trunk/wkgfunc.c
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2007-08-31 17:52:04 UTC (rev 9)
+++ trunk/Makefile 2007-09-02 16:06:04 UTC (rev 10)
@@ -1,14 +1,3 @@
-#
-# This is not valid in a Makefile
-#
-# if test -d /proc ; then
-# DYNAMIC= '-shared'
-# OPTIONS= ' -lsqlite3 -lm -g'
-# else
-# DYNAMIC= '-fno-common -dynamiclib'
-# OPTIONS= ''
-# fi
-
#UNAME = Darwin
UNAME = Linux
Modified: trunk/sqlfunc.c
===================================================================
--- trunk/sqlfunc.c 2007-08-31 17:52:04 UTC (rev 9)
+++ trunk/sqlfunc.c 2007-09-02 16:06:04 UTC (rev 10)
@@ -88,33 +88,7 @@
sqlite3_free((void*)pGeom);
}
-/**
- * SQL function Distance(b)
- * Returns the distance between two well know binaries as a double
- * Ex:
- * sqlite> SELECT AsText(BLOB_POINT) FROM testGeom WHERE Distance(BLOB_POINT,AsBinary('POINT(1.2 1.3 1.4 1.5)')) < 100.0
- */
-static void Distance(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- WKBGeometry *pGeomA, *pGeomB;
- double distance;
- if( sqlite3_value_type(argv[0]) == SQLITE_BLOB && sqlite3_value_type(argv[1]) == SQLITE_BLOB){
- pGeomA = GeomFromBinary((unsigned char *)sqlite3_value_blob(argv[0]));
- pGeomB = GeomFromBinary((unsigned char *)sqlite3_value_blob(argv[1]));
- distance = GeomDistance(pGeomA,pGeomB);
- if( distance < 0.0 )
- sqlite3_result_null(context); // if negative means distance can't be evalued
- sqlite3_result_double(context,distance);
- } else {
- sqlite3_result_error(context,messages[6],-1);
- }
-}
-
-
/**
* SQL function X(b)
* Returns the X-coordinate value for the blob b containing WKBGeometry Point as a double.
@@ -342,8 +316,7 @@
sqlite3_create_function(db, "AsBinary", 1, SQLITE_ANY, 0, AsBinary, 0, 0);
//sqlite3_create_function(db, "SRID", 1, SQLITE_ANY, 0, SRID, 0, 0);
//sqlite3_create_function(db, "Dimension", 1, SQLITE_ANY, 0, Dimension, 0, 0);
- sqlite3_create_function(db, "Distance", 2, SQLITE_ANY, 0,Distance, 0, 0);
-
+
//Point functions
sqlite3_create_function(db, "X", 1, SQLITE_ANY, 0, X, 0, 0);
sqlite3_create_function(db, "Y", 1, SQLITE_ANY, 0, Y, 0, 0);
Modified: trunk/wkgfunc.c
===================================================================
--- trunk/wkgfunc.c 2007-08-31 17:52:04 UTC (rev 9)
+++ trunk/wkgfunc.c 2007-09-02 16:06:04 UTC (rev 10)
@@ -51,6 +51,7 @@
*/
WKBGeometry* GeomFromText(char *pWKT){
int len, i;
+ char *ppos;
char *pType;
char *pContent;
WKBGeometry *pGeom;
@@ -90,6 +91,32 @@
//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'){
+/*
+ //fill geometry from token
+ sscanf(ppos+1, "%lf %lf %lf %lf",
+ &pGeom->linestring.points[i].x,
+ &pGeom->linestring.points[i].y,
+ &pGeom->linestring.points[i].z,
+ &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))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|