Example #1
0
OGRDataSource *OGRSFDriver::CopyDataSource( OGRDataSource *poSrcDS, 
                                            const char *pszNewName,
                                            char **papszOptions )

{
    if( !TestCapability( ODrCCreateDataSource ) )
    {
        CPLError( CE_Failure, CPLE_NotSupported, 
                  "%s driver does not support data source creation.",
                  GetName() );
        return NULL;
    }

    OGRDataSource *poODS;

    poODS = CreateDataSource( pszNewName, papszOptions );
    if( poODS == NULL )
        return NULL;

/* -------------------------------------------------------------------- */
/*      Process each data source layer.                                 */
/* -------------------------------------------------------------------- */
    for( int iLayer = 0; iLayer < poSrcDS->GetLayerCount(); iLayer++ )
    {
        OGRLayer        *poLayer = poSrcDS->GetLayer(iLayer);

        if( poLayer == NULL )
            continue;

        poODS->CopyLayer( poLayer, poLayer->GetLayerDefn()->GetName(), 
                          papszOptions );
    }
    
    return poODS;
}
OGRLayer   *OGRDataSourceWithTransaction::CopyLayer( OGRLayer *poSrcLayer,
        const char *pszNewName,
        char **papszOptions )
{
    if( !m_poBaseDataSource ) return NULL;
    return WrapLayer(m_poBaseDataSource->CopyLayer(poSrcLayer, pszNewName, papszOptions ));
}
Example #3
0
OGRDataSource *OGRSFDriver::CopyDataSource( OGRDataSource *poSrcDS, 
                                            const char *pszNewName,
                                            char **papszOptions )

{
    if( !TestCapability( ODrCCreateDataSource ) )
    {
        CPLError( CE_Failure, CPLE_NotSupported, 
                  "%s driver does not support data source creation.",
                  GetName() );
        return NULL;
    }

    OGRDataSource *poODS;

    poODS = CreateDataSource( pszNewName, papszOptions );
    if( poODS == NULL )
        return NULL;

/* -------------------------------------------------------------------- */
/*      Process each data source layer.                                 */
/* -------------------------------------------------------------------- */
    for( int iLayer = 0; iLayer < poSrcDS->GetLayerCount(); iLayer++ )
    {
        OGRLayer        *poLayer = poSrcDS->GetLayer(iLayer);

        if( poLayer == NULL )
            continue;

        poODS->CopyLayer( poLayer, poLayer->GetLayerDefn()->GetName(), 
                          papszOptions );
    }

    /* Make sure that the driver is attached to the created datasource */
    /* It is also done in OGR_Dr_CopyDataSource() C method, in case */
    /* another C++ implementation forgets to do it. Currently (Nov 2011), */
    /* this implementation is the only one in the OGR source tree */
    if( poODS != NULL && poODS->GetDriver() == NULL )
        poODS->SetDriver( this );

    return poODS;
}
Example #4
0
JNIEXPORT jlong JNICALL Java_es_gva_cit_jogr_OGRDataSource_copyLayerNat
  (JNIEnv *env, jobject obj, jlong cPtr, jlong poSrcLayer, jstring pszNewName, jobjectArray papszOptions){
  	  	
  	OGRDataSource 		*ds = (OGRDataSource *) 0 ;
  	int 				longitud;
  	char				**opciones;
  	OGRLayer			*layer_dstno;
  	OGRLayer			*layer;
  	long 				ptr_dtno=-1;
  	
  	ds = *(OGRDataSource **)&cPtr;
  	layer = *(OGRLayer **)&poSrcLayer;
  	if(ds!=NULL && layer!=NULL){
  		longitud = env->GetArrayLength( papszOptions); 
  		opciones = (char **)malloc(sizeof(char *)*longitud);
  		for(int i=0;i<longitud;i++){
	  		jstring el = (jstring)env->GetObjectArrayElement(papszOptions,i);
	  		const char *simple_option = env->GetStringUTFChars( el, 0);
	  		opciones[i]=(char *)malloc(strlen(simple_option));
	  		strcpy(opciones[i],simple_option);
	  		env->ReleaseStringUTFChars( el, simple_option);
  		}
  		
  		const char *name = env->GetStringUTFChars( pszNewName, 0);
  		layer_dstno = ds->CopyLayer(layer, name, opciones);
	  	env->ReleaseStringUTFChars( pszNewName, name);
  		
  	}
  	
  	for(int i=0;i<longitud;i++)free(opciones[i]);
  	free(opciones);
  	
  	if(layer_dstno==NULL)return -1;
  	
  	ptr_dtno = (long)&(*layer_dstno);
  	return (jlong)ptr_dtno;
  }