Repast / repast.simphony

Git repository for Repast Simphony development
repast.github.io
91 stars 21 forks source link

Allow GIS Styles to specify their own GIS layers #24

Open aliaksei135 opened 4 years ago

aliaksei135 commented 4 years ago

Currently, it seems only PlaceMarkLayer and SurfaceShapeLayer are allowed as GIS layers. I would like to have my own layers (subclassing from AbstractRenderableLayer) associated with my own styles.

Looks like this would just be changing DisplayGIS3D.registerStyle (and solve a TODO 😃 ). Would be happy to submit a PR

etatara commented 4 years ago

You're right, that it's just a matter of updating DisplayGIS3D.registerStyle and of course providing your own layers that implement AbstractRenderableLayer. The AbstractRenderableLayer class mostly just handles adding and removing agents from the model, and the subclasses provide all of the styling. The main constraint is that AbstractRenderableLayer implementations work with WWJ Renderable implementations, but I think that the WWJ Renderable is about as abstract as you can get within the API.

We'd be happy to include any improvements you share via a PR. There is a mechanism to provide implemented visualization classes to the Repast runtime without explicitly coding them in the Display classes, via the VizualizationRegistry. For example the GIS3DVisualizationRegistryData.java defines what types of style classes are available to the 3D GIS displays. We could potentially also define a map of available layers and their associated classes here as well. Please let me know if you'd like to discuss this further as it would be of benefit to the Repast community.

aliaksei135 commented 4 years ago

I think using WWJ Renderables is fine.

A couple of ways I have come up with:

  1. Naively, a way that springs to mind would be to make styles specify the layer they should be applied to by adding a getRenderableLayer method to the StyleGIS interface. This would require some modification of the existing style classes and probably wouldn't work as AbstractRenderableLayer specifies its the style.

  2. Allow the user to select the layers in the wizard somewhere and select what agents and styles apply to what layer. This would be similar to how StyleClassStep is currently and would use the VisualizationRegistry mechanism you described, but I'm not sure where this would fit in once it is in the registry.