Select parts with 'numberOfFloorsAboveGround' = 0.
Delete them.
For each feature in this layer:
If it is a building part:
If it have levels under ground ('numberOfFloorsBelowGround' < 0) but not above ground ('numberOfFloorsAboveGround' = 0), drops it.
If it have an associated building and is not inside it, drops it. It have associated building if there exists a building with the value of the catastral reference in the 'base:localId' field.
If it haven't an associated building, adds it to a dictionary grouped by the cadastral reference.
With this dictionary of parts without associated building, for each building cadastral reference, generates the building footprint from the merging of all the parts.
This problem occurs both in buildings, building parts, and swimming pools. Its resolution is interdependent, that is, there may be a node of a building that is not duplicated at first but it is if we consider the other data sets. For this reason, the elements of the three data sets must be copied in the same data warehouse. From now, when we say element we refer to buildings, their parts and other constructions (pools).
The coordinates are maintained in the original UTM projection to simplify the distance calculation.
Parameters:
'dup_thr' = 1.2 cm. This value was established with test taking into account that JOSM draws coordinates with arbitrary precision, but the validation of duplicated nodes round the coordinates to the sevent decimal. An angle of 10-7 degrees is about 0.011 meters (1.1 cm) in latitude.
'dist_thr' = 2 cm.
'straight_thr' = 2°.
Steps:
For each geometry 'geom' in this layer.
For each vertex 'point' in the outermost ring.
If this coordinates was not visited previously.
Search for geometries intersecting a bounding box of 'dist_thr' radius around 'point'.
For each candidate geometry.
Search the nearest vertex to 'point' in the candidate geometry.
If the distance to the nearest vertex ('dist_v') is 0, it belongs to 'geom'.
If any of the adjacent vertices 'va' and 'vb' is near than 'dup_thr' deletes it.
If 0 < 'dist_v' < 'dup_thr', it don't belong to 'geom'. Move it to 'point' position.
If 'dist_v' > 'dup_thr', it don't belong to 'geom'. 'point' is a topological point if it fullfit this conditions:
The distance from 'point' to the nearest segment in the candidate geometry is below 'dist_thr' and the nearest point to 'point' in this segment is not any of their extremes.
The angle formed by 'point' with the extremes of the segment is straight (The difference with 180º is below 'ang_thr').
Inserting it as a vertex in the candidate geometry does not generate an invalid geometry.
If 'point' is a topological point insert it as a new vertex in the candidate geometry.
Motivation:Unneded nodes. The use of an external tool to simplify does not allow all the control we would like or refine the results. That is why an own algorithm is developed.
We intend to eliminate excessive vertices in straight lines, such as the red vertices in the image.
Excessive nodes in a straight line.
To do this, each vertex of a geometry is examined. The vertex is a candidate to be eliminated if it is not a corner. It is considered that it is not a corner if the angle it forms with the previous and next vertices does not differ much from 180° (it is straight).
The red node is a candidate to be deleted.
The straight angle condition is not enought. If the distance separating the previous and next vertices is enought large, although the angle is almost straight, the cathetus can measure meters and eliminating the vertex would mean an excessive modification of the building. The cathetus is the shortest distance between the vertex and the line joining the previous and next vertices.
Removing this node causes a displacement of several meters.
You can not delete a vertex if in another geometry there is a vertex in the same position. That would lead to topological errors. In the following image the green nodes can be eliminated, the red one does not because they belongs to the parts of the building (light gray).
Node belonging to several geometries.
We have to check the angle in all the geometries that have a node in that position. In the previous image the green nodes belong to two geometries: the footprint of the building and it parts.
Preconditions:
The elements of the building, parts and other constructions (pools) dataset must be in the same data warehouse.
Duplicate nodes have been removed.
Topological nodes have been added.
The coordinates are maintained in the original UTM projection to simplify the distance calculation.
Algorithm to generate definition files for the task manager
Motivation: La creación de proyectos en el gestor de tareas para split of data in tasks.
Steps:
Se crea un conjunto de datos para rústica 'rustic_zoning' y otro para urbana 'urban_zoning'.
Se copian los elementos con valor 'POLIGONO' en el campo levelName del conjunto 'zoning' al conjunto 'rustic_zoning' y los que tienen el valor 'MANZANA' a 'urban_zoning', separando las geometrías multiparte.
Se fusionan los elementos 'MANZANA' adyacentes (si tienen algún segmento en común) para evitar colocar en distintas tareas edificios que tengan paredes comunes.
Se asigna un identificador único a cada polígono.
Results: Se generan dos ficheros de salida: urban_zoning.geojson y rustic_zoning.geojson.
Las abreviaturas tipo de vía de Catastro (especificadas en este documento) se expanden usando un diccionario, personalizable por el usuario.
Generar un archivo de corrección con los nombres de vías en Catastro y la transformación propuesta para cada uno.
A continuación se realiza una revisión manual del archivo de corrección. Este archivo será usado por el programa en la siguiente ejecución para transformar los nombres de Catastro. Para algunos tipos de vías, se colocará el nombre en una etiqueta addr:place=* en lugar de addr:street=*