[postgis-users] dont_force() and "best_type"

Frank Warmerdam warmerdam at pobox.com
Mon Jun 24 09:00:08 PDT 2002


Folks,

I am trying to use the PostGIS support in MapServer to render annotation
associated with a point layer.  I wasn't getting anything and traced it
to dont_force() returning MS_FAILURE.

It looks like this:

// if there is any polygon in wkb, return force_polygon
// if there is any line in wkb, return force_line
// otherwise return force_point

int 
dont_force(char 
*wkb, shapeObj *shape)
{
	int offset =0;
	int ngeoms ;
	int	type,t;
	int		best_type;
	
//printf("dont force");
	
	best_type = MS_SHAPE_NULL;  //nothing in it
		
	memcpy( &ngeoms, &wkb[5], 4);
	offset = 9;  //were the first geometry is
	for (t=0; t<ngeoms; t++)
	{
		memcpy( &type, &wkb[offset+1], 4);  // type of this geometry

		if (type == 3) //polygon
		{
			best_type = MS_SHAPE_POLYGON;	
		}
		if ( (type ==2) && ( best_type != MS_SHAPE_POLYGON) )
		{
			best_type = MS_SHAPE_LINE;
		}
		if (   (type==1) && (best_type != MS_SHAPE_NULL) )
		{
			best_type = MS_SHAPE_POINT;	
		}
	}

	if (best_type == MS_SHAPE_POINT)
	{
		return force_to_points(wkb,shape);
	}
	if (best_type == MS_SHAPE_LINE)
	{
		return force_to_lines(wkb,shape);
	}
	if (best_type == MS_SHAPE_POLYGON)
	{
		return force_to_polygons(wkb,shape);
	}


	return(MS_FAILURE); //unknown type
}

By patching the "best_type != MS_SHAPE_NULL" to be "best_type == MS_SHAPE_NULL"
I was able to get things working, otherwise with only point geometries the
best_type remained MS_SHAPE_NULL.

Should I apply this patch?  I don't entirely understand what this function
is trying to accomplish.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent






More information about the postgis-users mailing list