As part of a configuration validation process I need to check if the list of coordinate system options retrieved from an external list are defined in the instance of FME running the validation workbench. This validation process needs to work with both inbuilt and custom projections that have been defined. My configuration list is based on the FME name of the projection (i.e. for custom projections, matching the attribute COORDINATE_SYSTEM_DEF). Is there a way to read all currently defined coordinate systems to check if the items in the list exist?
Hi @jstanger,
Please use a PythonCaller, with the following code:
import fme
import fmeobjects
def testCoordsys(feature):
testCoordsys = feature.getCoordSys()
coordsysManager = fmeobjects.FMECoordSysManager()
allCoordsys = coordsysManager.getCoordSysList()
if testCoordsys in allCoordsys:
feature.setAttribute('_valid_coordsys', 'yes')
else:
feature.setAttribute('_valid_coordsys', 'no')
In the PythonCaller, you will need to expose the new _valid_coordsys attribute to make it visible to Workbench.
After the PythonCaller, you can use a Tester to route the features based on the value of _valid_coordsys.
What about reading the coordsys.db file in your FME installation folder, which turns out to be a nicely formatted CSV?
You might have other coordinate systems in the <FME_install>\\Reproject\\LocalCoordSysDefs.fme and <FME_install>\\Reproject\\MyCoordSysDefs.fme which are also text based.
However, there might be other coordinate systems in other shared folders and who knows where, so probable the way @daveatsafe describes is the most effective.
What about reading the coordsys.db file in your FME installation folder, which turns out to be a nicely formatted CSV?
You might have other coordinate systems in the <FME_install>\\Reproject\\LocalCoordSysDefs.fme and <FME_install>\\Reproject\\MyCoordSysDefs.fme which are also text based.
However, there might be other coordinate systems in other shared folders and who knows where, so probable the way @daveatsafe describes is the most effective.
@fgiron I had considered this approach but as you point out it requires scanning additional files for custom coordinate systems which can be located in various places. In my case I'll be running this workbench in either desktop or server so prefer @daveatsafe's solution as it seems to cover all cases and be pretty portable. Thanks.