Structure for adding dataset to layer

Topics: Data Access, SharpMap v0.9 / v1.x, WinForms Controls
May 13, 2009 at 4:51 PM

Hi,

 

I am new to this, my problem is I am trying to a dataset with an X and Y postion as well as some other information labels and stats to a layer on the map. what is the correct format to load this data ?

 

thanks

LostRock

Coordinator
May 13, 2009 at 6:07 PM

Hi LostRock, if your data is in an oledb compliant database you can use the OledbPointProvider  otherwise you can create a FeatureDataTable populate it with the features and use a GeometryFeatureProvider hth jd

May 13, 2009 at 6:23 PM

Hello johndiss,

 

Many thanks, will I have to format my dataset, as it is currently in the following format, x, y, label, image ?

Lostrock

Coordinator
May 13, 2009 at 7:53 PM

That should be ok - though I am not sure what you are storing in the image column - is it the name of an icon to use or is it the binary of an actual bitmap or even the wkb of the feature?

May 13, 2009 at 8:15 PM

Hello johndiss,

Okay I have the data in a FeatureDataTable and it seems to work well, but if I try to use the image (bitmap) to draw the specific icon for the point it fails saying that "Attribute data is not supported by the GeometryProvider."

Below is a sample from my code:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<font size="2">

 

</font>

 

if (_vehicleLayor == null

)<font size="2">

_vehicleLayor =

</font>

 

new SharpMap.Layers.VectorLayer("vehicles");<font size="2">

_liveVehicleRefresher =

</font>

new GISMappingControl.Tools.LiveVehicleRefresher(_connection);<font size="2">

_liveVehicleRefresher.onLatestDataSet +=

</font>

new GISMappingControl.Tools.LiveVehicleRefresher.LatestDataSet(_liveVehicleRefresher_onLatestDataSet);<font size="2">

 

</font>

 

//SharpMap.Data.FeatureDataTable featTable = new SharpMap.Data.FeatureDataTable(_liveVehicleRefresher.GetLatestDataSet.Tables[0]);

<font size="2">

SharpMap.Data.

</font>

FeatureDataTable tempTable = _liveVehicleRefresher.GetLatestDataSet;<font size="2">

_vehicleLayor.DataSource =

</font>

new SharpMap.Data.Providers.GeometryProvider(tempTable);<font size="2">

SharpMap.Rendering.Thematics.

</font>

CustomTheme lbiTheme = new SharpMap.Rendering.Thematics.CustomTheme(getVehicleLabel);<font size="2">

SharpMap.Styles.

</font>

LabelStyle defaultlbstyle = new SharpMap.Styles.LabelStyle();<font size="2">

defaultlbstyle.ForeColor =

</font>

Color.Black;

lbiTheme.DefaultStyle = defaultlbstyle;

<font size="2">

SharpMap.Layers.

</font>

LabelLayer lbLayer = new SharpMap.Layers.LabelLayer("vehicleName");<font size="2">

lbLayer.DataSource =

</font>

new SharpMap.Data.Providers.GeometryProvider(tempTable);<font size="2">

lbLayer.LabelColumn =

</font>

"VehicleID";

lbLayer.Theme = lbiTheme;

<font size="2">

 

</font>

 

//SharpMap.Rendering.Thematics.CustomTheme iTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetVehicleStyle);

<font size="2">

 

</font>

 

//SharpMap.Styles.VectorStyle defaultstyle = new SharpMap.Styles.VectorStyle();

<font size="2">

 

</font>

 

//defaultstyle.Fill = Brushes.Gray;

<font size="2">

 

</font>

 

//iTheme.DefaultStyle = defaultstyle;

<font size="2">

 

</font>

 

//_vehicleLayor.Theme = iTheme;

<font size="2">

SharpMap.Styles.

</font>

VectorStyle vs = new SharpMap.Styles.VectorStyle();<font size="2">

vs.Symbol = Properties.

</font>

Resources.red_light;<font size="2">

vs.Enabled =

</font>

true;<font size="2"><font size="2">

_vehicleLayor.Style = vs;

mapImage1.Map.Layers.Add(_vehicleLayor);

mapImage1.Map.Layers.Add(lbLayer);

mapImage1.Refresh();

 

Could you let me know where I am going wrong, would like to be able to change the Symbols according to the feature set.

Thanks

LostRock

</font></font><font size="2">

 

</font>

 

 

 

Coordinator
May 13, 2009 at 8:23 PM

use the GeometryFeatureProvider hth jd

May 13, 2009 at 9:12 PM

Hi johndiss,

Have made changes had the wrong version, but now I am getting an error on

IMathTransform

and

SharpMap.CoordinateSystems.ICoordinateSystem

Can you help ?

Thanks

Coordinator
May 13, 2009 at 9:26 PM

It sounds like you need to reference ProjNet.dll from the external references directory hth jd

May 13, 2009 at 9:32 PM

Hello johndiss,

I did reference it and I still get the error, have found a reference under GeoAPI ? is this correct ?



__________ Information from ESET Smart Security, version of virus signature database 4063 (20090508) __________

The message was checked by ESET Smart Security.

http://www.eset.com
Coordinator
May 13, 2009 at 9:47 PM

Are you using the source from the trunk on codeplex?

May 13, 2009 at 10:02 PM

Hi, Yes I am,

Have got it working, changed all refs to the GeoAPI and running fine. Is it wrong ?

Thanks



__________ Information from ESET Smart Security, version of virus signature database 4063 (20090508) __________

The message was checked by ESET Smart Security.

http://www.eset.com