Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

Conditional and FromStyleBlockAttr #1

Closed
vvoovv opened this issue May 1, 2020 · 13 comments
Closed

Conditional and FromStyleBlockAttr #1

vvoovv opened this issue May 1, 2020 · 13 comments

Comments

@vvoovv
Copy link
Owner

vvoovv commented May 1, 2020

claddingMaterial = PerBuilding(Value(Alternatives(
    FromAttr("roof:material", FromAttr.String, CladdingMaterials),
    Conditional(
        lambda roof: roof.footprint.getStyleBlockAttr("roofShape") == "flat",
        RandomWeighted(( ("concrete", 1), ("gravel", 1) ))
    ),
    Conditional(
        lambda roof: roof.footprint.getStyleBlockAttr("roofShape") == "dome",
        Constant("glass")
    ),
    FromStyleBlockAttr("claddingMaterial", FromStyleBlockAttr.Footprint)
)))
@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

Condtional has to arguments:

  • a condition
  • a value

It returns the value if the conditions is True, otherwise it returns None.

@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

It can be represented in PML as:

claddingMaterial:
    FromAttr("roof:material") |
    RandomWeighted( ("concrete", 1), ("gravel", 1) ) if item.footprint["roofShape"] == "flat" |
    glass if item.footprint["roofShape"] == "dome" |
    item.footprint["claddingMaterial"]
;           

@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

How to represent it in blosm nodes?

@vvoovv vvoovv changed the title Conditional Conditional and FromStyleBlockAttr May 1, 2020
@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

Conditional node

Input sockets:

  • condition
  • value

Output sockets:

  • value

@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

From Style Block node

Input sockets:
no

Output sockets:

  • value

Properties:

  • item (a choice between "self", "footprint" and "parent")
  • attribute (a list of popular style block attributes)

@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

From OSM node

Input sockets:
no

Output sockets:

  • value

Properties:

  • OSM tag (a long list of the popular OSM tags)

@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

Alternatives node

Input sockets (probably 7 values is enough):

  • value 1
  • value 2
  • value 3
  • value 4
  • value 5
  • value 6
  • value 7

Output sockets:

  • value

@vvoovv
Copy link
Owner Author

vvoovv commented May 1, 2020

How to represent it in blosm nodes?


    FromAttr("roof:material", FromAttr.String, CladdingMaterials),

From OSM.value -> Alternatives.value 1


    Conditional(
        lambda roof: roof.footprint.getStyleBlockAttr("roofShape") == "flat",
        RandomWeighted(( ("concrete", 1), ("gravel", 1) ))
    ),

RandomWeighted.value -> Conditional.value
Conditional.value -> Alternatives.value 2


    Conditional(
        lambda roof: roof.footprint.getStyleBlockAttr("roofShape") == "dome",
        Constant("glass")
    ),
)))

CladdingMaterial.value -> Conditional.value
Conditional.value -> Alternatives.value 3


    FromStyleBlockAttr("claddingMaterial", FromStyleBlockAttr.Footprint)

From Style Block.value -> Alternatives.value 4


And finally:
Alternatives.value -> Roof.claddingMaterial

@vvoovv
Copy link
Owner Author

vvoovv commented May 4, 2020

Per Building node

Input sockets:

  • value

Output sockets:

  • value

@vvoovv
Copy link
Owner Author

vvoovv commented May 4, 2020

Per Footprint node

Input sockets:

  • value

Output sockets:

  • value

@polarkernel
Copy link
Contributor

I do not really understand the term item in the condition. The proposition in PML is

glass if item.footprint["roofShape"] == "dome"

while the corrsponding Python code becomes

    Conditional(
        lambda roof: roof.footprint.getStyleBlockAttr("roofShape") == "dome",
        Constant("glass")
    ),

How can a translator find that the item is roof here? Where does this context come from?

@vvoovv
Copy link
Owner Author

vvoovv commented May 16, 2020

Any variable can be used in the Python's lambda syntax:
lambda anything: anything is None

I'd suggest always use the variable item in the Python code.

@vvoovv
Copy link
Owner Author

vvoovv commented Aug 6, 2020

To be continued at prochitecture/pml#6

@vvoovv vvoovv closed this as completed Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants