duanhuokuang5280 2016-04-06 08:56 采纳率: 100%
浏览 83

如何通过OpenStreetMap PHP Api更新节点

I'm trying to update a node that i've created before via the OSM PHP API. I've developed some functions that makes some CRUD operations by using the open street map API.

My update function is getting the node and the changeset id to make this operation, then i'm making a put request via this url /api/0.6/node/#id

    $ls_url_update_node = $this->get_api()->get_base_url() . "/api/0.6/node/".$this->get_id();
    $lo_requete = Request::put($ls_url_update_node);

    $ls_xml_node = $this->generate_xml($po_changeset);

    $lo_requete = Request::put($ls_url_update_node)
        ->sendsType('text/xml')
        ->addHeader('Authorization', $this->get_api()->get_authorization_header())
        ->body($ls_xml_node);
    $lo_response = $lo_requete->send();

The genarate_xml function try to generate a valid XML that respect the OSM specifications.

<osm>
 <node id="123" lat="..." lon="..." version="142" changeset="12"   user="fred" uid="123" visible="true" timestamp="2005-07-30T14:27:12+01:00">
  <tag k="note" v="Just a node"/>
   ...
 </node>
</osm>

The OSM Api returns this error message : Cannot parse valid node from xml string. Mayeb i've skip some differences between the creation and the update of a node. So any help please.

  • 写回答

1条回答 默认 最新

  • dslpofp041310584 2016-04-06 09:51
    关注

    You have to send your request to /api/0.6/changeset/create. Also it must contain a <changeset> element. Please refer to the API documentation for creating changesets.

    Adding elements is done by sending to /api/0.6/[node|way|relation]/create, see the API documentation for creating elements. There you must refer a previously opened changeset.

    If you still encounter problems it might be a good idea to use one of the popular OSM editors and look at their requests/responses via wireshark or a similar program.

    评论

报告相同问题?

悬赏问题

  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)