Overview
The following operations allow you to work with hierarchies. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with hierarchies, see Sample configuration.
Operation | Description |
---|---|
Retrieves the children (admin divisions and populated places) for a given geonameId. | |
1Working with Hierarchies in GeoNames | Retrieves all GeoNames higher up in the hierarchy of a place name (returns a list of GeoName records, ordered by hierarchy level. The top hierarchy (continent) is the first element in the list). |
Operation details
This section provides further details on the operations related to hierarchies.
Retrieving the children
The
operation retrieves the children (admin divisions and populated places) for a given geonameId.getChildren
<geonames.getChildren> <responseType>{$ctx:responseType}</responseType> <geonameId>{$ctx:geonameId}</geonameId> <maxRows>{$ctx:maxRows}</maxRows> <hierarchy>{$ctx:hierarchy}</hierarchy> </geonames.getChildren>
Properties
The responseType to get the response of the getChildren method.responseType:
The geonameId of the parent.geonameId:
The number of rows returned, default is 200.maxRows:
This parameter allows the of use other hierarchies then the default administrative.hierarchy:
Sample request
Following is a sample REST/JSON request that can be handled by the getChildren
operation.
{ "apiUrl": "http://api.geonames.org", "username": "buddhima", "responseType": "json", "geonameId": "3175395", "maxRows": "1", "hierarchy": "tourism" }
Related GeoNames documentation
http://www.geonames.org/export/place-hierarchy.html#children
Retrieving all GeoNames higher up in the hierarchy of a place name
The
operation retrieves all GeoNames higher up in the hierarchy of a place name (returns a list of GeoName records, ordered by hierarchy level. The top hierarchy (continent) is the first element in the list).listHierarchyOfPlaceNames
<geonames.listHierarchyOfPlaceNames> <responseType>{$ctx:responseType}</responseType> <geonameId>{$ctx:geonameId}</geonameId> </geonames.listHierarchyOfPlaceNames>
Properties
The responseType of the listHierarchyOfPlaceNames method.responseType:
The geonameId of the hierarchy.geonameId:
Sample request
Following is a sample REST/JSON request that can be handled by the listHierarchyOfPlaceNames
operation.
{ "apiUrl": "http://api.geonames.org", "username": "buddhima", "responseType": "json", "geonameId": "3175395" }
Related GeoNames documentation
http://www.geonames.org/export/place-hierarchy.html#hierarchy
Sample configuration
Following is a sample proxy service that illustrates how to connect to GeoNames with the init
operation and use the getChildren
operation. The sample request for this proxy can be found in the getChildren sample request.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="geonames_getChildren" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="apiUrl" expression="json-eval($.apiUrl)" /> <property name="username" expression="json-eval($.username)" /> <property name="responseType" expression="json-eval($.responseType)" /> <property name="geonameId" expression="json-eval($.geonameId)" /> <property name="maxRows" expression="json-eval($.maxRows)" /> <property name="hierarchy" expression="json-eval($.hierarchy)" /> <geonames.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <username>{$ctx:username}</username> </geonames.init> <geonames.getChildren> <responseType>{$ctx:responseType}</responseType> <geonameId>{$ctx:geonameId}</geonameId> <maxRows>{$ctx:maxRows}</maxRows> <hierarchy>{$ctx:hierarchy}</hierarchy> </geonames.getChildren> <respond /> </inSequence> <outSequence> <send /> </outSequence> </target> <description /> </proxy>