1

I would like to display land parcel dimensions on a map layer. The source layer in GeoServer has the parcel boundaries as line features.

I made an attempt using the geomLength function in an SLD, however the displayed labels appear to represent the length in pixels, not metres or any other real-world unit. The values double when I zoom in and halve when I zoom out.

This same issue was reported a few years ago in this GeoServer forum post, but there appears to be no response.

The label code I'm using is here:

<ogc:Label> <ogc:Function name="geomLength"> <ogc:PropertyName>SHAPE</ogc:PropertyName> </ogc:Function> </ogc:Label>

You can see a sample output WMS map image here

Is there a way to label the lines with lengths in real-world units?

3

No, it's not possible at the moment, geometries are generalized, reprojected, rescaled to screen in place for performance reasons, by the time this function is evaluated it's too late. The code would have to be modified to perform these evaluations before the geometry is modified. It's possible, not immediate to do in general (if done, it would have to affect evaluation of all style properties that might be using the geometry, not just the labels), especially if the same geometry is used by other symbolizers before.

  • would multiplying by the scale help? – Ian Turton Jun 11 '16 at 10:41
  • Not really due to simplification (the simplification is screen oriented, when zoomed out you are shaving out a lot of the actual length). And then there's the fact geomLength is purely cartesian, like, even if we evaluated earlier, there would still be a problem with data in WGS84 – Andrea Aime Jun 11 '16 at 12:13
  • @iant I actually tried multiplying by the scale, and the results were initially promising, but OpenLayers would specify a different dpi in the map request depending on the user's device, so the results were different on every device! – Simon O'Keefe Jun 13 '16 at 2:39
1

The obvious way to do it is to calculate the lengths of all the lines and store it as an attribute before loading the data into GeoServer.

  • The service is hosted by the state government, so I don't have any control over it. But now I know that labelling by length is not possible, I'll approach the state government and see if they'll add a field for the length, as you suggest. – Simon O'Keefe Jun 13 '16 at 2:45
  • You can get their data as a zipped shapefile from a WFS query with services.land.vic.gov.au/catalogue/publicproxy/guest/… – ThomasG77 Jun 13 '16 at 3:09
  • We're trying to stay away from downloading and maintaining this data! Also I believe they've limited the WFS to 15K records. But thanks for the suggestion. – Simon O'Keefe Jun 13 '16 at 3:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.