Skip to content

Commit

Permalink
Small tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
kenguest committed May 20, 2020
1 parent 48c5050 commit f9d8e88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
17 changes: 12 additions & 5 deletions Services/OpenStreetMap.php
Expand Up @@ -29,6 +29,9 @@
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version Release: @package_version@
* @link http://pear.php.net/package/Services_OpenStreetMap
*
*
* @method int getTimeout()
*/
class Services_OpenStreetMap
{
Expand Down Expand Up @@ -282,7 +285,11 @@ public static function getIDs($args): array
*/
public function loadXml(string $file): void
{
$this->xml = file_get_contents($file);
$this->xml = '';
$contents = file_get_contents($file);
if ($contents !== false) {
$this->xml = $contents;
}
}

/**
Expand Down Expand Up @@ -334,18 +341,18 @@ public function search(array $criteria): array
{
$results = [];

$xml = simplexml_load_string($this->xml);
if (!$xml) {
$xmlElement = simplexml_load_string($this->xml);
if (!$xmlElement) {
return [];
}
foreach ($criteria as $key => $value) {
foreach ($xml->xpath('//way') as $node) {
foreach ($xmlElement->xpath('//way') as $node) {
$results = array_merge(
$results,
$this->searchNode($node, $key, $value, 'way')
);
}
foreach ($xml->xpath('//node') as $node) {
foreach ($xmlElement->xpath('//node') as $node) {
$results = array_merge(
$results,
$this->searchNode($node, $key, $value, 'node')
Expand Down
8 changes: 3 additions & 5 deletions Services/OpenStreetMap/Changeset.php
Expand Up @@ -663,11 +663,9 @@ public function updateObjectId(string $type, string $oldId, string $newId): void
return;
}
foreach ($this->members as $member) {
if ($member->getType() == $type) {
if ($member->getId() == $oldId) {
$member->setId($newId);
$this->updateMap[$oldId] = $newId;
}
if ($member->getType() == $type && $member->getId() == $oldId) {
$member->setId($newId);
$this->updateMap[$oldId] = $newId;
}
}
}
Expand Down

0 comments on commit f9d8e88

Please sign in to comment.