Skip to content

Create New Tool To Group Very Small Buildables Into a Seperate Containers for IXML Files at every Level #443

@R3tes

Description

@R3tes

Some codebases include many tiny buildings when visually represented (for example, gardens representing classes under 10 lines of code) that clutter the city layout. Rather than excluding them altogether, this new tool should let the user put those buildings into a new (virtual) container for “small things” so they remain represented int the end, but don’t overwhelm the main city view. The threshold for what counts as “small” is user-defined, and the user also selects which property triggers this grouping. The grouping should be done locally at every depth of the buildable tree.

Example tool run:

<buildable id="8b89726d-bdbb-4b7e-83d3-970ffa195458" name="codemetropolis" type="ground">
    <position x="0" y="0" z="0"/>
    <size x="9" y="9" z="9"/>
    <attributes/>
    <children>
        <buildable id="111aaa22-bbbb-43ab-9ea1-999999abcd11" name="LushGarden" type="garden">
            <position x="0" y="0" z="0"/>
            <size x="9" y="9" z="9"/>
            <attributes>
                <attribute name="flower-ratio" value="0.4"/>
            </attributes>
            <children/>
        </buildable>
        <buildable id="222bbb33-cccc-43ab-9ea1-000000abcd22" name="SparseGarden" type="garden">
            <position x="0" y="0" z="0"/>
            <size x="9" y="9" z="9"/>
            <attributes>
                <attribute name="flower-ratio" value="0.05"/>
            </attributes>
            <children>
                <buildable id="333ccc44-dddd-43ab-9ea1-aaaaaaabcd33" name="MiniGardenPatch" type="garden">
                    <position x="0" y="0" z="0"/>
                    <size x="9" y="9" z="9"/>
                    <attributes>
                        <attribute name="flower-ratio" value="0.02"/>
                    </attributes>
                    <children/>
                </buildable>
            </children>
        </buildable>
        <buildable id="444ddd55-eeee-43ab-9ea1-ffffffabcd44" name="CactusGarden" type="garden">
            <position x="0" y="0" z="0"/>
            <size x="9" y="9" z="9"/>
            <attributes>
                <attribute name="flower-ratio" value="0.2"/>
            </attributes>
            <children/>
        </buildable>
    </children>
</buildable>
java -jar GroupSmallBuildablesLocally.jar \
     --input originalFlower.xml \
     --property flower-ratio \
     --threshold 0.1 \
     --output groupedFlower.xml
<buildable id="8b89726d-bdbb-4b7e-83d3-970ffa195458" name="codemetropolis" type="ground">
    <position x="0" y="0" z="0"/>
    <size x="9" y="9" z="9"/>
    <attributes/>
    <children>

        <!-- "LushGarden" (0.4) stays as is -->
        <buildable id="111aaa22-bbbb-43ab-9ea1-999999abcd11" name="LushGarden" type="garden">
            <position x="0" y="0" z="0"/>
            <size x="9" y="9" z="9"/>
            <attributes>
                <attribute name="flower-ratio" value="0.4"/>
            </attributes>
            <children/>
        </buildable>

        <!-- "CactusGarden" (0.2) also remains a direct child -->
        <buildable id="444ddd55-eeee-43ab-9ea1-ffffffabcd44" name="CactusGarden" type="garden">
            <position x="0" y="0" z="0"/>
            <size x="9" y="9" z="9"/>
            <attributes>
                <attribute name="flower-ratio" value="0.2"/>
            </attributes>
            <children/>
        </buildable>

        <!-- New local container for the gardens with flower-ratio < 0.1 -->
        <buildable id="localSmallContainer_1" name="SparseGardens" type="virtual">
            <position x="0" y="0" z="0"/>
            <size x="9" y="9" z="9"/>
            <attributes/>
            <children>

                <!-- "SparseGarden" is placed here (0.05 < 0.1) -->
                <buildable id="222bbb33-cccc-43ab-9ea1-000000abcd22" name="SparseGarden" type="garden">
                    <position x="0" y="0" z="0"/>
                    <size x="9" y="9" z="9"/>
                    <attributes>
                        <attribute name="flower-ratio" value="0.05"/>
                    </attributes>
                    <children>
                        <!-- Nested container for smaller child "MiniGardenPatch" (0.02) -->
                        <buildable id="localSmallContainer_2" name="SparseGardens_UnderSparseGarden" type="virtual">
                            <position x="0" y="0" z="0"/>
                            <size x="9" y="9" z="9"/>
                            <attributes/>
                            <children>
                                <buildable id="333ccc44-dddd-43ab-9ea1-aaaaaaabcd33" name="MiniGardenPatch" type="garden">
                                    <position x="0" y="0" z="0"/>
                                    <size x="9" y="9" z="9"/>
                                    <attributes>
                                        <attribute name="flower-ratio" value="0.02"/>
                                    </attributes>
                                    <children/>
                                </buildable>
                            </children>
                        </buildable>
                    </children>
                </buildable>
            </children>
        </buildable>
    </children>
</buildable>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions