-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.html
162 lines (121 loc) · 4.84 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="description" content="Services openstreetmap : OpenStreetMap is a global project with an aim of collaboratively collecting map data. This package aims to make communicating with the OSM API intuitive." />
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
<title>Services openstreetmap</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="forkme_banner" href="https://github.com/kenguest/Services_Openstreetmap">Fork Me on GitHub</a>
<h1 id="project_title">Services openstreetmap</h1>
<h2 id="project_tagline">OpenStreetMap is a global project with an aim of collaboratively collecting map data. This package aims to make communicating with the OSM API intuitive.</h2>
<section id="downloads">
<a class="zip_download_link" href="https://github.com/kenguest/Services_Openstreetmap/zipball/master">Download this project as a .zip file</a>
<a class="tar_download_link" href="https://github.com/kenguest/Services_Openstreetmap/tarball/master">Download this project as a tar.gz file</a>
</section>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h1>Services_OpenStreetMap</h1>
<p><a href="http://www.openstreetmap.org/">OpenStreetMap</a> is a global project with an aim of collaboratively collecting map
data. This package aims to make communicating with the OSM API intuitive.</p>
<h2>Usage</h2>
<h3>Initialisation</h3>
<p>Simply require and initialize the Services_OpenStreetMap class:</p>
<pre><code>require_once 'Services/OpenStreetMap.php';
$osm = new Services_OpenStreetMap();
</code></pre>
<h3>Downloading Data, saving to an OSM file</h3>
<pre><code>$osm->get(-8.3564758, 52.821022799999994, -7.7330017, 53.0428644);
file_put_contents("area_covered.osm", $osm->getXml());
</code></pre>
<h3>Search for a specific POI, in a saved OSM file</h3>
<pre><code>$osm = new Services_OpenStreetMap();
$osm->loadXml("./osm.osm");
$results = $osm->search(array("amenity" => "pharmacy"));
echo "List of Pharmacies\n";
echo "==================\n\n";
foreach ($results as $result) {
$name = null;
$addr_street = null;
$addr_city = null;
$addr_country = null;
$addr_housename = null;
$addr_housenumber = null;
$opening_hours = null;
$phone = null;
extract($result);
$line1 = ($addr_housenumber) ? $addr_housenumber : $addr_housename;
if ($line1 != null) {
$line1 .= ', ';
}
echo "$name\n{$line1}{$addr_street}\n$phone\n$opening_hours\n\n";
}
</code></pre>
<h3>Get a specific Node</h3>
<pre><code>require_once 'Services/OpenStreetMap.php';
$osm = new Services_OpenStreetMap();
var_dump($osm->getNode(52245107));
Getting specific changesets, ways etc follow the same pattern.
</code></pre>
<h3>Updating a way, or several.</h3>
<pre><code>require_once 'Services/OpenStreetMap.php';
// A password file, is a colon delimited file.
// Eg. fred@example.com:yabbadabbado
$config = array('passwordfile' => './credentials');
$osm = new Services_OpenStreetMap($config);
$changeset = $osm->createChangeset();
$changeset->begin("These ways are lit");
$ways = $osm->getWays($wayId, $way2Id);
foreach ($ways as $way) {
$way->setTag('highway', 'residential');
$way->setTag('lit', 'yes');
$changeset->add($way);
}
$changeset->commit();
</code></pre>
<h3>Creating a node.</h3>
<pre><code>require_once 'Services/OpenStreetMap.php';
// A password file, is a colon delimited file.
// Eg. fred@example.com:yabbadabbado
$config = array('passwordfile' => './credentials');
$osm = new Services_OpenStreetMap($config);
$changeset = $osm->createChangeset();
$changeset->begin("Added Acme Vets.");
$lat = 52.8638729;
$lon = -8.1983611;
$node = $osm->createNode($lat, $lon, array(
'name' => 'Acme Vets',
'building' => 'yes',
'amenity' => 'vet')
);
$changeset->add($node);
$changeset->commit();
</code></pre>
<h3>Working with user information.</h3>
<pre><code>$config = array(
'user' => 'fred@example.com',
'password' => 'w1lma4evah'
);
$osm = new Services_OpenStreetMap($config);
$user = $osm->getUser();
echo 'My OSM Mugshot is at ', $user->getImage(), "\n";
</code></pre>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p class="copyright">Services openstreetmap maintained by <a href="https://github.com/kenguest">kenguest</a></p>
<p>Published with <a href="http://pages.github.com">GitHub Pages</a></p>
</footer>
</div>
</body>
</html>