1

I want to create an application using vector tile. I am using openlayers v.5 and geoserver 2.14.1 for this purpose. In geoserver SLD i have added OGC filter which filters geometries on the basis of scale and provide PerpendicularOffset to the features. For WMS layer this SLD is working fine, but for vector layer only filters are working but offset is not working.

Here is my sample SLD:

   <se:Rule>
      <se:Name>1;+</se:Name>
      <se:Description>
        <se:Title>1;+</se:Title>
      </se:Description>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
          <ogc:Or>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>FUNCTIONCL</ogc:PropertyName>
              <ogc:Literal>1</ogc:Literal>
            </ogc:PropertyIsEqualTo>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>FUNCTIONCL</ogc:PropertyName>
              <ogc:Literal>2</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Or>
      </ogc:Filter>
   <se:MinScaleDenominator>500000</se:MinScaleDenominator>
      <se:MaxScaleDenominator>1000000</se:MaxScaleDenominator> 
      <se:LineSymbolizer>
        <se:Stroke>
          <se:SvgParameter name="stroke"><ogc:PropertyName>color</ogc:PropertyName></se:SvgParameter>
          <se:SvgParameter name="stroke-width">3</se:SvgParameter>
          <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
          <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
        </se:Stroke>
     <se:PerpendicularOffset>3</se:PerpendicularOffset>
      </se:LineSymbolizer>
    </se:Rule>
    <se:Rule>
      <se:Name>1;+</se:Name>
      <se:Description>
        <se:Title>1;+</se:Title>
      </se:Description>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>FUNCTIONCL</ogc:PropertyName>
              <ogc:Literal>1</ogc:Literal>
            </ogc:PropertyIsEqualTo>
      </ogc:Filter>
   <se:MinScaleDenominator>1000000</se:MinScaleDenominator>
      <se:MaxScaleDenominator>30000000</se:MaxScaleDenominator> 
      <se:LineSymbolizer>
        <se:Stroke>
          <se:SvgParameter name="stroke"><ogc:PropertyName>color</ogc:PropertyName></se:SvgParameter>
          <se:SvgParameter name="stroke-width">3</se:SvgParameter>
          <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
          <se:SvgParameter name="stroke-linecap">square</se:SvgParameter>
        </se:Stroke>
    <se:PerpendicularOffset>3</se:PerpendicularOffset>
      </se:LineSymbolizer>
    </se:Rule>

I have read http://docs.opengeospatial.org/per/17-041.pdf book page 24, which states that "For vector tiles, only the "what rules (filters)" are relevant so as to configure what data to put inside a vector tile. The "how rules (symbology)" are under the control of the client."

I have also tried mapbox style in the client side by adding olms.js in the code.

style file: line.json

  {
 "version": 8,
 "name": "states",
 "sources": {
 "states": {
  "type": "vector",
  "data": "http://localhost:8080/geoserver/gwc/service/tms/1.0.0/cite:tmc@EPSG%3A900913@geojson/{z}/{x}/{-y}.geojson"
}
},
  "layers": [
 {
  "id": "line_casing",
  "source": "states",
  "type": "line",
  "paint": {
    "line-color": "blue",
    "line-width": "2",
    "line-offset": 50
  }
  }
  ]
  }

sample code:

    var projection_epsg_no = '900913';

    var tmcsource = new ol.source.VectorTile({
        cacheSize: 0,
        tilePixelRatio: 1, // oversampling when > 1
        tileGrid: ol.tilegrid.createXYZ({ maxZoom: 19, tileSize: 512 }),
        format: new ol.format.MVT(),
        url: 'http://localhost:8080/geoserver/gwc/service/tms/1.0.0/' + layer +
        '@EPSG%3A' + projection_epsg_no + '@pbf/{z}/{x}/{-y}.pbf'
    });

    fetch('line.json').then(function (response) {
        response.json().then(function (glStyle) {
    map.addLayer(new ol.layer.VectorTile({
        style: olms.getStyleFunction(glStyle, 'states'),
        source: tmcsource
    })
            );
        });
    });

"line-color", "line-width" properties are working fine but line-offset property is still not working.

Is there is any way to provide offset client side using vector tile??

  • as the quote you include says this is a client side issue so I have removed your geoserver tag – Ian Turton Jan 28 at 11:27
  • 2
    if you search the source of olms.getStyleFunction github.com/openlayers/ol-mapbox-style/blob/master/… for line-offset there are no matches, so presumably it isn't supported because there is no simple equivalent in OpenLayers. If you were to save the output from olms.getStyleFunction it might be possible to use that as the basis for a custom OpenLayers style function to reproduce a similar effect. – Mike Jan 28 at 11:46

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.