Metacity
  • Welcome
  • Metacity
    • Installation
    • [dev] CGAL Dependency
    • Data Import
    • Models and Attributes
    • Layers
    • Grids
    • Quad-trees
    • Dockerized Processor
    • Development notes
  • Archives
    • DataAPI
      • Development
    • MetacityGL
      • Installation
      • Creating a MetacityGL App
      • Writing Custom Layers
      • Loading Metacity Data
      • Development notes
    • BananaGL
      • Development
    • AMOS
      • Synthetic Population
        • Case Studies
        • Data Specification
        • Activity Chains
        • Spatial Distribution
        • MATSim population input and comparison
        • Households
      • MATSim
        • Basic Info
        • Running Scenario
          • Config File
          • Current state
        • Input information
          • OSM
          • Filtering GTFS
          • Coordinates
        • Output
          • Processing
      • OICT
        • MapResolver
      • Resources
        • Trafic Simulation
        • MATSim
        • Vis and Meta Software
        • Synthetic Population
        • Public Relations
        • Inspiration
    • Metacity Block Edition
      • Epic Games Mega Grant
      • 🧠Internal notes
  • Links
    • Homepage
    • GitHub
  • Code of Conduct
Powered by GitBook
On this page
  • Layer Modifiers
  • Height Mapping
  • Simplification
  • Height Map Re-mesh
Edit on GitHub
  1. Metacity

Layers

Organizing things into groups and how to modify them

Sometimes, it is handy to organize things into groups. In Metacity, you can use Layers.

from metacity.geometry import Layer, Model
layer = Layer()

models = [Model(), Model()]
#Layer.add_models(self, models: List[Model]) -> None
layer.add_models(models)

It is also possible to add a single model:

from metacity.geometry import Layer, Model
layer = Layer()

model = Model()
#Layer.add_model(self, model: Model) -> None
layer.add_model(model)

You can access the individual models again. Deleting a Model from the returned list does not remove it from the Layer. The models are not copied, the returned list contains references to the models stored inside Layer.

from metacity.geometry import Layer
layer = Layer()
#... loading data, processing it

#Layer.get_models(self) -> List[Model]
models = layer.get_models()

Moreover, it is possible to store and load the contents of a Layer to and from the .gltf format.

from metacity.geometry import Layer
layer = Layer()
#... loading data, processing it

#Store the data
#Layer.to_gltf(filename: str) -> None
layer.to_gltf("layer.gltf")

#Load the data
#Layer.from_gltf(filename: str) -> None
layer_copy = Layer()
layer_copy.from_gltf("layer.gltf")

Layer Modifiers

Layer offers a few handy methods which can modify models:

Height Mapping

If you have 2D point data in one Layer and a mesh with the height information (such as terrain) in a different one, you can easily map the original 2D data onto the terrain:

from metacity.geometry import Layer
from metacity.io import parse_recursively

terrain = Layer()
terrain.add_models(parse_recursively("terrain"))

trees = Layer()
trees.add_models(parse_recursively("trees"))

#Layer.map_to_height(self, layer: Layer) -> None
trees.map_to_height(terrain)

Simplification

In case you need to simplify your geometry by approximating it with its crude envelope (not a perfect convex hull), you can use the following method:

from metacity.geometry import Layer
from metacity.io import parse_recursively

buildings = Layer()
buildings.add_models(parse_recursively("buildings"))

#Layer.simplify_envelope(self) -> None
buildings.simplify_envelope()

Height Map Re-mesh

It is possible to re-mesh a model using a height-map approach. A grid of vertices is generated and placed "on top" of the source model, effectively covering it.

The new mesh is divided into several tiles (each is a separate Model), and each tile is further divided according to the supplied parameters:

from metacity.geometry import Layer
from metacity.io import parse_recursively

terrain = Layer()
terrain.add_models(parse_recursively("terrain"))

#Layer.simplify_remesh_height(self, tile_side: float, tile_divisions: int) -> None
terrain.simplify_remesh_height(100, 4)
PreviousModels and AttributesNextGrids

Last updated 2 years ago

In the example, the tile_side is an arbitrary number (let's say 100), and tile_divisions is equal to 4. The first tile is always aligned with the minimum coordinates of the Layer bounding box. The dotted lines correspond to edges in the newly generated mesh, bold dots are new vertices.