Esempio n. 1
0
        /// <summary>
        /// Creates a new changeset by opening one.
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="created_by"></param>
        /// <returns></returns>
        public long ChangeSetOpen(string comment, string created_by)
        {
            if (created_by == null || created_by.Length == 0)
            { // a created by tag always has to exist and have a usefull value.
                throw new ArgumentOutOfRangeException("A created by tag always has to exist and have a usefull value.");
            }

            // build a new changeset.
            OsmSharp.Osm.Xml.v0_6.osm osm = new Osm.Xml.v0_6.osm();
            osm.changeset = new Osm.Xml.v0_6.changeset[1];
            OsmSharp.Osm.Xml.v0_6.changeset changeset = new Osm.Xml.v0_6.changeset();
            changeset.tag      = new OsmSharp.Osm.Xml.v0_6.tag[1];
            changeset.tag[0]   = new Osm.Xml.v0_6.tag();
            changeset.tag[0].k = "created_by";
            changeset.tag[0].v = created_by;
            osm.changeset[0]   = changeset;

            // serialize the changeset.
            XmlSerializer serializer = new XmlSerializer(typeof(OsmSharp.Osm.Xml.v0_6.osm));
            MemoryStream  mem_stream = new MemoryStream();
            Stream        stream     = mem_stream;

            serializer.Serialize(stream, osm);
            stream.Flush();
            mem_stream.Flush();
            byte[] put_data = mem_stream.ToArray();

            // do the api call.
            string response_string = this.DoApiCall(true, "api/0.6/changeset/create", Method.PUT, put_data);

            _current_changeset    = changeset;
            _current_changeset.id = long.Parse(response_string);
            return(_current_changeset.id);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the changeset information with the given id from the API. Does not include the actual changes.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ChangeSetInfo ChangeSetGet(long id)
        {
            string response = this.DoApiCall(false, string.Format(
                                                 "/api/0.6/changeset/{0}", id), Method.GET, null);

            if (response != null && response.Trim().Length > 0)
            {
                XmlReaderSource        xml_source = new XmlReaderSource(XmlReader.Create(new StringReader(response)));
                OsmDocument            osm        = new OsmDocument(xml_source);
                Osm.Xml.v0_6.changeset xml_node   = (osm.Osm as OsmSharp.Osm.Xml.v0_6.osm).changeset[0];
                return(this.Convertv6XmlChangeSet(xml_node));
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new changeset by opening one.
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="created_by"></param>
        /// <returns></returns>
        public long ChangeSetOpen(string comment, string created_by)
        {
            if (created_by == null || created_by.Length == 0)
            { // a created by tag always has to exist and have a usefull value.
                throw new ArgumentOutOfRangeException("A created by tag always has to exist and have a usefull value.");
            }

            // build a new changeset.
            OsmSharp.Osm.Xml.v0_6.osm osm = new Osm.Xml.v0_6.osm();
            osm.changeset = new Osm.Xml.v0_6.changeset[1];
            OsmSharp.Osm.Xml.v0_6.changeset changeset = new Osm.Xml.v0_6.changeset();
            changeset.tag = new OsmSharp.Osm.Xml.v0_6.tag[1];
            changeset.tag[0] = new Osm.Xml.v0_6.tag();
            changeset.tag[0].k = "created_by";
            changeset.tag[0].v = created_by;
            osm.changeset[0] = changeset;

            // serialize the changeset.
            XmlSerializer serializer = new XmlSerializer(typeof(OsmSharp.Osm.Xml.v0_6.osm));
            MemoryStream mem_stream = new MemoryStream();
            Stream stream = mem_stream;
            serializer.Serialize(stream, osm);
            stream.Flush();
            mem_stream.Flush();
            byte[] put_data = mem_stream.ToArray();

            // do the api call.
            string response_string = this.DoApiCall(true, "api/0.6/changeset/create", Method.PUT, put_data);

            _current_changeset = changeset;
            _current_changeset.id = long.Parse(response_string);
            return _current_changeset.id;
        }