hslayers / map-compositions

MIT License
0 stars 0 forks source link

Support for inheritance #7

Open fzadrazil opened 2 years ago

fzadrazil commented 2 years ago

As described here https://github.com/hslayers/hslayers-ng/issues/3307, there are cases where it would be useful to have a mechanism for extending a composition by another one. It would mean to introduce a new parameter extends that would specify the "parent" composition. Any ideas or objections to this?

jirik commented 2 years ago

Interesting idea that needs clarification, mostly how to merge inherited properties (e. g. objects, arrays) with properties of child layer. It should be described for each property of map composition file.

fzadrazil commented 2 years ago

I would not expect parent and child to contain a definition of the same layer. But in such case, the "new" definition would completely overwrite the parent without any merging of the properties.

jirik commented 2 years ago

OK, and how can you decide if two layers are same? I am not sure about it.

And what about inheritance of other composition root properties?

Bold properties are currently required. If we enable to inherit them, it means to change also JSON schema. And I assume we will not find sufficient JSON schema syntax to describe rules for required properties among inherited compositions. So we will probably need to write more validation logic on our own.

And what about multi-level inheritance, e.g. composition A -> composition B -> composition C? Support it, or not?

fzadrazil commented 2 years ago

I suppose the original idea was to inherit only the layers collection. For all the reasons you are mentioning. So the validation stays more or less the same. We would just have to check if the schema_version is the same for parent and child.

OK, and how can you decide if two layers are same? I am not sure about it.

Right. As I said, I don't see as relevant to define the same layer in child map. So lets not support overwriting any properties. Simply take all the layers from parent and add all layers from child.

We could probably discuss this online and describe the conslusions here.

jirik commented 2 years ago

Summary of today's call: Let's start only with inheriting layers collection. All layers from parent composition will be added (visually below) layers of child composition. Only single-level inheritance will be possible.

On Layman, we will need to implement following: