[mapserver-users] copyright, logos, etc

Eichner, Andreas - SID Andreas.Eichner at sid.sachsen.de
Wed Feb 11 05:32:54 PST 2015


> what I really need to do is to
> make an SQL query (something like select name from map where id=%MYID%)
> and use that attribute in the TEXT part of the FEATURE section (something
> like FEATURE POINTS x y END TEXT "Species name: [name]" END)
> 
> Any idea is welcome on how to do that in the "Mapserver way" ..
> 

I have not test it but I would suggest replacing the inlined feature with a OGR point layer connected to a MYSQL view or a OGR VRT datasource that associates every line with the position of the annotation.

1) MYSQL view:
CREATE OR REPLACE VIEW species_annotation AS SELECT id, GeomFromText('POINT(60 -10)') AS Shape, name FROM map;

LAYER
...

#  FEATURE
#    POINTS
#      60 -10    # the offset (from lower left) in pixels
#    END # Points
#    TEXT "© xyz company 2006"  # this is your displaying text
#  END # Feature
  CONNECTIONTYPE ogr
  CONNECTION 'MYSQL: ...'
  DATA 'species_annotation'
  LABELITEM 'name'
  FILTER ([id]=%MYID%)

...
END # Layer


2) OGR VRT datasource:
In species_annotation.vrt:
<OGRVRTDataSource>
    <OGRVRTLayer name="species_annotation">
        <SrcDataSource>MYSQL: ...</SrcDataSource>
        <SrcSQL>SELECT id, 60 as x, -10 as y, name FROM map</SrcSQL>
        <FID>id</FID>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>NULL</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="x" y="y" reportSrcColumn="false" />
    </OGRVRTLayer>
</OGRVRTDataSource>

Test with: ogrinfo -al species_annotation.vrt -fid <existing id>


LAYER
...
  CONNECTIONTYPE ogr
  CONNECTION 'species_annotation.vrt'
  DATA 'species_annotation'
  LABELITEM 'name'
  FILTER ([id] = %MYID%)
...
END # Layer


HTH


More information about the mapserver-users mailing list