Opened 16 years ago
Closed 16 years ago
#2337 closed defect (invalid)
Create Spatial Index for Shapefiles with Space in Name
Reported by: | Geoheber | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | 1.5.0 |
Severity: | normal | Keywords: | Create Spatial Index Shapefile Space Blank Filename Quotes |
Cc: |
Description
Problem in Function OGRShapeDataSource::ExecuteSQL
If an OGRLayer contains a shapefile which has been loaded out of a file which name has a space in its filename, the name of this layer contains the space, too. If one want to create a spatial index by calling
m_poDS->ExecuteSQL("CREATE SPATIAL INDEX ON sweden rivers",NULL,NULL);
for example, the call fails because in ExecuteSQL the string is tokenized by the space sign, so the name it tries to look up is only "sweden". It doesn't find this layer and fails. One cannot quote the name such as
m_poDS->ExecuteSQL("CREATE SPATIAL INDEX ON 'sweden rivers'",NULL,NULL);
because this isn't handled in GetLayerByName. So, there isn't any possibility if one have only an OGRLayer without further infos to create a spatial index on it.
Workaround: If one knows its an OGRShapeLayer, one can call CreateSpatialIndex() directly.
Now I found its realizable by double-quotes, so it is not a bug!
m_poDS->ExecuteSQL("CREATE SPATIAL INDEX ON \"sweden rivers\"",NULL,NULL);