Re: [gdal-dev] adding a new method to OGRFieldDefn & gdalautotest

2018-11-07 Thread Even Rouault
On mercredi 7 novembre 2018 19:56:10 CET Alan Stewart wrote:
> Thanks, Even, I certainly didn't read the file header. After making all your
> suggested changes the compiler is erroring on
> swig/python/extensions/gdal_wrap.cpp, which I have not touched.
> 
> I notice it is using " Visual C++ for Python", version 9.0. Is that the
> correct compiler to use?

In theory, yes, but in practice you can force the use of your current MSVC 
version and it happens to work just fine, by setting the following env 
variables

set DISTUTILS_USE_SDK=1
set MSSdk=1

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] adding a new method to OGRFieldDefn & gdalautotest

2018-11-06 Thread Even Rouault
On mardi 6 novembre 2018 21:16:04 CET Alan Stewart wrote:
> I'm working in Windows 7 with VS 2017 and Python 2.7.15.
> 
> I've added a new method to this class,  and wish to add tests for it to
> gdalautotest. I found and added the new method to swig/python/osgeo/ogr.py.
> Is there anything else I need to do to add python support for my new class
> method?

As the header of this file warns it, this is a generated file that you 
shouldn't edit. Adding new methods in it is not sufficient. Code must also be 
added swig/python/extensions/ogr_wrap.cpp.
So edit swig/include/ogr.i to define your new method there, and run "make 
generate" in swig/python (you need SWIG to be available) (or "nmake /f 
makefile.vc python" from swig/ on Windows)

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] adding a new method to OGRFieldDefn & gdalautotest

2018-11-06 Thread Alan Stewart
I'm working in Windows 7 with VS 2017 and Python 2.7.15.

I've added a new method to this class,  and wish to add tests for it to 
gdalautotest. I found and added the new method to swig/python/osgeo/ogr.py. Is 
there anything else I need to do to add python support for my new class method?

The current errors I get when calling it from my new test seems to indicate I 
need to do something further to get swig to recognize it, though after 
rebuilding the new method does appear in my python's 
Lib/site-packages/GDAL-2.3.0-py2.7-win32.egg/osgeo/ogr.py.

The test (so far):

def ogr_fgdb_26():

try:
shutil.rmtree('tmp/aliasname.gdb')
except OSError:
pass
gdaltest.unzip('tmp', 'data/aliasname.gdb.zip')
if not os.path.exists('data/aliasname.gdb'):
gdaltest.post_reason('failure to unzip archive')
return 'fail'

ds = ogr.Open('data/aliasname.gdb')
if not ds:
gdaltest.post_reason('failure to open dataset')
return 'fail'

## retrieve and test table
table00 = ds.GetLayerByName('table00')
layerDefn = table00.GetLayerDefn()
fieldDfn = layerDefn.GetFieldDefn(layerDefn.GetFieldIndex('has_alias'))
name = fieldDfn.GetName()
alias = fieldDfn.GetAliasName()
print('name: {0} alias: {1}'.format(name, alias))

The runtime error:

Traceback (most recent call last):
  File "../pymod\gdaltest_python2.py", line 43, in run_func
result = func()
  File "C:\devel\GitHub\gdal\autotest\ogr\ogr_fgdb.py", line 2626, in 
ogr_fgdb_26
alias = fieldDfn.GetAliasName()
  File "C:\Python27\lib\site-packages\gdal-2.3.0-py2.7-win32.egg\osgeo\ogr.py", 
line 5415, in 
__getattr__ = lambda self, name: _swig_getattr(self, FieldDefn, name)
  File "C:\Python27\lib\site-packages\gdal-2.3.0-py2.7-win32.egg\osgeo\ogr.py", 
line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
  File "C:\Python27\lib\site-packages\gdal-2.3.0-py2.7-win32.egg\osgeo\ogr.py", 
line 69, in _swig_getattr_nondynamic
return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'


Alan Stewart
Senior Software Engineer
TerraGo Technologies
3200 Windy Hill Road, Suite 1550W
Atlanta, GA 30339 USA
O.  +1 678.391.9615

www.terragotech.com

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev