Topic: Adding Buildings

Im trying to add buildings to an Online Maps demo, but none get displayed.

- I have a tilemap
- I have OnlineMapsBuildingScript assigned in the Editor

...but no Buildings appear to be created. I put a debug line in to the script so can see that GenerateBuildings gets started, and run many times, so Im guessing that it IS making buildings somewhere, but they dont get added to the scene, and dont get added to the hierarchy. It gives me the message about tghe Zoom level 15 will create a very large number of buildings, so how do I limit the number of buildings it creates?

Can anyone advise what needs to be changed? Does this feature work correctly?

I just want to be able to load buildings for around a dozen tiles. I will be limiting the amount that the user can pan the map.

thanks

Re: Adding Buildings

Hello.

It has been changed address of OSM Overpass API requests, so the building is not created.
The problem is fixed.
Please update Online Maps through the built-in update (Component / Infinity Code / Online Maps / Check Updates) to the latest beta version.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Adding Buildings

Excellent, thanks for sorting that - I now have buildings smile LOTS of buildings...! Is there any way of limiting the number of buildings shown? Perhaps limiting to just the largest ones (by area) maybe. At the zoom level that I need to be at, there are hundreds of thousands of buildings...

Would be good to have some way of perhaps hiding them until needed. Or just showing a specific set of buildings from a list?

Also, just had a thought - would it be possible to have a search facility that searches the 'name' field in the XML, and then only shows the building when it is clicked in a search?

thanks!

Re: Adding Buildings

Another thought, can the buildings be cached too?

Re: Adding Buildings

We added the ability to limit the total number of buildings and the number of active (visible) buildings.
We added the ability to control the creation and showing of buildings (example attached).
Please update Online Maps.

Unfortunately, we have no idea how to do caching of buildings.
If you have any suggestions how to do it, we can discuss.

Post's attachments

Attachment icon ControlBuildingsExample.cs 820 b, 173 downloads since 2015-10-29 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

6 (edited by andy3d 2015-10-29 16:41:51)

Re: Adding Buildings

Many thanks for that. My project is still running very slowly. I think its because although that code only shows certain buildings it still loads them into memory first. At the moment it tries to load all buildings in the area, and then it limits the number of buildings that are shown.

I think what I need is to load only the buildings I need, by checking the tags for "university", "public" or "hospital" and creating & showing only those. Not sure how to do that tho...

Re: Adding Buildings

Yeh, my project has become completely unresponsive with creating too many unneeded buildings, so I need to just select the ones that meet my criteria, so Im trying this:


private bool OnCreateBuilding(OnlineMapsBuildingsNodeData data)
    {
        // find public, university, hospital
        if (data.way.HasTagValue("public") || data.way.HasTagValue("university") || data.way.HasTagValue("hospital") )
        {
            Debug.Log("found building that needs to be built!");
            return true;
        } else
        {
            return false;
        }
    }
}

But its still going ahead and creating all buildings, not just those. Am I missing something here? It doesnt debug anything, so Im guessing its not finding those tag values. It probably needs to search within the value.

Thanks a lot

Re: Adding Buildings

We added the ability to control requests to OSM Overpass API.
Please update Online Maps.
Example of using attached.

Important: first test your request in overpass turbo.
http://wiki.openstreetmap.org/wiki/Over … uage_Guide
http://overpass-turbo.eu/

Post's attachments

Attachment icon BuildingCustomRequestExample.cs 495 b, 170 downloads since 2015-10-29 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Adding Buildings

I checked your code without modifications. This works well.
Creates only the buildings with the specified parameters.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

10 (edited by andy3d 2015-10-30 07:52:38)

Re: Adding Buildings

Many thanks Alex, I think Im getting closer now. your help is very much appreciated. Still having problems with the buildings though... When I show them all, its way too slow, and my filter isnt working well...

I now have my filter within the main Online Maps Buildings script, rather than duplicating in a different script. I need to check in all nodes, for a list of case-insensitive values of any length. So I think I need to change this line of the LoadNewBuildings() function:

string requestData = String.Format("node({0},{1},{2},{3});way(bn)[{4}];(._;>;);out;", br.y, tl.x, tl.y, br.x, "'building'");

...but Im not sure how to construct it. I have this working in OverpassTurbo:

node
  [~'^.*$' ~ '^.*hospital.*$|^.*public.*$|^.*university.*$|^.*student.*$|^.*college.*$']
({{bbox}});
out;

Just need to get that into the requestData string somehow... Hope you can point me in the right direction?


I would then need to make Markers automatically for these buildings, using the name field for the label. Is that possible?

Also, how would I go about adding a click event on a dynamic marker? (I have Playmaker too, but not sure how to refer to a marker that it made dynamically?)

thanks a lot for your help

Re: Adding Buildings

Something like:

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

private string OnPrepareRequest(string originalRequest, Vector2 topLeft, Vector3 bottomRight)
{
    return String.Format("node(0},{1},{2},{3});way(bn)['building'~'hospital|public|dormitory|commercial|university|industrial'];(._;>;);out;node(0},{1},{2},{3})['amenity'~'university|college'];way(bn)['building'];(._;>;);out;", bottomRight.y, topLeft.x, topLeft.y, bottomRight.x);
}

Not used: Student, council, engineering, quay, enterprise, trading
Not refer to buildings: marina, park

Map Features:
http://wiki.openstreetmap.org/wiki/Map_ … s#Building


Yes, you can create markers for these buildings.

// To avoid duplication of markers.
private List<string> usedIDs = new List<string>();

private void Start()
{
    OnlineMapsBuildings.instance.OnBuildingCreated += OnBuildingCreated;
}

private void OnBuildingCreated(OnlineMapsBuildingBase building)
{
    if (usedIDs.Contains(building.id)) return;

    string label = building.id;
    foreach (OnlineMapsBuildingMetaInfo metaInfo in building.metaInfo)
    {
        if (metaInfo.title == "name")
        {
            label = metaInfo.info;
            break;
        }
    }
    OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(building.centerCoordinates, label);
    marker.OnClick += OnMarkerClick;
    usedIDs.Add(building.id);
}

private void OnMarkerClick(OnlineMapsMarkerBase marker)
{
    Debug.Log(marker.label);
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.