Hello there,
I have an application which preprocesses some data to be displayed as contour maps and arrays of vector arrows on my map. The contours are rendered out to bitmaps and used in a RasterLayer which is then serialized to file for loading later in our client app. All that is working fine.
The arrow shapes are created as LineShapes and added to a ShapeFileFeatureLayer in ReadWrite mode. The layer is then written out to a new shapefile, and later loaded up to a ShapeFileFeatureLayer in the client app. They stubbornly refuse to display. I’m sure I’m getting the column definitions or something similar wrong. I hope someone here can point me in the right direction.
Here is the code which generates the shapefile (it’s not complete):
…
Collection cols = new Collection();
cols.Add(new DbfColumn(ArrowColumnName, DbfColumnType.Character, 32, 0));
ShapeFileFeatureSource.CreateShapeFile(ShapeFileType.Multipoint, sdfFileName, cols);
ShapeFileFeatureLayer arrowFeatureLayer = new ShapeFileFeatureLayer(fileName, ShapeFileReadWriteMode.ReadWrite);
arrowFeatureLayer.Open();
arrowFeatureLayer.EditTools.BeginTransaction();
int i=0;
foreach (ArrowLine gv in gvArrows)
{
var arrow = new LineShape();
… some calculations of lengths and coordinates here …
arrow.Vertices.Add(start);
arrow.Vertices.Add(end);
arrow.Vertices.Add(barb);
Feature arrowFeature = new Feature((LineShape)mProjection.ConvertToExternalProjection(arrow));
arrowFeature.ColumnValues.Add(ArrowColumnName, ArrowColumnName + i++);
arrowFeatureLayer.EditTools.Add(arrow);
}
arrowFeatureLayer.EditTools.CommitTransaction();
arrowFeatureLayer.Close();
This produces shapefiles which have something in them, and I load them into an overlay on my mapControl like this:
if (File.Exists(fileName))
{
ShapeFileFeatureLayer flayer = new ShapeFileFeatureLayer(fileName);
flayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Black));
flayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
flayer.FeatureSource.Projection = MapControl.GetProjection();
this.Layers.Add(flayer);
}
[The overlay is a class derived from the ThinkGeo LayerOverlay class].
I know it’s a lot of code, but am I using the correct DbColumns and ShapeFileType etc when generating the shapefiles?
Many thanks for any assistance.
Regards,
Scott D.