Topic: OnGenerateBuildingHeight coordinates

Hi,

I would like to implement a custom method to set proper buidling heights when non can be found in OSM using the height or level tag. I've found the OnGenerateBuildingHeight func and it allow me to set custom heights. However, I need to get the coordinates (lat lon, or tile) in order to obtain the correct building height but I see no way of deriving this from the OnlineMapsOSMWay argument.

Am I missing some way of obtaining the coordinates from the way object or is the OnGenerateBuildingHeight func not intended for this purpose? Do you recommend another manner of implementing this custum buildingheight functionality?

Thanks!

Roy

Re: OnGenerateBuildingHeight coordinates

Hello.

OnGenerateBuildingHeight is not suitable for your purposes.
Right now Online Maps has no good way to do this.
Give me 1-2 days, and I'll add some API so you can do what you want.

Kind Regards,
Infinity Code Team

Re: OnGenerateBuildingHeight coordinates

Great, thanks!

I've found a workaround, which uses the OnCreateBuilding to save the OnlineMapsBuildingsNodeData and use this to find the usedNodes and recalculate the center. This is not ideal, so anything you can add to the API would be great.

Re: OnGenerateBuildingHeight coordinates

Hi Alex,

Another request/suggestion if you'll find time to work on the API change. Perhaps you can include polylabel like functionality in finding the "center" of the polygon. This gives much better results in my application with concave buildings.

This is some example code:
https://github.com/mapbox/polylabel/issues/26

Roy

Re: OnGenerateBuildingHeight coordinates

We added an event:

public Action <OnlineMapsOSMWay, List<OnlineMapsOSMNode>> OnlineMapsBuildings.OnPrepareCreateBuilding

to which the way and used nodes are passed.

To specify the height of the building, simply add the height tag to the way.



I do not know why buildings must be centered based on a polylabel.
But we have added you the way to do it.
We added event:

public Func <List<Vector3>, Vector3> OnlineMapsBuildings.OnCalculateBuildingCenter

so that you can intercept the calculation of the center point, and calculate it based on polylabel.

The new version will be available in 24 hours.

Kind Regards,
Infinity Code Team

Re: OnGenerateBuildingHeight coordinates

Thanks Alex!
I'll try it out very soon

Re: OnGenerateBuildingHeight coordinates

Hi Alex,

I'm just trying this functionality, but shouldn't this method return true?

    protected static bool GetHeightFromString(string str, ref float height)
    {
        if (string.IsNullOrEmpty(str)) return false;

        int l = str.Length;
        if (!TryGetFloat(str, 0, l, out height))
        {
            if (str[l - 2] == 'c' && str[l - 1] == 'm')
            {
                if (TryGetFloat(str, 0, l - 2, out height))
                {
                    height /= 10;
                    return true;
                }
            }
            else if (str[l - 1] == 'm') return TryGetFloat(str, 0, l - 1, out height);
        }
        return false ------- true????;
    }

Re: OnGenerateBuildingHeight coordinates

Hello.

The answer is in OnlineMapsBuildingBuiltIn.AnalizeHouseTags (line: 55).

return false;

Kind Regards,
Infinity Code Team