Revision 6516

View differences:

org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
    <modelVersion>4.0.0</modelVersion>
3
    <parent>
4
        <groupId>org.gvsig</groupId>
5
        <artifactId>org.gvsig.topology.lib</artifactId>
6
        <version>1.0.109</version>
7
    </parent>
8
    <artifactId>org.gvsig.topology.lib.impl</artifactId>
9
    <name>${project.artifactId}</name>
10
    <dependencies>
11
        <dependency>
12
            <groupId>org.gvsig</groupId>
13
            <artifactId>org.gvsig.topology.lib.api</artifactId>
14
            <scope>compile</scope>
15
        </dependency>
16
        <dependency>
17
            <groupId>org.gvsig</groupId>
18
            <artifactId>org.gvsig.tools.lib</artifactId>
19
            <scope>compile</scope>
20
        </dependency>
21
        <dependency>
22
            <groupId>org.gvsig</groupId>
23
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
24
            <scope>compile</scope>
25
        </dependency>
26
        <dependency>
27
            <groupId>org.gvsig</groupId>
28
            <artifactId>org.gvsig.fmap.dal.swing.api</artifactId>
29
            <scope>compile</scope>
30
        </dependency>
31
        <dependency>
32
            <groupId>org.json</groupId>
33
            <artifactId>json</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.tools.dynform.spi</artifactId>
39
            <scope>compile</scope>
40
        </dependency>
41
    </dependencies>
