Problem importing map shp/dbf

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
sicorspa
Newbie
Newbie
Posts: 43
Joined: Tue Jan 13, 2009 12:00 am

Post by sicorspa » Wed Feb 04, 2009 10:59 am

Yes, it works.

Maybe the problem can be the resource compiler that I'm using... I'm using BRCC32 in the borland delphi 7 \bin directory, are you using something other??

However i have also loaded the map from resource with loadmap function, but the problem is linking with dbf, because if I set the dataset property (changing the TChart in TDBChart) after have loaded the map, the series resets all the values and the shapes disappear.

With loadmap function is all automated, so, how can i connect my datasource?

Many thanks

Manuel

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Feb 04, 2009 11:49 am

Hi Manuel,

I've used the same BRCC32 ( the one inside \bin dirctory ), just ad the -32 parameter to allow to use it directly throught the IDE.
About the datasource linking, please take a look at the TeeMaps demo source which does the same you're looking for (and it uses the code I show you). You will see that just before to call the LoadFromResource method it tries to load the data from dbf.

sicorspa
Newbie
Newbie
Posts: 43
Joined: Tue Jan 13, 2009 12:00 am

Post by sicorspa » Wed Feb 04, 2009 1:23 pm

sorry, i have tryed the TeeMaps demo on your site and also the one in my steema soft directory, and no one load the dbf.

they configure and open open the table with the dbf, but nothing is done to the series.

Infact the data in the series1 is all incorrect and the name of the country isn't loaded (obviously checking the load from dbf checkbox)

seeking in the source code there is only this code referred to the dbf

Code: Select all

  procedure TryLoadTable;
  var tmp : String;
  begin
    tmp:=ChangeFileExt(ComboFlat1.Text,'.dbf');

    if FileExists(tmp) then
    begin
      Table1.Close;
      Table1.DatabaseName:=ExtractFilePath(tmp);
      Table1.TableName:=ExtractFileName(tmp);
      Table1.Open;
      Table1.First;
    end;
  end;
this open only the table1 component with the dbf file, but doesn't link it to the series..

am I loosing something?

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Feb 04, 2009 3:53 pm

Hi Manuel,

I'm sorry, I'm not sure what you mean, there's a booleanparameter into the LoadMap which allows to decide if you wanto to clear the Series when it's called.
I've just sent the TeeShp.pas file just in case you want to check how works the LoadMap and it's posibilities.

sicorspa
Newbie
Newbie
Posts: 43
Joined: Tue Jan 13, 2009 12:00 am

Post by sicorspa » Wed Feb 04, 2009 4:59 pm

Ok, i have seen how LoadMap works and now it's all more clear.

But what I'm saying is that in the demo of TeeMap the load of the dbf value doesn't work, because the demo call

TryLoadTable

and after

LoadMap that is this

Code: Select all

  procedure LoadMap;
  begin
    case ComboFlat1.ItemIndex of
      0: TWorldSeries.LoadMapFromResource(Series1,'TeeWorldShp','TeeWorldShx');
      1: TWorldSeries.LoadMapFromResource(Series1,'TeeUSAStatesShp','TeeUSAStatesShx');
    else
      TWorldSeries.LoadMapFromResource(Series1,'TeeSpainShp','TeeSpainShx');
    end;
  end;
so if I'm right in the demo the DBF isn't loaded in the series1 but only in the Table1, that isn't used as DataSource in Series1, so nothing is loaded.


tomorrow i will try 16 and 32 bit resource, because now (in Italy it's 18 pm) I must go home.
I will update you soon

Many thanks

Manuel

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Feb 05, 2009 8:59 am

Hi Manuel,

yes, you're correct, the table is loaded but not linked to any Series, I'm not sure why we leaved as is, we'll take revise for the next maintenance.
tomorrow i will try 16 and 32 bit resource, because now (in Italy it's 18 pm) I must go home.
I will update you soon
Ok, here in Spain we have the same time.

sicorspa
Newbie
Newbie
Posts: 43
Joined: Tue Jan 13, 2009 12:00 am

Post by sicorspa » Thu Feb 05, 2009 11:32 am

but i can't figure how to connect the database (dbf) in your example maps.zip, after the LoadFromResource call.

I have tried to set the DataSource value to my ClientDataSet, to add it with Datasources.Add but all this things clear all value in my series1

What am I missing?

In Bar series all this things works (after setting the YValues.ValueSource to the field values name), but in Map series setting only ZValues.ValuesSource nothing change.

Can you give me an example?

Many thanks

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Feb 06, 2009 12:30 am

Hi Manuel,

I'm afraid there's not a way to merge the data from the DataSource (dataset) and resource file directly ( by using the LoadFromResource call ), only the LoadMap method does.
In case you want to use the LoadFromResource method, to update (or add) the Label values to the Series created and populated you should iterate through the dataset and setting the values manually. Similar code to this could be used :

Code: Select all

    while not Table1.Eof do
    begin
       Series1.XLabel[i] := Table1.FieldValues['NAME'];
       ...
       table1.Next;
     end;

sicorspa
Newbie
Newbie
Posts: 43
Joined: Tue Jan 13, 2009 12:00 am

Post by sicorspa » Fri Feb 06, 2009 7:27 am

ok, this is not a bad solution, but the main problem is:

DBF contain 239 record
Series1 contain near 1000 record...

how can i link these data???
the loadmap do itself...

i will try to take the code from loadmap and modify to load with resource, hope to find the solution

many thanks for now, i will update you soon :)

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Feb 06, 2009 8:42 am


how can i link these data???
the loadmap do itself...

i will try to take the code from loadmap and modify to load with resource, hope to find the solution
Yes, one way would be to use the same code as the one used into the TeeShp.pas file for LoadMap method.

Post Reply