Opened 20 years ago

Last modified 20 years ago

#521 closed defect (fixed)

warnings when running ogr.py with python 2.3

Reported by: silke@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

Running python ogr.py gives the following warnings:

/usr/lib/python2.3/site-packages/ogr.py:103: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbPoint25D = 0x80000001
/usr/lib/python2.3/site-packages/ogr.py:104: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbLineString25D = 0x80000002
/usr/lib/python2.3/site-packages/ogr.py:105: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbPolygon25D = 0x80000003
/usr/lib/python2.3/site-packages/ogr.py:106: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbMultiPoint25D = 0x80000004
/usr/lib/python2.3/site-packages/ogr.py:107: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbMultiLineString25D = 0x80000005
/usr/lib/python2.3/site-packages/ogr.py:108: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbMultiPolygon25D = 0x80000006
/usr/lib/python2.3/site-packages/ogr.py:109: FutureWarning: hex/oct constants >
sys.maxint will return positive values in Python 2.4 and up
  wkbGeometryCollection25D = 0x80000007

--------------------

It yould be nice to adapt ogr.py so that it will also usable with pyton 2.4

Change History (3)

comment:1 by warmerdam, 20 years ago

Silke,

It isn't clear to me what to do for this.  Do you have any suggestions from
the Python gurus at Intevation?  

comment:2 by silke@…, 20 years ago

Hallo Frank,

currently 0x80000001 will be interpretated as a short integer in a 2-complement
representation that is, since the first bit is set, it is the negativ value.
Starting from python 2.4 0x80000001 will be interpretated as long integer thus
being 2147483649. Probably the current ogr.py will still work with python 2.4
but getting warnings when starting an application should always be avoided.

So Bernhard (our main python guru :-) suggested to use negativ integere for  the
definition of wkbPoint25D etc. i.e.
wkbPoint25D = -2147483647
wkbLineString25D = -2147483646

and so on.

I don't have any test case to check whether this really produces the right
results. But I hope this helps.

      Silke

comment:3 by warmerdam, 20 years ago

I have changed the definitions to look like this:
wkb25Bit = -2147483648 # 0x80000000
wkbUnknown = 0
wkbPoint = 1  
wkbLineString = 2
wkbPolygon = 3
wkbMultiPoint = 4
wkbMultiLineString = 5
wkbMultiPolygon = 6
wkbGeometryCollection = 7
wkbNone = 100
wkbLinearRing = 101
wkbPoint25D =              wkbPoint              + wkb25Bit
wkbLineString25D =         wkbLineString         + wkb25Bit
wkbPolygon25D =            wkbPolygon            + wkb25Bit
wkbMultiPoint25D =         wkbMultiPoint         + wkb25Bit
wkbMultiLineString25D =    wkbMultiLineString    + wkb25Bit
wkbMultiPolygon25D =       wkbMultiPolygon       + wkb25Bit
wkbGeometryCollection25D = wkbGeometryCollection + wkb25Bit

Hopefully this will avoid the problem while retaining relative clarity. 

Note: See TracTickets for help on using tickets.