วันพุธที่ 2 มีนาคม พ.ศ. 2559

Labeling on line


update GeoServer2.12 document   2017.11.28

<TextSymbolizer>

   <Label>
      <ogc:PropertyName>RD_NAME</ogc:PropertyName>
      <ogc:Literal><![CDATA[
]]></ogc:Literal>แสดงผลคนละบรรทัด
      <ogc:PropertyName>RD_NAME_EN</ogc:PropertyName>
   </Label>

<![CDATA[]]>  ช่วยในการแสดงชื่อมากกว่า 1 ฟิลด์ สัมพันธ์กับ
<VendorOption name="followLine">false</VendorOption>
ต้องทำให้เป็น disable คำสั่งนี้จึงแสดงผลคนละบรรทัด แต่ label ไม่โค้งตามเส้น หากใช้กับเส้นถนน ก็จะทำให้ชื่อถนนดูไม่สวยงาม

 
   <Font>
      <CssParameter name="font-family">Arial</CssParameter>
      <CssParameter name="font-weight">normal</CssParameter>
      <CssParameter name="font-size">15</CssParameter>
   </Font>


<LabelPlacement> The SLD specification defines two alternative label placement strategies which can be used in the <LabelPlacement> element:
  • <PointPlacement> places labels at a single point 
  • <LinePlacement> places labels along a line 

    <LabelPlacement>
For lines, this point lies at the middle of the visible portion of the line.
       <PointPlacement>
            <AnchorPoint>
               <AnchorPointX>0.5</AnchorPointX>
              <AnchorPointY>0.5</AnchorPointY>
            </AnchorPoint>
            <Displacement>
               <DisplacementX>0</DisplacementX>
               <DisplacementY>0</DisplacementY>
           </Displacement>
       </PointPlacement>        










Displacement of X=10 pixels (compare with default anchor point of (X=0, Y=0.5) shown above)





 Displacement of Y=-10 pixels (compare with anchor point (X= 0.5, Y=1.0) - not shown)



      


       <LinePlacement> 
         <PerpendicularOffset>0</PerpendicularOffset>
       </LinePlacement>                                   
   </LabelPlacement>


<PerpendicularOffset> The optional <PerpendicularOffset> element allows you to position a label above or below a line.

 
PerpendicularOffset = 0 (default) 

PerpendicularOffset = 10

   <Halo>กำหนดขอบ Label
      <Radius>
         <ogc:Literal>1</ogc:Literal>กำหนดรัศมี
      </Radius>
      <Fill>
         <CssParameter name="fill">#FF0000</CssParameter>สีของขอบ
      </Fill>
   </Halo> 
   <Fill>
      <CssParameter name="fill">#000000</CssParameter> แสดงสี Label
   </Fill>

Geoserver Enhanced Options

ให้เลือกอันใดอันหนึ่ง
   <VendorOption name="group">yes</VendorOption>
Lines are joined together, clipped to the view rectangle, and the longest path is used.


    <VendorOption name="labelAllGroup">true</VendorOption>
It causes all of the disjoint paths in a line group to be labeled, not just the longest one.


    <VendorOption name="spaceAround">0</VendorOption>
    <VendorOption name="followLine">true</VendorOption>
It is required to use <LinePlacement> along with this option to ensure that labels are placed along lines:
    <VendorOption name="maxDisplacement">10</VendorOption>
the value should always be lower than the value for repeat.
    <VendorOption name="repeat">100</VendorOption>
  • determines how often GeoServer displays labels along a line
  • Normally GeoServer labels each line only once, regardless of length.
  • Specifying a positive value for this option makes the labeller attempt to draw the label every repeat pixels.
  • For long or complex lines (such as contour lines) this makes labeling more informative.

   <VendorOption name="maxAngleDelta">90</VendorOption>
   <VendorOption name="autoWrap">50</VendorOption>
กำหนดการแสดงความยาวของ label ตาม pixel ไม่ให้ยาวเกินไป
Label อาจมีการ split มากกว่า1บรรทัด ตามความยาว pixel ที่กำหนด
<VendorOption name="forceLeftToRight">false</VendorOption>

<VendorOption name="conflictResolution">false</VendorOption>

<VendorOption name="goodnessOfFit">0.3</VendorOption>

<VendorOption name="graphic-resize">stretch</VendorOption>

<VendorOption name="graphic-margin">margin</VendorOption>

<VendorOption name="partials">true</VendorOption>

<VendorOption name="underlineText">true</VendorOption>

<VendorOption name="strikethroughText">true</VendorOption>

<VendorOption name="charSpacing">3</VendorOption>

<VendorOption name="wordSpacing">5</VendorOption>


</TextSymbolizer>







ไม่มีความคิดเห็น:

แสดงความคิดเห็น