# Location Based Indoor and Outdoor Lightweight Activity Recognition System
## 3 Outdoor Activity Recognition System
### Semantic Location Extraction
#### 3.2.2 Building Partitioning Method  
The workflow of the building partitioning method is the following. First of all, the edges of the buildings' polygon are obtained. To do so, the nearby buildings are also requested in case a block is composed of different buildings surrounding the area. We are interested in the external edges of the building, so if a wall is shared between different buildings, there cannot be placed the entrance to the shops. In the example that we are going to use (see Figure 14), all the edges are external as the block is the whole building. The geometry of the building is simplified to minimize the number of edges. Then, those edges which length surpass a threshold are only considered. The rest of them are expanded to complete the geometry of the building.  
Then, the neighbour nodes are obtained (see Figure 15). The node with the red point is the target shop whose surface is going to be computed. We do not consider neighbors the following nodes:  
* Nodes that only have informative tags.
* Nodes that represent elements with no surface (such as telephone booths or cash machines).
* Hotels (if a hotel is marked as a node it implies that there are floors in that building functioning as a hotel, but there could be some ground floor stores).  
Figure 14: The edges of the building in green.  
Figure 15: The target shop and its neighbours.  
After that, the edge is selected and a point projected onto it (see Figure 16). We obtain the edge closest to the point that represents the node we are analyzing. Then, the store is projected on that edge. In the following figure, the blue line represents the selected edge and the white dot the projected node.  
Next, we create the initial surface of the amenity (see Figure 17). A circle of an area of \(15\) m\({}^{2}\) is created on the previously projected point. If the distance between the store and the projected point is bigger than the threshold (\(15\) m), the store would be used as the center of the circle.  
After, the remaining edges are assigned (see Figure 18). Each of the neighboring nodes are linked with the nearest edge. In the following image, linked nodes and edges share the same color.  
Figure 16: The point of the shop projected on the edge.  
Figure 17: Initial surface.  
Figure 19: The nearest neighboring nodes per edge.  
Figure 18: The neighbouring nodes per edge.  
2. **Neighbours on consecutive edges**. It is checked which of the two points is closest to another edge (see Figure 21). That edge is used as a basis for the same procedure shown in 1.
3. **Points in non-consecutive edges**. In this case, the dots are used instead of the projections. We use the nearest neighbor in the red edge (see Figure 22).  
Figure 21: Limit B.  
Figure 22: Limit C.  
Next, the boundaries of the polygon are created (see Figures 23 and 24). Starting from the limits calculated in the previous step, a polygon that contains neighbors' points is created and subtracted from the initial circular surface. The resulting surface is subtracted by the limit of the next neighbor, and so on. Then, the perimeter of the building is subtracted, and we compute the minimum rotated rectangle circumscribing the resulting surface.  
In order to normalize polygons with atypical shapes, the convex hull of the polygon is calculated, obtaining the smallest convex polygon that contains all the points of the initial polygon [55] (see Figure 25).  
Figure 23: Initial surface subtracted by limits B and C.  
Figure 24: The surface subtracted by limit A and the resulting surface.  
Figure 25: Convex hull  
After that, the previously calculated limits are again subtracted from the surface (see Figure 26).  
Figure 26: Again the calculated limits are subtracted.  
Figure 27: The final surface.