Page 2 of 2

Re: Limiting polygons from a shapefile

Posted: Thu Jul 30, 2009 7:02 pm
by 10549917
Please try something like the following

Code: Select all

var
  MapFieldName, MapValueFieldName : string;
  tmpshp, tmp, tmpdbf : string;
  Series3, Series4 : TMapSeries;
begin
  dmPGC.adocPG.Connected := false;
  dmPGC.qAllPolygons.Close;
  dmPGC.cdsAllPolygons.Open;

  DBcPlates.View3D := false;
  DBChart1.View3D := false;

  Series3 := TMapSeries.Create(self);
  DBcPlates.AddSeries(Series3);
  Series4 := TMapSeries.Create(self);
  DBChart1.AddSeries(Series4);

  tmp := 'c:/Program Files/EIMT/Paleogis/beTestPolygons';
  tmpshp := tmp + '.SHP';
  tmpdbf := tmp + '.DBF';
  MapFieldName := 'PLATEID';
  MapValueFieldName := 'OBJECTID';
  try
    LoadMap(Series1,tmpshp,dmPGC.cdsAllPolygons,MapFieldName,MapValueFieldName,true);
    LoadMap(MapSeries1,tmpshp,dmPGC.Table1,MapFieldName,MapValueFieldName,true);
    LoadMap(Series3,tmpshp,dmPGC.cdsAllPolygons,MapFieldName,MapValueFieldName,true);
    LoadMap(Series4,tmpshp,dmPGC.cdsAllPolygons,MapFieldName,MapValueFieldName,true);
  finally
  end;
  Series1.ColorEachPoint := true;
  ChartGrid1.Repaint;
  MapSeries1.ColorEachPoint := true;
  ChartGrid2.Repaint;
  Series3.ColorEachPoint := true;
  ChartGrid1.Repaint;
  Series4.ColorEachPoint := true;
  ChartGrid2.Repaint;

In this case I have a project with two DBcharts and two chartgrids, predefined to have one mapseries each. I have also tried to create an additional two mapseries at runtime in case this influences things but it does not.

Load the shapefile infromation from some source (mine is an ADO table but should not matter) and have alook at the Text and Value fields in the chartgrids. Note that only the first series loaded has the correct information whereas all subsequent loads have the same contents in these fields, repeated for each row in the chartgrid. All series ought to have Text and Value contents like the first one.

In all cases, the actual polygons shown are correct (with the exception of the 2nd and 3rd rows being the same) but the Text and Value fields hold incorrect contents. Only when these fields have the correct contents can one iterate through and switch off (hide) individual shape polygons.

I hope this makes sense and that you can replicate.

Regards
Bruce

Re: Limiting polygons from a shapefile

Posted: Fri Jul 31, 2009 11:36 am
by yeray
Hi Bruce,

After each LoadMap call, the RecNo of your cdsAllPolygons ClientDataSet is pointing to the last position of the data so the following solves this:

Code: Select all

dmPGC.cdsAllPolygons.RecNo := 1;

Re: Limiting polygons from a shapefile

Posted: Tue Aug 04, 2009 4:13 pm
by 10549917
Thanks.

Bruce