Merge avec avec la branche aur-br05-26032025
This commit is contained in:
15
pom.xml
15
pom.xml
@@ -14,7 +14,7 @@
|
|||||||
<name>fiscad</name>
|
<name>fiscad</name>
|
||||||
<description>Application de collecte des données socio-foncières</description>
|
<description>Application de collecte des données socio-foncières</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>11</java.version>
|
<java.version>17</java.version>
|
||||||
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -97,14 +97,12 @@
|
|||||||
<version>2.3.0</version>
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.locationtech.jts</groupId>
|
<groupId>org.locationtech.jts</groupId>
|
||||||
<artifactId>jts-core</artifactId>
|
<artifactId>jts-core</artifactId>
|
||||||
<version>1.19.0</version>
|
<version>1.16.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-spatial</artifactId>
|
<artifactId>hibernate-spatial</artifactId>
|
||||||
@@ -116,6 +114,7 @@
|
|||||||
<artifactId>jackson-datatype-jts</artifactId>
|
<artifactId>jackson-datatype-jts</artifactId>
|
||||||
<version>1.2.4</version>
|
<version>1.2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.teiid</groupId>
|
<groupId>org.teiid</groupId>
|
||||||
<artifactId>teiid-optional-geo</artifactId>
|
<artifactId>teiid-optional-geo</artifactId>
|
||||||
@@ -142,6 +141,14 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version> <!-- ou une version plus récente -->
|
||||||
|
<configuration>
|
||||||
|
<release>17</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/parcelleGeom", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/parcelle-geom", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "ParcelleGeometrie")
|
@Tag(name = "ParcelleGeometrie")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@@ -32,7 +32,7 @@ public class ParcelleGeomController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping(value = "/create-from-geojsonfile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public ResponseEntity<?> createTpe(@RequestPart(required = true) MultipartFile file) {
|
public ResponseEntity<?> createTpe(@RequestPart(required = true) MultipartFile file) {
|
||||||
try{
|
try{
|
||||||
int n = parcelleGeomService.createParcelleFromGeoJsonFile(file);
|
int n = parcelleGeomService.createParcelleFromGeoJsonFile(file);
|
||||||
@@ -53,7 +53,15 @@ public class ParcelleGeomController {
|
|||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
public ResponseEntity<?> getAllTpeList() {
|
public ResponseEntity<?> getAllTpeList() {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(), "Liste des tpe chargée avec succès."),
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(), "Liste des parcelle chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/by-quartier/{codeQuartier}")
|
||||||
|
public ResponseEntity<?> getAllTpeList(@PathVariable String codeQuartier) {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListUnQuatier(codeQuartier), "Liste des parcelle chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -63,17 +71,22 @@ public class ParcelleGeomController {
|
|||||||
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(pageable), "Liste des tpe chargée avec succès."),
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(pageable), "Liste des parcelle chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getTpeById(@PathVariable Long id) {
|
public ResponseEntity<?> getParcelleGeomById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomById(id), "Tpe trouvé avec succès."),
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomById(id).orElse(null), "parcelle trouvé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public class Arrondissement extends BaseEntity implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
private String nom;
|
||||||
|
private String longitude;
|
||||||
|
private String latitude;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Commune commune;
|
private Commune commune;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public class Commune extends BaseEntity implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
private String nom;
|
||||||
|
private String longitude;
|
||||||
|
private String latitude;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Departement departement;
|
private Departement departement;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ public class Secteur extends BaseEntity implements Serializable {
|
|||||||
private User chefSecteur;
|
private User chefSecteur;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Structure structure;
|
private Structure structure;
|
||||||
//@JsonIgnore
|
|
||||||
//@OneToMany(mappedBy = "secteur")
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "secteur_id")
|
@JoinColumn(name = "secteur_id")
|
||||||
private List<SecteurDecoupage> secteurDecoupages;
|
private List<SecteurDecoupage> secteurDecoupages;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package io.gmss.fiscad.entities.infocad.metier;
|
package io.gmss.fiscad.entities.infocad.metier;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -15,15 +11,14 @@ import lombok.NoArgsConstructor;
|
|||||||
import org.hibernate.annotations.ColumnDefault;
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import org.hibernate.annotations.SQLDelete;
|
import org.hibernate.annotations.SQLDelete;
|
||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
|
||||||
import org.locationtech.jts.geom.MultiPolygon;
|
|
||||||
import org.locationtech.jts.geom.Point;
|
|
||||||
import org.locationtech.jts.geom.Polygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
import org.n52.jackson.datatype.jts.GeometryDeserializer;
|
import org.n52.jackson.datatype.jts.GeometryDeserializer;
|
||||||
import org.n52.jackson.datatype.jts.GeometrySerializer;
|
import org.n52.jackson.datatype.jts.GeometrySerializer;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Entity
|
@Entity
|
||||||
@@ -77,6 +72,9 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
|
|||||||
@OneToOne
|
@OneToOne
|
||||||
private Parcelle parcelle;
|
private Parcelle parcelle;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Quartier quartier;
|
||||||
|
|
||||||
@ColumnDefault("0")
|
@ColumnDefault("0")
|
||||||
private int geomSrid;
|
private int geomSrid;
|
||||||
|
|
||||||
@@ -87,8 +85,8 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
@JsonSerialize(using = GeometrySerializer.class)
|
@JsonSerialize(using = GeometrySerializer.class)
|
||||||
@JsonDeserialize(contentUsing = GeometryDeserializer.class)
|
@JsonDeserialize(contentUsing = GeometryDeserializer.class)
|
||||||
// @Column(name = "geom_32631",columnDefinition = "geometry(Polygon,32631)")
|
@Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)")
|
||||||
//private Polygon geometry32631 ;
|
//private Polygon geometry32631 ;
|
||||||
@Column(columnDefinition = "geometry")
|
//@Column(columnDefinition = "geometry")
|
||||||
private Geometry geometry;
|
private Polygon geometry;
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package io.gmss.fiscad.entities.infocad.parametre;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -43,6 +44,8 @@ public class Structure extends BaseEntity implements Serializable {
|
|||||||
private String tel;
|
private String tel;
|
||||||
private String email;
|
private String email;
|
||||||
private String adresse;
|
private String adresse;
|
||||||
|
@ManyToOne
|
||||||
|
private Commune commune;
|
||||||
//@JsonIgnore
|
//@JsonIgnore
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "arrondissements_structures",
|
@JoinTable(name = "arrondissements_structures",
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import io.gmss.fiscad.interfaces.infocad.metier.ParcelleGeomService;
|
|||||||
import io.gmss.fiscad.paylaods.request.ParcelleGeomPayload;
|
import io.gmss.fiscad.paylaods.request.ParcelleGeomPayload;
|
||||||
import io.gmss.fiscad.repositories.infocad.metier.ParcelleGeomRepository;
|
import io.gmss.fiscad.repositories.infocad.metier.ParcelleGeomRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
|
import org.locationtech.jts.geom.GeometryFactory;
|
||||||
import org.locationtech.jts.geom.Polygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
import org.locationtech.jts.io.ParseException;
|
import org.locationtech.jts.io.ParseException;
|
||||||
|
import org.locationtech.jts.io.WKTWriter;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -57,6 +60,10 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
|
|||||||
JsonNode feature = features.next();
|
JsonNode feature = features.next();
|
||||||
createOnParcelleFromGeoJson(feature);
|
createOnParcelleFromGeoJson(feature);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
parcelleGeomRepository.majIdQuartier();
|
||||||
|
}catch (Exception e){
|
||||||
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,40 +73,43 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
|
|||||||
JsonNode propertiesNode = feature.get("properties");
|
JsonNode propertiesNode = feature.get("properties");
|
||||||
WKTReader wktReader = new WKTReader();
|
WKTReader wktReader = new WKTReader();
|
||||||
if (geometryNode != null) {
|
if (geometryNode != null) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
Polygon geometry = null;
|
||||||
ParcelleGeomPayload parcelleGeomPayload =new ParcelleGeomPayload();
|
|
||||||
try {
|
try {
|
||||||
parcelleGeomPayload = objectMapper.readValue(propertiesNode.toString(), ParcelleGeomPayload.class);
|
geometry = convertGeoJsonToPolygon(geometryNode.toString());
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
Geometry geometry = null;
|
|
||||||
try {
|
|
||||||
String wkt = convertGeoJsonToWKT(geometryNode);
|
|
||||||
geometry = wktReader.read(wkt);
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
ParcelleGeom parcelleGeom = new ParcelleGeom();
|
ParcelleGeom parcelleGeom = new ParcelleGeom();
|
||||||
parcelleGeom.setGeometry(geometry);
|
parcelleGeom.setGeometry(geometry);
|
||||||
parcelleGeom.setCommune(parcelleGeomPayload.getDepartement());
|
parcelleGeom.setDepartement(propertiesNode.get("DEPARTEMENT").textValue());
|
||||||
parcelleGeom.setArrondissement(parcelleGeomPayload.getArrondissement());
|
parcelleGeom.setCommune(propertiesNode.get("COMMUNE").textValue());
|
||||||
parcelleGeom.setVillageQuartier(parcelleGeomPayload.getVillageQuartier());
|
parcelleGeom.setArrondissement(propertiesNode.get("ARRONDISSEMENT").textValue());
|
||||||
parcelleGeom.setCodeBloc(parcelleGeomPayload.getCodeBloc());
|
parcelleGeom.setVillageQuartier(propertiesNode.get("VILLAGE_QUARTIER").textValue());
|
||||||
parcelleGeom.setCodeParcelle(parcelleGeomPayload.getCodeParcelle());
|
parcelleGeom.setCodeBloc(propertiesNode.get("CODE_BLOC").textValue());
|
||||||
parcelleGeom.setCodeEquipe(parcelleGeomPayload.getCodeEquipe());
|
parcelleGeom.setCodeParcelle(propertiesNode.get("CODE_PARCELLE").textValue());
|
||||||
parcelleGeom.setSuperficie(parcelleGeomPayload.getSuperficie());
|
parcelleGeom.setCodeEquipe(propertiesNode.get("CODE_EQUIPE").textValue());
|
||||||
parcelleGeom.setElNumeroEtatLieux(parcelleGeomPayload.getElNumeroEtatLieux());
|
|
||||||
parcelleGeom.setElLot(parcelleGeomPayload.getElLot());
|
|
||||||
parcelleGeom.setRfuQuartierOuZone(parcelleGeomPayload.getRfuQuartierOuZone());
|
try {
|
||||||
parcelleGeom.setElLettreParcelle(parcelleGeomPayload.getElLettreParcelle());
|
parcelleGeom.setSuperficie(Integer.parseInt(propertiesNode.get("SUPERFICIE").textValue()));
|
||||||
parcelleGeom.setRfuIlot(parcelleGeomPayload.getRfuIlot());
|
}catch (Exception e){
|
||||||
parcelleGeom.setRfuLettreParcelle(parcelleGeomPayload.getRfuLettreParcelle());
|
|
||||||
parcelleGeom.setDateCollecte(parcelleGeomPayload.getDateCollecte());
|
}
|
||||||
parcelleGeom.setNomLotissement(parcelleGeomPayload.getNomLotissement());
|
parcelleGeom.setElNumeroEtatLieux(propertiesNode.get("EL_NUMERO_ETAT_LIEUX").textValue());
|
||||||
parcelleGeom.setNomEtPrenoms(parcelleGeomPayload.getNomEtPrenoms());
|
parcelleGeom.setElLot(propertiesNode.get("EL_LOT").textValue());
|
||||||
parcelleGeom.setSourceCollecte(parcelleGeomPayload.getSourceCollecte());
|
parcelleGeom.setRfuQuartierOuZone(propertiesNode.get("RFU_QUARTIER_OU_ZONE").textValue());
|
||||||
parcelleGeom.setObservations(parcelleGeomPayload.getObservations());
|
parcelleGeom.setElLettreParcelle(propertiesNode.get("EL_LETTRE_PARCELLE").textValue());
|
||||||
|
parcelleGeom.setRfuIlot(propertiesNode.get("RFU_ILOT").textValue());
|
||||||
|
parcelleGeom.setRfuLettreParcelle(propertiesNode.get("RFU_LETTRE_PARCELLE").textValue());
|
||||||
|
parcelleGeom.setDateCollecte(propertiesNode.get("DATE_COLLECTE").textValue());
|
||||||
|
parcelleGeom.setNomLotissement(propertiesNode.get("NOM_LOTISSEMENT").textValue());
|
||||||
|
parcelleGeom.setNomEtPrenoms(propertiesNode.get("NOM_ET_PRENOMS").textValue());
|
||||||
|
parcelleGeom.setSourceCollecte(propertiesNode.get("SOURCE_COLLECTE").textValue());
|
||||||
|
parcelleGeom.setObservations(propertiesNode.get("OBSERVATIONS").textValue());
|
||||||
return parcelleGeomRepository.save(parcelleGeom);
|
return parcelleGeomRepository.save(parcelleGeom);
|
||||||
}else {
|
}else {
|
||||||
return null;
|
return null;
|
||||||
@@ -118,37 +128,53 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ParcelleGeom> getParcelleGeomList(Pageable pageable) {
|
public Page<ParcelleGeom> getParcelleGeomList(Pageable pageable) {
|
||||||
return null;
|
return parcelleGeomRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ParcelleGeom> getParcelleGeomList() {
|
public List<ParcelleGeom> getParcelleGeomList() {
|
||||||
return null;
|
return parcelleGeomRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ParcelleGeom> getParcelleGeomListUnQuatier(String codeQuartier) {
|
||||||
|
return parcelleGeomRepository.findAllByQuartier_Code(codeQuartier);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ParcelleGeom> getParcelleGeomById(Long id) {
|
public Optional<ParcelleGeom> getParcelleGeomById(Long id) {
|
||||||
return Optional.empty();
|
return parcelleGeomRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String convertGeoJsonToWKT(JsonNode geometryNode) {
|
public Polygon convertGeoJsonToPolygon(String geoJson) throws Exception {
|
||||||
String type = geometryNode.get("type").asText();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String coordinates = geometryNode.get("coordinates").toString();
|
JsonNode rootNode = mapper.readTree(geoJson);
|
||||||
switch (type) {
|
|
||||||
case "Point":
|
if (!rootNode.has("type") || !rootNode.has("coordinates")) {
|
||||||
return "POINT " + formatCoordinates(coordinates);
|
throw new IllegalArgumentException("GeoJSON invalide");
|
||||||
case "LineString":
|
|
||||||
return "LINESTRING " + formatCoordinates(coordinates);
|
|
||||||
case "Polygon":
|
|
||||||
return "POLYGON " + formatCoordinates(coordinates);
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Type géométrique non pris en charge : " + type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatCoordinates(String jsonCoords) {
|
String type = rootNode.get("type").asText();
|
||||||
return jsonCoords.replace("[", "(").replace("]", ")").replace(",", " ");
|
JsonNode coordinatesNode = rootNode.get("coordinates");
|
||||||
|
|
||||||
|
GeometryFactory geometryFactory = new GeometryFactory();
|
||||||
|
|
||||||
|
if ("Polygon".equals(type) || "geometry".equals(type)) {
|
||||||
|
JsonNode firstRing = coordinatesNode.get(0);
|
||||||
|
Coordinate[] coordinates = new Coordinate[firstRing.size()];
|
||||||
|
for (int i = 0; i < firstRing.size(); i++) {
|
||||||
|
JsonNode point = firstRing.get(i);
|
||||||
|
double x = point.get(0).asDouble();
|
||||||
|
double y = point.get(1).asDouble();
|
||||||
|
coordinates[i] = new Coordinate(x, y);
|
||||||
|
}
|
||||||
|
return geometryFactory.createPolygon(coordinates);
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException("Type GeoJSON non supporté: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,5 +20,7 @@ public interface ParcelleGeomService {
|
|||||||
void deleteParcelle(Long id) throws NotFoundException;
|
void deleteParcelle(Long id) throws NotFoundException;
|
||||||
Page<ParcelleGeom> getParcelleGeomList(Pageable pageable);
|
Page<ParcelleGeom> getParcelleGeomList(Pageable pageable);
|
||||||
List<ParcelleGeom> getParcelleGeomList();
|
List<ParcelleGeom> getParcelleGeomList();
|
||||||
|
List<ParcelleGeom> getParcelleGeomListUnQuatier(String codeQuartier);
|
||||||
|
|
||||||
Optional<ParcelleGeom> getParcelleGeomById(Long id);
|
Optional<ParcelleGeom> getParcelleGeomById(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ public interface ArrondissementEnqResponse {
|
|||||||
public String getCode();
|
public String getCode();
|
||||||
|
|
||||||
public String getLibelle();
|
public String getLibelle();
|
||||||
|
public String getLongitude();
|
||||||
|
public String getLatitude();
|
||||||
|
|
||||||
public Long getCommuneId();
|
public Long getCommuneId();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ public interface ArrondissementSyncResponse {
|
|||||||
public String getCode();
|
public String getCode();
|
||||||
|
|
||||||
public String getNom();
|
public String getNom();
|
||||||
|
public String getLongitude();
|
||||||
|
public String getLatitude();
|
||||||
|
|
||||||
public Long getCommuneId();
|
public Long getCommuneId();
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,8 @@ public interface CommuneEnqResponse {
|
|||||||
public String getCode();
|
public String getCode();
|
||||||
|
|
||||||
public String getLibelle();
|
public String getLibelle();
|
||||||
|
public String getLongitude();
|
||||||
|
public String getLatitude();
|
||||||
|
|
||||||
public Long getNombreEnquete();
|
public Long getNombreEnquete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ public interface CommuneSyncResponse {
|
|||||||
public Long getId();
|
public Long getId();
|
||||||
|
|
||||||
public String getCode();
|
public String getCode();
|
||||||
|
public String getLongitude();
|
||||||
|
public String getLatitude();
|
||||||
public String getNom();
|
public String getNom();
|
||||||
|
|
||||||
public Long getDepartementId();
|
public Long getDepartementId();
|
||||||
|
|||||||
@@ -12,25 +12,25 @@ import java.util.List;
|
|||||||
public interface ArrondissementRepository extends JpaRepository<Arrondissement, Long> {
|
public interface ArrondissementRepository extends JpaRepository<Arrondissement, Long> {
|
||||||
List<Arrondissement> findAllByCommune(Commune commune);
|
List<Arrondissement> findAllByCommune(Commune commune);
|
||||||
|
|
||||||
@Query(value = "select a.id,code, nom, a.commune_id as communeId from arrondissement a" +
|
@Query(value = "select a.id,code, nom,longitude,latitude, a.commune_id as communeId from arrondissement a" +
|
||||||
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id" +
|
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id" +
|
||||||
" where a.deleted is false and sa.structure_id = ?1 ", nativeQuery = true)
|
" where a.deleted is false and sa.structure_id = ?1 ", nativeQuery = true)
|
||||||
List<ArrondissementSyncResponse> getArrondissementResponse(Long structure_id);
|
List<ArrondissementSyncResponse> getArrondissementResponse(Long structure_id);
|
||||||
|
|
||||||
@Query(value = "Select distinct T.id,T.code, T.libelle, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
@Query(value = "Select distinct T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
||||||
" From (select a.id,a.code, a.nom as libelle, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
|
" From (select a.id,a.code, a.nom as libelle,a.longitude,a.latitude, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
|
||||||
" left join bloc b on b.arrondissement_id=a.id " +
|
" left join bloc b on b.arrondissement_id=a.id " +
|
||||||
" left join enquete e on e.bloc_id=b.id )T " +
|
" left join enquete e on e.bloc_id=b.id )T " +
|
||||||
" group by T.id,T.code, T.libelle, T.communeId ", nativeQuery = true)
|
" group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
|
||||||
List<ArrondissementEnqResponse> getAdminArrondissementEnqResponse();
|
List<ArrondissementEnqResponse> getAdminArrondissementEnqResponse();
|
||||||
|
|
||||||
|
|
||||||
@Query(value = "Select T.id,T.code, T.libelle, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
@Query(value = "Select T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
||||||
" From (select distinct a.id,a.code, a.nom as libelle, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
|
" From (select distinct a.id,a.code, a.nom as libelle,a.longitude,a.latitude, a.commune_id as communeId, e.id as enqueteId from arrondissement a" +
|
||||||
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id " +
|
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id " +
|
||||||
" left join bloc b on b.arrondissement_id=a.id " +
|
" left join bloc b on b.arrondissement_id=a.id " +
|
||||||
" left join enquete e on e.bloc_id=b.id" +
|
" left join enquete e on e.bloc_id=b.id" +
|
||||||
" where sa.structure_id = ?1 )T " +
|
" where sa.structure_id = ?1 )T " +
|
||||||
" group by T.id,T.code, T.libelle, T.communeId ", nativeQuery = true)
|
" group by T.id,T.code, T.libelle,T.longitude,T.latitude, T.communeId ", nativeQuery = true)
|
||||||
List<ArrondissementEnqResponse> getArrondissementEnqResponse(Long structure_id);
|
List<ArrondissementEnqResponse> getArrondissementEnqResponse(Long structure_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,28 +11,28 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
public interface CommuneRepository extends JpaRepository<Commune, Long> {
|
||||||
|
|
||||||
@Query(value = "select id, code, nom, departement_id as departementid from commune ", nativeQuery = true)
|
@Query(value = "select id, code, nom,longitude,latitude, departement_id as departementid from commune ", nativeQuery = true)
|
||||||
List<CommuneSyncResponse> getCommuneResponse();
|
List<CommuneSyncResponse> getCommuneResponse();
|
||||||
|
|
||||||
List<Commune> findAllByDepartement(Departement departement);
|
List<Commune> findAllByDepartement(Departement departement);
|
||||||
|
|
||||||
@Query(value = " Select T.id,T.code, T.libelle, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
@Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
||||||
" From (select distinct c.id as id,c.code as code, c.nom as libelle, e.id as enqueteId from arrondissement a" +
|
" From (select distinct c.id as id,c.code as code, c.nom as libelle,c.longitude,c.latitude, e.id as enqueteId from arrondissement a" +
|
||||||
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id " +
|
" inner join arrondissements_structures sa on sa.arrondissement_id=a.id " +
|
||||||
" inner join commune c on c.id= a.commune_id " +
|
" inner join commune c on c.id= a.commune_id " +
|
||||||
" left join bloc b on b.arrondissement_id=a.id " +
|
" left join bloc b on b.arrondissement_id=a.id " +
|
||||||
" left join enquete e on e.bloc_id=b.id " +
|
" left join enquete e on e.bloc_id=b.id " +
|
||||||
" where sa.structure_id = ?1 )T" +
|
" where sa.structure_id = ?1 )T" +
|
||||||
" group by T.id,T.code, T.libelle", nativeQuery = true)
|
" group by T.id,T.code, T.libelle,T.longitude,T.latitude", nativeQuery = true)
|
||||||
List<CommuneEnqResponse> getCommuneEnqResponse(Long structure_id);
|
List<CommuneEnqResponse> getCommuneEnqResponse(Long structure_id);
|
||||||
|
|
||||||
@Query(value = " Select T.id,T.code, T.libelle, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
@Query(value = " Select T.id,T.code, T.libelle,T.longitude,T.latitude, sum(case when T.enqueteId is null then 0 else 1 end) as nombreEnquete " +
|
||||||
" From (select distinct c.id as id,c.code as code, c.nom as libelle, e.id as enqueteId from arrondissement a" +
|
" From (select distinct c.id as id,c.code as code,c.longitude,c.latitude, c.nom as libelle, e.id as enqueteId from arrondissement a" +
|
||||||
" left join arrondissements_structures sa on sa.arrondissement_id=a.id " +
|
" left join arrondissements_structures sa on sa.arrondissement_id=a.id " +
|
||||||
" left join commune c on c.id= a.commune_id " +
|
" left join commune c on c.id= a.commune_id " +
|
||||||
" left join bloc b on b.arrondissement_id=a.id " +
|
" left join bloc b on b.arrondissement_id=a.id " +
|
||||||
" left join enquete e on e.bloc_id=b.id)T " +
|
" left join enquete e on e.bloc_id=b.id)T " +
|
||||||
" group by T.id,T.code, T.libelle", nativeQuery = true)
|
" group by T.id,T.code, T.libelle,T.longitude,T.latitude", nativeQuery = true)
|
||||||
List<CommuneEnqResponse> getAdminCommuneEnqResponse();
|
List<CommuneEnqResponse> getAdminCommuneEnqResponse();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
||||||
List<Quartier> getAllByArrondissement(Arrondissement arrondissement);
|
List<Quartier> getAllByArrondissement(Arrondissement arrondissement);
|
||||||
@@ -23,5 +24,5 @@ public interface QuartierRepository extends JpaRepository<Quartier, Long> {
|
|||||||
" where q.deleted is false ", nativeQuery = true)
|
" where q.deleted is false ", nativeQuery = true)
|
||||||
List<QuartierSyncResponse> getAdminQuartierResponse();
|
List<QuartierSyncResponse> getAdminQuartierResponse();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public interface ParcelleGeomRepository extends JpaRepository<ParcelleGeom, Long> {
|
public interface ParcelleGeomRepository extends JpaRepository<ParcelleGeom, Long> {
|
||||||
|
|
||||||
|
List<ParcelleGeom> findAllByQuartier_Code(String code);
|
||||||
|
|
||||||
|
@Query(value = "update parcelle_geom " +
|
||||||
|
"set quartier_id=T.quartier_id " +
|
||||||
|
"from " +
|
||||||
|
"(select quartier.id as quartier_id,upper(quartier.nom) as nom_quartier,c.nom as nom_commune " +
|
||||||
|
"from quartier inner join public.arrondissement a on a.id = quartier.arrondissement_id " +
|
||||||
|
"inner join public.commune c on c.id = a.commune_id)T " +
|
||||||
|
"where parcelle_geom.village_quartier=T.nom_quartier " +
|
||||||
|
"and upper(parcelle_geom.commune)=upper(T.nom_commune) ",nativeQuery = true)
|
||||||
|
void majIdQuartier();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user