42
</project>
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PointMustBeProperlyInsidePolygon.json
1
{
2
    "id": "PointMustBeProperlyInsidePolygon",
3
    "name": "Debe estar incluida correctamente",
4
    "description": [ 
5
        "<img src=\"@@@_d/PointMustBeProperlyInsidePolygon.png\">\n",
6
        "Requiere que los puntos se encuentren dentro de las entidades de área. Esto resulta útil cuando las entidades de punto están relacionadas con polígonos, tales como pozos y rellenos de pozos o puntos de dirección y parcelas."
7
    ],
8
    "actions" : {
9
        "Delete": {
10
            "name" : "Eliminar",
11
            "description": [ 
12
                "La solución Eliminar quita las entidades de punto que no se encuentran correctamente dentro de las entidades poligonales. Tenga en cuenta que puede usar la herramienta Editar para mover el punto dentro de la entidad poligonal si no desea eliminarla. Esta solución se puede aplicar a uno o más errores del tipo Debe estar incluida correctamente."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/LineMustBeCoveredByBoundaryOfPolygon.json
1
{
2
    "id": "LineMustBeCoveredByBoundaryOfPolygon",
3
    "name": "Debe estar cubierto por el límite de",
4
    "description": [ 
5
        "<img src=\"@@@_d/LineMustBeCoveredByBoundaryOfPolygon.png\">\n",
6
        "Requiere que las líneas estén cubiertas por los límites de las entidades de área. Esto es útil para modelar líneas, tales como líneas de lote, que deben coincidir con el eje de las entidades poligonales, tales como lotes."
7
    ],
8
    "actions" : {
9
        "Subtract": {
10
            "name" : "Sustraer",
11
            "description": [ 
12
                "La solución Sustraer quita los segmentos de línea que no coinciden con el límite de las entidades poligonales. Si la entidad de línea no comparte ningún segmento en común con el límite de una entidad poligonal, la entidad se borrará. Esta solución puede aplicarse a uno o varios errores del tipo Debe estar cubierto por el límite de."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/LineMustBeLargerThanTolerance.json
1
{
2
    "id": "LineMustBeLargerThanTolerance",
3
    "name": "Debe ser mayor que la tolerancia",
4
    "description": [ 
5
        "<img src=\"@@@_d/LineMustBeLargerThanTolerance.png\">\n",
6
        "Es necesario que una entidad no se colapse durante el proceso de validación. Esta regla es obligatoria para una topología y se aplica a todas las clases de entidad de línea y poligonal. En los casos en los que se infringe esta regla, la geometría original permanece sin cambios."
7
    ],
8
    "actions" : {
9
        "delete": {
10
            "name" : "Eliminar",
11
            "description": [ 
12
                "La solución Eliminar quita las entidades de línea que se podrían colapsar durante el proceso de validación en base a la tolerancia cluster de la topología. Esta solución se puede aplicar a uno o más errores del tipo Debe ser mayor que la tolerancia cluster."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonMustNotOverlapWithPolygon.json
1
{
2
    "id": "PolygonMustNotOverlapWithPolygon",
3
    "name": "No debe superponerse con",
4
    "description": [ 
5
        "<img src=\"@@@_d/PolygonMustNotOverlapWithPolygon.png\">\n",
6
        "Requiere que el interior de los pol?gonos en una clase (o subtipo) de entidad no se deba superponer con el interior de los pol?gonos en otra clase (o subtipo) de entidad. Los pol?gonos de las dos clases de entidad pueden compartir ejes o v?rtices o estar completamente inconexos. Esta regla se utiliza cuando un ?rea no puede pertenecer a dos clases de entidad separadas. Resulta ?til para combinar dos sistemas mutuamente exclusivos de clasificaci?n de ?rea, tales como zonificaci?n y tipos de masa de agua, en las que las ?reas definidas en la clase de zonificaci?n tampoco se pueden definir en la clase de masa de agua y viceversa."
7
    ],
8
    "actions" : {
9
        "Subtract": {
10
            "name" : "Subtract",
11
            "description": [ 
12
                "La soluci?n Sustraer quita la parte de superposici?n de cada entidad que causa el error y deja un espacio o vac?o en su lugar. Esta soluci?n se puede aplicar a uno o m?s errores seleccionados del tipo No debe superponerse con."
13
            ]
14
        },
15
        "Merge": {
16
            "name" : "Merge",
17
            "description": [ 
18
                "La soluci?n Fusionar agrega la parte de superposici?n de una entidad y la sustrae del resto que infringen la regla. Es necesario elegir la entidad que recibe la parte de superposici?n utilizando el cuadro de di?logo Fusionar. Esta soluci?n se puede aplicar ?nicamente a un error de tipo No debe superponerse con."
19
            ]
20
        }
21
    }
22
}
23

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonMustNotOverlapPolygon.json
1
{
2
    "id": "PolygonMustNotOverlapPolygon",
3
    "name": "No debe superponerse",
4
    "description": [ 
5
        "<img src=\"@@@_d/must_not_overlap.png\">\n",
6
        "Requiere que el interior de los pol&iacute;gonos no se superponga. Los pol&iacute;gonos pueden compartir ejes o v&eacute;rtices. Esta regla se utiliza cuando un &aacute;rea no puede pertenecer a dos o m&aacute;s pol&iacute;gonos. Resulta &uacute;til para modelar l&iacute;mites administrativos, como c&oacute;digos postales o distritos electorales, y clasificaciones de &aacute;rea mutuamente exclusivas, como cobertura de suelo o tipo de forma de suelo."
7
    ],
8
    "actions" : {
9
        "CreateFeature": {
10
            "name" : "Crear entidad",
11
            "description": [ 
12
                "La soluci&oacute;n Crear entidad crea una nueva entidad poligonal fuera de la forma de error y quita la parte de superposici&oacute;n de cada una de las entidades, que provoca el error para crear una representaci&oacute;n plana de la geometr&iacute;a de entidad. Esta soluci&oacute;n se puede aplicar a uno o m&aacute;s errores seleccionados del tipo No debe superponerse."
13
            ]
14
        },
15
        "Subtract": {
16
            "name" : "Sustraer",
17
            "description": [ 
18
                "La soluci&oacute;n Sustraer quita la parte de superposici&oacute;n de la geometr&iacute;a de cada entidad que causa el error y deja un espacio o vac&iacute;o en su lugar. Esta soluci&oacute;n se puede aplicar a uno o m&aacute;s errores seleccionados del tipo No debe superponerse. "
19
            ]
20
        },
21
        "Merge": {
22
            "name" : "Fusionar",
23
            "description": [ 
24
                "La soluci&oacute;n Fusionar agrega la parte de superposici&oacute;n de una entidad y la sustrae del resto que infringen la regla. Es necesario elegir la entidad que recibe la parte de superposici&oacute;n utilizando el cuadro de di&aacute;logo Fusionar. Esta soluci&oacute;n se puede aplicar &uacute;nicamente a un error de tipo No debe superponerse."
25
            ]
26
        }
27
    }
28
}
29

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonMustBeCoveredByPolygon.json
1
{
2
    "id": "PolygonMustBeCoveredByPolygon",
3
    "name": "Debe estar cubierto por",
4
    "description": [ 
5
        "<img src=\"@@@_d/PolygonMustBeCoveredByPolygon.png\">\n",
6
        "Requiere que los polígonos de una clase (o subtipo) de entidad estén contenido en polígonos de otra clase (o subtipo) de entidad. Los polígonos pueden compartir ejes o vértices. Cualquier área definida en la clase de entidad contenida debe estar cubierta por un área en la clase de entidad de cobertura. Esta regla se utiliza cuando las entidades de área de un tipo dado se deben localizar dentro de las entidades de otro tipo. Esta regla es útil al modelar áreas que sean subconjuntos de un área circundante mayor, como unidades de administración en bosques o bloques dentro de grupos de bloques."
7
    ],
8
    "actions" : {
9
        "CreateFeature": {
10
            "name" : "Crear entidad",
11
            "description": [ 
12
                "La solución Crear entidad crea una nueva entidad poligonal a partir de la parte de superposición del polígono existente, de modo que el límite de cada entidad de ambas clases de entidad es el mismo. Esta solución puede aplicarse a uno o varios errores seleccionados del tipo Debe estar cubierto por."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/GeometryMustNotBeNull.json
1
{
2
    "id": "GeometryMustNotBeNull",
3
    "name": "La geometría no debe ser nula",
4
    "description": [ 
5
        "Requiere que las  geometrías no sean nulas"
6
    ]
7
}
8

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonContainsPolygon.json
1
{
2
    "id": "PolygonContainsPolygon",
3
    "name": "Contiene polígono",
4
    "description": [ 
5
        "<img src=\"@@@_d/contains_polygon.png\">\n",
6
        "El polígono superior es un error porque no contiene ningún polígono.\n\n",
7
        "Requiere que cada polígono del conjunto de datos contenga al menos un polígono del otro conjunto de datos.\n"
8
    ]
9
}
10

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonContainsPoint.json
1
{
2
    "id": "PolygonContainsPoint",
3
    "name": "Contiene punto",
4
    "description": [ 
5
        "<img src=\"@@@_d/contains_point.png\">\n",
6
        "El pol&iacute;gono superior es un error porque no contiene ning&uacute;n punto.\n\n",
7
        "Requiere que cada pol&iacute;gono del conjunto de datos contenga al menos un punto del otro conjunto de datos.\n",
8
        "Los puntos deben estar contenidos en el pol&iacute;gono, no en su per&iacute;metro,\n"
9
    ],
10
    "actions" : {
11
        "CreateFeature": {
12
            "name" : "Crear feature",
13
            "description": [ 
14
                "<i>Crear feature</i> realiza la correcci&oacute;n creando un nuevo punto en",
15
                "la feature, en el centroide del pol&iacute;gono que ha causado el error.\n",
16
                "El punto creado en la feature se garantiza que estar&aacute; dentro del pol&iacute;gono de la feature."
17
            ]
18
        }
19
    }
20
}
21

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonContainsOnePoint.json
1
{
2
    "id": "PolygonContainsOnePoint",
3
    "name": "Contiene un punto",
4
    "description": [ 
5
        "<img src=\"@@@_d/polygon_contains_one_point.png\">\n",
6
        "El polígono superior es un error porque contiene más de un punto. Los puntos son errores cuando están fuera de un polígono.\n\nRequiere que cada polígono contenga una entidad de puntos y que cada entidad de puntos se encuentre dentro de un único polígono. Esto se utiliza cuando debe haber una correspondencia uno a uno entre las entidades de una clase de entidad poligonal y las entidades de una clase de entidad de puntos, como los límites administrativos y sus capitales. Cada punto debe estar perfectamente dentro de un polígono y cada polígono debe contener exactamente un punto. Los puntos deben encontrarse en el interior del polígono, no en el límite."
7
    ]
8
}
9

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonContainsOnePoint.json
1
{
2
    "id": "PolygonContainsOnePoint",
3
    "name": "Contains One Point",
4
    "description": [ 
5
        "<img src=\"@@@_d/polygon_contains_one_point.png\">\n",
6
        "The top polygon is an error because it contains more than one point. Points are errors when they are outside a polygon.\n\nRequires that each polygon contains one point feature and that each point feature falls within a single polygon. This is used when there must be a one-to-one correspondence between features of a polygon feature class and features of a point feature class, such as administrative boundaries and their capital cities. Each point must be properly inside exactly one polygon and each polygon must properly contain exactly one point. Points must be within the polygon, not on the boundary. Requires that each polygon contains one point feature and that each point feature falls within a single polygon. This is used when there must be a one-to-one correspondence between features of a polygon feature class and features of a point feature class, such as administrative boundaries and their capital cities. Each point must be properly inside exactly one polygon and each polygon must properly contain exactly one point. Points must be within the polygon, not on the boundary."
7
    ]
8
}
9

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PointMustBeProperlyInsidePolygon.json
1
{
2
    "id": "PointMustBeProperlyInsidePolygon",
3
    "name": "Must Be Properly Inside",
4
    "description": [ 
5
        "<img src=\"@@@_d/PointMustBeProperlyInsidePolygon.png\">\n",
6
        "Requires that points fall within area features. This is useful when the point features are related to polygons, such as wells and well pads or address points and parcels."
7
    ],
8
    "actions" : {
9
        "Delete": {
10
            "name" : "Delete",
11
            "description": [ 
12
                "The Delete fix removes point features that are not properly within polygon features. Note that you can use the Edit tool and move the point inside the polygon feature if you do not want to delete it. This fix can be applied to one or more Must Be Properly Inside errors."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/LineMustBeCoveredByBoundaryOfPolygon.json
1
{
2
    "id": "LineMustBeCoveredByBoundaryOfPolygon",
3
    "name": "Must Be Covered By Boundary Of",
4
    "description": [ 
5
        "<img src=\"@@@_d/LineMustBeCoveredByBoundaryOfPolygon.png\">\n",
6
        "Requires that lines be covered by the boundaries of area features. This is useful for modeling lines, such as lot lines, that must coincide with the edge of polygon features, such as lots."
7
    ],
8
    "actions" : {
9
        "Subtract": {
10
            "name" : "Subtract",
11
            "description": [ 
12
                "The Subtract fix removes line segments that are not coincident with the boundary of polygon features. If the line feature does not share any segments in common with the boundary of a polygon feature, the feature will be deleted. This fix can be applied to one or more Must Be Covered By Boundary Of errors."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/LineMustBeLargerThanTolerance.json
1
{
2
    "id": "LineMustBeLargerThanTolerance",
3
    "name": "Must Be Larger Than Tolerance",
4
    "description": [ 
5
        "<img src=\"@@@_d/LineMustBeLargerThanTolerance.png\">\n",
6
        "Requires that a feature does not collapse during a validate process.\n",
7
        "This rule is mandatory for a topology and applies to all line feature classes.\n",
8
        "In instances where this rule is violated, the original geometry is left unchanged.\n"
9
    ],
10
    "actions" : {
11
        "delete": {
12
            "name" : "Delete",
13
            "description": [ 
14
                "Removes line features that would collapse during the validate",
15
                "process based on the topology's tolerance."
16
            ]
17
        }
18
    }
19
}
20

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonMustNotOverlapWithPolygon.json
1
{
2
    "id": "PolygonMustNotOverlapWithPolygon",
3
    "name": "Must Not Overlap With",
4
    "description": [ 
5
        "<img src=\"@@@_d/PolygonMustNotOverlapWithPolygon.png\">\n",
6
        "Requires that the interior of polygons in one feature class (or subtype) must not overlap with the interior of polygons in another feature class (or subtype). Polygons of the two feature classes can share edges or vertices or be completely disjointed. This rule is used when an area cannot belong to two separate feature classes. It is useful for combining two mutually exclusive systems of area classification, such as zoning and water body type, where areas defined within the zoning class cannot also be defined in the water body class and vice versa."
7
    ],
8
    "actions" : {
9
        "Subtract": {
10
            "name" : "Subtract",
11
            "description": [ 
12
                "The Subtract fix removes the overlapping portion of each feature that is causing the error and leaves a gap or void in its place. This fix can be applied to one or more selected Must Not Overlap With errors."
13
            ]
14
        },
15
        "Merge": {
16
            "name" : "Merge",
17
            "description": [ 
18
                "The Merge fix adds the portion of overlap from one feature and subtracts it from the others that are violating the rule. You need to pick the feature that receives the portion of overlap using the Merge dialog box. This fix can be applied to one Must Not Overlap With error only."
19
            ]
20
        }
21
    }
22
}
23

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonMustBeCoveredByPolygon.json
1
{
2
    "id": "PolygonMustBeCoveredByPolygon",
3
    "name": "Must Be Covered By",
4
    "description": [ 
5
        "<img src=\"@@@_d/PolygonMustBeCoveredByPolygon.png\">\n",
6
        "Requires that polygons of one feature class (or subtype) must be contained within polygons of another feature class (or subtype). Polygons may share edges or vertices. Any area defined in the contained feature class must be covered by an area in the covering feature class. This rule is used when area features of a given type must be located within features of another type. This rule is useful when modeling areas that are subsets of a larger surrounding area, such as management units within forests or blocks within block groups."
7
    ],
8
    "actions" : {
9
        "CreateFeature": {
10
            "name" : "Create feature",
11
            "description": [ 
12
                "The Create Feature fix creates a new polygon feature out of the portion of overlap from the existing polygon so the boundary of each feature from both feature classes is the same. This fix can be applied to one or more selected Must Be Covered By errors."
13
            ]
14
        }
15
    }
16
}
17

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonMustNotOverlapPolygon.json
1
{
2
    "id": "PolygonMustNotOverlapPolygon",
3
    "name": "Must Not Overlap",
4
    "description": [ 
5
        "<img src=\"@@@_d/must_not_overlap.png\">\n",
6
        "Requires that the interior of polygons in the dataset not overlap.",
7
        "The polygons can share edges or vertices.",
8
        "This rule is used when an area cannot belong to two or more polygons.",
9
        "The polygons overlaps when the geometries have some points in common;",
10
        "but not all points in common (so if one geometry is inside the other",
11
        "overlaps would be false).",
12
        "The overlapping section must be the same kind of shape as the two geometries;",
13
        "so two polygons that touch on a point are not considered to be overlapping.",
14
        "It is useful for modeling administrative boundaries, such as ZIP Codes",
15
        "or voting districts, and mutually exclusive area classifications,",
16
        "such as land cover or landform type."
17
    ],
18
    "actions" : {
19
        "CreateFeature": {
20
            "name" : "Create feature",
21
            "description": [ 
22
                "The Create Feature fix creates a new polygon feature out of",
23
                "the error shape and removes the portion of overlap from each",
24
                "of the features, causing the error to create a planar",
25
                "representation of the feature geometry.\n",
26
                "This fix can be applied to one or more selected Must Not Overlap errors."
27
            ]
28
        },
29
        "Subtract": {
30
            "name" : "Subtract",
31
            "description": [ 
32
                "The Subtract fix removes the overlapping portion of geometry",
33
                "from each feature that is causing the error and leaves a gap",
34
                "or void in its place. This fix can be applied to one or more",
35
                "selected Must Not Overlap errors."
36
            ]
37
        },
38
        "Merge": {
39
            "name" : "Merge",
40
            "description": [ 
41
                "The Merge fix adds the portion of overlap from one feature",
42
                "and subtracts it from the others that are violating the rule.",
43
                "You need to pick the feature that receives the portion of",
44
                "overlap using the Merge dialog box.",
45
                "This fix can be applied to one Must Not Overlap error only."
46
            ]
47
        }
48
    }
49
}
50

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/GeometryMustNotBeNull.json
1
{
2
    "id": "GeometryMustNotBeNull",
3
    "name": "Geometry must not be null",
4
    "description": [ 
5
        "Requires that geometries are not null"
6
    ]
7
}
8

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonContainsPolygon.json
1
{
2
    "id": "PolygonContainsPolygon",
3
    "name": "Contains Polygon",
4
    "description": [ 
5
        "<img src=\"@@@_d/contains_polygon.png\">\n",
6
        "The top polygon is an error because it does not contain a polygon.\n\n",
7
        "Requires that a polygon in the primary dataset contain at least one",
8
        "polygon from the secondary dataset.\n"
9
    ]
10
}
11

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonContainsPoint.json
1
{
2
    "id": "PolygonContainsPoint",
3
    "name": "Contains Point",
4
    "description": [ 
5
        "<img src=\"@@@_d/contains_point.png\">\n",
6
        "The top polygon is an error because it does not contain a point.\n\n",
7
        "Requires that a polygon in the primary dataset contain at least one",
8
        "point from the secondary dataset.\n",
9
        "Points must be within the polygon, not on the boundary.\n",
10
        "This is useful when every polygon should have at least one associated",
11
        "point, such as when parcels must have an address point."
12
    ],
13
    "actions" : {
14
        "CreateFeature": {
15
            "name" : "Create feature",
16
            "description": [ 
17
                "The Create Feature fix creates a new point feature at the centroid",
18
                "of the polygon feature that is causing the error.\n",
19
                "The point feature that is created is guaranteed to be within the polygon feature."
20
            ]
21
        }
22
    }
23
}
24

  
0 25

  
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.topology.lib.impl.TopologyImplLibrary
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/customizablerule/CustomizableRule0ActionsFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2021 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.topology.lib.impl.customizablerule;
25

  
26
import org.gvsig.expressionevaluator.DataTypes;
27
import org.gvsig.json.Json;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.dynobject.DynField_v2;
30
import org.gvsig.tools.dynobject.DynObject;
31
import org.gvsig.tools.dynobject.DynObjectManager;
32
import org.gvsig.tools.dynobject.DynStruct_v2;
33
import org.gvsig.tools.i18n.I18nManager;
34
import org.gvsig.topology.lib.api.TopologyDataSet;
35
import org.gvsig.topology.lib.api.TopologyLocator;
36
import org.gvsig.topology.lib.api.TopologyManager;
37
import org.gvsig.topology.lib.api.TopologyRule;
38
import org.gvsig.topology.lib.spi.AbstractTopologyRuleFactory;
39

  
40
/**
41
 *
42
 * @author gvSIG Team
43
 */
44
@SuppressWarnings("UseSpecificCatch")
45
public class CustomizableRule0ActionsFactory extends AbstractTopologyRuleFactory {
46
    
47
    public static final String NAME = "Customizable0";
48
    
49
    public static final String PARAM_NAME_NAME = "name";
50
    public static final String PARAM_CHECK_NAME = "check";
51
    public static final String PARAM_ERRMSG_NAME = "errmsg";
52
    
53
    private DynStruct_v2 ruleParametersDefinition;
54
    
55
    public CustomizableRule0ActionsFactory() {
56
        super(
57
                NAME, 
58
                "Customizable0", 
59
                "",
60
                null
61
        );
62
        DynObjectManager dynObjectManager = ToolsLocator.getDynObjectManager();
63
        this.ruleParametersDefinition = (DynStruct_v2) dynObjectManager.get("Topology", "CustomizableRule0Parameters");
64
        if( ruleParametersDefinition==null ) {
65
            ruleParametersDefinition = (DynStruct_v2) dynObjectManager.createDynClass("Topology", "CustomizableRule0Parameters", null);
66
            DynField_v2 param;
67
            param = (DynField_v2) ruleParametersDefinition.addDynFieldString(PARAM_NAME_NAME);
68
            param.setMandatory(true);
69
            param.setLabel("_Name");
70
            param.setDescription("_Name_of_the_rule");
71

  
72
            param = (DynField_v2) ruleParametersDefinition.addDynField(PARAM_CHECK_NAME,DataTypes.EXPRESSION);
73
            param.setMandatory(true);
74
            param.setLabel("_Check_expression");
75
            param.setDescription("_Verification_expression_If_false_the_rule_fails");
76
            
77
            param = (DynField_v2) ruleParametersDefinition.addDynFieldString(PARAM_ERRMSG_NAME);
78
            param.setMandatory(true);
79
            param.setLabel("_Error_message");
80
            param.setDescription("_Message_to_show_if_check_fail");
81
            
82
//            DynField_v2 action = (DynField_v2) ruleParametersDefinition.addDynField("action");
83
//            action.setType(DataTypes.EXPRESSION);
84
        }
85
    }
86

  
87
    @Override
88
    public String getName() {
89
        I18nManager i18n = ToolsLocator.getI18nManager();
90
        return i18n.getTranslation("_Customizable");
91
    }
92

  
93
    @Override
94
    public boolean canApplyToDataSet(TopologyDataSet dataSet) {
95
        return true;
96
    }
97

  
98
    @Override
99
    public boolean canApplyToSecondaryDataSet(TopologyDataSet dataSet) {
100
        return true;
101
    }
102
    
103
    @Override
104
    public TopologyRule createRule(String dataSet1, String dataSet2, double tolerance) {
105
        TopologyRule rule = new CustomizableRule0ActionsImpl(this, tolerance, dataSet1, dataSet2);
106
        return rule;
107
    }    
108

  
109
    @Override
110
    public boolean hasRuleParameters() {
111
        return true;
112
    }
113

  
114
    @Override
115
    public DynObject createRuleParameters() {
116
        DynObjectManager dynObjectManager = ToolsLocator.getDynObjectManager();
117
        DynObject param = dynObjectManager.createDynObject(this.ruleParametersDefinition);
118
        return param;
119
    }
120

  
121
    public static void selfRegister() {
122
        try {
123
            TopologyManager manager = TopologyLocator.getTopologyManager();
124
            manager.addRuleFactories(new CustomizableRule0ActionsFactory());
125
            Json.registerSerializer(CustomizableRule0ActionsImpl.class);
126
        } catch(Exception ex) {
127
            LOGGER.warn("Can't register topology rule from "+CustomizableRule0ActionsFactory.class.getSimpleName(), ex);
128
        }
129
    }
130
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/customizablerule/CustomizableRuleActionImpl.java
1
package org.gvsig.topology.lib.impl.customizablerule;
2

  
3
import javax.json.JsonObject;
4
import org.gvsig.expressionevaluator.Expression;
5
import org.gvsig.expressionevaluator.ExpressionUtils;
6
import org.gvsig.expressionevaluator.MutableSymbolTable;
7
import org.gvsig.json.Json;
8
import org.gvsig.json.JsonObjectBuilder;
9
import org.gvsig.json.SupportJson;
10
import org.gvsig.tools.dynobject.DynObject;
11
import org.gvsig.topology.lib.api.ExecuteTopologyRuleActionException;
12
import org.gvsig.topology.lib.api.TopologyReportLine;
13
import org.gvsig.topology.lib.api.TopologyRule;
14
import org.gvsig.topology.lib.spi.AbstractTopologyRuleAction;
15

  
16
/**
17
 *
18
 * @author gvSIG Team
19
 */
20
public class CustomizableRuleActionImpl 
21
        extends AbstractTopologyRuleAction 
22
        implements SupportJson {
23
    
24
    protected Expression action;
25
    protected MutableSymbolTable symbolTable;
26

  
27
    public CustomizableRuleActionImpl() {
28
        super(CustomizableRule0ActionsFactory.NAME);
29
    }
30

  
31
    public Expression getAction() {
32
        return this.action;
33
    }
34

  
35
    public void setAction(Expression action) {
36
        this.action = action;
37
    }
38

  
39
    public void setId(String id) {
40
        this.idAction = id;
41
    }
42

  
43
    public void setName(String name) {
44
        this.name = name;
45
    }
46

  
47
    public void setShortDescription(String description) {
48
        this.shortDescription = description;
49
    }
50

  
51
    public MutableSymbolTable getSymbolTable() {
52
        if (this.symbolTable == null) {
53
            this.symbolTable = ExpressionUtils.createSymbolTable();
54
            this.symbolTable.setVar("action", this);
55
        }
56
        return this.symbolTable;
57
    }
58

  
59
    @Override
60
    public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) throws ExecuteTopologyRuleActionException {
61
        MutableSymbolTable st = this.getSymbolTable();
62
        st.setVar("rule", rule);
63
        st.setVar("line", line);
64
        st.setVar("parameters", parameters);
65
        this.action.execute(symbolTable);
66
        return EXECUTE_OK;
67
    }
68

  
69
    @Override
70
    public void fromJson(JsonObject json) {
71
        this.idAction = (String) Json.toObject(json, "idAction");
72
        this.idRule = (String) Json.toObject(json, "idRule");
73
        this.name = (String) Json.toObject(json, "name");
74
        this.shortDescription = (String) Json.toObject(json, "shortDescription");
75
        this.action = (Expression) Json.toObject(json, "expression");
76
    }
77

  
78
    @Override
79
    public JsonObject toJson() {
80
        return toJsonBuilder().build();
81
    }
82

  
83
    @Override
84
    public JsonObjectBuilder toJsonBuilder() {
85
        JsonObjectBuilder builder = Json.createObjectBuilder();
86
        builder.add("idAction", idAction);
87
        builder.add("idRule", idRule);
88
        builder.add("name", name);
89
        builder.add("shortDescription", shortDescription);
90
        builder.add("expression", action);
91
        return builder;
92
    }
93
    
94
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/customizablerule/CustomizableRule0ActionsImpl.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2021 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.topology.lib.impl.customizablerule;
25

  
26
import org.apache.commons.lang3.StringUtils;
27
import org.gvsig.expressionevaluator.Expression;
28
import org.gvsig.expressionevaluator.MutableSymbolTable;
29
import org.gvsig.fmap.dal.DALLocator;
30
import org.gvsig.fmap.dal.DataTypeUtils;
31
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable;
32
import org.gvsig.fmap.dal.feature.Feature;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.task.SimpleTaskStatus;
35
import org.gvsig.topology.lib.api.TopologyReport;
36
import org.gvsig.topology.lib.api.TopologyRuleFactory;
37
import static org.gvsig.topology.lib.impl.customizablerule.CustomizableRule0ActionsFactory.PARAM_CHECK_NAME;
38
import static org.gvsig.topology.lib.impl.customizablerule.CustomizableRule0ActionsFactory.PARAM_ERRMSG_NAME;
39
import static org.gvsig.topology.lib.impl.customizablerule.CustomizableRule0ActionsFactory.PARAM_NAME_NAME;
40
import org.gvsig.topology.lib.spi.AbstractTopologyRule;
41

  
42
/**
43
 *
44
 * @author gvSIG Team
45
 */
46
@SuppressWarnings("UseSpecificCatch")
47
public class CustomizableRule0ActionsImpl
48
        extends AbstractTopologyRule 
49
    {
50

  
51

  
52
    protected Expression check;
53
    protected String errmsg;
54
    protected FeatureSymbolTable featureSymbolTable;
55
    protected MutableSymbolTable symbolTable;
56

  
57
    public CustomizableRule0ActionsImpl() {
58
        
59
    }
60
            
61
    public CustomizableRule0ActionsImpl(
62
            TopologyRuleFactory factory,
63
            double tolerance,
64
            String dataSet1,
65
            String dataSet2
66
    ) {
67
        super(factory, tolerance, dataSet1, dataSet2);
68
    }
69

  
70
    @Override
71
    public String getName() {
72
        try {
73
            return super.getName()+ "("+(String) this.getParameters().getDynValue(PARAM_NAME_NAME)+")";
74
        } catch(Exception ex) {
75
            return super.getName();
76
        }
77
    }
78

  
79
    @Override
80
    protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception {
81
        if (this.symbolTable == null) {
82
            this.featureSymbolTable = DALLocator.getDataManager().createFeatureSymbolTable();
83
            this.symbolTable = this.featureSymbolTable.createParent();
84
            this.symbolTable.setVar("rule", this);
85
        }
86
        if( this.check == null ) {
87
            this.check = (Expression) this.getParameters().getDynValue(PARAM_CHECK_NAME);
88
        }
89
        this.symbolTable.setVar("taskStatus", taskStatus);
90
        this.symbolTable.setVar("report", report);
91
        this.symbolTable.setVar("feature1", feature1);
92
        this.featureSymbolTable.setFeature(feature1);
93
        Object n = this.check.execute(this.featureSymbolTable);
94
        if( DataTypeUtils.isTrue(n, false) ) {
95
            return;
96
        }
97
        report.addLine(
98
                this, 
99
                this.getDataSet1(), 
100
                null, // Dataset2
101
                feature1.getDefaultGeometry(),
102
                null, // Error
103
                feature1.getReference(), 
104
                null, // feature2
105
                false, // is an exception?
106
                getErrorMessage()
107
        );
108
    }
109

  
110
    private String getErrorMessage() {
111
        if( this.errmsg == null ) {
112
            this.errmsg = (String) this.getParameters().getDynValue(PARAM_ERRMSG_NAME);
113
            if( StringUtils.isBlank(this.errmsg) ) {
114
                this.errmsg = ToolsLocator.getI18nManager().getTranslation("_The_verification_expression_was_not_met");
115
            }
116
        }
117
        return this.errmsg;
118
    }
119
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.topology.lib.impl;
25

  
26
import java.util.ArrayList;
27
import java.util.Collections;
28
import java.util.HashMap;
29
import java.util.List;
30
import java.util.Map;
31
import org.gvsig.fmap.dal.DataStore;
32
import org.gvsig.topology.lib.api.TopologyDataSet;
33
import org.gvsig.topology.lib.api.TopologyManager;
34
import org.gvsig.topology.lib.api.TopologyPlan;
35
import org.gvsig.topology.lib.api.TopologyRuleFactory;
36
import org.gvsig.topology.lib.api.TopologyServices;
37

  
38
/**
39
 *
40
 * @author jjdelcerro
41
 */
42
public class DefaultTopologyManager implements TopologyManager {
43

  
44
    private final Map<String,TopologyRuleFactory> factories;
45
    private TopologyServices services;
46
    
47
    public DefaultTopologyManager() {
48
        this.factories = new HashMap<>();
49
    }
50
    
51
    @Override
52
    public TopologyPlan createTopologyPlan() {
53
        TopologyPlan plan = new DefaultTopologyPlan(this, this.services);
54
        return plan;
55
    }
56

  
57
    @Override
58
    public List<TopologyRuleFactory> getRuleFactories() {
59
        List<TopologyRuleFactory> l = new ArrayList<>(this.factories.values());
60
        return Collections.unmodifiableList(l);
61
    }
62

  
63
    @Override
64
    public List<TopologyRuleFactory> getRuleFactories(TopologyDataSet dataSet) {
65
        List<TopologyRuleFactory>  f = new ArrayList<>();
66
        for (TopologyRuleFactory factory : this.factories.values()) {
67
            if( factory.canApplyToDataSet(dataSet) ) {
68
                f.add(factory);
69
            }
70
        }
71
        return f;
72
    }
73

  
74
    @Override
75
    public TopologyRuleFactory getRulefactory(String id) {
76
        if( id==null ) {
77
            return null;
78
        }
79
        TopologyRuleFactory factory = this.factories.get(id.toLowerCase());
80
        return factory;
81
    }
82
    
83
    @Override
84
    public void addRuleFactories(TopologyRuleFactory factory) {
85
        if( factory==null ) {
86
            throw new IllegalArgumentException("Invalid null value.");
87
        }
88
        this.factories.put(factory.getId().toLowerCase(), factory);
89
    }
90

  
91
    @Override
92
    public TopologyDataSet createDataSet(String name, DataStore store) {
93
        TopologyDataSet dataSet = new DefaultTopologyDataSet(this.services, name, store);
94
        return dataSet;
95
    }
96
    
97
    @Override
98
    public void setDefaultServices(TopologyServices services) {
99
        this.services = services;
100
    }
101

  
102
    @Override
103
    public TopologyServices getDefaultServices() {
104
        return this.services;
105
    }
106
    
107
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.109/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyPlan.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.topology.lib.impl;
25

  
26
import java.util.ArrayList;
27
import java.util.Collection;
28
import java.util.Collections;
29
import java.util.Date;
30
import java.util.HashMap;
31
import java.util.List;
32
import java.util.Map;
33
import javax.json.JsonArray;
34
import javax.json.JsonObject;
35
import javax.json.JsonValue;
36
import org.gvsig.fmap.dal.DataStore;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38
import org.gvsig.fmap.geom.GeometryLocator;
39
import org.gvsig.fmap.geom.GeometryManager;
40
import org.gvsig.fmap.geom.type.GeometryType;
41
import org.gvsig.json.Json;
42
import org.gvsig.json.JsonArrayBuilder;
43
import org.gvsig.json.JsonObjectBuilder;
44
import org.gvsig.tools.ToolsLocator;
45
import org.gvsig.tools.task.SimpleTaskStatus;
46
import org.gvsig.topology.lib.api.TopologyDataSet;
47
import org.gvsig.topology.lib.api.TopologyManager;
48
import org.gvsig.topology.lib.api.TopologyPlan;
49
import org.gvsig.topology.lib.api.TopologyRule;
50
import org.gvsig.topology.lib.api.TopologyRuleFactory;
51
import org.gvsig.topology.lib.api.TopologyServices;
52
import org.gvsig.topology.lib.spi.AbstractTopologyRule;
53
import org.slf4j.Logger;
54
import org.slf4j.LoggerFactory;
55

  
56
/**
57
 *
58
 * @author jjdelcerro
59
 */
60
@SuppressWarnings("UseSpecificCatch")
61
public class DefaultTopologyPlan implements TopologyPlan {
62

  
63
    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultTopologyPlan.class);
64
    
65
    private final TopologyManager manager;
66
    private final Map<String,TopologyDataSet> dataSets;
67
    private final List<TopologyRule> rules;
68

  
69
    private String name;
70
    private DefaultTopologyReport report;
71
    private TopologyServices services;
72
    private double tolerance;
73
    private SimpleTaskStatus taskStatus;
74
    private boolean useUI;
75
    private boolean acceptExceptions;
76
    
77
    public DefaultTopologyPlan(TopologyManager manager, TopologyServices services) {
78
        this.manager = manager;
79
        this.services = services;
80
        this.dataSets = new HashMap<>();
81
        this.rules = new ArrayList<>();
82
        this.report = null;
83
        this.name = "TopologyPlan-" + String.format("%08X", new Date().getTime());
84
        this.tolerance = 0;
85
        this.useUI = true;
86
    }
87

  
88
    @Override
89
    public void setName(String name) {
90
        this.name = name;
91
    }
92

  
93
    @Override
94
    public String getName() {
95
        return this.name;
96
    }
97

  
98
    @Override
99
    public void clear() {
100
        this.name = "";
101
        this.tolerance = 0;
102
        this.services = null;
103
        this.report = null;
104
        this.dataSets.clear();
105
        this.rules.clear();
106
    }
107

  
108
    @Override
109
    public double getTolerance() {
110
        return tolerance;
111
    }
112

  
113
    @Override
114
    public void setTolerance(double tolerance) {
115
        this.tolerance = tolerance;
116
    }
117

  
118
    @Override
119
    public void setTopologyServices(TopologyServices services) {
120
        this.services = services;
121
        for (TopologyDataSet dataSet : this.dataSets.values()) {
122
            if(dataSet instanceof DefaultTopologyDataSet){
123
                ((DefaultTopologyDataSet)dataSet).setTopologyServices(services);
124
            }
125
        }
126
    }
127
    
128
    @Override
129
    public TopologyServices getTopologyServices() {
130
        return this.services;
131
    }
132
    
133
    @Override
134
    public SimpleTaskStatus getTaskStatus() {
135
        if( this.taskStatus == null ) {
136
            this.taskStatus = ToolsLocator.getTaskStatusManager()
137
                    .createDefaultSimpleTaskStatus(this.getName());
138
        }
139
        return this.taskStatus;
140
    }
141
    
142
    @Override
143
    public void execute() {
144
        SimpleTaskStatus theTaskStatus = this.getTaskStatus();
145
        try {
146
            theTaskStatus.restart();
147
            theTaskStatus.message("Preparing the execution of the plan");
148
            theTaskStatus.setAutoremove(true);
149
            theTaskStatus.setIndeterminate();
150
            for (TopologyDataSet dataSet : this.dataSets.values()) {
151
                dataSet.restart();
152
            }
153
            this.getReport().removeAllLines();
154
            long steps = 0;
155
            for (TopologyRule rule : this.rules) {
156
                steps += rule.getSteps();
157
                steps++;
158
            }
159

  
160
            theTaskStatus.setRangeOfValues(0, steps);
161
            theTaskStatus.setCurValue(0);
162
            for (TopologyRule rule : this.rules) {
163
                if( theTaskStatus.isCancellationRequested() ) {
164
                    theTaskStatus.cancel();
165
                    break;
166
                }
167
                theTaskStatus.message(rule.getName());
168
                rule.execute(theTaskStatus, this.getReport());
169
                theTaskStatus.incrementCurrentValue();
170
            }
171
        } catch(Exception ex) {
172
            LOGGER.warn("Problems executing topology plan '"+this.getName()+"'.", ex);
173
            theTaskStatus.abort();
174
        } finally {
175
            if( theTaskStatus.isRunning() ) {
176
                theTaskStatus.terminate();
177
            }
178
            this.getReport().setCompleted(true);
179
        }
180
    }
181

  
182
    @Override
183
    public TopologyDataSet addDataSet(String name, DataStore store) {
184
        TopologyDataSet dataSet = manager.createDataSet(name, store);
185
        return this.addDataSet(dataSet);
186
    }
187

  
188
    @Override
189
    public TopologyDataSet addDataSet(TopologyDataSet dataSet) {
190
        if( this.dataSets.containsKey(dataSet.getName()) ) {
191
            throw new IllegalArgumentException("Already exists a dataSet with this name ("+dataSet.getName()+").");
192
        }
193
        this.dataSets.put(dataSet.getName(), dataSet);
194
        return dataSet;
195
    }
196

  
197
    @Override
198
    public TopologyDataSet getDataSet(String name) {
199
        return this.dataSets.get(name);
200
    }
201

  
202
    @Override
203
    public boolean containsDataSet(String name) {
204
        return this.dataSets.containsKey(name);
205
    }
206

  
207
    @Override
208
    public Collection<TopologyDataSet> getDataSets() {
209
        Collection<TopologyDataSet> x = dataSets.values();
210
        return Collections.unmodifiableCollection(x);
211
    }
212

  
213
    @Override
214
    public Collection<TopologyDataSet> getSecondaryDataSets(TopologyRuleFactory ruleFactory) {
215
        List<TopologyDataSet> secondaryDataSets = new ArrayList<>();
216
        for (TopologyDataSet dataSet : dataSets.values()) {
217
            if( ruleFactory.canApplyToSecondaryDataSet(dataSet) ) {
218
                secondaryDataSets.add(dataSet);
219
            }
220
        }
221
        return secondaryDataSets;
222
    }
223
    
224
    @Override
225
    public TopologyRule addRule(String id, String dataSet1, String dataSet2, double tolerance) {
226
        TopologyRuleFactory factory = this.manager.getRulefactory(id);
227
        if( factory == null ) {
228
            throw new IllegalArgumentException("Can't locate factory for rule '"+id+"'.");
229
        }
230
        if( ! this.canApplyRule(factory, dataSet1, dataSet2) ) {
231
            throw new IllegalArgumentException(
232
                    "Can't apply rule '"+factory.getName()+"' to the datasets '"+dataSet1+"/"+dataSet2+"'."
233
            );
234
        }
235
        TopologyRule rule = factory.createRule(dataSet1, dataSet2, tolerance);
236
        return this.addRule(rule);
237
    }
238

  
239
    @Override
240
    public TopologyRule addRule(TopologyRule rule) {
241
        if( rule.getPlan()!=null && rule.getPlan()!=this ) {
242
            rule = (AbstractTopologyRule) org.gvsig.tools.lang.Cloneable.cloneQuietly(rule);
243
        }
244
        ((AbstractTopologyRule)rule).setPlan(this);
245
        this.rules.add(rule);
246
        return rule;
247
    }
248

  
249
    private boolean canApplyRule(TopologyRuleFactory factory, String dataSet1, String dataSet2) {
250
        try {
251
            GeometryManager geomManager = GeometryLocator.getGeometryManager();
252
            TopologyDataSet dataset = this.getDataSet(dataSet1);
253
            FeatureStore store = (FeatureStore) dataset.getStore();
254
            GeometryType gt = store.getDefaultFeatureType().getDefaultGeometryAttribute().getGeomType();
255
            for (Integer geometryType1 : factory.getGeometryTypeDataSet1()) {
256
                if( gt.isTypeOf(geometryType1) ) {
257
                    if( factory.getGeometryTypeDataSet2()==null ) {
258
                        return true;
259
                    }
260
                    dataset = this.getDataSet(dataSet2);
261
                    store = (FeatureStore) dataset.getStore();
262
                    gt = store.getDefaultFeatureType().getDefaultGeometryAttribute().getGeomType();
263
                    for (Integer geometryType2 : factory.getGeometryTypeDataSet2()) {
264
                        if( gt.isTypeOf(geometryType2) ) {
265
                            return true;
266
                        }
267
                    }
268
                }
269
            }
270
            return false;
271
        } catch(Exception ex) {
272
            return false;
273
        }
274
    }    
275

  
276
    @Override
277
    public Collection<TopologyRule> getRules() {
278
        return Collections.unmodifiableList(rules);
279
    }
280
    
281
    @Override
282
    public boolean hasRules() {
283
        return !this.rules.isEmpty();
284
    }
285

  
286
    @Override
287
    public DefaultTopologyReport getReport() {
288
        if( this.report == null ) {
289
            this.report = new DefaultTopologyReport(this);
290
        }
291
        return this.report;
292
    }
293

  
294
    @Override
295
    public JsonObject toJson() {
296
        return this.toJsonBuilder().build();
297
    }
298

  
299
    @Override
300
    public JsonObjectBuilder toJsonBuilder() {
301
        JsonObjectBuilder me = Json.createObjectBuilder();
302
        me.add_class(this);
303
        me.add("name", this.name);
304
        me.add("tolerance", this.tolerance);
305
        me.add("acceptExceptions", this.acceptExceptions);
306
        
307
        JsonArrayBuilder jsonDataSets = Json.createArrayBuilder();
308
        for (TopologyDataSet dataSet : this.dataSets.values()) {
309
            jsonDataSets.add((DefaultTopologyDataSet)dataSet);
310
        }
311
        me.add("dataSets", jsonDataSets);
312
        
313
        JsonArrayBuilder jsonRules = Json.createArrayBuilder();
314
        for (TopologyRule rule : this.rules) {
315
            jsonRules.add(rule);
316
        }
317
        me.add("rules", jsonRules);
318
        
319
        return me;
320
    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff