Hi Steve,

Thank you for the reply.

This is the C# code sent to me by one of the developers. He calls the OGR2OGR 
method only once per script, but when he tries to call the script again, it 
works with no problem. Which is not the case on my PC:

GlobalSettings settings = new 
GlobalSettings();settings.ResetGdalError();UtilsClass utils = new 
MapWinGIS.UtilsClass();string options = "--configCONFIG_FILE \"C:\\Program 
Files\\MapWindow GIS Lite\\MapWinGIS\\gdal-data\\osmconf.ini\"--config 
OSM_USE_CUSTOM_INDEXING NO -skipfailures -f \"ESRIShapefile\"";bool result = 
utils.OGR2OGR(@"C:\rome.osm", @"C:\rome_sph_files", options);if (!result){    
// Both line should be the same:    
Debug.WriteLine(utils.ErrorMsgFromObject(utils));   
Debug.WriteLine(utils.ErrorMsg[utils.LastErrorCode]);    
Debug.WriteLine(settings.GdalLastErrorMsg);} if (!result) return;

He also assigns the path to the osmconf.ini file, but that does not make my 
problem go away, when I try to do the same.

Below is the ironpython code that I use. I call the OGR2OGR method twice in 
that script, instead of once:

import clr iteropMapWinGIS_dll_filePath = "C:\\ProgramFiles\\MapWindow GIS 
Lite\\Interop.MapWinGIS.dll"clr.AddReferenceToFileAndPath(iteropMapWinGIS_dll_filePath)import
 MapWinGIS  utils = MapWinGIS.UtilsClass()osm_filePath = 
"C:\\rome.osm"shps_filePath = "C:\\rome_sph_files"bstrOptions = 
'--configOSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI 
Shapefile"'convertToShapefiles_Result =MapWinGIS.UtilsClass.OGR2OGR(utils, 
osm_filePath, shps_filePath, bstrOptions, None)if convertToShapefiles_Result== 
False:    print "MapWinGIS.UtilsClass.OGR2OGRfailed the first time"   print 
utils.ErrorMsg    print utils.LastErrorCode    print 
MapWinGIS.GlobalSettingsClass().GdalLastErrorNo    print 
MapWinGIS.GlobalSettingsClass().GdalLastErrorMsg    print 
MapWinGIS.GlobalSettingsClass().GdalLastErrorTypeelse:    print 
"MapWinGIS.UtilsClass.OGR2OGRsuccessfully ran the first time"   print 
"------------"iteropMapWinGIS_dll_filePath2 = "C:\\ProgramFiles\\MapWindow GIS 
Lite\\Interop.MapWinGIS.dll"clr.AddReferenceToFileAndPath(iteropMapWinGIS_dll_filePath2)import
 MapWinGIS utils2 = MapWinGIS.UtilsClass()osm_filePath2 = 
"C:\\athens.osm"shps_filePath2 = "C:\\athens_sph_files"bstrOptions2 = 
'--configOSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI 
Shapefile"'convertToShapefiles_Result2 =MapWinGIS.UtilsClass.OGR2OGR(utils2, 
osm_filePath2, shps_filePath2,bstrOptions2, None)if 
convertToShapefiles_Result2== False:    print 
"MapWinGIS.UtilsClass.OGR2OGRfailed the second time"   print utils2.ErrorMsg    
print utils2.LastErrorCode    print 
MapWinGIS.GlobalSettingsClass().GdalLastErrorNo    print 
MapWinGIS.GlobalSettingsClass().GdalLastErrorMsg    print 
MapWinGIS.GlobalSettingsClass().GdalLastErrorTypeelse:    
print"MapWinGIS.UtilsClass.OGR2OGR successfully ran the secondtime"

The mentioned Map Window GIS application can be downloaded from here (version 
MapWindow Lite Win32 1.0.5.0):
https://mapwindow4.codeplex.com/releases/view/542097
I attached the upper mentioned "rome.osm" and "athens.osm" files along with .py 
file in 
here:https://www.dropbox.com/s/2jq1a248jupdfzq/osm_files_plus_ironpythonOGR2OGR.zip?dl=0

The OGR2OGR method essentially converts the .osm files to .shp file format.

Thank you in advance for taking a look.

I would welcome any kind of advice !!

Kind regards,
Djordje Spasic
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to