Example #1
0
def createAndImportTables(S57Files, nFileCount = 1, nProcCount=1):
	# Open the source and destination data source
	section2 = config['Database']
	# To formulate a string like this from config file
	#'PG:dbname=rameshN host=127.0.0.1 port=5433 user=postgres password=postgres'
	connectionString = "PG:"
	for k, v in section2.items():
		connectionString += k + "=" + v + " "
	poODS = ogr.Open( connectionString, True )
	gdal.PushErrorHandler('CPLQuietErrorHandler')

	# Process each layer
	for index, item in enumerate(S57Files):
		#Open data source
		s57FileHandle = ogr.Open(S57Files[index], False)

		#Second pass to do the real job */
		nLayerCount = s57FileHandle.GetLayerCount()
		logger.info(str(index+1) + "/" + str(nFileCount) + \
				'\t' "Processing file: " + os.path.basename(item) + \
				" having %s" % nLayerCount + " layers" + \
				' ' + "on CPU: " + str(nProcCount) + "   " + \
				str(os.path.getsize(item)/(1024)) + "KB" )
		for iLayer in range(nLayerCount):
			poLayer = s57FileHandle.GetLayer(iLayer)
			# Create tables
			psInfo = myOgr2Ogr.newSetupTargetLayer( poLayer, poODS)
			poLayer.ResetReading()
			# Import Data
			myOgr2Ogr.newTranslateLayer( psInfo, poODS, poLayer)

		s57FileHandle.Destroy()

	poODS.Destroy()
	return True
Example #2
0
def createAndImportTables(S57Files, nFileCount=1, nProcCount=1):
    # Open the source and destination data source
    section2 = config['Database']
    # To formulate a string like this from config file
    #'PG:dbname=rameshN host=127.0.0.1 port=5433 user=postgres password=postgres'
    connectionString = "PG:"
    for k, v in section2.items():
        connectionString += k + "=" + v + " "
    poODS = ogr.Open(connectionString, True)
    gdal.PushErrorHandler('CPLQuietErrorHandler')

    # Process each layer
    for index, item in enumerate(S57Files):
        #Open data source
        s57FileHandle = ogr.Open(S57Files[index], False)

        #Second pass to do the real job */
        nLayerCount = s57FileHandle.GetLayerCount()
        logger.info(str(index+1) + "/" + str(nFileCount) + \
          '\t' "Processing file: " + os.path.basename(item) + \
          " having %s" % nLayerCount + " layers" + \
          ' ' + "on CPU: " + str(nProcCount) + "   " + \
          str(os.path.getsize(item)/(1024)) + "KB" )
        for iLayer in range(nLayerCount):
            poLayer = s57FileHandle.GetLayer(iLayer)
            # Create tables
            psInfo = myOgr2Ogr.newSetupTargetLayer(poLayer, poODS)
            poLayer.ResetReading()
            # Import Data
            myOgr2Ogr.newTranslateLayer(psInfo, poODS, poLayer)

        s57FileHandle.Destroy()

    poODS.Destroy()
    return True
Example #3
0
def createDBObjects(S57Files):
	# Open the source and destination data source
	section2 = config['Database']
	# To formulate a string like this from config file
	#'PG:dbname=rameshN host=127.0.0.1 port=5433 user=postgres password=postgres'
	connectionString = "PG:"
	for k, v in section2.items():
		connectionString += k + "=" + v + " "
	poODS = ogr.Open( connectionString, True )
	gdal.PushErrorHandler('CPLQuietErrorHandler')

	# Process each file
	for index, item in enumerate(S57Files):
		#Open data source
		s57FileHandle = ogr.Open(S57Files[index], False)

		#Process the Layer in the File
		#This would create the table(s) for each layer
		nLayerCount = s57FileHandle.GetLayerCount()
		for iLayer in range(nLayerCount):
			poLayer = s57FileHandle.GetLayer(iLayer)
			psInfo = myOgr2Ogr.newSetupTargetLayer( poLayer, poODS)
		s57FileHandle.Destroy()
	poODS.Destroy()
Example #4
0
def createDBObjects(S57Files):
    # Open the source and destination data source
    section2 = config['Database']
    # To formulate a string like this from config file
    #'PG:dbname=rameshN host=127.0.0.1 port=5433 user=postgres password=postgres'
    connectionString = "PG:"
    for k, v in section2.items():
        connectionString += k + "=" + v + " "
    poODS = ogr.Open(connectionString, True)
    gdal.PushErrorHandler('CPLQuietErrorHandler')

    # Process each file
    for index, item in enumerate(S57Files):
        #Open data source
        s57FileHandle = ogr.Open(S57Files[index], False)

        #Process the Layer in the File
        #This would create the table(s) for each layer
        nLayerCount = s57FileHandle.GetLayerCount()
        for iLayer in range(nLayerCount):
            poLayer = s57FileHandle.GetLayer(iLayer)
            psInfo = myOgr2Ogr.newSetupTargetLayer(poLayer, poODS)
        s57FileHandle.Destroy()
    poODS.Destroy()