Nikhil Singh commited on
Commit
8f1daaf
·
1 Parent(s): 8f62e6d

fixed issues related to incorrect call

Browse files
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
src/trackemdown/__pycache__/__init__.cpython-310.pyc DELETED
Binary file (255 Bytes)
 
src/trackemdown/__pycache__/main.cpython-310.pyc DELETED
Binary file (2.08 kB)
 
src/trackemdown/__pycache__/models.cpython-310.pyc DELETED
Binary file (930 Bytes)
 
src/trackemdown/core.py CHANGED
@@ -4,7 +4,7 @@ import re
4
  from typing import List
5
  import httpx
6
  import h3
7
- from .models import GeotagResult
8
 
9
  # Regex for validating "latitude,longitude" input
10
  COORD_REGEX = re.compile(r"^-?([1-8]?[0-9]|[1-9]0)\.{1}\d{1,15}\s*,\s*-?([1]?[0-7]?[0-9]|[1]?[1-8]?[0])\.{1}\d{1,15}$")
@@ -26,7 +26,7 @@ class NoResultsFoundError(GeotaggingError):
26
  pass
27
 
28
 
29
- async def fetch_geotags(q: str, resolution: int) -> List[GeotagResult]:
30
  """
31
  Fetches geotag information for a given query string (address or lat,lng).
32
 
@@ -35,7 +35,7 @@ async def fetch_geotags(q: str, resolution: int) -> List[GeotagResult]:
35
  resolution: The H3 resolution (0-15).
36
 
37
  Returns:
38
- A list of GeotagResult objects.
39
 
40
  Raises:
41
  InvalidCoordinatesError: If the input coordinates are malformed.
@@ -76,7 +76,7 @@ async def fetch_geotags(q: str, resolution: int) -> List[GeotagResult]:
76
  lat, lon = float(loc['lat']), float(loc['lon'])
77
  geotag = h3.latlng_to_cell(lat, lon, resolution)
78
  results.append(
79
- GeotagResult(
80
  address=loc.get('display_name', 'N/A'),
81
  latitude=lat,
82
  longitude=lon,
 
4
  from typing import List
5
  import httpx
6
  import h3
7
+ from .models import GeoTagResult
8
 
9
  # Regex for validating "latitude,longitude" input
10
  COORD_REGEX = re.compile(r"^-?([1-8]?[0-9]|[1-9]0)\.{1}\d{1,15}\s*,\s*-?([1]?[0-7]?[0-9]|[1]?[1-8]?[0])\.{1}\d{1,15}$")
 
26
  pass
27
 
28
 
29
+ async def fetch_geotags(q: str, resolution: int) -> List[GeoTagResult]:
30
  """
31
  Fetches geotag information for a given query string (address or lat,lng).
32
 
 
35
  resolution: The H3 resolution (0-15).
36
 
37
  Returns:
38
+ A list of GeoTagResult objects.
39
 
40
  Raises:
41
  InvalidCoordinatesError: If the input coordinates are malformed.
 
76
  lat, lon = float(loc['lat']), float(loc['lon'])
77
  geotag = h3.latlng_to_cell(lat, lon, resolution)
78
  results.append(
79
+ GeoTagResult(
80
  address=loc.get('display_name', 'N/A'),
81
  latitude=lat,
82
  longitude=lon,
src/trackemdown/main.py CHANGED
@@ -1,7 +1,7 @@
1
  """FastAPI application for the Geotagging Service."""
2
 
3
  from fastapi import FastAPI, HTTPException, Query
4
- from .models import GeotagResponse
5
  from .core import fetch_geotags, NoResultsFoundError, GeocodingServiceError, InvalidCoordinatesError
6
 
7
  app = FastAPI(
@@ -12,7 +12,7 @@ app = FastAPI(
12
 
13
  @app.get(
14
  "/geotag",
15
- response_model=GeotagResponse,
16
  summary="Get H3 geotag for an address or coordinates",
17
  tags=["Geotagging"],
18
  )
@@ -29,10 +29,10 @@ async def get_geotag(
29
  """
30
  try:
31
  results = await fetch_geotags(q, resolution)
32
- return GeotagResponse(
33
  query=q,
34
  resolution=resolution,
35
- results=results,
36
  )
37
  except InvalidCoordinatesError as e:
38
  raise HTTPException(status_code=400, detail=str(e))
 
1
  """FastAPI application for the Geotagging Service."""
2
 
3
  from fastapi import FastAPI, HTTPException, Query
4
+ from .models import GeoTagResponse
5
  from .core import fetch_geotags, NoResultsFoundError, GeocodingServiceError, InvalidCoordinatesError
6
 
7
  app = FastAPI(
 
12
 
13
  @app.get(
14
  "/geotag",
15
+ response_model=GeoTagResponse,
16
  summary="Get H3 geotag for an address or coordinates",
17
  tags=["Geotagging"],
18
  )
 
29
  """
30
  try:
31
  results = await fetch_geotags(q, resolution)
32
+ return GeoTagResponse(
33
  query=q,
34
  resolution=resolution,
35
+ result=results,
36
  )
37
  except InvalidCoordinatesError as e:
38
  raise HTTPException(status_code=400, detail=str(e))