2015-04-13

Use Time Positions on Time Line

タイムライン上の時間位置の利用

Summary of this thread.
このスレッドのまとめ。
FME Community Answers > Merge features based on time

Assuming you have two datasets:
- one contains rasters having a datetime attribute,
- another contains GPS points also having a datetime attribute.
The goal is to give each raster the geographic coordinate of a point having smallest time difference from the raster.
二つのデータセットがあるものとします。
- ひとつは日付時刻属性を持つラスターから成り、
- もう一つはやはり日付時刻属性を持つGPSポイントから成る。
目標は、各ラスターに、そのラスターからの時間差が最も小さいポイントの地理座標を与えることです。

Seemingly the solution would be complicated, but you can solve it easily with the NeighborFinder if you replace every geometry with a time position on a time line - i.e. a coordinate (time, 0) on the X axis.
一見、解決策は複雑になりそうですが、ジオメトリをタイムラインにおける時間位置 - つまりX軸上の座標 (時間, 0) に置き換えれば、NeighborFinerを使って簡単に解決できます。

(1) Convert the datetime value to the count of seconds since the epoch, using a DateFormatter (Destination Date Format: %s).
DateFormatter (Destination Date Format: %s) によって日付時刻値をエポックからの秒数に変換します。

(2) Extract the raster data as an attribute by a RasterExtractor, and replace the geometry with a point (X=seconds, Y=0) by a VertexCreator.
RasterExtractorによってラスターデータを属性として抽出し、VertexCreatorによってジオメトリをポイント (X=秒数, Y=0) に置き換えます。

(3) Extract geographic coordinate (x, y) of the GPS points by a CoordinateExtractor, and replace the geometry with a point (X=seconds, Y=0) by a VertexCreator, as well.
CoordinateExtractorによってGPSポイントの地理座標 (x, y) を抽出し、同様にVertexCreratorによってジオメトリをポイント (X=秒数, Y=0) に置き換えます。

Here, the point (X=second, Y=0) represents the time position of a feature on a time line (X-axis).
ここで、ポイント (X=秒数, Y=0) がタイムライン(X軸)上のフィーチャーの時間位置を表します。

(4) Add a NeighborFinder; send the (2) features to the Base port; send the (3) features to the Candidate port. Then, each Matched feature will have the geographic coordinate (x, y) of a GPS point which has smallest time difference.
NeighborFinderを追加し、(2)のフィーチャーをBaseポートに、(3)のフィーチャーをCandidateポートに送ります。すると、Matchedフィーチャー は、時間差が最小のGPSポイントの地理座標 (x, y)を持つことになります。

(5) Finally, restore the original raster of each Matched feature by a RasterReplacer.
最後にRasterReplacerによってMatchedフィーチャーを元のラスターに復元します。

I think you have ever learned about "Number Line" in school. In fact, the time line is not any one other than the Number Line.
Elementary mathematics is also very helpful in some cases.
学校で「数直線」について習ったことがあると思います。実のところ、タイムラインは数直線に他なりません。
初等数学も時にはとても役に立ちます。

No comments:

Post a Comment