mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Add style-spec option to specify interpolation mode for raster-style sources

Open huaruiw opened this issue 9 years ago • 14 comments

mapbox-gl-js version: v0.34.0

Steps to Trigger Behavior

  1. create an ImageSource using a nice pixelated image
  2. add raster layer using created source

Expected Behavior

have an option to use gl.NEAREST so that my image is pixelated rather than blurry.

Actual Behavior

My nice pixelated image is now a blurry and ugly because ImageSource._prepareImage uses gl.LINEAR :( https://github.com/mapbox/mapbox-gl-js/blob/master/src/source/image_source.js#L157-L158

huaruiw avatar Mar 18 '17 19:03 huaruiw

Something for the GL Style Spec raster layer.

CartoCSS exposed this as the raster-scaling property.

Could be useful for maps like weather radars, mobile cell coverage too:

idr033

selection_494

andrewharvey avatar Mar 19 '17 04:03 andrewharvey

@andrewharvey yes! that's exactly what I meant.

huaruiw avatar Mar 19 '17 04:03 huaruiw

Updated the title to reflect a style-spec feature request (as @andrewharvey noted).

cc @mapbox/gl

anandthakker avatar Mar 21 '17 12:03 anandthakker

the texture is created in the source and not in the layer, so the source cannot know the layer paint properties when it creates the texture.

huaruiw avatar Sep 03 '17 04:09 huaruiw

Exactly what I am looking for. I am unable to use mapbox/GL for a lot of annotation jobs that require pixel-level accuracy.

Can we expect this anytime soon?

rohitrameshrao avatar Feb 12 '18 08:02 rohitrameshrao

To implement this, set the texture scale mode to gl.NEAREST, and expose this as an option in the style spec.

kkaefer avatar Feb 12 '18 08:02 kkaefer

@kkaefer Can you help with where can I change the texture scale mode to gl.nearest? I don't mind hard-coding this in my js file for now.

rohitrameshrao avatar Mar 26 '18 10:03 rohitrameshrao

@rohitrameshrao I believe it's the gl.LINEAR at https://github.com/mapbox/mapbox-gl-js/blob/3c07b72a59d78bc6240a8e3d77a54bec7619af5d/src/source/image_source.js#L201

andrewharvey avatar Mar 26 '18 11:03 andrewharvey

Thanks @andrewharvey! I tried changing it and building it. The map is still not pixelated! :/

rohitrameshrao avatar Mar 27 '18 10:03 rohitrameshrao

@rohitrameshrao that place in the code sets it for Image sources, if you're using a raster tile source then you'll also need to set it around https://github.com/mapbox/mapbox-gl-js/blob/3c07b72a59d78bc6240a8e3d77a54bec7619af5d/src/source/raster_tile_source.js#L106

UPDATE: ^ isn't right, I'm working on a PR which should solve this.

andrewharvey avatar Mar 27 '18 12:03 andrewharvey

@rohitrameshrao take a look at https://github.com/mapbox/mapbox-gl-js/pull/6411 for the delta to get it working, at the moment I can only work out how to hardcode an Image source as either linear or nearest filtering, so if you need an urgent solution you could just use the current PR which has it hardcoded...

andrewharvey avatar Mar 28 '18 05:03 andrewharvey

@rohitrameshrao from my testing #6411 is working well, would appreciate if you could test it out too.

andrewharvey avatar Apr 21 '18 05:04 andrewharvey

@andrewharvey Sure! Will test this in the next couple of days and let you know. Thanks!

rohitrameshrao avatar Apr 23 '18 07:04 rohitrameshrao

Awesome thanks!

huaruiw avatar Jun 19 '18 05:06 huaruiw