pear / Services_Openstreetmap

Makes communicating with the Open Street Map API, and Nominatim, from PHP intuitive.
https://pear.php.net/package/Services_OpenStreetMap/
BSD 3-Clause "New" or "Revised" License
202 stars 53 forks source link

Removing Tag? #13

Closed autumnus closed 7 years ago

autumnus commented 7 years ago

Is it possible to remove a Tag from an OSM-object? The API for changing an object says : "A full representation of the element as it should be after the update has to be provided." see here

But if I provide data which does not contain a key/tag anymore it seems to stay in the database. I would use following procedure:

    $changeset = $osmService->createChangeset();
    $changeset->begin($comment);
    $node = $osmService->getNode($osmID);

    $node->setTags($data);

    $changeset->add($node);
    $changeset->commit();

and $data is an array:

$data = array();
//$data["fax"]  = "+1234567890";
$data["name"]  = "NAME";
$data["city"]  = "LA";

Is that the correct way or am I missing something?

kenguest commented 7 years ago

Hi @autumnus, you're not missing anything - Services_OpenStreetMap is. The package currently lacks the functionality for removing a specified tag, or group of tags, from an object.

I'll push up changes to support this shortly.

autumnus commented 7 years ago

Wow, really fast! If I understand your changes I can now, after getting the object, remove tags, before adding it the the changeset again and commit it. This already helps a lot, thanks. But is that the way the OSM-API describes? I understand the quotation from the API I wrote in my last post that way that the removal also has to be done, when I update the data of an object. So if one key/tag is not present int the provided data any more, it is removed.

autumnus commented 7 years ago

If I read my own post again and review your changes, now it can be done, like the OSM-API tells. Thanks again! It would just be some more convenient, if I would not have to remove the tags explicitly.

kenguest commented 7 years ago

I've added a new method, setAllTags, that might make things more intuitive and less awkward to use.

https://github.com/kenguest/Services_Openstreetmap/commit/3323d7ccb38eb4d37de5ba87a8158f0bf99a721e

kenguest commented 7 years ago

Closing this, as I think everything required has been addressed.