Hi,
A simple question:
Is the index range in an FMEObjects FMEAggregate geometry parts list 0-based or 1-based ?
The documentation doesn't say anything about this either way.
It's for code in a PythonCaller.
Cheers
Lars I.
Hi,
A simple question:
Is the index range in an FMEObjects FMEAggregate geometry parts list 0-based or 1-based ?
The documentation doesn't say anything about this either way.
It's for code in a PythonCaller.
Cheers
Lars I.
Hi @lifalin2016, you can check it yourself. e.g.
# PythonCaller Script Example
# Check whether part index of FMEAggregate is 0-based or 1-based.
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
self.logger = fmeobjects.FMELogFile()
def input(self,feature):
geom = feature.getGeometry()
if not isinstance(geom, fmeobjects.FMEAggregate):
self.logger.logMessageString('NOT Aggregate', fmeobjects.FME_WARN)
elif geom.getPartAt(0) != None:
self.logger.logMessageString('0-based', fmeobjects.FME_WARN)
elif geom.getPartAt(geom.numParts()) != None:
self.logger.logMessageString('1-based', fmeobjects.FME_WARN)
Hi @lifalin2016, you can check it yourself. e.g.
# PythonCaller Script Example
# Check whether part index of FMEAggregate is 0-based or 1-based.
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
self.logger = fmeobjects.FMELogFile()
def input(self,feature):
geom = feature.getGeometry()
if not isinstance(geom, fmeobjects.FMEAggregate):
self.logger.logMessageString('NOT Aggregate', fmeobjects.FME_WARN)
elif geom.getPartAt(0) != None:
self.logger.logMessageString('0-based', fmeobjects.FME_WARN)
elif geom.getPartAt(geom.numParts()) != None:
self.logger.logMessageString('1-based', fmeobjects.FME_WARN)
Indexes in Python should always be 0-based.
http://python-history.blogspot.ch/2013/10/why-python-uses-0-based-indexing.html (Written by Guido van Rossum himself)
If getPartAt() is 1-based, I'd flag it as a bug.
When working with FME - including Python scripting, you can almost always suppose that list indexing is 0-based. However, also note that there are some exceptions according to external language specifications. For example, as far as I know, XQuery and R use 1-based indexing.
As far as I know all lists in FME always start with 0