Limiting polygons from a shapefile

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Bruce
Newbie
Newbie
Posts: 16
Joined: Mon Aug 18, 2008 12:00 am

Re: Limiting polygons from a shapefile

Post by Bruce » Thu Jul 30, 2009 7:02 pm

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

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Limiting polygons from a shapefile

Post by Yeray » Fri Jul 31, 2009 11:36 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Bruce
Newbie
Newbie
Posts: 16
Joined: Mon Aug 18, 2008 12:00 am

Re: Limiting polygons from a shapefile

Post by Bruce » Tue Aug 04, 2009 4:13 pm

Thanks.

Bruce

Post Reply