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

Drag n drop des fichiers geojson en projection 2154 #1001

Merged
merged 3 commits into from
Feb 10, 2025
Merged

Conversation

totakoko
Copy link
Member

Permet de drag n drop des fichiers geojson en projection 2154 sur la carte. Ca sera utile pour vérifier que les fichiers des réseaux sont au bon format. (cf trello)
Sachant qu'il n'existe pas d'outils web pour visualiser ça facilement.

@@ -66,3 +74,30 @@ const FileDragNDrop = () => {
};

export default FileDragNDrop;

const isLambert93Projection = (geojson: any) => geojson.crs?.properties?.name && geojson.crs.properties.name.includes('2154');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je mettrai bien ca dans un utils/geo car c'est pas vraiment spécifique au drag n drop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ben je suis vraiment pas sûr qu'on utilise ça ailleurs de sitôt. Tu parles juste de isLambert93Projection ou des autres fonctions de conversion aussi ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme discuté => mis dans utils/geo

};

const convertGeoJSON = (geojson: any): any => {
if (isLambert93Projection(geojson)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

early exit please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est surtout valable quand y'a un else return je trouve. Et sinon ça voudrait dire qu'il faut inverser la condition. Donc pour pas grand chose.

=> j'ai refactor un peu pour gérer le if en dehors et donc cette fonction ne fait plus que convertir le geojson.

return proj4(from, to, coords);
};

const convertGeoJSON = (geojson: any): any => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert to what?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convertLambert93GeoJSONToWGS84 😂 J'ai ajouté des commentaires aussi. L'idée est d'obtenir un geojson en WGS 84. J'ai refactoré aussi un peu cf autre commentaire.

@@ -66,3 +74,30 @@ const FileDragNDrop = () => {
};

export default FileDragNDrop;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export dynamic pour bénéficier du code splitting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai fait un import dynamique 👍
Le code JS est uniquement chargé quand on fait le drag n drop maintenant.

Copy link
Collaborator

@martinratinaud martinratinaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏👏👏

@totakoko totakoko merged commit 1d57c4a into dev Feb 10, 2025
4 of 5 checks passed
@totakoko totakoko deleted the geojson_dnd_2154 branch February 10, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants