Proposed RFC on COLORRAMP Support (Bug 13 05)

Bill Binko bill at BINKO.NET
Tue Sep 27 17:29:41 EDT 2005


Steve,

When you say, "You don't know how many breaks", perhaps I'm 
misunderstanding you.  How do you get the break values into %breaks%?  I 
was under the assumption that someone was choosing a drop-down that had 
strings with the breaks in them.  Certainly if that's the case, you know 
how many there are at runtime.

I know you don't like this answer, but this also seems to be easily doable
in Mapscript.

As for you idea of making this a "discrete" METHOD, I am OK with that.  In 
fact, the INTERVALS keyword could be reused as follows:

COLORRANGE
  ...
  METHOD 'linear'
  INTERVALS 10 #10 equals partitions
END

COLORRANGE
  ...
  METHOD 'discrete'
  INTERVALS 0 10 25 50 75 100 #exact value boundaries
END

If that were the case, this would not conflict with the other discussions 
we're having about where these things lived.

Bill

On Tue, 27 Sep 2005, Stephen Woodbridge wrote:

> Bill,
> 
> Your example below works fine if you know the number of breaks ahead of 
> time, the big problem is that you do not. If you want to export a 
> control to the user to select the number of class breaks and then that 
> is applied to a classification algorithm which may return less than the 
> number requested, there is no way to deal with that under you scheme 
> that I can see.
> 
> Personally, I would like to move away from defining lots of classes for 
> this. The example mapfile was just how I had to do it now given the 
> tools that were available. If you classify into say 5 breaks and use the 
> ten classes I have defined you only get half way up the ramp or you have 
> to define multiple LAYER blocks each with a different number of breaks 
> and then turn on only the lay with the correct number of breaks, which 
> is kind of crazy.
> 
> I guess in general the big difference is whether you need to work with 
> continuous gradient ramps or discrete step ramps, with a variable number 
> of steps. In discrete steps each step has a value range and distribution 
> does not need to be linear.
> 
> You have spec'd a continuous value ramp, and forcing values into integer 
> step gets you part of the way there at the cost of the values. If you 
> implemented what you have spec'd and added the RAMPBREAKS or whatever as 
> an option all you would do code wise if convert the value to a integer 
> for your continuous ramp using a loop on the RAMPBREAKS and generate a 
> different styled legend maybe similar to my example in html. If the 
> RAMPBREAKS is absent then it is a continuous ramp. Maybe this should be 
> METHOD 'Discrete'.
> 
> -Steve W.
> 
> Bill Binko wrote:
> > Stephen, I thought your example would be a good test case to show how you 
> > would get what you wanted using the ColorRamp as defined in the RFC.  
> > I'm sure it's not 100% what you'd like, but it's fairly close.  
> > 
> > It does make an assumption that the %% substitution works everywhere, and 
> > I'll make sure to add that to the RFC.  It also produces a legend that is 
> > a bit different from yours, in that it puts the demographic name on the 
> > first class, and then just the high/low values in the graded color bar 
> > (see http://mapserver.gis.umn.edu/bugs/attachment.cgi?id=324&action=view )
> > 
> > Please use this as a starting point, and explain what won't work.  There 
> > may very well be some additional work on the legends that is needed, but I 
> > think the general need you're expressing is addressed.
> > 
> > Bill
> > 
> >   LAYER
> >     NAME "zcta_thematic"
> >     CONNECTIONTYPE postgis
> >     CONNECTION "host=linus port=5432 dbname=census user=pgsql"
> >     DATA "the_geom from (SELECT c.gid, c.the_geom, c.water, a.%demographic% as demog from %table% a, 
> >           sf3geo_zcta5 b, zcta c where c.state='%state%' and c.name=b.zcta5 and 
> >           a.stusab=b.stusab and a.logrecno=b.logrecno and b.stusab='%state%' and 
> >           b.sumlev='871'  ) as foo using srid=4326 using unique gid"
> >     TYPE POLYGON
> >     STATUS ON
> >     PROJECTION
> >       #"proj=latlong"
> >       "init=epsg:4326"
> >     END
> >     CLASSITEM "water"
> >     CLASS
> >       NAME "Water"
> >       EXPRESSION "t"
> >       OUTLINECOLOR 102 102 204
> >       COLOR 102 102 204
> >     END
> >     CLASS
> >       NAME "%demog%"
> >       EXPRESSION ([demog] > %break0% && [demog] <= %break1%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 102 102 102
> > 	MAXCOLOR 0 204 0
> > 	MINVALUE %break0%
> > 	MAXVALUE %break1%
> > 	RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break1% && [demog] <= %break2%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 0 204 0
> >         MAXCOLOR 51 255 51
> >         MINVALUE %break1%
> >         MAXVALUE %break2%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break2% && [demog] <= %break3%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 0 204 0
> > 	MAXCOLOR 102 255 102
> >         MINVALUE %break2%
> >         MAXVALUE %break3%
> >         RANGEITEM 'demog'
> >       END
> >     END      
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break3% && [demog] <= %break4%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 102 255 102
> > 	MAXCOLOR 153 255 153
> >         MINVALUE %break3%
> >         MAXVALUE %break4%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break4% && [demog] <= %break5%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 153 255 153
> > 	MAXCOLOR 204 255 204
> >         MINVALUE %break4%
> >         MAXVALUE %break5%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break5% && [demog] <= %break6%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 204 255 204
> >         MAXCOLOR 255 294 294
> >         MINVALUE %break5%
> >         MAXVALUE %break6%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break6% && [demog] <= %break7%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 255 294 294
> > 	MAXCOLOR 255 153 153
> >         MINVALUE %break6%
> >         MAXVALUE %break7%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break7% && [demog] <= %break8%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 255 153 153
> >         MAXCOLOR 255 102 102
> >         MINVALUE %break7%
> >         MAXVALUE %break8%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break8% && [demog] <= %break9%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 255 102 102 
> >         MAXCOLOR 255 51 51
> >         MINVALUE %break8%
> >         MAXVALUE %break9%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >     CLASS
> >       NAME " "
> >       EXPRESSION ([demog] > %break9% && [demog] <= %break10%)
> >       OUTLINECOLOR 0 0 0
> >       COLORRANGE
> >         MINCOLOR 255 51 51
> >         MAXCOLOR 255 0 0
> >         MINVALUE %break9%
> >         MAXVALUE %break10%
> >         RANGEITEM 'demog'
> >       END
> >     END
> >   END
> > 
> 
> 
> 



More information about the mapserver-dev mailing list