0

I've used SLD to label polygon features with their parcel Ids. The problem is for Ids include '.' and '-' marks, the ordering of character is messed up. For example 39.1 changes to 139. I've checked them in Pgsql and ArcMap which show them correctly.

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <se:Name>parcels</se:Name>
    <UserStyle>
      <se:Name>parcels</se:Name>

      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:MaxScaleDenominator>2000</se:MaxScaleDenominator>
          <se:PolygonSymbolizer>
             <se:Stroke>
              <se:SvgParameter name="stroke">#7e7e7e</se:SvgParameter>
              <se:SvgParameter name="stroke-width">0.7</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
          <se:TextSymbolizer> 
            <se:Geometry>
              <ogc:Function name="centroid">
                <ogc:PropertyName>geom</ogc:PropertyName>
              </ogc:Function>
            </se:Geometry>
            <se:Label>
              <ogc:PropertyName>id_fa</ogc:PropertyName>
            </se:Label>
            <se:Font>
              <se:SvgParameter name="font-family">Iranian Sans</se:SvgParameter>
              <se:SvgParameter name="font-size">11</se:SvgParameter>
              <se:SvgParameter name="font-weight">normal</se:SvgParameter>
            </se:Font>
            <se:LabelPlacement>
              <se:PointPlacement>
                <se:AnchorPoint>
                  <se:AnchorPointX>0.5</se:AnchorPointX>
                  <se:AnchorPointY>0.0</se:AnchorPointY>
                </se:AnchorPoint>
                <se:Displacement>
                  <se:DisplacementX>0</se:DisplacementX>
                  <se:DisplacementY>5</se:DisplacementY>
                </se:Displacement>
              </se:PointPlacement>
            </se:LabelPlacement>
            <se:Fill>
              <se:SvgParameter name="fill">#523735</se:SvgParameter>
            </se:Fill>
            <se:VendorOption name="autoWrap">150</se:VendorOption>
            <se:VendorOption name="maxDisplacement">50</se:VendorOption>
            <se:VendorOption name="group">yes</se:VendorOption>
          </se:TextSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>

    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

I should mention that I've translated English numbers to Arabic format using python and inserted them in a new field. Is it something wrong with that process?

5
  • Does Iranian sans have a - & . character?
    – Ian Turton
    Oct 21, 2018 at 19:06
  • @IanTurton yes it includes those characters and for other labels from osm data it works properly. Oct 22, 2018 at 7:41
  • do they show up correctly if you use a different font?
    – Ian Turton
    Oct 22, 2018 at 7:53
  • @IanTurton nope, but they show up correctly in Postgresql, QGIS and python. Oct 22, 2018 at 9:48
  • then we need a small sample of the file to test with
    – Ian Turton
    Oct 22, 2018 at 9:51

2 Answers 2

1

The problem was about the converting process of IDs to Arabic numbering format. I explored that there are two different Unicode types for Arabic numbers as stated here. In my method, all numbers should have been followed the same Unicode group such as (\xd9... or \xdb...) which I've fixed it and IDs show up properly.

def enToFaNumber(letter):
    charDict = {'0': '۰', '1': '۱', '2': '۲', '3': '۳', '4': '۴', '5': '۵', '6': '۶', '7': '۷', '8': '۸', '9': '۹',
                '.': '/'}
    char = charDict.get(letter)
    if char is None:
        return letter.encode('utf-8')

    return char
0

I can't reproduce this with the GeoServer topp:States layer, using the following SLD:

     <TextSymbolizer>         
        <Label>
          <ogc:Sub>
          <ogc:PropertyName>STATE_FIPS</ogc:PropertyName>
            <ogc:Literal>23.5</ogc:Literal>
          </ogc:Sub>
        </Label>
        <Font>
          <CssParameter name="font-family">Iranian Sans</CssParameter>
          <CssParameter name="font-size">11</CssParameter>
          <CssParameter name="font-weight">normal</CssParameter>
        </Font>
        <Fill>
          <CssParameter name="fill">#523735</CssParameter>
        </Fill>
        <VendorOption name="autoWrap">150</VendorOption>
        <VendorOption name="maxDisplacement">50</VendorOption>
        <VendorOption name="group">yes</VendorOption>
      </TextSymbolizer>

I get this map:

enter image description here

So it may be related to the python modification you are doing, if you can reproduce it with an included dataset, or with a small sample of your data feel free to open a GeoServer bug.

1
  • Thanks Ian the problem was about converting script and it's not a bug. Oct 22, 2018 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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