6

I'm a newbie to use GeoServer and SLDs so, sorry in advance if my question is stupid.

I'm trying to use the Point Stacker rendering transfomation for to cluster my point layer. I've a POSTGIS point layer with more than 514.000 points (all the OSM addresses in Italy ....), and so I can't to render them with a simple "red point" in my map and I can't render them using a clustering in the browser using Leaflet, OpenLayers, ecc ...

The structure of my POSTGIS layer is the following

enter image description here

If I try to use a default point symbol to render my layer the visualization is obviously slow but it works right and I can also to identify my point as I can show to you here

enter image description here

The field I'm interested on is "field_4"

I've tried to use the SLD that I've found here http://suite.opengeo.org/opengeo-docs/cartography/rt/pointstacker.html for clustering server side and it's working for mapping my layer as clustered points as I can show to you

enter image description here

I shoud add more classes in my SLD style and I'll do it, but at the moment the issue is that, using cluster, I can't identify points, not when they'are clustered (I don't want this ....), but when they are rappresented as single point. Here you are the case trying to identify the lowest triangle in the picture

enter image description here

The error is "internal error occurred Property 'count' could not be found in osm_civici": I haven't that field in my layer but I've seen that is a "field" used in the SLD style ....

NOTE: I'm using the SLD style found in OpenGeo Suite documentation at http://suite.opengeo.org/opengeo-docs/cartography/rt/pointstacker.html "as-is" and probably there is something to change but I don't know what ....

I'm using OpenGeoSuite Version 4.0.2 on Windows 7 (GeoServer 2.4-SNAPSHOT Git Revision f295d37d70c3b1f0e51942e8b031253e4d75459 Build Date 20-Jan-2014 22:29)

4

Your problem is related to Geoserver issue https://jira.codehaus.org/browse/GEOS-5228. See also discussion http://comments.gmane.org/gmane.comp.gis.geoserver.user/39166.

I understood that you want to get feature info only when user has zoomed in so much that points are not stacked together but a symbol marks exactly one point in the original data. In that case the symbol is in the same place than if you have a layer without the pointstacker SLD. Perhaps not exactly because the rendering machine can move the symbols a bit but close anyhow. In that case you should be able to use simple workaround: make your application to send GetFeatureInfo with &STYLES= pointing to a non-stacked style which may be "point" in your case. The following example shows how a GetFeatureInfo request looks like and you can see where to do the change.

http://localhost:8080/geoserver/wms?bbox=-130,24,-66,50&styles=population&format=jpeg&info_format=text/plain&request=GetFeatureInfo&layers=topp:states&query_layers=topp:states&width=550&height=250&x=170&y=160

Another workaround could be to to make a second layer "osm_civici_postgis_query" and use that only for GetFeatureRequests so that when your user clicks on the map the &layers and &query_layers parametes would automatically changed from "osm_civici_postgis" into "osm_civice_postgis_query". Because these two layer may not have the symbols exactly in the same place it might be good to add some tolerance with the "buffer" vendor option http://docs.geoserver.org/latest/en/user/services/wms/vendor.html. A large buffer may find more than one feature sometimes so I would also add for example &feature_count=10 to make the query to return more hits in such case. The default value is 1 and then user would get only one feature and that is not necessarily the closest feature from the clicked point because Geoserver does not sort the GetFeatureInfo results by the distance.

1

The solution from @Cesare didn't work for me. However I found another solution.

I added a dummy column called 'count' to the underlying view. Now I no longer get an error and results are reported back from GetFeatureInfo.

1

Your answer show me that there is a bug on GeoServer in this functionality: this is a point, bad point but a point.

