# Foreground extrusions missing with vector tile returned by the vector tile search API

**URL:** <https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137>\
**Category:** Elasticsearch\
**Created:** [May 6, 2022, 3:15pm UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137 "2022-05-06T15:15:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thibaultclem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thibaultclem/32/3668_2.png) [@thibaultclem](https://discuss.elastic.co/u/thibaultclem)\
**Post date:** [May 6, 2022, 3:15pm UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137/1 "2022-05-06T15:15:57Z")

</div>

We use Mapbox GL JS to retrieve tiles from the new vector tile search API.

Everything work as expected until we try to extrude the features to display it in 3D:

```auto
map.addLayer({
          id: 'building_layer',
          type: "fill-extrusion",
          source: 'building_source',
          minzoom: 12,
          "source-layer": "hits",
          paint: {
            "fill-extrusion-color": "#00ade6",
            "fill-extrusion-height": 2,
          },
        });

```

As you can see on the image, the foreground extrusions is missing:

 ![Screen Shot 2022-05-06 at 4.44.36 PM](https://us1.discourse-cdn.com/elastic/original/3X/b/5/b56dafd2fe812d3bb580c8ba0d1db9142b3541d3.png)

When I decode the tile using node-mapnik I get:

```auto
[{"name":"hits","extent":4096,"version":2,"features":[{"type":3,"properties":{"_id":"59633","_index":"building-v1","id":59633,"gross_floor":180,"floor_nb":2,"unit_nb":1,"protected_rank":0,"principal_type":"Zone d'habitation de très faible densité","city_name":"La Tour-de-Peilz"},"geometry":[9,934,5244,26,22,18,6,7,21,17,15]}]},{"name":"meta","extent":4096,"version":2,"features":[{"type":3,"properties":{"_shards.failed":0,"_shards.skipped":0,"_shards.successful":1,"_shards.total":1,"timed_out":false,"took":1},"geometry":[9,0,8192,26,8192,0,0,8191,8191,0,15]}]}]

```

Then when I try to get the validity report of this tile with node-mapnik I got the following error:

```auto
[Error: Vector Tile has POLYGON with first ring clockwise. It is not valid according to v2 of VT spec.]

```

It looks like an old issue in PostGIS 2.4.4 related on this post:

> <https://github.com/mapbox/mapbox-gl-js/issues/7767>
>
> I'm experiencing an issue displaying tiles generated using PostGIS St\_AsMVT in m…apbox. The foreground extrusions are always missing.
> 
> \<img src="https://s3-eu-west-1.amazonaws.com/www.iventis.co.uk/assets/postgis\_vs\_mapnik.png"\>
> 
> As this seems to be specific to tiles generated by PostGIS, I posted this as an issue with PostGIS (https://trac.osgeo.org/postgis/ticket/4293). However, they are suggesting the tile is valid and it therefore may be a mapbox issue (or something i'm doing wrong).
> 
> \*\*mapbox-gl-js version\*\*: v0.52.0
> \*\*browser\*\*: Chrome Version 71.0.3578.98
> 
> \### Steps to Trigger Behavior
> 
> 1. Create a MVT containing a Polygon generated from PostGIS using St\_AsMVT e.g.
> \*\*Query used to generate tile in PostGIS\*\*
> \`SELECT (ST\_AsMVT(q, '303', 4096, 'geom')) as data FROM
> (
> SELECT
> ST\_AsMVTGeom(
> ST\_MakeValid(ST\_Transform(ST\_GeomFromText('POLYGON((2.35044440995268 48.8547079153776,2.34939134536916 48.8548089953983,2.34865467128913 48.8544487872917,2.34849994773995 48.8531318335876,2.35117736888415 48.8532126364981,2.35044440995268 48.8547079153776))',4326),3857)),
> ST\_MakeBox2D(ST\_Point(260497.392395924, 6250714.42504853), ST\_Point(261720.384848486, 6249491.43259597)),
> 4096,
> 256,
> true
> ) geom
> ) as q\`
> 2. Display polygon using fill-extrusion
>  
> 
> \### Link to Demonstration
> 
> \*\*PostGIS tile rendered in mapbox\*\*
> https://s3-eu-west-1.amazonaws.com/www.iventis.co.uk/test.html
> 
> \### Expected Behavior
> 
> Fill-extrusion should render with solid sides/walls.
> 
> Here is an example with the same tile rendered from a Mapnik generated tile which appears correctly:
> 
> \*\*Mapnik tile rendered in mapbox\*\*
> https://s3-eu-west-1.amazonaws.com/www.iventis.co.uk/test\_mapnik.html
> 
> \### Actual Behavior
> 
> The foreground extrusions are always missing when tiles have been generated by PostGIS.
> 
> \### Links to tiles
> 
> \*\*PostGIS generated tile\*\*
> https://s3-eu-west-1.amazonaws.com/www.iventis.co.uk/assets/15/16597/11273.pbf
> 
> \*\*Mapnik generated tile\*\*
> https://s3-eu-west-1.amazonaws.com/www.iventis.co.uk/assets/mapnik/15/16597/11273.pbf

Who was fix in 2.4.5:  
[https://trac.osgeo.org/postgis/ticket/4079](https://trac.osgeo.org/postgis/ticket/4079)

Is there something I doing wrong, or do I need to create an issue on Github ?

For information the orientation of my geo\_shape is RIGHT.  
Elasticsearch version is 8.2.0, environment is Elastic cloud.

All the best,

Thibault

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [May 7, 2022, 7:19am UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137/2 "2022-05-07T07:19:32Z")

</div>

Hi Thibault,

Thank you for reporting, this looks very similar to the bug fixed in the upstream library we are using:

> <https://github.com/wdtinc/mapbox-vector-tile-java/issues/36>
>
> It seems that rings orientation in polygons is wrong. The specs says that exteri…or ring must be clockwise \*\*in screen coordinates\*\*. But orientation is flipped when JTS geometry is encoded to mvt, so preparation step should do the opposite orientation when it operates with JTS geometry. Mapbox encoder implementation does it like I say https://github.com/mapbox/geojson-vt/blob/d3bf094b1329dd84dcc8446ba407c9830469b808/src/tile.js#L113
> 
> Because of this issue extruded polygons are displayed inside out in mapboxgl viewer
> 
> !\[Screen Recording 2019-05-09 at 2 42 59 PM\_1\](https://user-images.githubusercontent.com/3988889/57440998-da88a980-726a-11e9-9c07-de18b13ef2f7.gif)
> 
> When I swapped orientation checks for exterior and interior rings in the following file then 3d polygons became normal
> https://github.com/wdtinc/mapbox-vector-tile-java/blob/e5e3df3fc2260709e289f972a1348c0a1ea30339/src/main/java/com/wdtinc/mapbox\_vector\_tile/adapt/jts/JtsAdapter.java#L366
> https://github.com/wdtinc/mapbox-vector-tile-java/blob/e5e3df3fc2260709e289f972a1348c0a1ea30339/src/main/java/com/wdtinc/mapbox\_vector\_tile/adapt/jts/JtsAdapter.java#L385

Unfortunately it seems the fix has never been released. Could you please open an issue in the Elasticsearch repository?

---

<div class="post-metadata">

**Author:** ![thibaultclem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thibaultclem/32/3668_2.png) [@thibaultclem](https://discuss.elastic.co/u/thibaultclem)\
**Post date:** [May 9, 2022, 6:59am UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137/3 "2022-05-09T06:59:31Z")

</div>

Hi Ignacio,

Thanks for your quick reply, I will open an issue on github.

Thibault

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [May 24, 2022, 5:01pm UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137/4 "2022-05-24T17:01:44Z")

</div>

Adding the issue here: [Foreground extrusions missing with vector tile returned by the vector tile search API · Issue #86560 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/86560)

It should have been fixed in 8.2.1 and 7.17.4.

Thanks!

---

<div class="post-metadata">

**Author:** ![thibaultclem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thibaultclem/32/3668_2.png) [@thibaultclem](https://discuss.elastic.co/u/thibaultclem)\
**Post date:** [May 30, 2022, 8:17am UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137/5 "2022-05-30T08:17:52Z")

</div>

I confirm the fix is working as expecting. Thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 27, 2022, 8:18am UTC](https://discuss.elastic.co/t/foreground-extrusions-missing-with-vector-tile-returned-by-the-vector-tile-search-api/304137/6 "2022-06-27T08:18:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
