<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — ParseOSMResponse and area elements]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=469&amp;type=atom" />
	<updated>2017-03-21T05:34:32Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=469</id>
		<entry>
			<title type="html"><![CDATA[Re: ParseOSMResponse and area elements]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2071#p2071" />
			<content type="html"><![CDATA[<p>Yay! Happy to be a part of moving this awesome asset forward. <img src="https://forum.infinity-code.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-21T05:34:32Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2071#p2071</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ParseOSMResponse and area elements]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2064#p2064" />
			<content type="html"><![CDATA[<p>Hello.</p><p>We added these methods into Online Maps.<br />The new version is already available through the built-in update system.</p><p>We will not add this into ParseOSMResponseFast, because this method is only for buildings, and its main task is to be as fast as possible. That&#039;s why it ignores most of XML standard, and can not be used for other tasks.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-03-20T15:42:08Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2064#p2064</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: ParseOSMResponse and area elements]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2059#p2059" />
			<content type="html"><![CDATA[<p>Here&#039;s the class for OnlineMapsOSMArea. It&#039;s basically OnlineMapsOSMNode with the lat/long stripped away and the name changed.</p><div class="codebox"><pre><code>/// &lt;summary&gt;
/// Open Street Map area element class
/// &lt;/summary&gt;
public class OnlineMapsOSMArea : OnlineMapsOSMBase
{

    public OnlineMapsOSMArea(OnlineMapsOSMAPIQuery.OSMXMLNode node)
    {
        id = node.GetAttribute(&quot;id&quot;);
    }

    /// &lt;summary&gt;
    /// Constructor
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;node&quot;&gt;Node&lt;/param&gt;
    public OnlineMapsOSMArea(OnlineMapsXML node)
    {
        id = node.A(&quot;id&quot;);

        tags = new List&lt;OnlineMapsOSMTag&gt;(node.count);

        foreach (OnlineMapsXML subNode in node) tags.Add(new OnlineMapsOSMTag(subNode));
    }

}</code></pre></div><p>And here&#039;s the changed versions of the two ParseOSMResponse routines.</p><div class="codebox"><pre><code>    /// &lt;summary&gt;
    /// Get data from the response Open Street Map Overpass API.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;response&quot;&gt;Response from Overpass API&lt;/param&gt;
    /// &lt;param name=&quot;nodes&quot;&gt;List of nodes&lt;/param&gt;
    /// &lt;param name=&quot;ways&quot;&gt;List of ways&lt;/param&gt;
    /// &lt;param name=&quot;relations&quot;&gt;List of relations&lt;/param&gt;
    public static void ParseOSMResponse(string response, out List&lt;OnlineMapsOSMNode&gt; nodes, out List&lt;OnlineMapsOSMWay&gt; ways, out List&lt;OnlineMapsOSMRelation&gt; relations, out List&lt;OnlineMapsOSMArea&gt; areas)
    {
        nodes = new List&lt;OnlineMapsOSMNode&gt;();
        ways = new List&lt;OnlineMapsOSMWay&gt;();
        relations = new List&lt;OnlineMapsOSMRelation&gt;();
        areas = new List&lt;OnlineMapsOSMArea&gt;();

        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(response);

            foreach (OnlineMapsXML node in xml)
            {
                if (node.name == &quot;node&quot;) nodes.Add(new OnlineMapsOSMNode(node));
                else if (node.name == &quot;way&quot;) ways.Add(new OnlineMapsOSMWay(node));
                else if (node.name == &quot;relation&quot;) relations.Add(new OnlineMapsOSMRelation(node));
                else if (node.name == &quot;area&quot;) areas.Add(new OnlineMapsOSMArea(node));
            }
        }
        catch
        {
            Debug.Log(response);
        }
    }

    /// &lt;summary&gt;
    /// Get data from the response Open Street Map Overpass API.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;response&quot;&gt;Response from Overpass API&lt;/param&gt;
    /// &lt;param name=&quot;nodes&quot;&gt;Dictionary of nodes&lt;/param&gt;
    /// &lt;param name=&quot;ways&quot;&gt;List of ways&lt;/param&gt;
    /// &lt;param name=&quot;relations&quot;&gt;List of relations&lt;/param&gt;
    public static void ParseOSMResponse(string response, out Dictionary&lt;string, OnlineMapsOSMNode&gt; nodes, out List&lt;OnlineMapsOSMWay&gt; ways, out List&lt;OnlineMapsOSMRelation&gt; relations, out List&lt;OnlineMapsOSMArea&gt; areas)
    {
        nodes = new Dictionary&lt;string, OnlineMapsOSMNode&gt;(64);
        ways = new List&lt;OnlineMapsOSMWay&gt;(64);
        relations = new List&lt;OnlineMapsOSMRelation&gt;(64);
        areas = new List&lt;OnlineMapsOSMArea&gt;(64);  // why do we specify a length of 64 here but not in the other ParseOSMResponse?

        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(response);

            foreach (OnlineMapsXML node in xml)
            {
                if (node.name == &quot;node&quot;)
                {
                    OnlineMapsOSMNode osmNode = new OnlineMapsOSMNode(node);
                    nodes.Add(osmNode.id, osmNode);
                }
                else if (node.name == &quot;way&quot;)
                {
                    ways.Add(new OnlineMapsOSMWay(node));
                }
                else if (node.name == &quot;relation&quot;)
                {
                    relations.Add(new OnlineMapsOSMRelation(node));
                }
                else if (node.name == &quot;area&quot;)
                {
                    areas.Add(new OnlineMapsOSMArea(node));
                }
            }
        }
        catch
        {
            Debug.Log(response);
        }
    }</code></pre></div><p>I didn&#039;t implement the change in ParseOSMResponseFast because that was a bit more involved, but you might want to if you decide to incorporate area elements into the base code. Also, a quick question you might have noticed in a comment in the code- why in the overload that uses a Dictionary for the nodes do you set both Dictionary and Lists to a size of 64 when declaring them? Just curious.</p><p>I&#039;ve tested the code here and it appears to be functional. I would love it if you were to incorporate it, as it might be useful to others, and it would keep me from having to pull it out into its own script inheriting from OnlineMapsOSMAPIQuery so as not to get overwritten whenever I update your code.</p><p>Thanks again, and I hope this proves useful, especially considering how much example code you provide to those using your asset.</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-20T03:42:55Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2059#p2059</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[ParseOSMResponse and area elements]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2056#p2056" />
			<content type="html"><![CDATA[<p>In trying to replicate the functionality of the Query Features button on OSM, I&#039;ve discovered an operator that yields an element that&#039;s not currently supported by OSM. I&#039;m going to add a version of it myself, but I thought you might want to see if you&#039;d like to add it to the standard distribution.</p><p>If you go to <a href="http://overpass-turbo.eu/">http://overpass-turbo.eu/</a> and paste in the following query</p><div class="codebox"><pre><code>is_in(34.17288, -118.5042);(._;&gt;;);out meta;</code></pre></div><p>you won&#039;t see anything on the map, but if you open up the Data display, you&#039;ll see a number of elements like this</p><div class="codebox"><pre><code>  &lt;area id=&quot;2716623880&quot;&gt;
    &lt;tag k=&quot;ele&quot; v=&quot;217&quot;/&gt;
    &lt;tag k=&quot;leisure&quot; v=&quot;park&quot;/&gt;
    &lt;tag k=&quot;name&quot; v=&quot;Balboa Sports Center&quot;/&gt;
  &lt;/area&gt;</code></pre></div><p>Currently, ParseOSMResponse only works with nodes, ways, and relations. Looking at the code for that procedure, it seems like it won&#039;t be too difficult for me to write a new procedure modeled on those that also includes support for area elements. Once I get it working reliably, I&#039;ll post it for you to check out and let me know if there are any errors not obvious to me, and to decide if it&#039;s something you&#039;d like to add to the base code.</p><p>Thanks again for your sterling support! <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-19T23:08:35Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2056#p2056</id>
		</entry>
</feed>
