Solved

FME Reader to retrieve all defined coordinate systems


Badge +1

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?

icon

Best answer by daveatsafe 8 April 2020, 19:37

View original

3 replies

Userlevel 2
Badge +17

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.

0684Q00000ArJuIQAV.png

After the PythonCaller, you can use a Tester to route the features based on the value of _valid_coordsys.

Badge +15

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.

Badge +1

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.

Reply