Think about setting measure values to every vertex of line geometries. Assume that the measure value has to be distance from start node of the line which the vertex belongs to.
If the coordinate system for measuring is same as the source coordinate system, a MeasureGenerator can be used simply.
If not, a quick way is to perform reprojection before and after the MeaureGenerator.
Reprojector -> MeasureGenerator -> Reprojector
But output line geometry may not be strictly same as input line, since interpolation is performed in reprojection process in general. Although the error caused by reprojection is slight amount, cannot be avoided.
If such an error will not be allowed, this workflow would be a workaround.
The pattern of the workflow - adding temporary ID, branching feature flow into multiple streams, and merging them after processing - is used in many cases. I think there are many general patterns which frequently appear in FME workspaces. I personally call them "Standard methods".
The pattern above is typical one. I call it "Counting-Branching-Merging" method, provisionally.
How do you call it?
=====
2014-03-04: I got a great comment on this subject. That is a suggestion regarding another workaround with the GeometryExtrator and GeometryReplacer like this.
In my quick test for a large dataset, this method was apparently more efficient in both memory usage and processing speed (Geometry Encoding: FME Binary). And also the original geometries have been restored exactly. I'm going to research further more in another opportunity.
I've never noticed such an effective usage of GeometryExtractor / Replacer. I would add the pattern of "ExtractGeometry-Processing-RestoreGeometry" to my "Standard methods".
Thanks for the input!
P.S. It is a basic usage of the GeometryExtractor / Replacer. I was blind ...
"This transformer is often used to make a copy of the feature's geometry into an attribute before some temporary geometry change is made, so that it can later be restored."
-- Help on the GeometryExtractor, FME 2014
"This transformer is typically used to restore geometry previously extracted into an attribute by the GeometryExtractor."
-- Help on the GeometryReplacer, FME 2014
-----
If "ExtractGeometry-Processing-RestoreGeometry" method would be used generally in many scenarios, it might be more convenient that the GeomeryExtractor and GeometryRepalcer have an optional parameter "Coordinate System Attribute", so that the method can extract and restore coordinate system without using the CoordinateSystemExtractor / Setter if necessary.
This is a very interesting subject, thanks for bringing it up. Personally, I tend to try and avoid FeatureMergers as much as possible since they are blocking and tend to eat up a lot of memory for non-trivial datasets. My go-to is now to use GeometryExtractor - Process - GeometryReplacer (and an AttributeRemover to delete the geometry attribute) to avoid the Count-Branch-Merge exercise, but I must admit I have never done any systematic profiling to see which is more efficient or if there is a break-even at some point. It would be very interesting to get the opportunity to research this further!
ReplyDeleteThank you for the comment. As you say, the GeometryExtractor / Replacer likely would be more efficient. I updated the article based on your suggestion, please see that.
Delete