mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 04:49:37 +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
|
@ -131,10 +131,3 @@ AdventureLog is licensed under the GNU General Public License v3.0.
|
|||
|
||||
- Logo Design by [redtechtiger](https://github.com/redtechtiger)
|
||||
- WorldTravel Dataset [dr5hn/countries-states-cities-database](https://github.com/dr5hn/countries-states-cities-database)
|
||||
- [Mexico GEOJSON](https://cartographyvectors.com/map/784-mexico-with-states)
|
||||
- [Japan GEOJSON](https://cartographyvectors.com/map/361-japan)
|
||||
- [Ireland GEOJSON](https://cartographyvectors.com/map/1399-ireland-provinces)
|
||||
- [Sweden GEOJSON](https://cartographyvectors.com/map/1521-sweden-with-regions)
|
||||
- [Switzerland GEOJSON](https://cartographyvectors.com/map/1522-switzerland-with-regions)
|
||||
- [Iceland GEOJSON](https://cartographyvectors.com/map/1453-iceland-with-regions)
|
||||
- [Austria GEOJSON](https://github.com/codeforgermany/click_that_hood/blob/main/public/data/austria-states.geojson)
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
|
||||
from django.urls import include, path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import CountryViewSet, RegionViewSet, VisitedRegionViewSet, regions_by_country, visits_by_country, GeoJSONView
|
||||
from .views import CountryViewSet, RegionViewSet, VisitedRegionViewSet, regions_by_country, visits_by_country
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'countries', CountryViewSet, basename='countries')
|
||||
|
@ -12,6 +12,5 @@ router.register(r'visitedregion', VisitedRegionViewSet, basename='visitedregion'
|
|||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
path('<str:country_code>/regions/', regions_by_country, name='regions-by-country'),
|
||||
path('<str:country_code>/visits/', visits_by_country, name='visits-by-country'),
|
||||
path('geojson/', GeoJSONView.as_view({'get': 'list'}), name='geojson'),
|
||||
path('<str:country_code>/visits/', visits_by_country, name='visits-by-country')
|
||||
]
|
||||
|
|
|
@ -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