On Sun, Nov 02, 2008 at 06:39:58PM +0100, Holger Issle wrote:

Ansonsten sollte es auch einfach sein, ein kleines Tool zu schreiben,
das eine Datei im API-Format (also ohne action="modified" o.ä.) nimmt
und jedes Objekt darin einzeln hochlädt.
Kann schon sein, aber nicht für mich :-(
Hab mal ein einfaches Python-Script angehängt, was genau das oben beschriebene macht. Es wird keinerlei Überprüfung der Eingabedaten vorgenommen und es können nur existierende Objekte modifiziert werden (nicht neue erstellt), aber für komplexere Änderungen sollte man besser eh was anderes verwenden (mit Rollback und so).

[MUA unterstützt kein Mail-Followup-To]
Aus sehr langer Gewöhnung Agent 1.93, und es stimmt da stehen bei Dir
beide Adressen im to:-Feld. Diesmal manuell gelöst.
Von Forte Inc.? Da besteht vermutlich keine Aussicht auf Besserung (aktuellste Version 4.2 => 1.93 wird wahrscheinlich nicht weiterentwickelt). Dann hoffe ich einfach mal, daß Du der einzige bist, der das noch benutzt. :)

CU Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/
#!/usr/bin/env python
# Author: Sascha Silbe
# "License": Public Domain
import base64
import ConfigParser
import os
import sys
import httplib
import xml.dom.minidom
import xml.xpath
from convcommon import *

apiHost       = "api.openstreetmap.org"
apiPort       = 80
apiBasePath   = "/api/0.5"
apiUploadPath = apiBasePath+"/%(type_)s/%(id_)d"


def uploadHttp(path, content) :
  global cfg

  authInfo = "Basic "+(cfg.get('global', 'username')+":"+cfg.get('global', 'password')).encode("base64").rstrip()
  hdrs = {
    "Authorization": authInfo,
    "Content-Length": len(content),
  }
  conn = httplib.HTTPConnection(apiHost, apiPort)
  conn.request("PUT", path, headers = hdrs, body = content.encode('utf-8'))
  resp = conn.getresponse()
  if (resp.status != 200) :
    raise IOError("API returned HTTP code %d: %s" % (resp.status, resp.reason))

def uploadSingle(rootNode, xmlNode, type_) :
  id_ = int(xmlNode.attributes['id'].nodeValue)
  newRootNode = rootNode.cloneNode(deep=False)
  newRootNode.appendChild(xmlNode)
  uploadHttp(apiUploadPath % locals(), newRootNode.toxml())

def uploadMulti(rootNode, type_) :
  for entry in xml.xpath.Evaluate("/osm/"+type_, rootNode) :
    uploadSingle(rootNode, entry, type_)

def uploadOsm(rootNode) :
  uploadMulti(rootNode, "node")
  uploadMulti(rootNode, "way")
  uploadMulti(rootNode, "relation")


def printSyntax(myName) :
  print "Syntax: "+myName+" <osmFile>"
  print "Sample: "+myName+" is_in_fixed.osm"
  print
  print "<osmFile> needs to be an XML file in the format used by OSM API 0.5."
  print "No merging or input validation is done, so please BE CAREFUL."
  print "Creation of new objects is NOT supported."
  print
  print "osmbulkupload.ini (in current directory) must contain the following:"
  print "[global]"
  print "username=<yourOsmUserName>"
  print "password=<yourOsmPassword>"
  return 100

def main(myName, args) :
  global cfg

  if len(args) != 1 :
    return printSyntax(myName)

  osmFName = args[0]

  cfg = ConfigParser.SafeConfigParser()
  cfg.read("osmbulkupload.ini")

  uploadOsm(xml.dom.minidom.parse(file(osmFName)).documentElement)

  return 0


sys.exit(main(sys.argv[0], sys.argv[1:]))

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Talk-de mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/talk-de

Antwort per Email an