Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My layers are present in postgis db which are being served to openlayers JS through geoserver. I have my layers corresponding to polygons,lines etc. whose attributes are stored in the same table itself. Like Halls table contain columns (hid, hall_geom,hall_name) etc. I want hall_name of each hall_geom(polygon) to be placed as a label on it in the map. I have tried SLD-styling form geoserver but couldn't make it successful(I think the styles given are for shape files and not tables in db).

Please show me a right way

share|improve this question
2  
can you post a link to the sld files? There is no reason why you can't add an SLD to a layer coming from a DB. –  iant Jun 4 '11 at 18:06
    
@iant, I haven't tried any relating to database but the code that is given for different styles in docs.geoserver.org/latest/en/user/styling/index.html , I think they are for shapefiles........ Can you give me any link which is done for layers in database –  Vikash Talanki Jun 4 '11 at 19:34
    
@iant, I got thw styles working –  Vikash Talanki Jun 5 '11 at 9:30
    
@VikashTalanki It's resolved then? You might want to post your solution and accept it as the answer :) –  R.K. Dec 22 '12 at 3:55

1 Answer 1

I had approximately the same problem : in fact, i want to place points and to style them according to "RSCP" (it is a row in my DB) : i solved the problem thanks to Filter function of SLD : here my SLD file : king:mesures2 Default Point A sample style that draws a point rule1 BLue Square

   <ogc:Filter>
        <ogc:PropertyIsLessThan>
         <ogc:PropertyName>rscp</ogc:PropertyName>
         <ogc:Literal>0</ogc:Literal>
        </ogc:PropertyIsLessThan>
      </ogc:Filter>

         <PointSymbolizer>
          <Graphic>
            <Mark>
              <WellKnownName>square</WellKnownName>
              <Fill>
                <CssParameter name="fill">#0000FF</CssParameter>
              </Fill>
            </Mark>
          <Size>6</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>

rule2 Gold Square

   <ogc:Filter>
        <ogc:PropertyIsBetween>
          <ogc:PropertyName>rscp</ogc:PropertyName>
          <ogc:LowerBoundary>
            <ogc:Literal>0</ogc:Literal>
          </ogc:LowerBoundary>
          <ogc:UpperBoundary>
            <ogc:Literal>11</ogc:Literal>
          </ogc:UpperBoundary>
        </ogc:PropertyIsBetween>
      </ogc:Filter>
         <PointSymbolizer>
          <Graphic>
            <Mark>
              <WellKnownName>square</WellKnownName>
              <Fill>
                <CssParameter name="fill">#FFD700</CssParameter>
              </Fill>
            </Mark>
          <Size>6</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>

  <Rule>
      <Name>rule3</Name>
      <Title>Red Square</Title>

   <ogc:Filter>
        <ogc:PropertyIsBetween>
          <ogc:PropertyName>rscp</ogc:PropertyName>
          <ogc:LowerBoundary>
            <ogc:Literal>11</ogc:Literal>
          </ogc:LowerBoundary>
          <ogc:UpperBoundary>
            <ogc:Literal>21</ogc:Literal>
          </ogc:UpperBoundary>
        </ogc:PropertyIsBetween>
      </ogc:Filter>
         <PointSymbolizer>
          <Graphic>
            <Mark>
              <WellKnownName>square</WellKnownName>
              <Fill>
                <CssParameter name="fill">#FF0000</CssParameter>
              </Fill>
            </Mark>
          <Size>6</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>

rule3 Red Square

    <ogc:Filter>
        <ogc:PropertyIsGreaterThan>
         <ogc:PropertyName>rscp</ogc:PropertyName>
         <ogc:Literal>21</ogc:Literal>
        </ogc:PropertyIsGreaterThan>
      </ogc:Filter>
         <PointSymbolizer>
          <Graphic>
            <Mark>
              <WellKnownName>square</WellKnownName>
              <Fill>
                <CssParameter name="fill">#00FF00</CssParameter>
              </Fill>
            </Mark>
          <Size>6</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>

</FeatureTypeStyle>
</UserStyle>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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