mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 03:35:18 +02:00
Remove unused GeoJSONView and related URL path; clean up README links
This commit is contained in:
parent
3df124b250
commit
7988ba4d68
15 changed files with 3 additions and 251909 deletions
|
@ -94,39 +94,4 @@ class VisitedRegionViewSet(viewsets.ModelViewSet):
|
|||
serializer.is_valid(raise_exception=True)
|
||||
self.perform_create(serializer)
|
||||
headers = self.get_success_headers(serializer.data)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
||||
|
||||
|
||||
class GeoJSONView(viewsets.ViewSet):
|
||||
"""
|
||||
Combine all GeoJSON data from .json files in static/data into a single GeoJSON object.
|
||||
"""
|
||||
def list(self, request):
|
||||
combined_geojson = {
|
||||
"type": "FeatureCollection",
|
||||
"features": []
|
||||
}
|
||||
|
||||
# Use Django's static file finder to locate the 'data' directory
|
||||
data_dir = finders.find('data')
|
||||
|
||||
if not data_dir or not os.path.isdir(data_dir):
|
||||
return Response({"error": "Data directory does not exist."}, status=404)
|
||||
|
||||
for filename in os.listdir(data_dir):
|
||||
if filename.endswith('.json'):
|
||||
file_path = os.path.join(data_dir, filename)
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
json_data = json.load(f)
|
||||
# Check if the JSON data is GeoJSON
|
||||
if isinstance(json_data, dict) and "type" in json_data:
|
||||
if json_data["type"] == "FeatureCollection":
|
||||
combined_geojson["features"].extend(json_data.get("features", []))
|
||||
elif json_data["type"] == "Feature":
|
||||
combined_geojson["features"].append(json_data)
|
||||
# You can add more conditions here for other GeoJSON types if needed
|
||||
except (IOError, json.JSONDecodeError) as e:
|
||||
return Response({"error": f"Error reading file {filename}: {str(e)}"}, status=500)
|
||||
|
||||
return Response(combined_geojson)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
Loading…
Add table
Add a link
Reference in a new issue