AliFlux / VectorTileRenderer

A comprehensive Vector Map Tile Renderer for .Net/C#
MIT License
187 stars 52 forks source link

Interpolated styles not supported #10

Open Gyroscope07 opened 5 years ago

Gyroscope07 commented 5 years ago

MapBox styles include interpolation definitions for things line-width, fill-opacity etc in the following form:

...
{
    ...
    "line-opacity": [
        "interpolate",
        ["linear"],
        ["zoom"],
        5,
        0,
        6,
        0.5
    ],
    ...
},
...

It looks as though the styles parser in this library can only handle distinct step definitions in this form:

...
{
    ...
    "line-opacity": {
        "base": 1.5,
        "stops": [
            [
                2,
                0.3
            ],
            [
                7,
                0
            ]
        ]
    },
    ...
}
....

which causes an invalid cast exception when trying to parse the style.json

if (paintData.ContainsKey("line-opacity")){
    paint.LineOpacity = Convert.ToDouble(getValue(paintData["line-opacity"], attributes));
}
System.InvalidCastException: 'Unable to cast object of type 'System.Object[]' to type 'System.IConvertible'.'
charlenni commented 5 years ago

As you can see, in this library only „stops“ are implemented. I assume, that you have to implement by your own. But be careful, this library creates tiles with integer zoom values.