Shapefile field problem
Jeff McKenna
jmckenna at DMSOLUTIONS.CA
Tue Dec 7 11:15:59 PST 2004
Abe,
I made a tiny mapfile with your test shp, and i see labels properly in
MapServer with it. I added an attribute in the "OWNERS_NAM" field and I
successfully displayed it in mapserver. Am i misunderstanding your
problem somehow? (mapfile below)
jeff
MAP
NAME "field-test"
STATUS ON
EXTENT 1260565.500000 941362.000000 1261605.125000 942198.625000
SIZE 400 300
SHAPEPATH "D:/DMSG/projects/mapserver-bugs/"
SYMBOLSET "../etc/symbols.sym"
FONTSET "../etc/fonts.txt"
IMAGETYPE gif
IMAGECOLOR 255 255 255
UNITS METERS
WEB
IMAGEPATH "/ms4w/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
METADATA
END
END
OUTPUTFORMAT
NAME "gif"
MIMETYPE "image/gif"
DRIVER "GD/GIF"
EXTENSION "gif"
IMAGEMODE PC256
TRANSPARENT FALSE
END
LAYER
NAME test
TYPE POLYGON
STATUS ON
DATA test
LabelItem "OWNERS_NAM"
CLASS
NAME "ttt"
COLOR 0 255 0
LABEL
COLOR 255 0 0
FONT fritqat-italic
TYPE truetype
SIZE 8
POSITION AUTO
PARTIALS FALSE
OUTLINECOLOR 255 255 255
END
END
END # Layer
END
Abe Gillespie wrote:
> I do appreciate the help, but I'm not looking for an "external to
> MapServer" way of getting access to my DBF field values. I just use my
> PHP script to *reveal* problematic shapefile fields. When there is a
> problem it's unusable to MapServer! I.e.: I can't use the field for
> labelling.
>
> -Abe
>
> On Dec 7, 2004, at 11:27 AM, Ryan, Adam wrote:
>
>> Abe,
>>
>> Here's a routine I use to get the header information (field info) from
>> a dbf
>> file.
>>
>> // ========== iDbf_fields ==============
>> // $f is a dbf file path, returns an array of field arrays
>> function iDbf_fields($f){
>> $h = fopen($f,"rb");
>> $a =
>> unpack("cversion/cyy/cmm/cdd/inumrecs/sheadsize/
>> srecsize",fread($h,12));
>> fread($h,20); //skip some reserved space
>> for($i=0;$i<($a["headsize"]-33)/32;$i++){
>> $fa = array();
>> $fname = trim(fread($h,11));
>> $fa["type"] = fread($h,1);
>> fread($h,4);
>> $fa = array_merge($fa,unpack("Clen/Cpre",fread($h,2)));
>> fread($h,14);
>> $flds[$fname] = $fa;
>> }
>> fclose($h);
>> return $flds;
>> }
>>
>> When I generate a result table I'll go through the array like this:
>> ($so is
>> the shape Object)
>>
>> foreach($flds as $fname => $fA){
>> $val = $so->values[$fname];
>> if ($val==null)$val=" ";
>> $val = str_replace(" ","
>> ",$val);
>> if ($fA["type"]=="D"){$val =
>> substr($val,4,2)."-".substr($val,6,2)."-".substr($val,0,4);}
>> echo "<td>$val</td>";}
>> }
>>
>>
>> Cheers to all,
>>
>> Adam
>>
>>> -----Original Message-----
>>> From: Abe Gillespie [mailto:agillesp at VT.EDU]
>>> Sent: Monday, December 06, 2004 5:14 PM
>>> To: MAPSERVER-USERS at LISTS.UMN.EDU
>>> Subject: Re: [UMN_MAPSERVER-USERS] Shapefile field problem
>>>
>>>
>>> It's a regular shapefile. I think I've mostly narrowed it
>>> down. It seems to me (though I may be completely off) that
>>> MapServer loads the first record of the DBF in order to get
>>> the field definitions. If the first record has a string
>>> field and the value is zero length it won't give me the field
>>> (though the field count is always correct). In addition, it
>>> won't give me any fields after that either. If, however, I
>>> make sure that field has some value (a dash, an "x",
>>> whatever) then the field definition will come in correctly.
>>> I still haven't narrowed down a problematic number field
>>> though. Mind you, this is all done in MapServer PHP v. 4.2.0.
>>>
>>> -Abe
>>>
>>> On Dec 6, 2004, at 6:15 PM, Daniel Morissette wrote:
>>>
>>>> Abe Gillespie wrote:
>>>>
>>>>> A good amount of fields aren't showing up in MapServer for
>>>
>>> me. I use
>>>
>>>>> the following PHP script to dump out all layers and their
>>>
>>> fields for
>>>
>>>>> debugging. Does MapServer have problems with certain data
>>>
>>> types or
>>>
>>>>> certain values in a row?
>>>>>
>>>>
>>>> Are you using a tiled shapefile layer or is this a regular
>>>
>>> shapefile
>>>
>>>> layer?
>>>>
>>>> --
>>>> ------------------------------------------------------------
>>>> Daniel Morissette dmorissette at dmsolutions.ca
>>>> DM Solutions Group http://www.dmsolutions.ca/
>>>> ------------------------------------------------------------
>>>>
>>>
>>
>
--
Jeff McKenna
GIS Specialist
DM Solutions Group Inc.
http://www.dmsolutions.ca
More information about the MapServer-users
mailing list