This article is a manual on creating your own OpenData import plugins for Geo2Tag platform. Detailed information about the basic classes and common interfaces of these plugins could be found in article Interfaces of the plugins for OpenData import.
Before you create your plugin for OpenData import you should to have the answers to the next questions:
- What kind of access to the open data you have:
- access protocol (HTTP(S), FTP, WebDav ..)
- the presence of encryption
- the presence of authorization
- How does user receive the open data: in form of array or element-by-element?
- In which format does the user receive data (XML/JSON/CSV/ other)?
- Is it possible to get access to element of data by the external link?
- Do the elements of data contain images and if so, how can you get an external link?
- What kind of information about location do elements of data contain:
- latitude, longitude and altitude
- postal address
- zip code
Creation the basic classes
The minimal realization OpenData import plugins contains inheritance/extension of the next classes:
- Job – the abstract class for the import.
- OpenDataObjectsLoader – the basic class for downloading elements of open data from external sources.
- OpenDataToPointTranslator – the abstract class for conversion elements of open data to the format of points Geo2Tag.
- OpenDataObjectsParser – the abstract class for split the array of open data into single elements.
- OpenDataToPointsLoader – the abstract class for points record to Geo2Tag DB.
- ODImportParser – parser of arguments for REST queries to the plugin.
To create ordinary REST queries you have to use:
- Resource class for manage a separate job of import JobResource.
- Factory method JobListResourceFactory for creating resource class in order to add and view all jobs of import.
For the overall sequence import actions you can use the existing function performImportActions: the passed parameters are the derived classes from the classes specified above. Also it’s possible to create your own implementation of the import function. In that case the main requirement will be a correspondence between the implementation your own class derived from Job and the prototype of the import function.
Adding a plugin
It’s necessary to formalize and connect created set of sources files according to the article Format and connection of plugins.