I try to create a SQLite OSM table to Shape File Converter
tool and have failed to create correct set of shape file columns for SQLite columns.
My DbfColumn
GetDBFColumnForSQLite(FeatureSourceColumn
featureSourceColumn) function works for the string type fields, but the code is definitely
wrong for other field types. I cannot find a code sample which allows me to set
a shape file field for different types of the SQLite fields. When the code creates a new shape file with my set of columns it raises the "Your input arguments are illegal, please check" error. For example, I'm getting this error for the osm_road5m_linestring table.
I have tried to use some code from your forum posts but no luck
(thinkgeo.com/forums/MapSuit...fault.aspx
and thinkgeo.com/forums/MapSuite...fault.aspx).
Please help.
Collection<DbfColumn> allColumns = new Collection<DbfColumn>();
foreach (FeatureSourceColumn column in sqliteFeatureSource.GetColumns())
{
if
(column.ColumnName.ToLower() == "geometry"
|| column.ColumnName.ToLower() == "id")
continue;
DbfColumn
dbfColumn = GetDBFColumnForSQLite(column);
if
(dbfColumn != null)
{
allColumns.Add(dbfColumn);
}
}
….
private
DbfColumn GetDBFColumnForSQLite(FeatureSourceColumn featureSourceColumn)
{
switch
(featureSourceColumn.TypeName.ToUpper())
{
case
"STRING":
case
"CHARACTER":
case
"VARCHAR":
case
"VARYING CHARACTER":
case
"CHARACTER VARYING":
case
"NCHAR":
case
"NATIVE CHARACTER":
case
"NVARCHAR":
case
"TEXT":
case
"CLOB":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Character,
featureSourceColumn.MaxLength, 0);
case
"MEMO":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Memo,
featureSourceColumn.MaxLength, 0);
case
"INTEGER":
case
"INT":
case
"TINYINT":
case
"SMALLINT":
case
"MEDIUMINT":
case
"BIGINT":
case
"UNSIGNED BIG INT":
case
"INT2":
case
"INT8":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.IntegerInBinary, 4, 0);
case
"LOGICAL":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Logical, 4, 0);
case
"DOUBLE":
case
"DOUBLE PRECISION":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Float, 0, 8);
case
"FLOAT":
case
"NUMERIC":
return new DbfColumn(featureSourceColumn.ColumnName, DbfColumnType.Numeric, 0, 8);
case
"DECIMAL":
case
"REAL":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Float, 0,
featureSourceColumn.MaxLength);
case
"DATE":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Date,
featureSourceColumn.MaxLength, 0);
case
"DATETIME":
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.DateTime,
featureSourceColumn.MaxLength, 0);
default:
return
new DbfColumn(featureSourceColumn.ColumnName,
DbfColumnType.Character,
featureSourceColumn.MaxLength, 0);
}
}
Thanks,
Gene