Using expressions Mapscript, attribute not found in shapefile

Gregor Mosheh gregor at HOSTGIS.COM
Sat Oct 7 12:55:25 EDT 2006


I'm pulling in a mapfile, then dynamically setting the DATA variable for a
layer to a shapefile which was generated on the fly. The PHP/Mapscript for
the layer is as follows:

   // grab the points layer and tweak it
   $points_datasource = $TEMPDIR.'/points_'.$_REQUEST['sessionid'].'.shp';
   $layer = $map->getLayerByName('points');
   $layer->set('data',$tracks_datasource);
   $layer->set('status',MS_ON);

The layer from the mapfile is as follows:
(the other classes omitted, for brevity)

LAYER
  NAME "points"
  TYPE point
  STATUS off
  DATA ""

  #CLASSITEM "DIRECTION"
  CLASS
    STYLE
      COLOR 0 0 255
      SIZE 6
      SYMBOL "point_circle"
    END
  END
END


So, the Mapscript populates the DATA part, then sets STATUS ON -- ta da!
This all works well and fine... until I uncomment the CLASSITEM declaration.
I then find this in the error_log and things stop working:

PHP Warning:  [MapServer Error]: msDBFGetItemIndex(): Item 'DIRECTION' not
found.


I've verified that it's setting $points_datasource properly (that's what I
ran ogrinfo on) and I'm sure that the shapefile has a DIRECTION attribute:

Layer name: points_0353ab4cbed5beae847a7ff6e220b5cf
Geometry: Point
Feature Count: 11
Extent: (-111.590177, 35.221856) - (-111.586098, 35.223218)
Layer SRS WKT:
(unknown)
POINTID: Real (11.0)
DIRECTION: String (80.0)
OGRFeature(points_0353ab4cbed5beae847a7ff6e220b5cf):0
  POINTID (Real) =         365
  DIRECTION (String) = W
  POINT (-111.586500999999998 35.222957)

(more features listed, but omitted for brevity)


Hardcoding the path to the shapefile and changing status to on allows me
to use shp2img, and that works just fine, classifying the shapes and all.
However, PHP/Mapscript still complains that there is no DIRECTION
attribute.

Any ideas?


-- 
HostGIS
Cartographic development and hosting services
707-822-9355
http://www.HostGIS.com/



More information about the mapserver-users mailing list