<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Buildings plugin]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=447</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=447&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Buildings plugin.]]></description>
		<lastBuildDate>Tue, 23 Jan 2018 18:25:10 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3259#p3259</link>
			<description><![CDATA[<p>Yes, you can determine when the buildings are done.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 23 Jan 2018 18:25:10 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3259#p3259</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3254#p3254</link>
			<description><![CDATA[<p>Okay, thanks. </p><p>I was saying I&#039;ve got OnBuildingCreated firing after OnAllBuildingsCreated fires, which confuses me. Once all buildings have been created, I wouldn&#039;t expect to be notified that a building was created.</p><p>In the next version, if I check both OnAllBuildingsCreated &amp; OnRequestFailed, I&#039;ll be able to determine when the buildings are done?</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Tue, 23 Jan 2018 01:54:24 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3254#p3254</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3252#p3252</link>
			<description><![CDATA[<p>No, OnAllBuildingsCreated will only triggered if at least one building has been generated.</p><p>Right now you need to use OnRequestSent trick.<br />But thanks that you show me this problem.<br />We added OnRequestFailed so that no one in the future needed to do this.<br />The next version will contain this.</p><p>Yes, now buildings are generated using inner ways too.</p><p>Unfortunately, I did not understand what you mean in the last post.<br />Please rephrase it.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 23 Jan 2018 01:06:05 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3252#p3252</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3248#p3248</link>
			<description><![CDATA[<p>OnAllBuildingsCreated doesn&#039;t seem to be working for me. I drop a debug in there and in OnBuildingCreated and I&#039;m getting notifications of buildings being created after being notified that they all already have been.</p><p>Am I missing something?</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 22 Jan 2018 20:27:48 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3248#p3248</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3246#p3246</link>
			<description><![CDATA[<p>Awesome, that makes sense. I appreciate the explanation.</p><p>I&#039;ll also be sure to go ahead and implement OnlineMapsBuildings.OnAllBuildingsCreated. Does this trigger if there are no buildings to create, or must the code in OnRequestSent still be run?</p><p>Also, on another note earlier in this thread, and since I missed some of the updates more recently, has there been any change in the way donut-shaped buildings are handled? Last I heard I think it was just the outer way defining the building, so at least they were showing up somewhat properly.</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 22 Jan 2018 19:27:58 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3246#p3246</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3245#p3245</link>
			<description><![CDATA[<p>First of all, starting from Online Maps v2.5.12 you can use OnlineMapsBuildings.OnAllBuildingsCreated.</p><p>How it works in the current script:<br />OnRequestSent is needed to get an instance of the request, and handle the situation when the map has no buildings. For example, there are no buildings in the sea, or it could just be a server error. In any case, this behavior must be handled.<br />The request is a private field, so you can get an instance of request only using reflection.</p><p>Online Maps take time to generate buildings.<br />An average of 1 millisecond per building.<br />But the map can contain hundreds and thousands of buildings at the same time (for example, New York or Moscow).<br />If you generate this number of buildings at the same time, it will just freeze your application for a few seconds.<br />Therefore, the map splits the generation of buildings into several frames (50 milliseconds per frame).</p><p>OnBuildingCreated will be invoked in each frame at least once.<br />In the frame when this action is not invoked, the generation of buildings was completed.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 22 Jan 2018 18:27:47 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3245#p3245</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3243#p3243</link>
			<description><![CDATA[<p>I have the code you provided for detecting when all the building have been rendered working, but don&#039;t get exactly how you&#039;re using it. As I&#039;m working more in the initialization routines of my scene, I find myself wanting to be sure I understand it. Could I ask you to explain it a bit? I&#039;m adding in some comments to explain my confusion and what I think&#039;s going on. Thanks!</p><div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>Example:<br /></p><div class="codebox"><pre><code>using System;
using System.Reflection;
using UnityEngine;

public class WaitingBuildingsCreation:MonoBehaviour
{
    private bool hasBuildingCreated = false;
    private bool firstBuildingCreated = false;
    private OnlineMapsBuildings buildings;

    private void Start()
    {
        buildings = OnlineMapsBuildings.instance;

        if (buildings.zoomRange.InRange(OnlineMaps.instance.zoom))
        {
            buildings.OnBuildingCreated += OnBuildingCreated;
            buildings.OnRequestSent += OnRequestSent;
        }
        else OnFinish();
    }

    private void OnRequestSent()
    {
        // Dirty hack to find out that the map does not have buildings.
        Type btype = typeof(OnlineMapsBuildings);
        FieldInfo field = btype.GetField(&quot;osmRequest&quot;, BindingFlags.Instance | BindingFlags.NonPublic);
        OnlineMapsOSMAPIQuery request = field.GetValue(buildings) as OnlineMapsOSMAPIQuery;
        request.OnComplete += OnRequestComplete;

        buildings.OnRequestSent -= OnRequestSent;

// my understanding here is that because a lack of building on the map means we won&#039;t get an event saying when one&#039;s created, so we can&#039;t know when they&#039;re done being created. We tie into the request so if it comes back and is too small, we know there aren&#039;t any buildings.

    }

    private void OnRequestComplete(string s)
    {
        if (s.Length &lt; 300) OnFinish();
    }

    private void OnBuildingCreated(OnlineMapsBuildingBase building)
    {
        firstBuildingCreated = true;
        hasBuildingCreated = true;
    }

    private void OnFinish()
    {
        buildings.OnBuildingCreated -= OnBuildingCreated;

        Debug.Log(&quot;All buildings are created.&quot;);
        Destroy(this);
    }

    private void Update()
    {

// while this line makes sense to me
        if (!firstBuildingCreated) return;

// it&#039;s here where I get confused. it seems to me that this is relying on a building being created every frame, otherwise this update loop my execute on the next frame without the building creation triggering hasBuildingCreated. Is this so? Can this be relied upon? Is there any other way to determine the number of building to be displayed on the map so we know when we&#039;ve shown them all?

        if (hasBuildingCreated)
        {
            hasBuildingCreated = false;
            return;
        }

        OnFinish();
    }
}</code></pre></div></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 22 Jan 2018 17:23:33 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3243#p3243</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2191#p2191</link>
			<description><![CDATA[<p>Unfortunately, we does not have examples for generating objects based on OSM data.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 12 Apr 2017 22:32:42 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2191#p2191</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2183#p2183</link>
			<description><![CDATA[<p>That&#039;s great, thanks. I&#039;ll hold off then on implementing the code you provided above, since a better version is due later this week. I appreciate the example, though, as it shows me how to modify such calls should I need to.</p><p>I&#039;m actually considering adapting the building code to allow me to draw lines on the map to represent ways and relations found in OSM- the border of a playground, for example, or a golf course, or some other feature that isn&#039;t a building. If you have any examples or suggestions on how to do it more easily, I&#039;d love to see them. If not, I&#039;ll work on it myself and if I get to the point where I&#039;ve got something I think the community would find useful, I&#039;ll be sure to share it here.</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Wed, 12 Apr 2017 17:37:59 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2183#p2183</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2170#p2170</link>
			<description><![CDATA[<p>First of all, you do not need to modify the code to change the request.<br />Use OnlineMapsBuildings.OnPrepareRequest.<br />Example:<br /></p><div class="codebox"><pre><code>using System;
using UnityEngine;

public class OnPrepareBuildingRequestExample
{
    private void Start()
    {
        OnlineMapsBuildings.instance.OnPrepareRequest += OnPrepareRequest;
    }

    private string OnPrepareRequest(string originalRequest, Vector2 topLeftCoords, Vector2 bottomRightCoords)
    {
        return String.Format(&quot;(way[{4}]({0},{1},{2},{3});relation[{4}]({0},{1},{2},{3}););out;&gt;;out skel qt;&quot;, bottomRightCoords.y, topLeftCoords.x, topLeftCoords.y, bottomRightCoords.x, &quot;&#039;building&#039;&quot;);
    }
}</code></pre></div><p>If you use this request directly, you will have a rather strange result.<br />I tested the map in Rome (near to coliseum), and it looks a pretty bad.</p><p>We have made changes to the code, and now it works correctly with relations, but uses only the outer ways.<br />The new version will be available later this week.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 11 Apr 2017 12:44:01 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2170#p2170</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2166#p2166</link>
			<description><![CDATA[<p>Wondering if you&#039;ve had a chance to think on this more. As it stands, any time you update I need to keep replacing your code with the line I mentioned in post 16 so that there aren&#039;t buildings that don&#039;t show up at all. </p><p>You said, &quot;If only generate outer way, the building will not look as marked on OSM.&quot; To me, at least, that would be preferable to the building now showing up at all. I haven&#039;t had a chance to mess with the CSG asset I mentioned yet, and hopefully I won&#039;t have to if your team can come up with a workable solution. Please let me know your thoughts on the matter.</p><p>Thanks!</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 10 Apr 2017 17:20:20 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2166#p2166</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2079#p2079</link>
			<description><![CDATA[<p>Using that line of code in post 16, I get meshes for the building, but also ones for the negative space inside them. I&#039;m wondering if the best way to achieve the goal might be through an implementation of Constructive Solid Geometry, taking the negative space meshes and subtracting them from the main building mesh. I found a free asset that looks like it might do the trick, but I thought I&#039;d pass the idea along to you before I got too far into it.</p><p><a href="https://www.assetstore.unity3d.com/en/#!/content/47418">https://www.assetstore.unity3d.com/en/#!/content/47418</a></p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Wed, 22 Mar 2017 19:35:49 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2079#p2079</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2078#p2078</link>
			<description><![CDATA[<p>After poking at it a bit more, I&#039;ve decided to use the following code for the time being.</p><div class="codebox"><pre><code>requestData = String.Format(&quot;(way[{4}]({0},{1},{2},{3});relation[{4}]({0},{1},{2},{3}););out;&gt;;out skel qt;&quot;, bry, tlx, tly, brx, &quot;&#039;building&#039;&quot;);</code></pre></div><p>It doesn&#039;t cut out the holes by implementing the inner ways, but for my purposes at the moment that&#039;s acceptable. At some point later I&#039;ll want to revisit the issue if you haven&#039;t fixed it by then, but just having the exterior borders of every building defined is worth the loss of the interior spaces.</p><p>I&#039;d rather have all the buildings be there with some of them being imperfect than the ones that would be imperfect not there at all.</p><p>Thanks again!</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Wed, 22 Mar 2017 17:06:22 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2078#p2078</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2070#p2070</link>
			<description><![CDATA[<p>Thanks for the suggestions, I&#039;ll start looking into them.</p><p>I see what you mean, but I hope it doesn&#039;t end up being more trouble than it&#039;s worth, as it&#039;d be nice to have a fully functional buildings component before the next major revision. If you don&#039;t end up implementing it and I find a way, I&#039;ll be sure to share it with the community.</p>]]></description>
			<author><![CDATA[null@example.com (Quidam)]]></author>
			<pubDate>Mon, 20 Mar 2017 23:53:39 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2070#p2070</guid>
		</item>
		<item>
			<title><![CDATA[Re: Buildings plugin]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2069#p2069</link>
			<description><![CDATA[<p>You have several ways:<br />1. The easiest way is increase &quot;Min Building Height&quot;.<br />2. When updating elevation data, you check the elevation for key points (for example, center + middle of bounding box edges), and update the roof points. It will be very similar to the example above (post 11), and I think you will do it without problems.<br />3. When updating elevation data, you check the elevation for center and all bottom points, and update the roof points. Not recommended, because it will be very slow.</p><p>Yes, it makes sense, but it&#039;s not so simple.<br />I foresee that when trying to generate relations (outer way + inner ways) this will have many artifacts due to triangulation.<br />If only generate outer way, the building will not look as marked on OSM.<br />It&#039;s a pretty difficult dilemma. Let me think about this a little.<br />In any case, thanks for the information.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 20 Mar 2017 22:40:29 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2069#p2069</guid>
		</item>
	</channel>
</rss>
