Setup details:
Geoserver: 2.12.1
DataStore: PostgreSQL 10.1 with PostGIS 2.4.2
mapbox-gl: 0.42.0

I am using mapbox-gl to render vector tiles from geoserver using TMS. I am styling the tiles using data-driven styling as explained here. The styling works amazingly for most of the part, but there are few datasets which are not being styled properly.
The problem occurs in case of interval based styling on an attribute which is not of Integer type in the postgreSQL tables.

The following are snapshots of the table:

postgres# \d+ layer_data

  Column  |   Type  
  lat     |   numeric  

On the Geoserver portal (Edit Layer --> 'Data' tab), the layer attribute looks like:
enter image description here

The feature data received on the mapbox-gl in JSON form is as follows:

  "__mlocate__created_by": 1,
  "__mlocate__created_date": "2016-05-02",
  "__mlocate__id": 343620,
  "__mlocate__layer_id": 410,
  "altitude": "0",
  "country": "India",
  "date_issue": "No",
  "id": "27283",
  "lat": "27.038510519999999",
  "lng": "88.459210400000003",

The URL being hit by the browser to get tiles is:

The style file does data-driven style as below:

'circle-color': {
        property: 'lat',
        type: 'interval',
        stops: [
          [6, '#eee4e5'],
          [12, '#cdaaea'],
          [24, '#bd82f8'],
          [37, '#9c55f1'],
          [49, '#8129fa'],

The styling doesn't work and all circles are just drawn in black color. I guess this is because the value of 'lat' field is being interpreted as String (notice that this value is enclosed in quotes in JSON data as opposed to some other values, which are Integer type in the database) and hence the styling is not working.
But since this is defined as numeric data type in postgres, is it the geoserver that is sending it as a wrong data type in tiles information or is it mapbox-gl who is mis-interpreting the information send by Geoserver?

  • if the circles are drawn in the correct place then the error is probably with your style not the coordinates – Ian Turton Dec 27 '17 at 11:32
  • @IanTurton The circles are in correct place because the geometry filed is in correct format. The 'lat' value here is an additional attribute and not used for marking circles. – Priyanshu Agarwal Dec 27 '17 at 12:53
  • @PriyanshuAgarwal I saw your post in the Geoserver mail group, did you ever find a solution. I have the same problem with big decimals being sent as strings. – mapping dom Mar 25 at 19:15
  • @mappingdom The feedback I had received from the geoserver guys was that the vector tiles was still evolving and not every data format is supported yet. Unfortunately, Big Decimal was one of them. I did not think of a workaround as this was a low priority task for me. In case you figure something out, please put it here as an answer. – Priyanshu Agarwal Mar 27 at 2:58
  • No I followed these (service-architecture.com/articles/database/…) and recast the numeric type in the source db as a work round – mapping dom Mar 28 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.