mobile-sdk
mobile-sdk copied to clipboard
[feature-request] style json `extends` fields
In an effort to reduce style size and since most "sub-styles" (voyager, positron...) share the same json data it would nice to be able to use something like "extends":"./voyager.json" just like it works in most config files like tsconfig.json
Right now in my style it would reduce the style by 30kb
Good idea, I have included this in develop branch (in mobile-carto-libs).
@mtehver awesome! Didnot have time to test it but looking at the code the merge is done the wrong way. You are applying the extend to the original picojson. It should be the other way around.if extends it become the original and for every property in the "non extends" you overwrite the property from the "extends" picojson
No, the file referenced by 'extends' field is taken as a base and fields from current file overwrite base fields. So it should work the same way as 'extends' in tsconfig.json works.
Sorry my bad must have read it wrong !
@mtehver saw one last thing which should be nice. Here https://github.com/CartoDB/mobile-carto-libs/blob/master/cartocss/src/cartocss/CartoCSSMapLoader.cpp#L166 when you "override" the extended style, if the "value" is an object it should be a "merge". This is what tsconfig does for compilerOptions for example. The really nice thing in our case is that it could allow to "override" or add some nutiparameters
I would rather keep the current behavior, as merging objects would not allow deleting keys in 'extended' styles. It is also more uniform approach, treating all types equally.
@mtehver i understand. Now it makes the new theme i create difficult to maintain. Let me explain.
As you know i handle "icons" with font icons to reduce size and allow coloring of icon.
So i store icons unicode chars in nutiparameters.
With the extends all styles get the icons from the extends.
Now i would like to enable/disable some feature based on the style. Like the streets style should have contours disabled by default.
I dont see any other to do that than with nutiparameters. But then i need to be able to override some nutiparameters while keeping the icons.
Will see if i can do it differently