Skip to main content
Solved

Create a report from features

  • October 3, 2019
  • 3 replies
  • 94 views

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

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  

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • 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
  • 48 replies
  • 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
  • 48 replies
  • October 7, 2019

Hi @dms2

 

I used the transformer TestFilter to filter the fisrt condition:

 

Thanks in Advance,

Danilo

Thanks! I got it. See my answer above.