Opened 19 years ago
Last modified 15 years ago
#1268 new enhancement
support for MIN/MAX functions
Reported by: | Owned by: | mapserverbugs | |
---|---|---|---|
Priority: | high | Milestone: | FUTURE |
Component: | WFS Server | Version: | 4.4 |
Severity: | minor | Keywords: | |
Cc: | tomkralidis |
Description
Bart's right, file an enhancement request. This could be quite an expensive computation for most datasources. One approach would be to develop a layer "item stats" file that could be used to hold such information, and then write a small program to build the file (much like shptree). Could store min/max, distinct value list and other things. A naming convention like "layername.column.stat" might work nicely. Then when a layer is opened it's stat(s) files could be opened if necessary. Just thinking out loud... Steve >>> Bart van den Eijnden <bartvde@XS4ALL.NL> 3/2/2005 3:59:16 AM >>> Hi, you could go and talk to the uDig people (udig.refractions.net), they must have encountered the same problem and maybe found a workaround. In the meantime, maybe it is wise to file an enhancement bug for Mapserver WFS for support of min/max functions. Best regards, Bart > Hi, > > My working group are thinking about how can one independent application > that use WFS, WMS SLD and Filter encoding, create SLD to define Styles in > similar manner that GIS desktop software do it. If one user need define > regular intervals from one feature attribute, application need known Max & Min > values of attribute. > We have revised filter encoding specification (OGC) and this operation are > enumerated as possible, but no open Source WFS implementation include. > > Regards, >
Attachments (1)
Change History (4)
comment:2 by , 16 years ago
Cc: | added |
---|
This would be really cool. Note that Filter allows for advertising your own functions. See http://www.who.int/tools/geoserver/wfs?request=GetCapabilities as an example.
Having said this, there are alot of functions in the example that would work only at runtime. For the approach specified above, stuff like min,max,distinct,count would be useful.
If there is interest here, I will work on this. Perhaps a command line tool "msitemstats.c" to generate a "stats" file, which would then need to be integrated.
comment:3 by , 15 years ago
Bart: attached is a command line utility to read a .dbf file and generate min/max statistics.
To use, apply the following patch:
Index: Makefile.in =================================================================== --- Makefile.in (revision 8778) +++ Makefile.in (working copy) @@ -259,7 +259,7 @@ OBJS= mapgeomtransform.o maprgbapng.o maptemplate.o mapbits.o maphash.o mapshape.o mapxbase.o mapparser.o maplexer.o maptree.o mapsearch.o mapstring.o mapsymbol.o mapfile.o maplegend.o maputil.o mapscale.o mapquery.o maplabel.o maperror.o mapprimitive.o mapproject.o mapraster.o mapsde.o mapogr.o mappostgis.o mapmygis.o maplayer.o mapresample.o mapwms.o mapwmslayer.o maporaclespatial.o mapgml.o mapprojhack.o mapthread.o mapdraw.o mapgd.o mapagg.o mapoutput.o mapgdal.o mapswf.o mapimagemap.o mapows.o mapwfs.o mapwfs11.o mapwfslayer.o mapcontext.o maphttp.o mapdrawgdal.o mappdf.o mapjoin.o mapgraticule.o mapcopy.o mapogcfilter.o mapogcsld.o maptime.o mapwcs.o mapwcs11.o mapcpl.o cgiutil.o maprasterquery.o mapobject.o mapgeos.o classobject.o layerobject.o mapio.o mappool.o mapsvg.o mapregex.o mappluginlayer.o mapogcsos.o mappostgresql.o mapcrypto.o mapowscommon.o maplibxml2.o mapdebug.o mapchart.o maptclutf.o $(EPPL_OBJ) $(AGG_FT_OBJ) EXE_LIST = shp2img shp2pdf legend mapserv shptree shptreevis \ - shptreetst scalebar sortshp mapscriptvars tile4ms \ + shptreetst scalebar sortshp msitemstats mapscriptvars tile4ms \ msencrypt mapserver-config # @@ -348,6 +348,9 @@ sortshp: sortshp.o $(LD) $(CFLAGS) sortshp.o $(EXE_LDFLAGS) -o sortshp +msitemstats: msitemstats.o + $(LD) $(CFLAGS) msitemstats.o $(EXE_LDFLAGS) -o msitemstats + tile4ms: tile4ms.o $(LD) $(CFLAGS) tile4ms.o $(EXE_LDFLAGS) -o tile4ms
Drop the attached file in trunk and build. This will create a msitemstats util which will output an ancillary .dbf.
Notes:
- if string types are used for numerical values, results may be dubious
- if the use case would be a custom OGC filter which asks for min or max of a given column, we would have to:
- advertise the function in Capabilities, i.e.:
<ogc:ArithmeticOperators> <ogc:Functions> <ogc:FunctionNames> <ogc:FunctionName nArgs="0">min</ogc:FunctionName> <ogc:FunctionName nArgs="0">max</ogc:FunctionName> </ogc:FunctionNames> </ogc:Functions>
- handle GetFeature with Filter like:
<ogc:Filter> <ogc:PropertyIsEqualTo> <ogc:Function name="min"> <ogc:PropertyName>itemname</ogc:PropertyName> </ogc:Function> </ogc:PropertyIsEqualTo> </ogc:Filter>
- the code would open the stats file, and search the "item" column for the value equal to ogc:PropertyName, and return min or max accordingly
- of course, the stats file would have to be declared in the mapfile with something like:
LAYER DATA "foo.shp" STATS "foo.stats.dbf" ... END
- it would be valuable to extend the attachment for more than just .dbf's. Maybe a utility to read a mapfile and operate on a given vector layer
Thoughts?