[mapserver-users] Expressions
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Sep 29 10:50:49 PDT 2010
First lets get rid of the parameter substitution to make sure we have a
syntax correct. So in your mapfile try:
EXPRESSION ([IncidentDa] > 20100816)
I set this to Aug 16th to see if you can pull any records. Also because
this is numeric, I removed the quotes. You can also try it with quotes
to see what works.
If this works then try:
EXPRESSION ([IncidentDa] > %LASTTWOWEEKS%)
Again without the quotes or with depending on what worked.
-Steve W
On 9/29/2010 11:49 AM, Jay Kapalczynski wrote:
> I thank you for your response....greatly appreciated as I cannot figure
> this out....
>
> I know that I have 4 features in the dataset that have a value of
> 20100916 that’s 13 days ago....so with the expression below those 4 or 5
> features should show up....but nothing shows up
>
> IncidentDa is the field (long integer)
>
> Param type is specifying YYYYMMDD my data has values of 20100916 (13 days)
>
> I have no idea what could be wrong…Thank you all for your help….
>
> *.XML file*
>
> <map-source name="Burglaries" type="mapserver">
>
> <file>./maple_grove_datasets/police/Burglaries.map</file>
>
> <param type="today" offset="-90" name="LASTNINTY" format="%4Y%2M%2D" />
>
> <param type="today" offset="-30" name="LASTTHIRTY" format="%4Y%2M%2D" />
>
> * <param type="today" offset="-14" name="LASTTWOWEEKS"
> format="%4Y%2M%2D" />*
>
> * <param type="today" offset="-7" name="LASTWEEK" format="%4Y%2M%2D" />*
>
> <param type="today" offset="0" name="TODAY" format="%4Y%2M%2D" />
>
> <layer name="Burglaries"/>
>
> </map-source>
>
> *.MAP file*
>
> CLASS
>
> NAME 'Last Weeks'
>
> EXPRESSION ('[IncidentDa]' > '%LASTTWOWEEKS%' && '[IncidentDa]' <
> '%LASTWEEK%')
>
> STYLE
>
> COLOR 0 100 50
>
> SYMBOL "bike"
>
> SIZE 12
>
> END
>
> END
>
> =======================================
>
> BUT if I simply place this in there I get all the points…so something is
> weird here because most of the dates are older than 7 days.
>
> CLASS
>
> NAME 'Last Weeks'
>
> EXPRESSION ('[IncidentDa]' > '%LASTWEEK%’)
>
> STYLE
>
> COLOR 0 0 0
>
> SYMBOL "tent"
>
> SIZE 12
>
> END
>
> #END
>
> -----Original Message-----
> From: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Stephen
> Woodbridge
> Sent: Wednesday, September 29, 2010 8:19 AM
> To: mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] Expressions
>
> In EXPRESSIONS you can evaluate any of the following:
>
> 1. Regular expressions treating the value as a string
>
> 2. numeric expressions using booleans like ==,<,>,<=,>=
>
> 3. string expressions like ==, !=, and I think strlen()
>
> So if you converted you dates into a format like YYYYMMDD then it would
>
> be easy to use a numeric expression like:
>
> EXPRESSION ('[dateValues]' > '%STARTDATE%' && '[dateValues]' < '%ENDDATE%')
>
> or
>
> EXPRESSION ('[dateValues]' > '%STARTDATE%')
>
> where STARTDATE is the YYYYMMDD value of two weeks ago and ENDDATE would
>
> be in the same format and allow you to extract record betwee any two
>
> start and end dates.
>
> Or you might be able to figure out a complex regular expression the
>
> represents the last two weeks like:
>
> EXPRESSION ('[dateValues]' =~ '/%LASTTWOWEEKS%/')
>
> I'm not sure what you would need for the regular expression.
>
> -Steve W
>
> On 9/28/2010 4:23 PM, Jay Kapalczynski wrote:
>
> > Anyone have anymore ideas about this….
>
> >
>
> > I have a string field with values
>
> >
>
> > And the code below. The expression does not seem to be running…if I only
>
> > use LASTTWOWEEKS it still draws all the points….and I know there are
>
> > values in there from 2008
>
> >
>
> > Thanks
>
> >
>
> > *From:* mapserver-users-bounces at lists.osgeo.org
>
> > [mailto:mapserver-users-bounces at lists.osgeo.org] *On Behalf Of *Jay
>
> > Kapalczynski
>
> > *Sent:* Tuesday, September 21, 2010 9:51 AM
>
> > *To:* 'Bob Basques'; mapserver-users at lists.osgeo.org
>
> > *Subject:* RE: [mapserver-users] Expressions
>
> >
>
> > My major question is can I do this with a String/text field? Its the
>
> > only way I can see keeping things in a %2Y%2M%2D format ex. 092110 (Sept
>
> > 21^st 2010), otherwise the 0 will get removed in a numeric field
>
> >
>
> > Can I use the format Year, Month, Day? Or do I have to use Month,
> Day, Year?
>
> >
>
> > In this example I eliminated two expressions and focused on one
>
> > Expression to see if it is working.
>
> >
>
> > *_I kept this_*
>
> >
>
> > <map-source name="Burglaries" type="mapserver">
>
> >
>
> > <file>./maple_grove_datasets/police/Burglaries.map</file>
>
> >
>
> > <param type="today" offset="-7" name="LASTWEEK" format="%2Y%2M%2D" />
>
> >
>
> > <param type="today" offset="-14" name="LASTTWOWEEKS"
> format="%2Y%2M%2D" />
>
> >
>
> > <param type="today" offset="-30" name="LASTTHIRTY" format="%2Y%2M%2D" />
>
> >
>
> > <param type="today" offset="-90" name="LASTNINTY" format="%2Y%2M%2D" />
>
> >
>
> > <layer name="Burglaries"/>
>
> >
>
> > </map-source>
>
> >
>
> > *_In my map file I used _**_ONLY_**_ this_*
>
> >
>
> > CLASS
>
> >
>
> > NAME 'Last Weeks'
>
> >
>
> > EXPRESSION ('[dateValues]' > '%LASTTWOWEEKS%')
>
> >
>
> > STYLE
>
> >
>
> > COLOR 0 100 50
>
> >
>
> > SYMBOL "bike"
>
> >
>
> > SIZE 12
>
> >
>
> > END
>
> >
>
> > END
>
> >
>
> > Now in my data I have these values (below), although every symbol was
>
> > displayed in the map
>
> >
>
> > NOTE THIS IS A TEXT FIELD
>
> >
>
> > 081204, 081225,090118
>
> >
>
> > These values (above) for the Year, Month, Day format specified in the
>
> > map source are clearly less than the “last two weeks”, Where as they are
>
> > older than the last 14 days….so none of them should show up, but they do
>
> >
>
> > Any thoughts
>
> >
>
> > *From:* mapserver-users-bounces at lists.osgeo.org
>
> > [mailto:mapserver-users-bounces at lists.osgeo.org] *On Behalf Of *Bob
> Basques
>
> > *Sent:* Friday, September 17, 2010 9:25 PM
>
> > *To:* mapserver-users at lists.osgeo.org
>
> > *Subject:* Re: [mapserver-users] Expressions
>
> >
>
> > A first stab at seeing more than one class, might be to try and switch
>
> > them around order wise, one filter may be overwriting the other for
> example.
>
> >
>
> > bobb
>
> >
>
> >
>
> >
>
> >
>
> > On 9/17/2010 8:20 AM, Jay Kapalczynski wrote:
>
> >
>
> > I am using GeoMoose but feel this is more a question for Map Server.
>
> >
>
> > I am trying to sort my points by dates using the code below….I think
>
> > that I can do this but not sure
>
> >
>
> > Is this a viable format “2Y%2M%2D” ?
>
> >
>
> > As for the field in the shapefile…If I use an integer it removes the 0
>
> > from the 092110, (sept 21^st 2010)
>
> >
>
> > If I use a date then there are “/” … 9/21/10
>
> >
>
> > The only way I can see this happening is using a text field with retains
>
> > the 0 in 092110
>
> >
>
> > When I use the textfield “dateValues” as seen below I can get the stars
>
> > to draw but only the LASTWEEK…for some reason the LASTTWOWEEKS does not
>
> > show and I know that I have a few records with dates in the last 14 days…
>
> >
>
> > Thoughts?
>
> >
>
> > THANKS….all your help is very appreciated….
>
> >
>
> > Main .xml file
>
> >
>
> > <map-source name="Burglaries" type="mapserver">
>
> >
>
> > <file>./maple_grove_datasets/police/Burglaries.map</file>
>
> >
>
> > <param type="today" offset="-7" name="LASTWEEK" format="%2Y%2M%2D" />
>
> >
>
> > <param type="today" offset="-14" name="LASTTWOWEEKS"
> format="%2Y%2M%2D" />
>
> >
>
> > <param type="today" offset="-30" name="LASTTHIRTY" format="%2Y%2M%2D" />
>
> >
>
> > <param type="today" offset="-90" name="LASTNINTY" format="%2Y%2M%2D" />
>
> >
>
> > <layer name="Burglaries"/>
>
> >
>
> > </map-source>
>
> >
>
> > .map file
>
> >
>
> > CLASS
>
> >
>
> > NAME 'Last Weeks'
>
> >
>
> > EXPRESSION ('[dateValues]' > '%LASTWEEK%')
>
> >
>
> > STYLE
>
> >
>
> > COLOR 0 0 0
>
> >
>
> > SYMBOL "star"
>
> >
>
> > SIZE 12
>
> >
>
> > END
>
> >
>
> > END
>
> >
>
> > CLASS
>
> >
>
> > NAME 'Last Two Weeks'
>
> >
>
> > EXPRESSION ('[dateValues]' > '%LASTTWOWEEKS%')
>
> >
>
> > STYLE
>
> >
>
> > COLOR 0 100 50
>
> >
>
> > SYMBOL "star"
>
> >
>
> > SIZE 12
>
> >
>
> > END
>
> >
>
> > END
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > _______________________________________________
>
> >
>
> > mapserver-users mailing list
>
> >
>
> > mapserver-users at lists.osgeo.org <mailto: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
>
> _______________________________________________
>
> mapserver-users mailing list
>
> mapserver-users at lists.osgeo.org
>
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list