Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev(validator-core): prevent validity test crash #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public class CoreErrorCodes {
public static final ErrorCode ATTRIBUTE_GEOMETRY_INVALID_DATA_EXTENT = ErrorCode.valueOf(
"ATTRIBUTE_GEOMETRY_INVALID_DATA_EXTENT"
);
public static final ErrorCode ATTRIBUTE_GEOMETRY_INVALID_INTERNAL = ErrorCode.valueOf(
"ATTRIBUTE_GEOMETRY_INVALID_INTERNAL"
);

public static final ErrorCode ATTRIBUTE_PATH_NOT_FOUND = ErrorCode.valueOf("ATTRIBUTE_PATH_NOT_FOUND");
public static final ErrorCode ATTRIBUTE_FILE_NOT_FOUND = ErrorCode.valueOf("ATTRIBUTE_FILE_NOT_FOUND");
Expand All @@ -223,4 +226,4 @@ public class CoreErrorCodes {
public static final ErrorCode DATABASE_CONSTRAINT_MISMATCH = ErrorCode.valueOf("DATABASE_CONSTRAINT_MISMATCH");
public static final ErrorCode TABLE_FOREIGN_KEY_NOT_FOUND = ErrorCode.valueOf("TABLE_FOREIGN_KEY_NOT_FOUND");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ public void validate(Context context, Attribute<Geometry> attribute) {
return;
}

if (!geometry.isValid()) {
// Permet de vérifier l'intégrité des données géographiques
// En attendant une mise à niveau de la librairie GeoTools/GEOS
boolean geometryReliability = false;
boolean geometryValidity = false;
try {
geometryValidity = !geometry.isValid();
geometryReliability = true;
} catch (Exception e) {
context.report(context.createError(CoreErrorCodes.ATTRIBUTE_GEOMETRY_INVALID_INTERNAL));
}

if (geometryReliability && geometryValidity) {
// recherche du point erreur avec la classe IsValidOp
IsValidOp isValidOp = new IsValidOp(geometry);
TopologyValidationError topologyValidationError = isValidOp.getValidationError();
Expand All @@ -52,4 +63,4 @@ public void validate(Context context, Attribute<Geometry> attribute) {
}
}

}
}
14 changes: 10 additions & 4 deletions validator-core/src/main/resources/error-code.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,19 @@
"level": "ERROR",
"message": "La géométrie de l'objet n'est pas topologiquement correcte. {TYPE_ERROR}",
"documentation": "Voir la documentation de PostGIS : http://www.postgis.fr/chrome/site/docs/workshop-foss4g/doc/validity.html"
},{"name":
"ATTRIBUTE_GEOMETRY_INVALID_DATA_EXTENT"
,
},
{
"name":"ATTRIBUTE_GEOMETRY_INVALID_DATA_EXTENT",
"level": "ERROR",
"message": "Les coordonnées de la géométrie de l'objet ne correspondent pas à la zone attendue.",
"documentation": ""
},
{
"name":"ATTRIBUTE_GEOMETRY_INVALID_INTERNAL",
"level": "ERROR",
"message": "Le processus de validation des géométries ne peut pas se résoudre. Essayez de simplifier vos géométries : https://postgis.net/docs/ST_Simplify.html",
"documentation": ""
},
{
"name": "ATTRIBUTE_PATH_NOT_FOUND",
"level": "ERROR",
Expand Down Expand Up @@ -795,4 +801,4 @@
"message": "L'objet {ID_OBJECT} de la table {ORIGIN_TABLE} doit faire référence à un objet de la table {REFERENCE_TABLE} via l'attribut {REFERENCE_NAME}. L'attribut n'est pas renseigné ({REF_VALUE}) ou alors la relation n'est pas vérifiée.",
"documentation": "[DEPRECATED] Remplacé par ATTRIBUTE_REFERENCE_NOT_FOUND pour migration du contrôle dans validator-core"
}
]
]
Loading