Thank you very much for your answers.  All 3 of them are super useful.

Ian, I do not have the luxury of building up the string in a single
attribute, so I need to use the Concatenate or strConcat functions from
Jody's reference.  Andrea, the WKT X and Y coordinates are not separated by
a comma but rather by a space.

The strConcat function only joins 2 strings, the Concatenate function is
able to join many strings.

So something like this should work:

label-geometry: [geomFromWKT(Concatenate('POINT(', label_lng, ' ',
label_lat, ')'))];
or
label-geometry:
[geomFromWKT(strConcat(strConcat(strConcat(strConcat('POINT(', label_lng),
' '), label_lat), ')'))];

However, the SLD created contains (for the space separator between X and
Y):
<ogc:Literal> </ogc:Literal>

and it appears from my testing and debugging that this is evaluated as ""
i.e. an empty string.

(I get the exception: `bad wkt` when evaluating it, and I have confirmed
the above in Eclipse)

Trying to force a `&nbsp;` into the Literal does not work.

Is there a bug with parsing a literal space?

So, I am very close to my solution, I just need a way to represent a
literal space, if anyone can assist, please?

Thanks

Peter

On Thu, 26 Oct 2023 at 17:29, Ian Turton <ijtur...@gmail.com> wrote:

> I usually use `geomFromWKT(geometry)` with a string like 'POINT('+x+'
> '+y+')' as the parameter. But a nicer function would be useful.
>
> There is also a pole of accessibility function that is better than
> centroid if you have oddly shaped polygons.
>
> Ian
>
> On Thu, 26 Oct 2023 at 16:22, Jody Garnett <jody.garn...@gmail.com> wrote:
>
>> There should be a function to create a point from lat, Lon but I do not
>> see it in the function list. It is a little to do anything other than
>> transform the main geometry - since often the data is queried using a BBOX
>> against the main geometry.
>>
>> For greater control I would recommend use the centroid as a staring
>> location, and provide an offset to determine the label position. The offset
>> can be expressed as an expression which you can adjust for scale.
>>
>> Reference:
>>
>>    -
>>    https://docs.geotools.org/stable/userguide/library/main/function_list.html
>>
>> --
>> Jody Garnett
>>
>>
>> On Oct 26, 2023 at 5:32:55 AM, Peter Smythe <g...@smythe.co.za> wrote:
>>
>>> Hi all
>>>
>>> I am trying to use 2 numeric attributes called label_lat and label_lng
>>> to create a point geometry for the labeling of a polygon.
>>>
>>> Can anyone point me to the correct format, if this is indeed possible?
>>>
>>> I cannot find the information on
>>> https://docs.geoserver.org/latest/en/user/styling/css/index.html
>>> <https://fdfdfha.r.af.d.sendibt2.com/tr/cl/xyoUP5eN464DydrOGqm8BDm7444mIJZfoKj7NPfOgCaOWczz2TBs_wlTzeAWk-wH7YI8cPsDW5UXJQ7xrUegk_MeefrvVxLjepbnzSSla_tRhI5B2JuKxN3QhnO3Cl32jH8y4FglrQP3-2eECQLO10LEafasD05kJX5EskHxKcfNNV8lJ-pknCUbsxUVR6QrSYLIdlY4KUwdeX8x1MKCdK5tPk-hXMkazYYWnOp5nCN0VV2kFx1PqYodo8t1EPzmgxXfk6qf1ufXJ_mbr3CdQpeVz1Mj47CsH7qGdzA>
>>>
>>> I have tried:
>>>
>>>     label-geometry: [label_lng], [label_lat];
>>>     label-geometry: [(label_lng, label_lat)];
>>> etc
>>>
>>> and the reverse coordinate orders
>>>
>>>     label-geometry: [centroid(geom)];   does work as expected, but I
>>> need more control.
>>>
>>>
>>> *I also cannot create a new column in the GeoServer SQL view that is
>>> visible in the output e.g. ST_Point (label_lng, label_lat, 4326) as
>>> label-geom *
>>> *i.e. if I create the new column, it must not be visible in the output.*
>>>
>>> Thanks
>>>
>>> Peter
>>>
>>> _______________________________________________
>>> Geoserver-users mailing list
>>>
>>> Please make sure you read the following two resources before posting to
>>> this list:
>>> - Earning your support instead of buying it, but Ian Turton:
>>> http://www.ianturton.com/talks/foss4g.html#/
>>> - The GeoServer user list posting guidelines:
>>> http://geoserver.org/comm/userlist-guidelines.html
>>>
>>> If you want to request a feature or an improvement, also see this:
>>> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>>>
>>>
>>> Geoserver-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>>
>> _______________________________________________
>> Geoserver-users mailing list
>>
>> Please make sure you read the following two resources before posting to
>> this list:
>> - Earning your support instead of buying it, but Ian Turton:
>> http://www.ianturton.com/talks/foss4g.html#/
>> - The GeoServer user list posting guidelines:
>> http://geoserver.org/comm/userlist-guidelines.html
>>
>> If you want to request a feature or an improvement, also see this:
>> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>>
>>
>> Geoserver-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>
>
>
> --
> Ian Turton
>

_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to