[Geoserver-users] SLD Using Different Geometry Attributes

Hi,
Geoserver 1.6.3
I have a feature that is a view in postgres on linux that has both a polygon
geometry for a property parcel boundary and the parcel centroid which is
calculated via postgis function. The 2 attributes names are
"parcel-geometry" and "parcel-geometry-centroid". parcel-geometry has a
spatial index on it.

the geometry_column tables looks like this.
oid,f_table_catalog,f_table_schema,f_table_name,f_table_geometry_column,
coord_dimenation,srid,type
390938526;"''";"public";"property_layer";"parcel-geometry";2;-1;"MULTIPOLYGON"
390938527;"''";"public";"property_layer";"parcel-geometry-centroid";2;-1;"POINT"

The Text Symoblizer SLD is pretty simple and work fine under certain cases.
...
<TextSymbolizer>
  <Geometry>
  <ogc:PropertyName>parcel-geometry-centroid</ogc:PropertyName>
</Geometry>
<Label>
    <ogc:PropertyName>formatted-apn</ogc:PropertyName>
   </Label>
      
        <CssParameter name="font-family">Verdana</CssParameter>
        <CssParameter name="font-style">Normal</CssParameter>
        <CssParameter name="font-size">12</CssParameter>

...

Here are the following cases with respect setting the <Geometry> element.

1) Works: If I don't specify the <Geometry> element, the parcel-geometry is
used to place the text label. (I am a bit unsure why, but it has something
to do with the default I suppose). Results in duplicate labels when parcel
geometry spans more that one tile.
2) Works : If I don't specify the <Geometry> element as parcel-geometry.
Works as same as #1.
3) Does NOT work: If I specify the <Geometry> element as
parcel-geometry-centroid, nothing is rendered and I don;t seem to get any
error messages, just a blank .png

I would prefer to use the centroid so as to avoid the duplicate labeling
issue when parcels span more than one tile.

Any thoughts would be appreciated.

Regards,
-Steve

--
View this message in context: http://www.nabble.com/SLD-Using-Different-Geometry-Attributes-tp19211578p19211578.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

bvader ha scritto:

Hi,
Geoserver 1.6.3
I have a feature that is a view in postgres on linux that has both a polygon
geometry for a property parcel boundary and the parcel centroid which is
calculated via postgis function. The 2 attributes names are
"parcel-geometry" and "parcel-geometry-centroid". parcel-geometry has a
spatial index on it.

the geometry_column tables looks like this.
oid,f_table_catalog,f_table_schema,f_table_name,f_table_geometry_column,
coord_dimenation,srid,type
390938526;"''";"public";"property_layer";"parcel-geometry";2;-1;"MULTIPOLYGON"
390938527;"''";"public";"property_layer";"parcel-geometry-centroid";2;-1;"POINT"

The Text Symoblizer SLD is pretty simple and work fine under certain cases.
...
<TextSymbolizer>
  <Geometry>
  <ogc:PropertyName>parcel-geometry-centroid</ogc:PropertyName>
</Geometry>
<Label>
    <ogc:PropertyName>formatted-apn</ogc:PropertyName>
   </Label>
              <CssParameter name="font-family">Verdana</CssParameter>
        <CssParameter name="font-style">Normal</CssParameter>
        <CssParameter name="font-size">12</CssParameter>

...

Here are the following cases with respect setting the <Geometry> element.

1) Works: If I don't specify the <Geometry> element, the parcel-geometry is
used to place the text label. (I am a bit unsure why, but it has something
to do with the default I suppose). Results in duplicate labels when parcel
geometry spans more that one tile.
2) Works : If I don't specify the <Geometry> element as parcel-geometry.
Works as same as #1.
3) Does NOT work: If I specify the <Geometry> element as
parcel-geometry-centroid, nothing is rendered and I don;t seem to get any
error messages, just a blank .png

Hum, to reproduce I did the following:
* imported states.shp into postgis
* run the following sql:

alter table states add column centroid geometry;
update states set centroid=centroid(the_geom);
insert into geometry_columns values('','public','states','centroid',2,4326,'POINT');

* registered the datastore and the layer into GeoServer.
* created the attached style

And it worked fine. So.. maybe you're missing some step, like
the registration of the geometry column in postgis?

I would prefer to use the centroid so as to avoid the duplicate labeling
issue when parcels span more than one tile.

