Skip to main content
Question

Adding data to road measures


Forum|alt.badge.img

Dear FME community,

 

 

I have a road dataset with lines that looks like this:VNKNNKVSTBSTLEN102010402005001000102010406008001000

 

The columns VNK/NNK are just identifiers for the road segment, the columns VST/BST are the measures (in metres) and the in column LEN is the value for the absolute length of one road.

 

 

The above table means, that one road segment 1020-1040 is divided into the segment from 200m - 500m (with a value for XYZ), and then from 600m -800m (with a different value for XYZ). The complete road goes from 0-1000 metres.

 

 

Problem: I need to fill the "invervalls" with Zero-Values. If the road has the length 1000 metres, then there are no values from 0-200, from 500-600 and from 800-1000. I can calculate the missing values from start (0-200) and the end (800-1000), but how do I get the interim value (500-600)? The could be many intervalls :-)

 

 

Goal: The target table should look like this (the bold lines were added):VNKNNKVSTBSTLEN10201040020010001020104020050010001020104050060010001020104060080010001020104080010001000

 

I already put these road segments into a list and calculated the ranges, but I would like to add the missing lines, not just the beginning/end. Any hints how this can be achieved?

Kind regards

Thomas

9 replies

lars_de_vries
Forum|alt.badge.img+10

You could use a Sorter and an AttributeManager transformer. When you sort the features first by segment and values, you can use the option of looking at 'Adjacent Features' to see whether VST from the next feature matches the BST value from the current feature. You can use feature[+1].VST to check or set the value from the next (or [-1] for the previous) feature.


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • March 31, 2018

A geometric solution. Create a line from (0, 0) to (LEN, 0), generate measure on it, split it by the given measures, then extract measures of start and end nodes for each segment.


Forum|alt.badge.img
  • Author
  • April 20, 2018
takashi wrote:

A geometric solution. Create a line from (0, 0) to (LEN, 0), generate measure on it, split it by the given measures, then extract measures of start and end nodes for each segment.

Thank you very much @takashi for your solution with the screenshot (and sorry for my late response, I didn't see that another answer was posted in the meantime). Your way works like a charm!

 


Forum|alt.badge.img
  • Author
  • April 20, 2018
lars_de_vries wrote:

You could use a Sorter and an AttributeManager transformer. When you sort the features first by segment and values, you can use the option of looking at 'Adjacent Features' to see whether VST from the next feature matches the BST value from the current feature. You can use feature[+1].VST to check or set the value from the next (or [-1] for the previous) feature.

Thank you @lars_de_vries

 

I didn't know the function with the "Adjacent Features" before and will have a look of how it works.

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • April 21, 2018
takashi wrote:

A geometric solution. Create a line from (0, 0) to (LEN, 0), generate measure on it, split it by the given measures, then extract measures of start and end nodes for each segment.

0684Q00000ArLENQA3.png

 

There is more than one way.

 

I think the InlineQuerier could also be used effectively here.

 

select x.VNK, x.NNK, x.M as VST, y.M as BST, x.LEN
from Measure as x inner join Measure as y
on y.VNK = x.VNK and y.NNK = x.NNK and y.count - 1 = x.count   

 

0684Q00000ArMW8QAN.png

 

Interestingly, JSON too does it.

 

Root Template Expression

 

[
    let $values := fn:distinct-values(
        for $m in (0, fme:process-features("SUB"), fme:get-attribute("LEN"))
        let $v := xs:double($m)
        order by $v ascending
        return $v
    )
    for $i in (1 to fn:count($values) - 1)
    return { "VST" : $values[$i], "BST" : $values[$i + 1] }
]
 
Sub Template Expression

 

fme:get-attribute("VST"),fme:get-attribute("BST")

 

0684Q00000ArMgbQAF.png


Forum|alt.badge.img
  • Author
  • May 8, 2018

Hi there, many thanks to @takashi and all the others!

I have an addendum to the above question:

The resulting table will look like this:

VNKNNKVSTBSTVALUE1231230200A123123200400A1231238001000B12312310001200B

Is there a way to "compress" it, like this? All values with adjacend VST/BST on the same road segment (VNK/NNK) should be combinded:

VNKNNKVSTBSTVALUE1231230400A1231238001200B

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • May 8, 2018
thomask wrote:

Hi there, many thanks to @takashi and all the others!

I have an addendum to the above question:

The resulting table will look like this:

VNKNNKVSTBSTVALUE1231230200A123123200400A1231238001000B12312310001200B

Is there a way to "compress" it, like this? All values with adjacend VST/BST on the same road segment (VNK/NNK) should be combinded:

VNKNNKVSTBSTVALUE1231230400A1231238001200B
Can the value of "VALUE" be used to aggregate segments?

 

 


Forum|alt.badge.img
  • Author
  • May 8, 2018
takashi wrote:
Can the value of "VALUE" be used to aggregate segments?

 

 

@takashi

 

I think so, but the problem is that I only want to aggregate where BST=VST, i.e. where there are no "gaps". If for example I have following table

 

 

VNK

 

NNKVSTBSTVALUE1231230200A123123200500A123123600800A1231238001000AThen the result should be:

 

 

VNKNNKVSTBSTVALUE1231230500A1231236001000A

 

When there is a gap (here: between station 500 and 600), it should be 2 or more seperate rows.

 

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • May 8, 2018
thomask wrote:

Hi there, many thanks to @takashi and all the others!

I have an addendum to the above question:

The resulting table will look like this:

VNKNNKVSTBSTVALUE1231230200A123123200400A1231238001000B12312310001200B

Is there a way to "compress" it, like this? All values with adjacend VST/BST on the same road segment (VNK/NNK) should be combinded:

VNKNNKVSTBSTVALUE1231230400A1231238001200B
OK. A possible way is:

 

 

AttributeCreator Conditional Value Setting:

 

 

AttributeManager Parameters:

 

 


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