Skip to content
This repository was archived by the owner on Nov 26, 2017. It is now read-only.

Commit 97233d4

Browse files
Buddhimabuddhima
authored and
buddhima
committed
JOpenstreetmap manual discription added
1 parent 58ffeb9 commit 97233d4

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

docs/manual/en-US/chapters/packages/openstreetmap

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## The Openstreetmap Package
2+
3+
### Using the Openstreetmap Package
4+
The intention of the Openstreetmap package is to provide an easy straightforward interface to work with OpenStreetMap. This is based on the version 0.6 of the OpenStreetMap API. You can find more information about the OpenStreetMap API at [http://wiki.openstreetmap.org/wiki/API_v0.6](http://wiki.openstreetmap.org/wiki/API_v0.6) .
5+
JOpenstreetmap is built upon JOAuth1Client package which provides OAuth 1.0 security infrastructure for the communications. JHttp package is also used as an easy way for the non-secure information exchanges.
6+
### Initiating JOpenstreetmap
7+
Initiating JOpenstreetmap is just a single line of code:
8+
9+
```php
10+
$osm = new JOpenstreetmap();
11+
```
12+
13+
This creates basic JOpenstreetmap object which can access publically available GET methods.
14+
But when you want to send data or get private data, you need to use JOpenstreetmapOauth object too.
15+
```php
16+
$key = "your_key";
17+
$secret = "your_secret";
18+
19+
$option = new JRegistry;
20+
$option->set('consumer_key', $key);
21+
$option->set('consumer_secret', $secret);
22+
$option->set('sendheaders', true);
23+
24+
$oauth = new JOpenstreetmapOauth($option);
25+
$oauth->authenticate();
26+
27+
$osm = new JOpenstreetmap($oauth);
28+
```
29+
30+
To obtain a key and secret, you have to obtain an account at OpenStreetMap. Through your account you need to [register](http://www.openstreetmap.org/user/username/oauth_clients/new) your application along with a callback URL.
31+
32+
### Accessing JOpenstreetmap API
33+
This API will do all types of interactions with OpenStreetMap API. This has been categorized in to 5 main sections: Changeset, Element, Gps, Info and User. All those are inherited from JOpenstreetmapObject and can be initiated through magic __get method of JOpenstreetmap class. Methods contained in each type of object are closely relate to the Openstreetmap API calls.
34+
35+
### General Usage
36+
For an example, to get an element with a known identifier you need to just add following two lines additionally after creating `$osm` .
37+
```php
38+
$element = $osm->elements;
39+
$result = $element->readElement('node', 123);
40+
41+
// To view SimpleXMLElement
42+
print_r($result);
43+
```
44+
For sending information to server you must use OAuth authentication. Following is a complete sample application of creating a new changeset. Later you can use your own changeset to add elements you want.
45+
```php
46+
$key = "your_key";
47+
$secret = "your_secret";
48+
49+
$option = new JRegistry;
50+
$option->set('consumer_key', $key);
51+
$option->set('consumer_secret', $secret);
52+
$option->set('sendheaders', true);
53+
54+
$oauth = new JOpenstreetmapOauth($option);
55+
$oauth->authenticate();
56+
57+
$osm = new JOpenstreetmap($oauth);
58+
59+
$changeset= $osm->changesets;
60+
61+
$changesets = array
62+
(
63+
"comment" => "My First Changeset",
64+
"created_by" => "JOpenstreetmap"
65+
);
66+
$result = $changeset->createChangeset($changesets);
67+
68+
// Returned value contains the identifier of new changeset
69+
print_r($result);
70+
```
71+
### More Information
72+
Following resources contain more information: [OpenStreetMap API](http://wiki.openstreetmap.org/wiki/API)

0 commit comments

Comments
 (0)