I can't use your suggestions because I've to use GeoExplorer (I'm using OpenGeoSuite Version 4.0.2 on Windows 7), as client of my clustered WMS service in my solution, so I've to try some other workaround.

I've tried to check newest GeoServer versions but the problem is still present.

After some test finally I've found a solution using a new SLD that is the follow ...

I shoud exclude it when I'm at a certain scale but seems that I cant' put a something like

<?xml version="1.0" encoding="ISO-8859-1"?>
 <StyledLayerDescriptor version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
  xmlns="http://www.opengis.net/sld"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
   <Name>Cluster points</Name>
   <UserStyle>
   <!-- Styles can have names, titles and abstracts -->
    <Title>Cluster points</Title>
    <Abstract>Styling using cluster points server side</Abstract>
    <FeatureTypeStyle>
      <Transformation>
        <ogc:Function name="gs:PointStacker">
          <ogc:Function name="parameter">
            <ogc:Literal>data</ogc:Literal>
          </ogc:Function>
          <ogc:Function name="parameter">
            <ogc:Literal>cellSize</ogc:Literal>
            <ogc:Literal>30</ogc:Literal>
          </ogc:Function>
          <ogc:Function name="parameter">
            <ogc:Literal>outputBBOX</ogc:Literal>
            <ogc:Function name="env">
           <ogc:Literal>wms_bbox</ogc:Literal>
            </ogc:Function>
          </ogc:Function>
          <ogc:Function name="parameter">
            <ogc:Literal>outputWidth</ogc:Literal>
            <ogc:Function name="env">
           <ogc:Literal>wms_width</ogc:Literal>
            </ogc:Function>
          </ogc:Function>
          <ogc:Function name="parameter">
            <ogc:Literal>outputHeight</ogc:Literal>
            <ogc:Function name="env">
              <ogc:Literal>wms_height</ogc:Literal>
            </ogc:Function>
          </ogc:Function>
        </ogc:Function>
      </Transformation>
     <Rule>
      <Name>rule1</Name>
      <Title>Singoli punti</Title>
      <MinScaleDenominator>2000</MinScaleDenominator>
      <PointSymbolizer>
        <Graphic>
          <Mark>
            <WellKnownName>circle</WellKnownName>
            <Fill>
              <CssParameter name="fill">#ff0000</CssParameter>
            </Fill>
          </Mark>
          <Size>6</Size>
        </Graphic>
      </PointSymbolizer>
     </Rule>
     <Rule>
        <Name>ruleGT1</Name>
        <Title>Cluster</Title>
        <ogc:Filter>
          <ogc:PropertyIsGreaterThan>
            <ogc:PropertyName>count</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
          </ogc:PropertyIsGreaterThan>
        </ogc:Filter>
        <MaxScaleDenominator>10000000</MaxScaleDenominator>
        <PointSymbolizer>
          <Graphic>
            <Mark>
              <WellKnownName>circle</WellKnownName>
              <Fill>
                <CssParameter name="fill">#ff0000</CssParameter>
              </Fill>
            </Mark>
            <Size>22</Size>
          </Graphic>
        </PointSymbolizer>
        <TextSymbolizer>
          <Label>
            <ogc:PropertyName>count</ogc:PropertyName>
          </Label>
          <Font>
            <CssParameter name="font-family">Arial</CssParameter>
            <CssParameter name="font-size">12</CssParameter>
            <CssParameter name="font-weight">bold</CssParameter>
          </Font>
          <LabelPlacement>
            <PointPlacement>
              <AnchorPoint>
                <AnchorPointX>0.5</AnchorPointX>
                <AnchorPointY>0.8</AnchorPointY>
              </AnchorPoint>
            </PointPlacement>
          </LabelPlacement>
          <Halo>
             <Radius>2</Radius>
             <Fill>
               <CssParameter name="fill">#ff0000</CssParameter>
               <CssParameter name="fill-opacity">0.9</CssParameter>
             </Fill>
          </Halo>
          <Fill>
            <CssParameter name="fill">#FFFFFF</CssParameter>
            <CssParameter name="fill-opacity">1.0</CssParameter>
          </Fill>
        </TextSymbolizer>
      </Rule>
    </FeatureTypeStyle>
  </UserStyle>
 </NamedLayer>
</StyledLayerDescriptor>

Here you're a sample picture showing identify on clustered poin layer using GeoExplorer

enter image description here

and another one using QGIS.

enter image description here

NOTE: in this manner, I don't know why, I'm able to identify directly point clusters too.

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.