Skip to main content
Solved

Create a report from features


dms2
Contributor
Forum|alt.badge.img+11
  • Contributor

What transformers do I need to generate a report from a number or features like these?

LAYERVALUECHECK_CLASSATTRIBUTEVALUEID1ID2SitesOut of domainSite_typeHistorical45SS023SitesOut of domainSite_typeNature cons60SS017Info_pointsOut of domainFacilityMMC22IP06Info_pointsNot a numberNum_visitsAbout 1015IP08StopsToo longVisibilityNot so good25ST041SitesOt of domainSite_typeHistorical31SS001SitesToo longIn_siteEmma (except Mondays)21SS015SitesOut of domainCertificCHECK62SS030

 

I need to generate a tree report showing for every LAYER every different VALUECHECK_CLASS, and for every VALUECHECK_CLASS every different ATTRIBUTE. And then show a table or anything similar with VALUES checked and the feature IDs (sorted if possible).

Something like this:

Sites

1. Out of domain

  • Site_type
ValuesGlobal IdLayer IdHistorical31

 

45SS001

 

SS023Natural cons60ss017
  • Values Global Id Layer Id
ValuesGlobal IdLayer IdCHECK

 

62

 

SS030

 

2. Too long

  • In_site
ValuesGlobal IdLayer IdEmma (except Mondays)21SS015

 

Info_points

1. Out of domain

  • Facility
ValuesGlobal IdLayer IdMMC22IP06

2. Not a number

  • Num_visits
ValuesGlobal IdLayer IdAbout 1015IP08

 

I thought the Aggregator transformer together with the HTMLReportGenerator transformer would help but I can't get at all what I want. Any ideas?

Best answer by dms2

After taking a break to clear my mind I found a solution.

I used a series of Aggregators to create nested lists. So the first Aggregator generates an Id list with ID2 and ID1 attribute values, the second Aggregator generates a list with VALUE attribute values and ID list values, and so on.

I end up having a feature for each LAYER value and each feature has nested lists like this:

Class{}.VALUECHECK_CLASS

Class{}.Attribute{}.ATTRIBUTE

Class{}.Attribute{}.Value{}.VALUE

Class{}.Attribute{}.Value{}.Id{}.ID1

Class{}.Attribute{}.Value{}.Id{}.ID2

 

Afterwards I used PythonCaller transformer to loop through each nested list starting with Class list to generate a tree report.

I used nested While loops to loop through list indexes:

        layer= feature.getAttribute('LAYER')
        ...
        classList = feature.getAttribute('Class{}.VALUECHECK_CLASS')
        l_classList  = len(classList)
        i = 0
        while i < l_classList :
            ...
           attrsList = feature.getAttribute('Class{'+str(i)+'}.Attribute{}.ATTRIBUTE')
            l_attrsList  = len(attrsList)
            j = 0
            while j < l_attrsList :
                ...
                valuesList = feature.getAttribute('Class{'+str(i)+'}.Attribute{'+str(j)+'}.Value{}.VALUE')
                l_valuesList  = len(valuesList)
                k = 0
                while k < l_valuesList :
                    ...
                    idsList = feature.getAttribute('Class{'+str(i)+'}.Attribute{'+str(j)+'}.Value{'+str(k)+'}.Id{}.ID1')
                    l_idsList = len(idsList)
                    l = 0
                    while l < l_idsList:
                        ...
                        l += 1
                    k += 1
                j += 1
            i += 1  

 

 

View original
Did this help you find an answer to your question?

3 replies

danilo_fme
Evangelist
Forum|alt.badge.img+45
  • Evangelist
  • October 4, 2019

Hi @dms2

 

I used the transformer TestFilter to filter the fisrt condition:

 

Thanks in Advance,

Danilo


dms2
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • Best Answer
  • October 7, 2019

After taking a break to clear my mind I found a solution.

I used a series of Aggregators to create nested lists. So the first Aggregator generates an Id list with ID2 and ID1 attribute values, the second Aggregator generates a list with VALUE attribute values and ID list values, and so on.

I end up having a feature for each LAYER value and each feature has nested lists like this:

Class{}.VALUECHECK_CLASS

Class{}.Attribute{}.ATTRIBUTE

Class{}.Attribute{}.Value{}.VALUE

Class{}.Attribute{}.Value{}.Id{}.ID1

Class{}.Attribute{}.Value{}.Id{}.ID2

 

Afterwards I used PythonCaller transformer to loop through each nested list starting with Class list to generate a tree report.

I used nested While loops to loop through list indexes:

        layer= feature.getAttribute('LAYER')
        ...
        classList = feature.getAttribute('Class{}.VALUECHECK_CLASS')
        l_classList  = len(classList)
        i = 0
        while i < l_classList :
            ...
           attrsList = feature.getAttribute('Class{'+str(i)+'}.Attribute{}.ATTRIBUTE')
            l_attrsList  = len(attrsList)
            j = 0
            while j < l_attrsList :
                ...
                valuesList = feature.getAttribute('Class{'+str(i)+'}.Attribute{'+str(j)+'}.Value{}.VALUE')
                l_valuesList  = len(valuesList)
                k = 0
                while k < l_valuesList :
                    ...
                    idsList = feature.getAttribute('Class{'+str(i)+'}.Attribute{'+str(j)+'}.Value{'+str(k)+'}.Id{}.ID1')
                    l_idsList = len(idsList)
                    l = 0
                    while l < l_idsList:
                        ...
                        l += 1
                    k += 1
                j += 1
            i += 1  

 

 


dms2
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • October 7, 2019
danilo_fme wrote:

Hi @dms2

 

I used the transformer TestFilter to filter the fisrt condition:

 

Thanks in Advance,

Danilo

Thanks! I got it. See my answer above.


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