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

Convert latitude/longitude fields with GeoJSON for map data #93

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

biru-codeastromer
Copy link
Contributor

Fixes #5

Description :

-This PR introduces the following changes to improve the handling of map data in the user stories.

Changes Made :

1.Replaced latitude and longitude fields with a geojson field:

-The geojson field now stores spatial data as a GeoJSON string, aligning with Decap CMS's map widget requirements.
-This eliminates redundancy and ensures consistency in how map data is stored and used.

2.Updated config.yml:

-Removed the latitude and longitude fields from the Decap CMS admin interface.
-Added a geojson field with the map widget, allowing users to select a point on the map directly.

3.Modified map.jsx:

-Updated the GraphQL query to fetch the geojson field instead of latitude and longitude.
-Parsed the geojson string to extract coordinates and render map markers.

4.Script to Migrate Existing Data:

-Added a script (convertToGeoJSON.js) to migrate existing latitude and longitude values to the geojson field in all index.yaml files.

Impact :

1.Simplified Data Structure: The geojson field serves as a single source of truth for map data, reducing redundancy and potential inconsistencies.

2.Alignment with Decap CMS: The changes align with Decap CMS's map widget, which expects spatial data in GeoJSON format.

3.Improved User Experience: Users can now select a point on the map directly in the admin interface, making it easier to input and manage map data.

Testing

  • Verified that the map markers render correctly on the user stories map page.
  • Confirmed backward compatibility by ensuring existing latitude and longitude values were successfully migrated to geojson.

Please review it and let me know for improvements .

@biru-codeastromer
Copy link
Contributor Author

biru-codeastromer commented Jan 30, 2025

I have raised the PR with a brand new approach with no new extra geojson fields files !

Eagerly awaiting feedbacks . Thanks !

@biru-codeastromer
Copy link
Contributor Author

I have resolved the conflicts in the meantime here.

Copy link
Member

@krisstern krisstern left a comment

Choose a reason for hiding this comment

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

Could you please tell me why you need to commit a convertToGeoJSON.js script for the repo? If this is for automation, you can keep it locally and need not submit it with the rest of the PR.

Copy link
Member

@krisstern krisstern left a comment

Choose a reason for hiding this comment

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

Could you also undo the unrelated formatting changes introduced to the YAML files in this PR?

@biru-codeastromer
Copy link
Contributor Author

Could you please tell me why you need to commit a convertToGeoJSON.js script for the repo? If this is for automation, you can keep it locally and need not submit it with the rest of the PR.

Yes it was for it . I will be updating it now .

@biru-codeastromer
Copy link
Contributor Author

Could you also undo the unrelated formatting changes introduced to the YAML files in this PR?

Sure !

@biru-codeastromer
Copy link
Contributor Author

I will be making the changes along with resolving the conflicts . Thanks !

@biru-codeastromer
Copy link
Contributor Author

Could you also undo the unrelated formatting changes introduced to the YAML files in this PR?

Hello Sir, I’ve corrected the formatting of the YAML files. Actually , the js-yaml library was reformatting the YAML files when it writes them back, so I used a regex to find and modify the map section .

Please review the changes. Thank you!

@biru-codeastromer
Copy link
Contributor Author

biru-codeastromer commented Feb 4, 2025

Hi Sir, I wanted to know your feedback if my approach this time is better than the previous .

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.

Metadata -> Convert latitude / longitude to geojson
2 participants