Page 1 of 1

map series does not adjust to new Z values

Posted: Fri Mar 21, 2008 8:45 pm
by 9340301
I am trying to write a GIS application, and am able to initialize my map by

1. clearing the sample shapes
2. adding a shape for each county and associating a Z value with it
3. calling ClearPalette and CreateRangePalette

And I end up with a nice map, where each county is color-coded according to its Z value, and the legend matches up with those Z values.

However, if I try to change what is plotted by

1. clicking on a radio button
2. calling an update function
3. going through the existing shapes county by county and changing the Z values
4. calling ClearPalette and CreateRangePalette

the plot does not adjust to the new Z values. For example, the initial variable that gets plotted has a maximum value of 466,700. When I try to switch to plotting a percentage, the new Z values are indeed between 0 and 100, but my palette/legend does not change, and calling MaxZValue still returns 466,700. The resulting plot is all one color, since the original palette called for painting all shapes with Z values smaller than 22,223 white, and of course ALL of the percentages fit this category.

I've looked around for the right function to call to get my map series object to recalculate the palette/legend, but without any luck. Any suggestions?

Thanks!

P.S. In case it helps, here is my update function:

Code: Select all

procedure TTfrmMain.updatePlot();
var
  i, j, yr, plotType, eInd: Integer;
  yrFile: file of WheatData;
  pgon: Polygon;
  wheatEntry: WheatData;
  maxZ: Double;
begin
  // determine year
  yr := StrToInt(cbPlotYear.Items[cbPlotYear.ItemIndex]) - 1900;
  msUSWheat.Title := Concat('Wheat Data 19',IntToStr(yr));
  try
    // open yrFile
    AssignFile(yrFile,Concat('gis_data\wheat_19',IntToStr(yr),'.dat'));
    Reset(yrFile);
    // determine plotType
    plotType := rgPlotType.ItemIndex;
    // go through polygon by polygon
    i := 0;
    maxZ := 0;
    while not eof(yrFile) do
    begin
      Read(yrFile,wheatEntry);
      for j := 1 to wheatEntry.nParts do
      begin
        if wheatEntry.isData then
        begin
          case plotType of
            0: msUSWheat.Shapes[i].Z := wheatEntry.acresPlanted;
            1: msUSWheat.Shapes[i].Z := wheatEntry.acresHarvested;
            2: msUSWheat.Shapes[i].Z := wheatEntry.percentHarvested;
            3: msUSWheat.Shapes[i].Z := wheatEntry.yieldPerAcre;
            4: msUSWheat.Shapes[i].Z := wheatEntry.totProduction;
          end;
          if msUSWheat.Shapes[i].Z > maxZ then
            maxZ := msUSWheat.Shapes[i].Z;
        end
        else
          msUSWheat.Shapes[i].Z := 0;
        inc(i);
      end;
    end;
    msUSWheat.ClearPalette;
    msUSWheat.CreateRangePalette;
  finally
    CloseFile(yrFile);
  end;
end;

Posted: Tue Apr 01, 2008 2:08 pm
by Pep
Hi nico,

using similar code to the following should be sufficient to update the ZValues and refhresh the Shapes and Legend :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
showmessage( floattostr(Series1.ZValues[0]));
Series1.ZValues[0] := 0.999;
showmessage( floattostr(Series1.ZValues[0]));  // now max is 0.999
Series1.UsePalette := true;
end;

Posted: Tue Apr 01, 2008 8:11 pm
by 9340301
Dear Pep,

My series ZValues are already correct, but the palette does not automatically adjust to these new values. If I don't apply any manual workarounds, then when I go from data between 0 and 720000 to data between 0 and 160, everything gets colored white.

Thanks,
Nico

Posted: Mon Apr 07, 2008 10:08 am
by narcis
Hi Nico,

We haven't been able to reproduce the problem here. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.