Spaces:
Running
Running
3857
Browse files
app.py
CHANGED
|
@@ -150,20 +150,16 @@ async def generate_model(request: GenerateRequest):
|
|
| 150 |
lon = centroid.x
|
| 151 |
lat = centroid.y
|
| 152 |
|
| 153 |
-
#
|
| 154 |
-
#
|
| 155 |
-
|
| 156 |
-
is_northern = lat >= 0
|
| 157 |
|
| 158 |
-
|
| 159 |
-
proj_str = f"+proj=utm +zone={utm_zone} +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
|
| 160 |
-
if not is_northern:
|
| 161 |
-
proj_str += " +south"
|
| 162 |
|
| 163 |
project = functools.partial(
|
| 164 |
pyproj.transform,
|
| 165 |
pyproj.Proj(init='epsg:4326'), # Source: WGS84
|
| 166 |
-
pyproj.Proj(
|
| 167 |
)
|
| 168 |
|
| 169 |
shape = transform(project, shape)
|
|
@@ -259,23 +255,10 @@ async def generate_model(request: GenerateRequest):
|
|
| 259 |
try:
|
| 260 |
# Create a pipeline to get factors
|
| 261 |
# We need the projection object
|
| 262 |
-
|
| 263 |
-
proj_wgs84 = pyproj.Proj(init='epsg:4326')
|
| 264 |
|
| 265 |
# Calculate convergence
|
| 266 |
-
|
| 267 |
-
# For a projection like UTM, we check at the central longitude/lat
|
| 268 |
-
# Actually get_factors works on the projection object with projected coordinates
|
| 269 |
-
# or using the transformer?
|
| 270 |
-
# Simpler way with newer pyproj:
|
| 271 |
-
# factors = proj_utm.get_factors(lon, lat) -> this expects coords in the proj logic
|
| 272 |
-
|
| 273 |
-
# Let's use the longitude to approximate or use pyproj correctly
|
| 274 |
-
# factors = pyproj.Factors ...
|
| 275 |
-
|
| 276 |
-
# Using the transformer might be complex to extract factors directly.
|
| 277 |
-
# Let's use the explicit Proj object for the calculated zone.
|
| 278 |
-
factors = proj_utm.get_factors(centroid_lon, centroid_lat)
|
| 279 |
convergence_angle = factors.meridian_convergence
|
| 280 |
logger.info(f"Calculated convergence angle: {convergence_angle} degrees")
|
| 281 |
|
|
|
|
| 150 |
lon = centroid.x
|
| 151 |
lat = centroid.y
|
| 152 |
|
| 153 |
+
# Project to Web Mercator (EPSG:3857)
|
| 154 |
+
# User requested usage of projected web mercator
|
| 155 |
+
logger.info("Projecting to Web Mercator (EPSG:3857)...")
|
|
|
|
| 156 |
|
| 157 |
+
proj_str = "epsg:3857"
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
project = functools.partial(
|
| 160 |
pyproj.transform,
|
| 161 |
pyproj.Proj(init='epsg:4326'), # Source: WGS84
|
| 162 |
+
pyproj.Proj(init='epsg:3857') # Target: Web Mercator
|
| 163 |
)
|
| 164 |
|
| 165 |
shape = transform(project, shape)
|
|
|
|
| 255 |
try:
|
| 256 |
# Create a pipeline to get factors
|
| 257 |
# We need the projection object
|
| 258 |
+
proj_target = pyproj.Proj(init='epsg:3857')
|
|
|
|
| 259 |
|
| 260 |
# Calculate convergence
|
| 261 |
+
factors = proj_target.get_factors(centroid_lon, centroid_lat)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
convergence_angle = factors.meridian_convergence
|
| 263 |
logger.info(f"Calculated convergence angle: {convergence_angle} degrees")
|
| 264 |
|