#---------------------------------------------------------------
-override CPPFLAGS := -I$(srcdir) -I$(top_builddir)/src/interfaces/libpq $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"' -DUSE_VERSION=$(USE_VERSION)
+override CPPFLAGS := -g -I$(srcdir) -I$(top_builddir)/src/interfaces/libpq $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"' -DUSE_VERSION=$(USE_VERSION)
all: shp2pgsql$(EXE) pgsql2shp$(EXE)
*
**********************************************************************
* $Log$
+ * Revision 1.12 2003/09/16 20:27:12 dblasby
+ * added ability to delete geometries.
+ *
* Revision 1.11 2003/08/08 18:19:20 dblasby
* Conformance changes.
* Removed junk from postgis_debug.c and added the first run of the long
{
TriggerData *trigdata = (TriggerData *) fcinfo->context;
char *colname ;
- char *locktablename ;
int id;
HeapTuple rettuple;
TupleDesc tupdesc;
char *relname;
bool isnull;
char query[1024];
+ int pk_type_oid;
+ char *pk_id = NULL;
+
elog(NOTICE,"in lockcheck()");
colname = trigdata->tg_trigger->tgargs[0];
- locktablename = trigdata->tg_trigger->tgargs[1];
- elog(NOTICE,"trigger was executed on the relation: '%s', with attribute named '%s', with locktable named '%s'", relname,colname,locktablename);
+
+ elog(NOTICE,"trigger was executed on the relation: '%s', with attribute named '%s', with locktable named '%s'", relname,colname,"authorization_table");
//get the value
+
+ pk_type_oid =SPI_gettypeid ( tupdesc , SPI_fnumber(tupdesc,colname));
+ elog(NOTICE,"primary key type # = %i", pk_type_oid ) ;
+
+ if (pk_type_oid == 23) //int4
+ {
+ int id = (int) DatumGetInt32( SPI_getbinval(rettuple, tupdesc, SPI_fnumber(tupdesc,colname), &isnull) );
+ if (isnull)
+ {
+ elog(ERROR,"lockcheck - column (%s) of table (%s) is null!",colname,relname);
+ }
+ pk_id = palloc(100);
+ sprintf(pk_id,"%i",id);
+ }
+ else if (pk_type_oid == 25) // text
+ {
+ Datum id = ( SPI_getbinval(rettuple, tupdesc, SPI_fnumber(tupdesc,colname), &isnull) );
+ if (isnull)
+ {
+ elog(ERROR,"lockcheck - column (%s) of table (%s) is null!",colname,relname);
+ }
+ pk_id = DatumGetCString(DirectFunctionCall1(textout,id));
+
+ }
+ else if (pk_type_oid == 1043) // varchar
+ {
+ Datum id = ( SPI_getbinval(rettuple, tupdesc, SPI_fnumber(tupdesc,colname), &isnull) );
+ if (isnull)
+ {
+ elog(ERROR,"lockcheck - column (%s) of table (%s) is null!",colname,relname);
+ }
+ pk_id = DatumGetCString(DirectFunctionCall1(varcharout,id));
+ }
+ else
+ {
+ elog(ERROR,"id column (%s) of table (%s) has to be either int4, text, or varchar. Its - %s (oid %i)",colname,relname,SPI_gettype ( tupdesc , SPI_fnumber(tupdesc,colname) ) ,pk_type_oid );
+ }
+
+
id = (int) DatumGetInt32( SPI_getbinval(rettuple, tupdesc, SPI_fnumber(tupdesc,colname), &isnull) );
- sprintf(query,"SELECT lock_key FROM %s WHERE expires >= now() AND id = %i", locktablename,id);
+ sprintf(query,"SELECT authid FROM %s WHERE expires >= now() AND tname = '%s' and fid = '%s'::text", "authorization_table",relname,pk_id);
elog(NOTICE,"about to execute :%s", query);
SPIcode = SPI_exec(query,0);
elog(NOTICE,"I do not own any locks (no lock table) - I cannot modify the row");
//PG_RETURN_NULL();
SPI_finish();
- return NULL;
+ //return NULL;
+ elog(ERROR,"attemted to modify a locked row that I do not have authorization for!");
}
- sprintf(query,"SELECT * FROM temp_lock_have_table WHERE xideq(transid , getTransactionID() ) AND lockcode =%s",lockcode);
+ sprintf(query,"SELECT * FROM temp_lock_have_table WHERE xideq(transid , getTransactionID() ) AND lockcode ='%s'",lockcode);
elog(NOTICE,"about to execute :%s", query);
SPIcode = SPI_exec(query,0);
elog(NOTICE,"I do not own the lock - I cannot modify the row");
//PG_RETURN_NULL();
SPI_finish();
- return NULL;
+ //return NULL;
+ elog(ERROR,"attemted to modify a locked row that I do not have authorization for!");
}
else
{
*
**********************************************************************
* $Log$
+ * Revision 1.25 2003/09/16 20:27:12 dblasby
+ * added ability to delete geometries.
+ *
* Revision 1.24 2003/08/08 18:19:20 dblasby
* Conformance changes.
* Removed junk from postgis_debug.c and added the first run of the long
LINE3D *line;
int32 *offsets1;
- if (geom1->type != LINETYPE)
+ if ( (geom1->type != LINETYPE) && (geom1->type != MULTILINETYPE) )
PG_RETURN_NULL();
offsets1 = (int32 *) ( ((char *) &(geom1->objType[0] ))+ sizeof(int32) * geom1->nobjs ) ;
- if (geom1->type != LINETYPE)
+ if ( (geom1->type != LINETYPE) && (geom1->type != MULTILINETYPE) )
PG_RETURN_NULL();
offsets1 = (int32 *) ( ((char *) &(geom1->objType[0] ))+ sizeof(int32) * geom1->nobjs ) ;
*
**********************************************************************
* $Log$
+ * Revision 1.9 2003/09/16 20:27:12 dblasby
+ * added ability to delete geometries.
+ *
* Revision 1.8 2003/08/08 18:19:20 dblasby
* Conformance changes.
* Removed junk from postgis_debug.c and added the first run of the long
initGEOS(MAXIMUM_ALIGNOF);
+elog(NOTICE,"intersection() START");
+
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
+
+elog(NOTICE," constructed geometrys - calling geos");
+
+//elog(NOTICE,"g1 = %s",GEOSasText(g1));
+//elog(NOTICE,"g2 = %s",GEOSasText(g2));
+
+
+if (g1==NULL)
+ elog(NOTICE,"g1 is null");
+if (g2==NULL)
+ elog(NOTICE,"g2 is null");
+//elog(NOTICE,"g2 is valid = %i",GEOSisvalid(g2));
+//elog(NOTICE,"g1 is valid = %i",GEOSisvalid(g1));
+
+
g3 = GEOSIntersection(g1,g2);
+elog(NOTICE," intersection finished");
+
if (g3 == NULL)
{
elog(ERROR,"GEOS Intersection() threw an error!");
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
- GEOSdeleteGeometry(g1);
- GEOSdeleteGeometry(g2);
+
result = GEOSrelateOverlaps(g1,g2);
+ GEOSdeleteGeometry(g1);
+ GEOSdeleteGeometry(g2);
if (result == 2)
{
elog(ERROR,"GEOS overlaps() threw an error!");
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
+
+
+ result = GEOSrelateContains(g1,g2);
GEOSdeleteGeometry(g1);
GEOSdeleteGeometry(g2);
- result = GEOSrelateContains(g1,g2);
if (result == 2)
{
elog(ERROR,"GEOS contains() threw an error!");
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
+
+ result = GEOSrelateWithin(g1,g2);
GEOSdeleteGeometry(g1);
GEOSdeleteGeometry(g2);
- result = GEOSrelateWithin(g1,g2);
+
if (result == 2)
{
elog(ERROR,"GEOS within() threw an error!");
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
+
+
+ result = GEOSrelateCrosses(g1,g2);
+
GEOSdeleteGeometry(g1);
GEOSdeleteGeometry(g2);
- result = GEOSrelateCrosses(g1,g2);
if (result == 2)
{
elog(ERROR,"GEOS crosses() threw an error!");
GEOMETRY *geom1 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
GEOMETRY *geom2 = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-
Geometry *g1,*g2;
bool result;
+
+
+
errorIfGeometryCollection(geom1,geom2);
initGEOS(MAXIMUM_ALIGNOF);
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
- GEOSdeleteGeometry(g1);
- GEOSdeleteGeometry(g2);
+
result = GEOSrelateIntersects(g1,g2);
+ GEOSdeleteGeometry(g1);
+ GEOSdeleteGeometry(g2);
if (result == 2)
{
elog(ERROR,"GEOS intersects() threw an error!");
g1 = POSTGIS2GEOS(geom1 );
g2 = POSTGIS2GEOS(geom2 );
+
+
+ result = GEOSrelateTouches(g1,g2);
+
GEOSdeleteGeometry(g1);
GEOSdeleteGeometry(g2);
- result = GEOSrelateTouches(g1,g2);
if (result == 2)
{
elog(ERROR,"GEOS touches() threw an error!");
void GEOSdeleteGeometry(Geometry *a)
{
try{
- //
+ delete a;
}
catch(...)
{
*
* This is free software; you can redistribute and/or modify it under
* the terms of hte GNU General Public Licence. See the COPYING file.
- *
+ *
**********************************************************************
* $Log$
+ * Revision 1.14 2003/09/16 20:27:12 dblasby
+ * added ability to delete geometries.
+ *
* Revision 1.13 2003/07/01 18:30:55 pramsey
* Added CVS revision headers.
*
}
-//tranform_geom( GEOMETRY, TEXT (input proj4), TEXT (input proj4), INT (output srid)
+//tranform_geom( GEOMETRY, TEXT (input proj4), TEXT (output proj4), INT (output srid)
// tmpPts - if there is a nadgrid error (-38), we re-try the transform on a copy of points. The transformed points
// are in an indeterminate state after the -38 error is thrown.
PG_FUNCTION_INFO_V1(transform_geom);
Datum transform_geom(PG_FUNCTION_ARGS)
{
- GEOMETRY *geom = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ GEOMETRY *geom ;
GEOMETRY *result;
PJ *input_pj,*output_pj;
- text *input_proj4_text = (PG_GETARG_TEXT_P(1));
- text *output_proj4_text = (PG_GETARG_TEXT_P(2));
- int32 result_srid = PG_GETARG_INT32(3);
+ text *input_proj4_text;
+ text *output_proj4_text;
+ int32 result_srid ;
+
+
+ geom = (GEOMETRY *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ input_proj4_text = (PG_GETARG_TEXT_P(1));
+ output_proj4_text = (PG_GETARG_TEXT_P(2));
+ result_srid = PG_GETARG_INT32(3);
+
input_proj4 = (char *) palloc(input_proj4_text->vl_len +1-4);
memcpy(input_proj4,input_proj4_text->vl_dat, input_proj4_text->vl_len-4);
input_proj4[input_proj4_text->vl_len-4] = 0; //null terminate
+
output_proj4 = (char *) palloc(output_proj4_text->vl_len +1-4);
memcpy(output_proj4,output_proj4_text->vl_dat, output_proj4_text->vl_len-4);
output_proj4[output_proj4_text->vl_len-4] = 0; //null terminate