1

In geoserver only geometry type of SQL server table is detected. Which means SLD style can't be applied ogc filter tag. But none of my SQL server field beside geometry are detected by geoserver. How can I do that ?

Create table script

CREATE TABLE My_GIS_Table
(
 LOCALNAME varchar(50),
 Coord  geometry not null,

 constraint PK_My_GIS_Table primary key (LOCALNAME)
)

SLD created with uDig from a shapefile.

<sld:Rule>
                    <sld:Name>MY_CITY_NAME</sld:Name>
                    <ogc:Filter>
                        <ogc:PropertyIsEqualTo>
                            <ogc:PropertyName>LOCALNAME</ogc:PropertyName>
                            <ogc:Literal>MY_CITY_NAME</ogc:Literal>
                        </ogc:PropertyIsEqualTo>
                    </ogc:Filter>
                    <sld:PolygonSymbolizer>
                        <sld:Fill>
                            <sld:CssParameter name="fill">#E31A1C</sld:CssParameter>
                            <sld:CssParameter name="fill-opacity">0.45</sld:CssParameter>
                        </sld:Fill>
                        <sld:Stroke>
                            <sld:CssParameter name="stroke-dashoffset">5</sld:CssParameter>
                            <sld:CssParameter name="stroke-dasharray">2.0</sld:CssParameter>
                        </sld:Stroke>
                    </sld:PolygonSymbolizer>
</sld:Rule>

Hypothetic SLD I'd like to create for my SQL Server table

Here I just want to change the part with tags. With something posibly like tags. Ogc tags and Geoserver wont recognize MY_GIS_TABLE field name LOCALNAME so I don't know how to edit the existing SLD to create a filter upon that field.

<MSSQL:Filter>
    <MSSQL:PropertyIsEqualTo>
    <MSSQL:PropertyName>LOCALNAME</MSSQL:PropertyName>
    <MSSQL:Literal>MY_CITY_NAME</MSSQL:Literal>
    </MSSQL:PropertyIsEqualTo>
</MSSQL:Filter>
  • Can you say more about how you added the table – Ian Turton Jun 22 '16 at 16:30
  • Also, what do you mean by "Which means SLD style can't be applied ogc filter tag"? In SLD any symbolizer can be applied to any geometry type, they get transformed on the fly. If you need to apply a certain type of symbolizer to a certain type of geometry there are suggestions here: docs.geoserver.org/latest/en/user/styling/sld-tipstricks/… – Andrea Aime Jun 22 '16 at 16:58
  • @iant I've edited my post with more details (and the details you've requested) – Jason Krs Jun 22 '16 at 19:28
  • @AndreaAime Actually, what I mean is to create a filter based on a database field (coloumn) value. With ESRI shapfiles, its straightforward (as long as the shp file has the propery). In case of a database coming from SQL Server, not only the geography (or geometry) fields are recognized by geoserver but I don't how how to apply a SLD filter according to the database field. Please see my post as I have added more details – Jason Krs Jun 22 '16 at 19:32
1

GeoServer (by default) doesn't make primary keys available to the renderer as they are usually just a simple integer or UUID so are of no real use for rendering.

There are two solutions to your issue

  1. add a serial column to your table for use as the primary key.
  2. ask GeoServer to expose primary keys for you.

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.