Ferramentas Pessoais
Você está aqui: Entrada Desarrollo Documentos gvSIG desktop 1.0 / 1.1 Plugins Catálogo y Nomenclator Adding a new Gazetteer protocol
Acções do Documento

Adding a new Gazetteer protocol

por Jorge Pieraúltima modificação 2010-06-01 22:46

This document explains how it is possible to add a new driver that supports a new gazetteer protocol

The new Gazetteer client offers the possibility to add new protocols. The idea is that anyone can add him own driver to manage its own protocol.

To add a new gazetteer protocol the first step is to create a new driver that just is a class that has to inherit of the IGazetteerServiceDriver interface. This interface forces to implement the common methods that all the Gazetteer drivers have to had. There is also an abstract class named AbstractGazetteerServiceDriver than implements this interface and it has a default implementation for some of the driver methods (but the using of this class is not necessary). Next figure shows the hierarchy:

TEXTO

Methods to implement

The unique methods that are not implemented in AbstractGazetteerServiceDriver and they have to be implemented on every driver are:

GazetteerCapabilities getCapabilities(URI uri) throws Exception;

It sends a message to the server and tries to discover the server capabilities that will be used to create the queries.The driver has to discover if the server is ready an has to return a GazetteerCapabilities object.

GazetteerCapabilities is a class that has some methods that the user interface uses: the isAvailable() method is used to know if the server is ready (it return true by deafult). The getVersion() method indicates the protocol version that has the server and the getServerMessage() is used to show a message that is written on the user interface.

public Feature[] getFeature(URI uri, Query query) throws Exception;

This method sends a request to the server to search a geographic name. It has to return an array of Feature's that is an object that contains a name and a position. The SRS actually is specified by the service (not for every feature).

Query is an object that contains the information to make the query (the searched name, the thesaurus selection, the selected area...). This query has been filled with the fields that the user has selected in the user interface.

public String getServiceName();

It has to return the service name that will be showed in the user interface to select this driver.

Driver register

To use a new driver, it has to be registered on the application using the GazetteerDriverRegister class. It implements the Singleton pattern: it has an static method to retrieve a register instance and this instance has a method to register the driver. Next fragment code can be used to register the ExampleNewDriver:

GazetteerDriverRegister register = GazetteerDriverRegister.getInstance();
register.register(new ExampleNewDriver());

Creating a thesaurus tree (searches by cathegory)

In the user interface there is a JTree that is used to make searches by cathegory. To fill this tree with a set of values it is necessary to fill the GazetteerCapabilities object returned in the getCapabilities method with a list of FeatureType Objects using the setFeatureTypes() method. A FeatureType object has basically a name, a description and a list of FeatureType objects that will be showed like children in the JTree.


Feito com Plone CMS, o Software Livre para Gestão de Conteúdos

Este sítio está em conformidade com as seguintes normas: