Skip to main content
Solved

FME Reader to retrieve all defined coordinate systems


jstanger
Forum|alt.badge.img+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?

Best answer by daveatsafe

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.

View original
Did this help you find an answer to your question?

3 replies

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • Best Answer
  • April 8, 2020

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.


fgiron
Supporter
Forum|alt.badge.img+20
  • Supporter
  • April 10, 2020

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.


jstanger
Forum|alt.badge.img+1
  • Author
  • April 11, 2020
fgiron wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings