OGRLayer * OGRILI1DataSource::ICreateLayer( const char * pszLayerName, CPL_UNUSED OGRSpatialReference *poSRS, OGRwkbGeometryType eType, CPL_UNUSED char ** papszOptions ) { FeatureDefnInfo featureDefnInfo = poImdReader->GetFeatureDefnInfo(pszLayerName); const char *table = pszLayerName; char * topic = ExtractTopic(pszLayerName); if (nLayers) VSIFPrintf( fpTransfer, "ETAB\n" ); if (topic) { table = pszLayerName+strlen(topic)+2; //after "__" if (pszTopic == NULL || !EQUAL(topic, pszTopic)) { if (pszTopic) { VSIFPrintf( fpTransfer, "ETOP\n" ); CPLFree(pszTopic); } pszTopic = topic; VSIFPrintf( fpTransfer, "TOPI %s\n", pszTopic ); } else { CPLFree(topic); } } else { if (pszTopic == NULL) pszTopic = CPLStrdup("Unknown"); VSIFPrintf( fpTransfer, "TOPI %s\n", pszTopic ); } VSIFPrintf( fpTransfer, "TABL %s\n", table ); OGRFeatureDefn* poFeatureDefn = new OGRFeatureDefn(table); poFeatureDefn->SetGeomType( eType ); OGRILI1Layer *poLayer = new OGRILI1Layer(poFeatureDefn, featureDefnInfo.poGeomFieldInfos, this); nLayers ++; papoLayers = static_cast<OGRILI1Layer **>( CPLRealloc(papoLayers, sizeof(OGRILI1Layer*) * nLayers) ); papoLayers[nLayers-1] = poLayer; return poLayer; }
OGRLayer * OGRILI1DataSource::CreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ) { const char *table = pszLayerName; char * topic = ExtractTopic(pszLayerName); if (pszTopic) VSIFPrintf( fpTransfer, "ETAB\n" ); if (topic) { table = pszLayerName+strlen(topic)+2; //after "__" if (pszTopic == NULL || !EQUAL(topic, pszTopic)) { if (pszTopic) { VSIFPrintf( fpTransfer, "ETOP\n" ); CPLFree(pszTopic); } pszTopic = topic; VSIFPrintf( fpTransfer, "TOPI %s\n", pszTopic ); } else { CPLFree(topic); } } else if (pszTopic == NULL) { pszTopic = CPLStrdup("Topic"); //TODO: From model? VSIFPrintf( fpTransfer, "TOPI %s\n", pszTopic ); } VSIFPrintf( fpTransfer, "TABL %s\n", table ); OGRILI1Layer *poLayer = new OGRILI1Layer(table, poSRS, TRUE, eType, this); nLayers ++; papoLayers = (OGRILI1Layer**)CPLRealloc(papoLayers, sizeof(OGRILI1Layer*) * nLayers); papoLayers[nLayers-1] = poLayer; return poLayer; }