[Mapserver-users] getting shapes with numeric attributes

eric.belenfant eric.belenfant at ac-orleans-tours.fr
Tue Jul 6 01:04:02 PDT 2004


Hi,

i read the examples in mapserver about how i can have the extent of some 
shapes in a layer.
However, when you use OGR files ( i use MAPINFO) files, the 
queryByAttributes function allows some comparisons on strings but not on 
numbers.
I read that SQL is allowed in the FILTER but only for spatial Databases 
and not for shape files and OGR !!

So, i have some shapes and attrbutes which are numeric.
How could i have the extent of the shapes in order to highlight these 
center on these shapes ???

thanks a lot

the php code

$layer->open();
           $query = 
$layer->queryByAttributes("_".$formation."","(_".$formation.">0)", 
MS_SINGLE);
           $resultat = $layer->getResult(0);
           $shape = $layer->getShape(-1,$resultat->shapeindex);
           $limites = $shape->bounds;
           $map->setextent( $limites->xmin, 
$limites->ymin,$limites->xmax, $limites->ymax);
                     $shape->free();

the .map
MAP
       NAME "Les bts par commune"
       SIZE 500 500
       STATUS ON
       UNITS METERS
       IMAGETYPE PNG
       EXTENT 426931.766796 2149441.377593 659404.715011 2438768.654693
       IMAGECOLOR 255 255 255
       FONTSET "C:/Program 
Files/EasyPHP1-7/www/mapserver/tutorial/fonts/fonts.list"              
SYMBOLSET      "C:/Program 
Files/EasyPHP1-7/www/mapserver/tutorial/symbols/symbols35.sym"

       WEB
       IMAGEPATH "C:/Program Files/EasyPHP1-7/tmp/"
       IMAGEURL "/tmp/"          LOG    "C:/Program 
Files/EasyPHP1-7/www/mapserver/mapserver.log"
       END

       LAYER
           NAME "polygones"
           TYPE POLYGON
           STATUS DEFAULT
           CONNECTIONTYPE OGR
           CONNECTION "C:\Program 
Files\EasyPHP1-7\www\mapserver\data\communes_bts1.TAB"
           TEMPLATE "bidon"
           CLASS
             COLOR 232 232 232
           END              END

       LAYER
           NAME "noms_principaux"
           TYPE POLYGON
           STATUS DEFAULT
           CONNECTIONTYPE OGR
           CONNECTION "C:\Program 
Files\EasyPHP1-7\www\mapserver\data\communes_bts1.TAB"
                     LABELITEM "NOM_COM"

           CLASS
                 COLOR 232 232 232
                 EXPRESSION ('[NOM_COM]' eq 'ORLEANS' OR '[NOM_COM]' eq 
'BLOIS' OR '[NOM_COM]' eq 'TOURS' OR '[NOM_COM]' eq 'BOURGES' OR 
'[NOM_COM]' eq 'CHARTRES' OR '[NOM_COM]' eq 'CHATEAUROUX' )
             LABEL
               COLOR 131 31 31
               SHADOWCOLOR 218 218 218
               SHADOWSIZE 2 2
               TYPE BITMAP
               FONT arial-bold
               SIZE medium
               ANTIALIAS TRUE
               POSITION CC
               PARTIALS FALSE
               MINDISTANCE 300
               BUFFER 4
               FORCE TRUE
             END # end of label
           END
       END

LAYER
           NAME "noms"
           TYPE POLYGON
           STATUS DEFAULT
           CONNECTIONTYPE OGR
           CONNECTION "C:\Program 
Files\EasyPHP1-7\www\mapserver\data\communes_bts1.TAB"
                     LABELITEM "NOM_COM"
           LABELMAXSCALE 1500000

           CLASS
                 COLOR 232 232 232
                 EXPRESSION ('[NOM_COM]' != 'ORLEANS' AND '[NOM_COM]' != 
'BLOIS' AND '[NOM_COM]' != 'TOURS' AND '[NOM_COM]' != 'BOURGES' AND 
'[NOM_COM]' != 'CHARTRES' AND '[NOM_COM]' != 'CHATEAUROUX' )
             LABEL
               COLOR 132 31 31
               SHADOWCOLOR 218 218 218
               SHADOWSIZE 2 2
               TYPE BITMAP
               FONT arial-bold
               SIZE small
               ANTIALIAS TRUE
               POSITION CC
               PARTIALS FALSE
               MINDISTANCE 300
               BUFFER 4
               #FORCE TRUE
             END # end of label
           END
       END
LAYER
           NAME "noms_choisis"
           TYPE POLYGON
           STATUS OFF
           CONNECTIONTYPE OGR
           CONNECTION "C:\Program 
Files\EasyPHP1-7\www\mapserver\data\communes_bts1.TAB"
                     LABELITEM "NOM_COM"
           #LABELMAXSCALE 1500000

           CLASS
                 COLOR 232 232 232
             LABEL
               COLOR 132 31 31
               SHADOWCOLOR 218 218 218
               SHADOWSIZE 2 2
               TYPE BITMAP
               FONT arial-bold
               SIZE small
               ANTIALIAS TRUE
               POSITION CC
               PARTIALS FALSE
               MINDISTANCE 300
               BUFFER 4
               #FORCE TRUE
             END # end of label
           END
       END

       LAYER
       NAME "couche_modele"
           TYPE POLYGON
           STATUS OFF
           CONNECTIONTYPE OGR
           CONNECTION "C:\Program 
Files\EasyPHP1-7\www\mapserver\data\communes_bts1.TAB"
       END
             LAYER
           NAME "lignes"
           TYPE LINE
           STATUS DEFAULT
           CONNECTIONTYPE OGR
           CONNECTION "C:\Program 
Files\EasyPHP1-7\www\mapserver\data\communes_bts1.TAB"
                     CLASS
               COLOR 100 50 200
           END
                 END

REFERENCE
   IMAGE 'images/bts_communes.png'
   SIZE 150 150
   EXTENT 426931.766796 2149441.377593 659404.715011 2438768.654693
   STATUS ON
   MINBOXSIZE 10
   MAXBOXSIZE 80
   COLOR -1 -1 -1
   OUTLINECOLOR 255 0 0
   MARKERSIZE 8
   MARKER 'star'
 END

      END

eric



More information about the MapServer-users mailing list