[maplab-users] PostGIS 0.7.5 returning '0' for shape indexes

Mike Leahy
Fri, 13 Jun 2003 12:48:58 -0500
Regarding this problem,

There is a post at
tml that indicates this problem can be solved by commenting out a line
in mapquery.c - and the example in the MapServer buglist is pretty much
the same problem I have...but considering the trouble I've gone through
just to compile postgis, I don't think I would have a great deal of luck
trying to compile MapServer & MapScript.  I don't suppose it would be
possible to get and up-to-date MapServer/MapScript w support for PostGIS
compiled with the fix described at the link above?

If not, I'll just continue working with the Multera-build of PostGIS...


-----Original Message-----
[] On Behalf Of Mike Leahy
Sent: June 13, 2003 11:28 AM
Subject: [maplab-users] PostGIS 0.7.5 returning '0' for shape indexes

Now that I have PostGIS 0.7.5 running in the Cygwin environment, the
GMapFactory project I am using is able to display the layers that I have
loaded into the database without any trouble.  However, when I query the
layers, I get the following error from the PHP script:

Fatal error: Assertion failed, Could not set shape values: 0, 0 in
C:\edumap\www\Independencia\wrapper\map_query.php on line 530

Line 530 in this case is labelled below, in the processQuery function.
I think the problem here is that for some reason the query is returning
a bunch of shapes with 0 or null spatial index.  I tried making an if
statement that skips the code in the loop if the spatial index is not
greater than zero, and I just ended up with some other error (i.e.,
there were no results to be displayed).

I'm not sure if this is a problem with the GMapFactory project,
MapScript, or PostGIS.  It seems that for the time being, I'm going to
have to stick with the beta version of PostGIS.  I tried creating
indexes on the GID fields for the spatial tables, but that doesn't seem
to have any affect.

Any suggestions for this one?

Many thanks,


function processQuery( $oLayer )
        // log entry
        $this->logFuncStart( LOG_VERBOSE, "processQuery() starting" );
		// create map object
		$oMap = $this->oSession->oMap;
		// initialize variables
		$axResults = array();
    	// get the number of results
    	$nNumResults = intval($oLayer->getNumResults());
		// return if no results
		if ( $nNumResults < 1 )
          	// log exit
            $this->logFuncEnd( LOG_ALL, "processQuery() done" );
			return "No results found for
		// open the layer to make the shape properties available
		if ( strpos( strtoupper( ms_GetVersion() ), "VERSION
3.6") > 0 )
    		$oLayer->open( $oMap->shapepath );

    	// add element to results array for each result row
	    for ($i=0; $i < $nNumResults; $i++)
            // get next shape row
            $oResult = $oLayer->getResult($i);
 Line 530:  $oShape = $oLayer->getShape($oResult->tileindex,
            // push the row array onto the results array
            $aTmp = $oShape->values;
            $aTmp = array_merge( $aTmp , 
                array("SHAPE_INDEX" => $oResult->shapeindex, 
                      "TILE_INDEX" => $oResult->tileindex, 
                      "LAYER_INDEX" => $oLayer->index ) );
			array_push( $axResults, $aTmp );
		// end for loop   
        // close the layer
				$this->log( LOG_VERBOSE, "Results:
      	// log exit
        $this->logFuncEnd( LOG_ALL, "processQuery() done" );	
		// return the array
		return $axResults;
	// end processQuery function

Maplab-users mailing list

This archive was generated by Pipermail.