Skip to content

Commit

Permalink
feat: Return CRS on locate from coords
Browse files Browse the repository at this point in the history
  • Loading branch information
JCruiz15 committed Jun 27, 2024
1 parent eae1af2 commit 4bb2a15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions sigpac_tools/locate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def __locate_in_feature_collection(
"""
for feature in featureCollection["features"]:
if feature["properties"][layer] == reference:
transform_coords(feature)
return feature["geometry"]
projection = "epsg:4326"
transform_coords(feature, "epsg:4326")
geom = feature["geometry"]
geom["CRS"] = projection
return geom
return None


Expand Down
4 changes: 2 additions & 2 deletions sigpac_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def lng_lat_to_tile(lng: float, lat: float, zoom: float) -> tuple[int, int]:
return tx, ty


def transform_coords(feature: dict) -> None:
def transform_coords(feature: dict, projection_id: str = "epsg:4326") -> None:
"""Transforms the coordinates of the given feature from EPSG:3857 to EPSG:4326
Parameters
Expand All @@ -71,7 +71,7 @@ def transform_coords(feature: dict) -> None:
for coords in feature["geometry"]["coordinates"]:
for coord in coords:
firstProjection = 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]'
secondProjection = pyproj.Proj("epsg:4326")
secondProjection = pyproj.Proj(projection_id)
optimus_prime = pyproj.Transformer.from_proj(
firstProjection, secondProjection
)
Expand Down

0 comments on commit 4bb2a15

Please sign in to comment.