To mercator and to wgs84 function #230
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Created Two Main Functions:
Based this branch off original omercator and oWsg co-ordinate function
geoToMercator(): Transforms WGS84 coordinates to Web Mercator projection
geoToWgs84(): Converts Web Mercator coordinates back to WGS84
Implemented in Clean, Distinct Files:
lib/src/to_mercator.dart: Contains WGS84→Mercator transformation logic
lib/src/to_wgs84.dart: Contains Mercator→WGS84 transformation logic
Updated lib/transform.dart to export both functions
Full GeoJSON Support:
Both functions handle all standard GeoJSON types
Support for Position, Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon
Complete handling of Feature and FeatureCollection objects
Preservation of properties and metadata
Key Features:
Accurate mathematical transformations based on spherical Mercator formulas
Altitude preservation throughout transformations
mutate parameter for performance optimization
Comprehensive error handling and input validation
Robust type safety with appropriate casting
Testing:
Created dedicated test files for each transformation direction
Tests cover all supported GeoJSON object types
Verified round-trip accuracy
All tests passing successfully
Usage Examples:
Created example files demonstrating real-world usage
Included examples for different GeoJSON types
Demonstrated round-trip conversion accuracy