[Geoserver-users] Use of $SCALE-info in an SQL View?

Hi,

In QGIS there is something what we call 'Geometry-generators': you actually generate a geometry based on some other geometry and some parameters, coming from 'expressions'.

In this way it is for example possible to create some kind of polygon based on a point layer.
My goal: create rotated 'wedges/sectors' with a data-based rotation from a point layer (talking about GSM 'beams' here), but (tricky part): size depending on the current map scale...

My plan to mimic this in a Geoserver WMS:
- have a point layer in postgis
- create a postgis function to create a wedge (taking the attribute in account)
- create a SQL view layer which creates a geom by calling this function

Question: is it possible for geoserver to 'insert' the scale (as being requested in the WMS request) into this function-call as parameter. Something like $SCALE or $SCALE_DENOMINATOR or so, which is to be replaced by Geoserver BEFORE handling over the query to postgis?

Looking into the docs[0], it looks like it would be possible with a (client site added) parameter. But in this case the 'scale'-information should come from the WMS-request-info (as it is not possible to change the client apps for us).

Mmm, now I am afraid this is maybe hard as it makes it impossible to 'cache' this view...

Anyone idea's?

Regards,

Richard Duivenvoorde

[0] https://docs.geoserver.org/stable/en/user/data/database/sqlview.html

It might be easier to do this in a custom function in GeoTools rather than in PostGIS - then you could pass in the scale env variable along with the feature that you are drawing.

Ian

···

Ian Turton

On 8/3/20 12:40 PM, Ian Turton wrote:

It might be easier to do this in a custom function in GeoTools rather than in PostGIS - then you could pass in the scale env variable along with the feature that you are drawing.

Ian

Mmm, that is (at least in my opinion) a little over the top... Adding java functions does not count as configuration I think :slight_smile:

I was hoping that I could use some kind of variable for this. Like you can apparently use 'wms_scale_denominator' in sld symbolizers:
https://docs.geoserver.org/stable/en/user/styling/sld/extensions/substitution.html

As an work-around in this case I can off course add the rules for every zoom level...

Regards,

Richard Duivenvoorde

wms_scale_denominator is a “env” variable that only the “env” function sees,
while view params follow a completely different path.
It would be possible to load up all env variables into the view params map I guess,
I assume it would have to be done with a new config flag to avoid potential regressions for
existing installations… and it would require some java coding, too :smiley:

Cheers
Andrea

···

Regards, Andrea Aime

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.