A warning, you will get the opposite problem with this approach: some labels will never show up. This will happen for the labels that happen
to sit between two tiles (labels that span more than one tile are not
drawn). See the attached screenshot, done with the style above, as you
can see, at this zoom level the North Dakota lable
If you can, use a solution like GeoWebCache with meta-tiling to alleviate the problem and speed up rendering while you're at it (provided the data is stable enough, i.e., does not change daily).
Otherwise, you can just give up using tiling for labels, and draw
a non tiled layer with a style that draws just the labels, the labels
will automatically adapt to the current drawing region as the
user moves around.

Cheers
Andrea

(Attachment centroids.sld is missing)

NorthDakotaMissingLabel.gif

I might suggest a different approach, that I typically use. I define a
view in PostGIS to calculate the centroids, based on polygon
boundaries, which I then register as a separate layer in Geoserver.
Then I use two different SLD's (one for polygons, one for the
centroids for the labels). I find this approach for me is easier and
offers you a bit of simplicity when defining the SLD's. You can also
turn the layer on and off separately in you client. Of course, using a
view offers a potential performance hit, when the table is very large,
but if you need to, you can always just create a separate table for
performance reasons.

Or maybe there is a particular reason why both the polygon and
centroid geometries need to be in the same table?

On Mon, Sep 1, 2008 at 10:04 AM, Andrea Aime <aaime@anonymised.com> wrote:

bvader ha scritto:

Hi,
Geoserver 1.6.3
I have a feature that is a view in postgres on linux that has both a
polygon
geometry for a property parcel boundary and the parcel centroid which is
calculated via postgis function. The 2 attributes names are
"parcel-geometry" and "parcel-geometry-centroid". parcel-geometry has a
spatial index on it.
the geometry_column tables looks like this.
oid,f_table_catalog,f_table_schema,f_table_name,f_table_geometry_column,
coord_dimenation,srid,type

390938526;"''";"public";"property_layer";"parcel-geometry";2;-1;"MULTIPOLYGON"

390938527;"''";"public";"property_layer";"parcel-geometry-centroid";2;-1;"POINT"

The Text Symoblizer SLD is pretty simple and work fine under certain
cases.
...
<TextSymbolizer>
<Geometry>
<ogc:PropertyName>parcel-geometry-centroid</ogc:PropertyName>
</Geometry>
<Label>
   <ogc:PropertyName>formatted-apn</ogc:PropertyName>
  </Label>
             <CssParameter name="font-family">Verdana</CssParameter>
       <CssParameter name="font-style">Normal</CssParameter>
       <CssParameter name="font-size">12</CssParameter>

...

Here are the following cases with respect setting the <Geometry> element.

1) Works: If I don't specify the <Geometry> element, the parcel-geometry
is
used to place the text label. (I am a bit unsure why, but it has something
to do with the default I suppose). Results in duplicate labels when parcel
geometry spans more that one tile.
2) Works : If I don't specify the <Geometry> element as parcel-geometry.
Works as same as #1.
3) Does NOT work: If I specify the <Geometry> element as
parcel-geometry-centroid, nothing is rendered and I don;t seem to get any
error messages, just a blank .png

Hum, to reproduce I did the following:
* imported states.shp into postgis
* run the following sql:

alter table states add column centroid geometry;
update states set centroid=centroid(the_geom);
insert into geometry_columns
values('','public','states','centroid',2,4326,'POINT');

* registered the datastore and the layer into GeoServer.
* created the attached style

And it worked fine. So.. maybe you're missing some step, like
the registration of the geometry column in postgis?

I would prefer to use the centroid so as to avoid the duplicate labeling
issue when parcels span more than one tile.

A warning, you will get the opposite problem with this approach: some labels
will never show up. This will happen for the labels that happen
to sit between two tiles (labels that span more than one tile are not
drawn). See the attached screenshot, done with the style above, as you
can see, at this zoom level the North Dakota lable
If you can, use a solution like GeoWebCache with meta-tiling to alleviate
the problem and speed up rendering while you're at it (provided the data is
stable enough, i.e., does not change daily).
Otherwise, you can just give up using tiling for labels, and draw
a non tiled layer with a style that draws just the labels, the labels
will automatically adapt to the current drawing region as the
user moves around.

Cheers
Andrea

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users