From c5e92c511c488c6293d42e53a8f32766bb9de947 Mon Sep 17 00:00:00 2001 From: mozman Date: Wed, 6 Mar 2024 10:48:17 +0100 Subject: [PATCH] use wgs84 converter functions from ezdxf.math --- src/ezdxf/addons/drawing/json.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/ezdxf/addons/drawing/json.py b/src/ezdxf/addons/drawing/json.py index 53c2b73d0..1aa0a3508 100644 --- a/src/ezdxf/addons/drawing/json.py +++ b/src/ezdxf/addons/drawing/json.py @@ -5,9 +5,8 @@ from typing_extensions import TypeAlias, override import abc import json -import math -from ezdxf.math import Vec2 +from ezdxf.math import Vec2, world_mercator_to_gps from ezdxf.path import Command, nesting from ezdxf.npshapes import orient_paths, single_paths @@ -340,7 +339,7 @@ def no_transform(location: Vec2) -> tuple[float, float]: return (location.x, location.y) -def make_function_wgs84_3395_to_4326(tol: float = 1e-6) -> TransformFunc: +def make_world_mercator_to_gps_function(tol: float = 1e-6) -> TransformFunc: """Returns a function to transform WGS84 World Mercator `EPSG:3395 `_ location given as cartesian 2D coordinates x, y in meters into WGS84 decimal degrees as longitude and latitude `EPSG:4326 `_ as @@ -350,14 +349,10 @@ def make_function_wgs84_3395_to_4326(tol: float = 1e-6) -> TransformFunc: tol: accuracy for latitude calculation """ - from ezdxf.addons.geo import wgs84_3395_to_4326 - from ezdxf.math import Vec3 def _transform(location: Vec2) -> tuple[float, float]: """Transforms WGS84 World Mercator EPSG:3395 coordinates to WGS84 EPSG:4326.""" - result = wgs84_3395_to_4326(Vec3(location), tol) - return result.x, result.y - + return world_mercator_to_gps(location.x, location.y, tol) return _transform @@ -380,10 +375,10 @@ class GeoJSONBackend(_JSONBackend): .. autofunction:: no_transform Factory function to make a transform function from WGS84 World Mercator - `EPSG:3395 `_ coordinates to WGS84 `EPSG:4326 `_, - uses the converter function from the :mod:`ezdxf.addons.geo` add-on. + `EPSG:3395 `_ coordinates to WGS84 (GPS) + `EPSG:4326 `_. - .. autofunction:: make_function_wgs84_3395_to_4326 + .. autofunction:: make_world_mercator_to_gps_function The GeoJSON format supports only straight lines so curved shapes are flattened to polylines and polygons.