Skip to content

Commit

Permalink
Corrige la recherche de permis par point
Browse files Browse the repository at this point in the history
Le SRID utilisé pour la transformation n'était pas celui utilisé par le serveur

Issue #204647

Change-Id: I015efbbf353ff603266f03e51b5eb96a1abdfa3c
  • Loading branch information
tdegivry committed Feb 6, 2024
1 parent 18927b7 commit a697813
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ privileged aspect Permis_Remocra_Finder {
* @return
*/
@SuppressWarnings("unchecked")
public static List<Permis> Permis.findPermisByXYTolerance(int srid, float x, float y, int toleranceMeters, int firstResult, int maxResults, Geometry zoneInclusion) {
public static List<Permis> Permis.findPermisByXYTolerance(int sridSource, float x, float y, int sridCible, int toleranceMeters, int firstResult, int maxResults, Geometry zoneInclusion) {
EntityManager em = Permis.entityManager();

Geometry point = GeometryUtil.toGeometry("POINT(" + x + " " + y + ")", srid);
Geometry point = GeometryUtil.toGeometry("POINT(" + x + " " + y + ")", sridSource);

String sql = "SELECT o.* FROM remocra.Permis AS o WHERE ST_DWithin(st_transform(:point, "+srid+"), geometrie, :tolerance) ";
String sql = "SELECT o.* FROM remocra.Permis AS o WHERE ST_DWithin(st_transform(:point, "+sridCible+"), geometrie, :tolerance) ";
if (zoneInclusion != null) {
sql += " AND (st_transform(:point, "+srid+") && :zoneInclusion AND ST_Within(st_transform(:point, "+srid+"), :zoneInclusion) )";
sql += " AND (st_transform(:point, "+sridCible+") && :zoneInclusion AND ST_Within(st_transform(:point, "+sridCible+"), :zoneInclusion) )";
}
sql += " order by ST_Distance(st_transform(:point, "+srid+"), geometrie)";
sql += " order by ST_Distance(st_transform(:point, "+sridCible+"), geometrie)";

Query q = em.createNativeQuery(sql, Permis.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,18 @@ protected List<Permis> getRecords() {
ZoneCompetence zc =
utilisateurService.getCurrentUtilisateur().getOrganisme().getZoneCompetence();
Integer tolerance = parametreProvider.get().getToleranceChargementMetres();
int sridCible = parametreProvider.get().getSridInt();
int firstResult = 0;
int maxResults = 10;
return Permis.findPermisByXYTolerance(
srid.intValue(), x, y, tolerance, firstResult, maxResults, zc.getGeometrie());
srid.intValue(),
x,
y,
sridCible,
tolerance,
firstResult,
maxResults,
zc.getGeometrie());
}
}.serialize();
}
Expand Down

0 comments on commit a697813

Please sign in to comment.