[mapserver-users] Using a attribute substring for labeling

Richard Greenwood richard.greenwood at gmail.com
Mon Feb 29 18:43:34 PST 2016


Probably not the direction you want to go, but if you did it as a WFS, or
other client-side vector layer, you could process the text in the browser
with JavaScript, at least in OpenLayers.

On Mon, Feb 29, 2016 at 10:30 AM, Lime, Steve D (MNIT) <
Steve.Lime at state.mn.us> wrote:

> Jeff's suggestion is a good one. There's no way to do that using text
> expressions - you can concatenate and do simple transformations (e.g.
> toupper) but there is no substring operator. Would be a nice addition...
> --Steve
>
> -----Original Message-----
> From: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] On
> Behalf Of Jeff McKenna
> Sent: Monday, February 29, 2016 7:28 AM
> To: mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] Using a attribute substring for labeling
>
> On 2016-02-29 9:02 AM, lars lingner wrote:
> > Hello,
> >
> > while using a ShapeFile, created with gdaltindex, as data source for a
> > layer I'd like to use a substring of the location attribute for labeling.
> >
> > I could (and probably will) preprocess the ShapeFile to add the label
> > text as additional attribute. But I wanted to try this step within
> > MapServer first.
> >
> > My current example contains a path and file name. The file name has a 4
> > digit number in it I would like to use as label. To make it more
> > complicated, the substring has various positions within the whole string.
> > Maybe there is a way with tostring() which accepts sprintf formatting,
> > but I couldn't figure out the correct syntax yet.
> >
> > With a database layer of course I would be able to use SQL to extract a
> > substring and pass it as additional attribute, but not with a ShapeFile.
> >
> > Is there a way to extract a substring from an attribute value and use it
> > as label? It would be nice to have a function available to use in
> > EXPRESSION or TEXT parameter.
> >
> > Thank you in advance for any hints.
> >
> > Lars
>
> Hi Lars,
>
> Did you try piping this shapefile layer through an OGR connection
> (CONNECTIONTYPE OGR) and then passing your SQL in the data statement?
> I'd first start at the ogrinfo commandline, and test your SQL there with
> the -sql switch, and then move to the mapfile next.
>
> Otherwise I'd probably need a sample of your data to dive into this.
>
> -jeff
>
>
>
>
>
>
> --
> Jeff McKenna
> MapServer Consulting and Training Services
> http://www.gatewaygeomatics.com/
>
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>



-- 
Richard W. Greenwood, PLS
www.greenwoodmap.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20160229/e754f930/attachment.htm>


More information about the MapServer-users mailing list