Skip to main content

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).

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


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.


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


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.


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.


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