Skip to main content
Solved

Is it possible to set fme_geometry at runtime using an attribute value?


jfd553

Context

I am building a custom transformer. I need to transform input features into points to process them and then build back the features geometry before to output them. Output features are expected to have the same geometry type as input ones.

 

Problem

I thought I could just reconstruct the geometry of the features using the LineBuilder transformer, but it creates polygons with closed lines, even when the input feature is a line (fme_line), not a polygon.

 

Question

How can I reset the features geometry to their original ones before sending the features to the output port? The GeometryCoercer could do the job if I could set the output geometry at runtime (e.g. using an attribute with original fme_geometry value).

Best answer by jfd553

takashi wrote:

Hi @jfd553​ , is the geometry type of input features always Line? Could it be any other geometry type(s)?

Hi @Takashi Iijima, the expected geometries are fme_point, fme_line, fme_polygon and potentially fme_donut. The more I look for a solution, the more I think a TestFilter (on original fme_geometry value) dispatching features to appropriate GeometryCoercers and/or Geometry Transformers (e.g. AreaBuilder) might be the simplest solution.

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

6 replies

drc43
Contributor
Forum|alt.badge.img+11
  • Contributor
  • January 5, 2022

Hi @jfd553​ ,

 

I'm not completely sure I'm understanding your question, but have you looked at the GeometryExtractor and GeometryReplacer transformers. The GeometryExtractor will allow you to extract the geometry to an attribute, allowing you to then manipulate your features in other ways, and then replace the geometry of the features from the attribute with the GeometryReplacer prior to output.

http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/geometryextractor.htm

http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/geometryreplacer.htm


jfd553
  • Author
  • January 5, 2022
drc43 wrote:

Hi @jfd553​ ,

 

I'm not completely sure I'm understanding your question, but have you looked at the GeometryExtractor and GeometryReplacer transformers. The GeometryExtractor will allow you to extract the geometry to an attribute, allowing you to then manipulate your features in other ways, and then replace the geometry of the features from the attribute with the GeometryReplacer prior to output.

http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/geometryextractor.htm

http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/geometryreplacer.htm

Yes I looked, thank you. The custom transformer slightly modify the coordinates of the features, without modifying their geometry type (fme_geometry). So, I just need to reset the fme_geometry to its initial value. I could use a TestFilter to direct the features to different GeometryCoercers according to their initial values, but I was looking for something simpler.


takashi
Influencer
  • January 5, 2022

Hi @jfd553​ , is the geometry type of input features always Line? Could it be any other geometry type(s)?


jfd553
  • Author
  • Best Answer
  • January 6, 2022
takashi wrote:

Hi @jfd553​ , is the geometry type of input features always Line? Could it be any other geometry type(s)?

Hi @Takashi Iijima, the expected geometries are fme_point, fme_line, fme_polygon and potentially fme_donut. The more I look for a solution, the more I think a TestFilter (on original fme_geometry value) dispatching features to appropriate GeometryCoercers and/or Geometry Transformers (e.g. AreaBuilder) might be the simplest solution.


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • January 7, 2022

I honestly think that the GeometryExtractor and GeometryReplacer transformers (as jfd553 mentioned) are the simplest solution. With that, you can record the geometry as it enters (GeometryExtractor) and return that as it exits (GeometryReplacer). Then you don't need to test for changes or anything.


jfd553
  • Author
  • January 12, 2022
mark2atsafe wrote:

I honestly think that the GeometryExtractor and GeometryReplacer transformers (as jfd553 mentioned) are the simplest solution. With that, you can record the geometry as it enters (GeometryExtractor) and return that as it exits (GeometryReplacer). Then you don't need to test for changes or anything.

My custom transformer slightly alter the features geometry. Therefore, I understand that I cannot use the GeometryExtractor - GeometryReplacer combination to get the result I need. My custom transformer uses a Chopper to isolate/process each coordinate after which it rebuilds the input features using a LineBuilder. The LineBuilder transforms all resulting closed lines to fme_polygon, but my input (closed) lines can also be of type fme_line or fme_donut.

 

Since there is no way to alter the GeometryCoercer expected output at runtime, I think a TestFilter (on original fme_geometry value) dispatching features to an appropriate GeometryCoercer and/or Geometry Transformers (e.g. AreaBuilder) is the best solution.


Reply


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