Skip to main content
Hello,

 

I want to create lines from points based on the following:

 

 

1) Each feature contains an attribute with one of the following value: 

 

A+, A or A-

 

2) Feature with A+ means start of the line

 

3) Feature(s) with A mean means continuation of the line. 

 

4) A- means end of the line. 

 

5) Another A+ means it will start a new line. 

 

 

I know I can use point connector to connect the points. But, I am having a hard time on creating and then keeping it connected until I encounter A- to break it. 

 

 

Any ideas?

 

 
Hi,

 

 

These approaches flashed in my mind.

 

 

1. AttributeCreator with the "Prior/Subsequent Feature Attribute Retrieval (Multiple Feature Attribute Support)" option and the "Conditional Value" setting

 

(1) AttributeExposer

 

Attribute To Expose: _line_id

 

(2) AttributeCreator

 

Number of Prior Features: 1

 

If Attribute is Missing, Null, or Empty: Use Fallback Value

 

Fallback Value: 0

 

Attributes To Set (Conditional Value Setting):

 

_line_id = If _attr = A+ Then featureT-1]._line_id + 1 Else featureE-1]._line_id

 

(3) PointConnector (Connection Break Point: _line_id)

 

 

 

2. VariableSetter/VariableRetriever

 

(1) Sampler

 

Sampling Type: First N Features

 

Sampling Amount: 1

 

(2) VariableSetter (for the "Sampled" feature, i.e. the first feature)

 

VariableName: vLineId

 

Value: 1

 

(3) VariableRetriever (for every feature)

 

VariableName: vLineId

 

Attribute ReceivingValue: _line_id

 

(4) VariableSetter_2

 

VariableName: vLineId

 

Value (Conditional Value setting):

 

If _attr = A- Then _line_id + 1 Else _line_id

 

(5) PointConnector (Connection Break Point: _line_id)

 

 

 

3. PythonCaller

 

-----

 

class FeatureProcessor(object):

 

    def __init__(self):

 

        self.line = None

 

        

 

    def input(self, feature):

 

        attr = feature.getAttribute('_attr')

 

        if attr == 'A+': # start

 

            self.line = feature

 

        elif self.line != None:

 

            self.line.addCoordinate(*feature.getCoordinate(0))

 

            if attr == 'A-': # end

 

                self.pyoutput(self.line)

 

                self.line = None

 

-----

 

 

Takashi
Regarding the VariableSetter/Retriever approach, this may be smarter than the previous one.

 


Reply