5

I want to develop geoserver extension that intercepts wms request, checks specific url parameter, builds clusters of points and generate the response image with clusters.

I've studied a little the geoserver code. And I'm planning now to replace "FeatureLayer" in "mapContent" by my class. The class replaces real points by clusters of points.

The problem is I don't know how to inject my extension code into wms processing.

  • It's all here. Enjoy :D Failing that, it might be easier to do client side, say with OpenLayers clustering, and use Geoserver to generate based on WMS parameters you send. – John Powell Feb 17 '15 at 12:19
  • Where is "here"? It's geoserver source. I see. Can you specify more exact? Client side clustering cannot be used with more than 600 points because of perfomance. – Belowee P. Feb 17 '15 at 13:27
  • 1
    In the folder called WMS. The point being, if you want to create a plugin for Geoserver, you will need to understand the source code. This is why I suggested doing this client side, using cluster strategy, and calling your wms with appropriate layers to build up the image you want. – John Powell Feb 17 '15 at 13:29
  • I may have misunderstood your question, though. If you could explain a bit more what you are trying to do? – John Powell Feb 17 '15 at 13:30
  • I want to build clusters of points like in a openlayers client and generate image of map with these clusters. – Belowee P. Feb 18 '15 at 9:00
4

You have eclipse workspace as it shown in Geoserver Developers Quick Start.

Create new java project. Create new class:

package org.geoserver.wms.cluster;

import org.geoserver.wms.GetMapCallback;
import org.geoserver.wms.GetMapCallbackAdapter;
import org.geoserver.wms.GetMapRequest;
import org.geoserver.wms.WMSMapContent;

public class ClusterGetMapCallbackAdapter extends GetMapCallbackAdapter
        implements GetMapCallback {

    public ClusterGetMapCallbackAdapter() {
    }
    @Override
    public GetMapRequest initRequest(GetMapRequest request) {       
        return request;
    }
    @Override
    public void initMapContent(WMSMapContent mapContent) {    
    }
    @Override
    public WMSMapContent beforeRender(WMSMapContent mapContent) {
        return mapContent;
    }
}

Add file applicationContext.xml to META-INF directory:

<?xml version="1.0" encoding="UTF-8"?>
<beans>
    <bean id="getMapCallback" class="org.geoserver.wms.cluster.ClusterGetMapCallbackAdapter">
    </bean>
</beans>

Append new project to the dependencies of "gs-wms" project. Build solution. Set breakpoints at your code. Start geoserver. Create WMS layer. Browse to GetMap request. See breakpoints hitting.

|improve this answer|||||

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.