Skip to content

Commit

Permalink
fix(atlas): mettre à jour les identifiants géographiques et ajouter d…
Browse files Browse the repository at this point in the history
…es cas particuliers pour les collectivités d'outre-mer
  • Loading branch information
jerem1508 committed Jan 15, 2025
1 parent 78ecb01 commit 7ce3d00
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 8 deletions.
36 changes: 33 additions & 3 deletions client/src/pages/atlas/charts/map-with-polygon-and-bubbles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default function MapWithPolygonAndBubbles({
}) {
const [searchParams] = useSearchParams();
const geoId = searchParams.get("geo_id") || "";

if (isLoading) {
return <MapSkeleton />;
}

const mapOptions = {
chart: {
map: "countries/ie/ie-all",
Expand Down Expand Up @@ -137,7 +137,7 @@ export default function MapWithPolygonAndBubbles({
}

// special case : France but idToFocus === Saint-Martin
if (geoId === "PAYS_100" && currentId === "978") {
if (geoId === "PAYS_100" && currentId === "D978") {
mapOptions.mapView["center"] = [-63.1, 18.1];
mapOptions.mapView["zoom"] = 9;
mapOptions.chart["height"] = "150";
Expand All @@ -152,6 +152,36 @@ export default function MapWithPolygonAndBubbles({
mapOptions.chart["width"] = "130";
}

// special case : collectivités
if (geoId === "R00") {
mapOptions.chart["height"] = "130";
mapOptions.chart["width"] = "250";
}

// special case : collectivités but idToFocus === Nouvelle-Calédonie
if (geoId === "R00" && currentId === "D988") {
mapOptions.mapView["center"] = [165.7, -21];
mapOptions.mapView["zoom"] = 5.5;
}

// special case : collectivités but idToFocus === Polynésie française
if (geoId === "R00" && currentId === "D987") {
mapOptions.mapView["center"] = [-149.5, -17.5];
mapOptions.mapView["zoom"] = 7;
}

// special case : collectivités but idToFocus === Saint-Martin
if (geoId === "R00" && currentId === "D978") {
mapOptions.mapView["center"] = [-63.1, 18.1];
mapOptions.mapView["zoom"] = 9;
}

// special case : collectivités but idToFocus === Wallis et Futuna
if (geoId === "R00" && currentId === "D986") {
mapOptions.mapView["center"] = [-178, -13.3];
mapOptions.mapView["zoom"] = 6;
}

return (
<HighchartsReact
constructorType={"mapChart"}
Expand Down
100 changes: 98 additions & 2 deletions client/src/pages/atlas/components/main/tabs/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export function General() {
.forEach((item) => {
let polygon;
switch (item.geo_id) {
case "D988":
// Nouvelle-Calédonie
case "D988":
case "A40":
mapbubbleData.push({
z:
item.data.find((d) => d.annee_universitaire === currentYear)
Expand All @@ -134,7 +136,9 @@ export function General() {
});
break;

// Polynésie française
case "D987":
case "A41":
mapbubbleData.push({
z:
item.data.find((d) => d.annee_universitaire === currentYear)
Expand All @@ -145,7 +149,9 @@ export function General() {
});
break;

// Saint-Martin
case "978":
case "D978":
mapbubbleData.push({
z:
item.data.find((d) => d.annee_universitaire === currentYear)
Expand All @@ -156,6 +162,19 @@ export function General() {
});
break;

// Wallis et Futuna
case "D986":
case "A42":
mapbubbleData.push({
z:
item.data.find((d) => d.annee_universitaire === currentYear)
?.effectif || 0,
name: item.geo_nom,
lat: -13.3,
lon: -178,
});
break;

default:
polygon =
polygonsData.find((d) => d.originalId === item.geo_id)
Expand Down Expand Up @@ -226,7 +245,7 @@ export function General() {
<div className="item ">
<MapWithPolygonAndBubbles
currentYear={currentYear}
idToFocus="978"
idToFocus="D978"
isLoading={isLoadingHistoric}
mapbubbleData={mapbubbleData}
polygonsData={polygonsData}
Expand Down Expand Up @@ -346,6 +365,83 @@ export function General() {
);
}

// cas particulier des collectivités d'outre-mer
if (geoId === "R00") {
return (
<>
<Row className="fr-my-5w">
<Col>
<Title as="h3" look="h5">
<span
className="fr-icon-pie-chart-2-fill fr-mr-1w"
aria-hidden="true"
/>
Répartition des effectifs étudiants dans les collectivités
d'outre-mer
</Title>
</Col>
</Row>
<Row gutters>
<Col md={8}>
<Row gutters>
<Col md={6}>
<div className="standard-item">
<MapWithPolygonAndBubbles
currentYear={currentYear}
idToFocus="D988"
isLoading={isLoadingHistoric}
mapbubbleData={mapbubbleData}
polygonsData={polygonsData}
/>
<div className="item-label">Nouvelle-Calédonie</div>
</div>
</Col>
<Col md={6}>
<div className="standard-item">
<MapWithPolygonAndBubbles
currentYear={currentYear}
idToFocus="D987"
isLoading={isLoadingHistoric}
mapbubbleData={mapbubbleData}
polygonsData={polygonsData}
/>
<div className="item-label">Polynésie française</div>
</div>
</Col>
<Col md={6}>
<div className="standard-item">
<MapWithPolygonAndBubbles
currentYear={currentYear}
idToFocus="D978"
isLoading={isLoadingHistoric}
mapbubbleData={mapbubbleData}
polygonsData={polygonsData}
/>
<div className="item-label">Saint-Martin</div>
</div>
</Col>
<Col md={6}>
<div className="standard-item">
<MapWithPolygonAndBubbles
currentYear={currentYear}
idToFocus="D986"
isLoading={isLoadingHistoric}
mapbubbleData={mapbubbleData}
polygonsData={polygonsData}
/>
<div className="item-label">Wallis et Futuna</div>
</div>
</Col>
</Row>
</Col>
<Col md={4}>
<SubList />
</Col>
</Row>
</>
);
}

if (polygonsData.length > 1) {
return (
<>
Expand Down
20 changes: 20 additions & 0 deletions client/src/pages/atlas/components/main/tabs/styles.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
.standard-item{
border: 1px solid var(--border-default-grey);
position: relative;
border-radius: 5px;

.item-label {
position: absolute;
padding: 2px;
font-size: 10px;
font-weight: 500;
text-align: center;
background-color: var(--border-default-grey);
border-bottom: 1px solid var(--border-default-grey);
border-radius: 5px 5px 0 0;
top: 0;
width: 100%;
line-height: normal;
}
}

.atlas-map {
.item {
width: 150px;
Expand Down
7 changes: 7 additions & 0 deletions client/src/pages/atlas/components/main/tabs/sub-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export default function SubList() {
)
);

// Special case "Saint-Martin" (geo_id = 978)
dataHistoric.data.forEach(item => {
if (item.geo_id === '978') {
item.geo_id = 'D978';
}
});

return (
<Container fluid as="section">
<Row style={{ width: "100%" }}>
Expand Down
6 changes: 6 additions & 0 deletions client/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function getParentFromLevel(parents, geoId) {
if (geoId === "PAYS_100") {
return null;
}
if (geoId === "D978") {
return { geo_nom: parents.reg_nom, geo_id: parents.reg_id };

}
if (geoId.startsWith("R")) {
return { geo_nom: "France", geo_id: "PAYS_100" };
}
Expand All @@ -61,6 +65,8 @@ function getParentFromLevel(parents, geoId) {
if (geoId.startsWith("U")) {
return { geo_nom: parents.reg_nom, geo_id: parents.reg_id };
}

// default = communes
return { geo_nom: parents.dep_nom, geo_id: parents.dep_id };
}

Expand Down
6 changes: 3 additions & 3 deletions server/src/routes/tableaux/atlas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ router.route("/atlas/get-geo-polygons").get(async (req, res) => {
}
if (geoId.startsWith("R") || geoId.startsWith("A") || geoId.startsWith("P")) {
const ids = await db.collection("atlas2024").distinct("geo_id", filters);
if (geoId.startsWith("P")) {
if (geoId.startsWith("P") || geoId === "R00") {
ids.push("D988"); //Nouvelle-Caledonie
ids.push("D987"); //Polynesie-Francaise
ids.push("D986"); //Wallis-et-Futuna
ids.push("D985"); //Saint-Pierre-et-Miquelon
ids.push("D984"); //Saint-Barthelemy
ids.push("978"); //Saint-Martin
ids.push("D978"); //Saint-Martin
}
const polygons = [];
for (let i = 0; i < ids.length; i++) {
Expand Down Expand Up @@ -355,7 +355,7 @@ router.route("/atlas/number-of-students-historic-by-level").get(async (req, res)
query = {
geo_id: { $ne: "R99" }, // français à l'etrangers
$or: [
{ geo_id: "978" },
{ geo_id: "D978" },
{ geo_id: "D986" },
{ geo_id: "D987" },
{ geo_id: "D988" },
Expand Down

0 comments on commit 7ce3d00

Please sign in to comment.