Facade Classification #1
Replies: 44 comments 117 replies
-
Before we discuss possible implementations (I will propose many of them later), I like to discuss definitions first, so that we get some kind of clear base. Mainly the definition of facade classes is not yet clear to me. Ways
In general, OSM ways are not polygons. What do you mean by polygon chain?
What is the difference between a way-segment line and a way? Facade classes
There exists only extremely few literature on this subject. Most ideas come from the search for positions, where POIs could be placed. One paper proposes some weighting of building edges using similar features as we currently discuss, an idea we could eventually adapt to our problem. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Added a section about an existent implementaton for the facade classification (in the beginning of the document). |
Beta Was this translation helpful? Give feedback.
-
One more note to your proposal. Buildings without any way in their neighborhood must be identified. A fallback facade classification should be applied to those buildings. |
Beta Was this translation helpful? Give feedback.
-
Your proposal seems to be appropriate also for the task of the way clasterization I mentioned in one of my previous message. Let's consider an example in Rotterdam:
1e Middellandstraat is divided into two separate road ways by two tram tracks. There are two designated cycleways and two designated pedestrian ways (only one is marked in OpenStreetMap) on each side of the street, The idea is to cluster them together to find the borders of the street. Front building facades, fences, rivers, water channels, areas with grass on a street can also be added to the cluster to estimate the borders of the whole street. After the cluster is formed, an appropriate street texture is selected and/or geometry for the ways that form the street cluster is created. |
Beta Was this translation helpful? Give feedback.
-
Wanted to add additional comments about the facade classification. A facade facing a street gets more decorations than a facade not visible from a street. Entrances to shops, cafes are typically located in the facades facing the street. If two different facades face two different streets, both facades get the same level of decorations. |
Beta Was this translation helpful? Give feedback.
-
A question to your proposal. How to detect the case A facade hides other facades from a way segment? In the examples below: |
Beta Was this translation helpful? Give feedback.
-
I started to experiment with real data and have some first results and observations. I will post them each in a different post so that we may discuss them separately. Preprocessing of Way-SegementsOften I observed that streets have been drawn using a lot of small segments, as shown in the image a) below. Using my proposition with coordinate transformation, processing of each short segment is very inefficient. I propose to simplify the streets, for instance using a Douglas–Peucker algorithm. For my experiments I used this implementation from GitHub. Image b) shows the result for the same street as a). Simplifiying streets could maybe also be helpful for your way clusterization. The simplification does not help, where streets have sharp curves, as shown in the next image. Another observation I made (donwloading all streets tagged highway) are very short (~5m long) streets of only one segment. Maybe it would help to demand at least one segment to have a minimal length. To select only streets, that can be used to find front facades, should also be considered. Maybe by selecting a group of keys for highway, should also be considered. |
Beta Was this translation helpful? Give feedback.
-
Selection of Buildings from Way-SegmentThe selection of buildings that have to be investigated from a transformed way-segment is a very complex task. I do not yet have a reliable solution. For my experiments, I transformed the centers of the buildings to the coordinate system of the way segment. Building centers are available from OSM-data and seem to correspond to the center of gravity of the building's shape. The advantage of using them is that there is only one center per building, which reduces the load to transform all of them. Centers within a rectangle around the way-segment have been accepted for further investigation. For instance the following selection in image a) used a range of 50 m above and below the way-segment and 10 m on both sides (green rectangle): The configuration of this range is very delicate. The center of large building, like a supermarket, easily does not get selected, because its center is too far away (see example in image b)). Once I had an example (unfortunately I can't find it anymore), where a long building along a street didn't get detected, because its center was to far to the right. Therefore, a building placed behind it got a front facade, because it was not more hidden. Eventually it would be better to find building vertices within such a range and then include all the affiliated buildings. But then, all building vertices would have to be transformed and the vertices would need a link back to the building. Maybe your idea using a kd-tree and the original untransformed coordinates for the selection could help. |
Beta Was this translation helpful? Give feedback.
-
Visibility TestingA first attempt for visibility testing is encouraging. The algorithm starts with the edges of all buildings from a selection and using their transformed coordinates, aligned to way-segment, as described above. Here a description in pseudo-code:
There exist sometimes small issues, but I did not yet find whether they are produced already by the selection process. Here a first example of visible facades (in green), showing some issues: EDIT: Ther was a line missing in the pseudo-code. |
Beta Was this translation helpful? Give feedback.
-
Selection of Buildings from Way-Segment, IIAs already discussed, the selection of buildings to find the visibility of their facades relative to a way segment is not yet solved. Although I do not yet have an implementation, I like to propose another approach. Let me first repeat the actual algorithm to highlight then the difference: For every way-segment do:
The following image illustrates this process in the state of the transformed coordinate system: This algorithm has two main disadvantages:
Therefore let me describe another approach:
For every way-segment do:
The following image illustrates this process in the state of the original coordinate system: The advantages of this approach are:
and there is one (small) disadvatage:
Unsolved until nowI was not yet able to implement this proposition. The main reasons are the following:
As always, it's a balance between algorithms and data structures. Maybe you have some hints? |
Beta Was this translation helpful? Give feedback.
-
Finally, we will have similar issues as we had with bpypolyskel. Here an example, where a facade (orange arrow in left image) was not accepted as front facade, although it should in my opinion. On the right we see, that a small part of the building is hidden (orange arrow), because the building edges are not recatangular. This may be true or be an effect of imprecise drawing by the user. We will have to accept some tolerance, for instance of half a meter. |
Beta Was this translation helpful? Give feedback.
-
Another issue is building parts. Some buildings have a detailed 3D mapping. Specifically, there may be additional footprints that represent building parts in 3D. The problem is how to process the building parts. Should they be classified like all building footprints? An alternative would be to classify a footprint for the whole building first and the use that facade classification to assign facade visibility for the building parts. |
Beta Was this translation helpful? Give feedback.
-
Blender's KD-tree isn't available in the command line mode. What would be the replacement for the command line mode? Have you already tried scipy.spatial.KDTree? |
Beta Was this translation helpful? Give feedback.
-
I created an issue #4 to discuss the integration of the code that calculates the facade visibility. |
Beta Was this translation helpful? Give feedback.
-
My another concern are T-crossings leading to false visibilty values. Note the marked visible edges in the vicinity of the T-crossings. |
Beta Was this translation helpful? Give feedback.
-
In our discussion until here, the following parameters have been defined to be stored in the "winning" edge: visibility For the way-segment, I am not yet clear about what data you like to have, the category of the way it belongs to, or a reference to the segment itself (which is not yet available from the current code). The above parameters are computed for every way-segment and every way, one after the other in the loop that starts at line 107 in facade_visibility.py. The task is now to replace the method updateVisibility() of the class BldgEdge, which is called for every way-segment and every edge at line 270 in facade_visibility.py, if the edge is within the given range around the way-segment. The replacement of this method has to determine the "winning" edge and to store the data mentioned above for this edge, so that finally the data required to classify the edge according to your proposition can be processed. Every call to this method for the same edge is a vote for the winning edge. But what is the "winning" edge? As long as dx < dy, the maximum visibility can be used as criteria, as it is done currently. When the visibilities are equal for that case, the smaller distance should be relevant, because there could be for instance two parallel way-segments, which both see the edge. Then the nearer one should be stored. But what if dy > dx? Even an edge with an angle of 89° relative to the way-segment can have 100% visibility. Should such a way-segment be preferred to another, that has an angle of 50° and that is much nearer to the same edge? Could you please try to explain, what criteria you like to use, this is not yet clear to me? |
Beta Was this translation helpful? Give feedback.
-
I renamed the script setup/mpl_base.py to setup/mpl_facade_visibility.py |
Beta Was this translation helpful? Give feedback.
-
In berlin_karl_marx_allee.osm: The edges of the outline of the building at the red arrow are all classified as shared edges, but they shouldn't. |
Beta Was this translation helpful? Give feedback.
-
I committed a first version of facade classification. It is not yet completed and is thought to enable experiments for further improvements of this feature. The version includes a renderer (BuildingClassificationRender) for facade classes, which currently replaces the visibility renderer (BuildingVisibilityRender) in the setup file. After a lot of experiments, I changed several ideas of the original concept and the given code of the last commit. Below, I describe and discuss these changes.
As already said, it's a first attempt, but it produces already quite acceptable results. Please feel free to improve the code wherever you like. |
Beta Was this translation helpful? Give feedback.
-
As always in computational geometry, there are decisions that need some tolerances. To decide whether an intersection is within a way-segment, the limit had to be increased a little bit. This change is committed. |
Beta Was this translation helpful? Give feedback.
-
I added a new command line option --classification. If it's given, the facade classification is displayed. The facade visibility is displayed otherwise. |
Beta Was this translation helpful? Give feedback.
-
I think it would look more natural if the edges marked with the blue color were classified as the front ones. |
Beta Was this translation helpful? Give feedback.
-
I just found that we have a very old bug, probably in event processing, that I didn't recognize until today. Many edges get a visibility that is larger than 1.0. I try first to fix it, maybe other issues are related to it. |
Beta Was this translation helpful? Give feedback.
-
A new experimental version of facade classification is committed and ready for further experiments. The main changes are the following:
From discussion "Facade Classification #1":
This step was really important. See for instance the rightmost facade of the u-shaped building in the left image below (btw. I changed the color of side facades locally to blue, because my sick eye can't see yellow on white, it dazzles too much): The nearer low category ways produced a visibility of 100%, so that the major road (thicker line width) couldn't win. The right image shows the result after the correction. In many cases, the new strategy using the loops of way-categories works fine. However, in my opinion it produces severe misclassifications that fall into the eye immediately. I don't know whether it is really a progress. See for instance two kinds of misclassifications, both from bern_old_town.osm (thicker brown line means more important way-category):
This bug is fixed. I continue now with the development of a distance vs. building size restriction. |
Beta Was this translation helpful? Give feedback.
-
This is the last criteria reamining for facade classification. As a preparation I did some investigations to get a feeling on how this could be realized. The distance of the way-segment to an edge is already transferred in VisibilityInfo as the sum of the y-distances Y1+Y2 in the way-segment coodinate system. To compute the fraction, a measure of the building size is required. The proposed maximum distance in x- and y-coordinates depends on the coordinate system and on the angle of the building in this system. Therefore this measure is not precise, but can be a good indicator. To minimize the computation load, I propose to compute this measure in the geographic coordinate system. In the way-segment coordinate system, this size would have to be computed every time, a building appears in the search range of a way-segment, which may happen several times for the same building. Therefore, in the following investigations I used this proposition. A next question to answer is: Where to set the threshold for this fraction to filter out visible building edges located too far away from the related way-segment? To get more insight, I measured the distribution (normalized by its peak value) of this fraction for edges classified as front edges in the maps we have stored in our osm_extracts repository. Here are the results (click on the images to magnify them): beijing_center, berlin_karl_marx_allee, bern_old_town, bratislava_old_town husum_altstadt, krasnaya_polyana, manhattan_01, moscow_leningradski_prospekt All look very similar, except krasnaya_polyana, which has a much broader distribution (reason see below). As a threshold, I selected for further tests a threshold value of 7.5, all edges that have a fraction larger than this threshold are plotted in red in the following images. For instance for husum_altstadt, the following edges are classified as too far away (left: whole map, right: NE-part magnified): In my opinion, this is near to what we want to have. The solution for the broad distribution in the case of krasnaya_polyana is simple: There the roads are far away from each other (100-200m). Many buildings between them are small and their fraction value becomes large. On the Mapbox satellite image we can also see that there is much green between the streets (must be a nice place!), which confirms the result: My proposition is to use this fraction and a threshold of about 7.5 and set the visibility for all edges beyond it to zero, so that the front facades get set by the longest edge of the building. |
Beta Was this translation helpful? Give feedback.
-
I added the file mckinney.osm to osm_extracts to have an example of a typical US town. |
Beta Was this translation helpful? Give feedback.
-
I found a case in krasnya_polyana.osm that doesn't work as I would expect. |
Beta Was this translation helpful? Give feedback.
-
Found another classification case which doesn't look natural for me (file mckinney.osm). I don't have an idea at the moment what to do with it. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Introduction
This is a proposal for facade classification. A facade class (front, back, side, left, right) is assigned to each edge of a building footprint depending on the relative position of the footprint edge and the neighboring streets. The streets are represented by their centerlines. A plot of land and eventually other entities represented by a polygon can be classified in the similar way.
Existed implementations
Facade classification is implemented in the ESRI City Engine (see the section Street selectors in the linked page). The two images below are from the documentation for ESRI City Engine:
Definitions
A way is a polygon chain. A way can represent a street, a path, a road, etc.
A way segment is bounded by two distinct end points.
A way segment line is a line to which the way segment belongs.
Assignment of facade classes
If a facade touches a facade of another building or a building part and is completely hidden, there is no need to classify it. Actually that facade should be skipped for further processing.
Let's consider the simplest case:
A way consisting of a single segment is on the left, a building is on the right. The facade class depends on the angle between the normal to the way and the normal to the facade. The front facade is marked with the green color, the back one is marked with the red color, the side facades are marked with the yellow color.
The problem is how to orient the normal to the way: is it pointing leftwards or rightwards on the image above?
It's assumed that the way segment line does not cross any edge of the building footprint. Pick up a point on the way. The cross product <vector between the point on the way and any footprint's vertex and> x <a unit vector along the way> should point upwards. If it points downwards, then change the direction of the unit vector along the way. Then the normal to the way can be calculated as the cross product <unit vector along the way> x <the basis vector for the z-axis>.
A more complex example:
The facade class still depends on the angle between the normal to the way segment and the one to the facade.
Even more complex example:
There are two way segments in this example: A and B. Each facade is considered against each segment. Suppose a facade is classified as the back one for a way segment and as the side one for another way segment. The resulting class would be side. Suppose a facade is classified as the side one for a way segment and as front one for another way segment. The resulting class would be front.
Even more complex example:
There are two crossing ways in this example. All concepts described above are also applied to this example.
Getting the nearest ways for a building
It's important to have a robust method of getting the nearest ways for a building to assign facade classes according to the procedure above.
Blender provides a generic 3-dimensional kd-tree to perform spatial searches.
All way segments can be placed into a kd-tree. Then a call of the find_range(..) function can be made for the center of a building to find way segments located in the vicinity of the building. If a way segment is too long, it can be divided into a number of parts.
An appropriate radius must be chosen for the call of the find_range(..).
Advanced cases
Some advanced cases are described in this section. The code to process them may be provided later.
(1) A facade is hidden from a way by other buildings
The facade A of the building (2) is hidden from the upper way segment by the building (1).
If facade F1 is classified as either front or side one for a specific way segment, then the projection of the facade's edge on the way segment should be stored. Also the distance (for example the shortest distance from the facade's edge to the way segment line) from the facade to the the way segment line should be stored. If another building is processed against the same way segment and
then the way segment is not processed for the facade F1. If there is a way segment against which the facade F1 was processed before, then the facade F1 is processed against it again to find the facade class.
(2) A facade hides other facades from a way segment
This case is applicable only to concave building footprints. The facade A hides the facades B, C, D from the way segment. The method described in the previous section can be used here as well to find out if a facade is hidden by another facade.
There must be a proposal how to classify a facade hidden by another facade. Perhaps it can be classified as side one. Or an additional facade class can be introduced for that case.
(3) A way segment line intersects a facade's edge
A unit vector along the way segment and pointing towards the building should be used to detemine a facade class instead of the normal to the way segment line.
Beta Was this translation helpful? Give feedback.
All reactions