Sandro,
You were partially right.
I was using a relative path to the shape file. I tested
@"gis_data\Soils" and @".\gis_data\Soils" and VirtualShape()
apparently didn't like that. When I used the full path to the file I
got all of the data.
theShpFile = @"D:\SharpMap\src\SharpMapDemo\bin\Debug\gis_data\Soils";
cmd.CommandText = "CREATE VIRTUAL TABLE tmpTable USING
VirtualShape('" + theShpFile + "', 'CP1252', 3746)";
Note: In C# the @ will generate
"D:\\SharpMap\\src\\SharpMapDemo\\bin\\Debug\\gis_data\\Soils"
After the succesfull creation of the vitrual shape table I execute:
cmd.CommandText = "SELECT
RecoverGeometryColumn('Soils','Geometry',3746,'MULTIPOLYGON',2);";
The end result is a spatial table and the only thing missing is the
primary key. There is a "PKUID" field in the temporary virtual table
but it is not designated as a primary key. The vSiols table created
with Load Shapefile has a "PK_UID" field which is designated a primary
key. "PKUID" and "PK_UID" have the identical data.
So to summarize:
1. Using SharpMap v0.9, Spatialite SQL VirtualShape() was the only
straight forward way I've found to read shape files in code.
a. I was unable to add spatial characteristics to the Virtual
Table using RecoverGeometryColumn()
1) The geometry field was tagged as geometry but NO
ggi_tmpTable_Geometry & ggu_tmpTable_Geometry fields
2) An entry was added to geometry_columns
b. I copied the Virtual table to a Soils Table
c. Finally, I added the spatial Geometry to the Soils table using
RecoverGeometryColumn()
d. ** Dropping the tmpTable didn't clean up the geometry_columns table
2. You might use the SpatialTool .Loadshp ... command in a shell.
a. I had some problems with this too that I haven't resolved.
b. Requires delivering spatialite_tool.exe which I'd rather NOT do.
3. You might use the SharpMap v2.0 - Not stable - Spatialite Data Provider.
a. May be added to SharpMap v0.9 and built
b. Download and build SharpMap v2.0
** Dropping any spatial table with code doesn't clean up the
geometry_columns table.
Thanks,
Joe