diff --git a/src/api/geo/serializers.py b/src/api/geo/serializers.py index 5a0aed9b..eb0f6bbe 100644 --- a/src/api/geo/serializers.py +++ b/src/api/geo/serializers.py @@ -4,8 +4,6 @@ from .models import * from drf_spectacular.utils import extend_schema_serializer, OpenApiExample from django.core.exceptions import ObjectDoesNotExist -from drf_writable_nested.serializers import WritableNestedModelSerializer -from drf_writable_nested.mixins import UniqueFieldsMixin class CRUDLocationTypeSerializer(serializers.ModelSerializer): class Meta: diff --git a/src/api/requirements.txt b/src/api/requirements.txt index 2d922086..bd387f37 100644 --- a/src/api/requirements.txt +++ b/src/api/requirements.txt @@ -20,7 +20,6 @@ django-storages==1.13.2 django-tinymce==3.6.1 djangorestframework==3.14.0 drf-spectacular==0.26.5 -drf-writable-nested==0.7.0 drf-yasg==1.21.7 feedparser==6.0.10 Flask==2.3.2 diff --git a/src/api/voyages3/urls.py b/src/api/voyages3/urls.py index d19fcfbc..84678e75 100644 --- a/src/api/voyages3/urls.py +++ b/src/api/voyages3/urls.py @@ -25,7 +25,7 @@ from django.views.generic import TemplateView urlpatterns = [ - path('admin/', admin.site.urls), +# path('admin/', admin.site.urls), path('tinymce/', include('tinymce.urls')), path('voyage/',include('voyage.urls')), path('timelapse/',include('timelapse.urls')), @@ -36,7 +36,7 @@ path('blog/',include('blog.urls')), path('common/',include('common.urls')), path('captcha/', include('captcha.urls')), - path('filebrowser/', site.urls), +# path('filebrowser/', site.urls), path('tinymce/', site.urls), re_path(r'^_nested_admin/', include('nested_admin.urls')), path('schema/', SpectacularAPIView.as_view(), name='schema'), diff --git a/src/geo-networks/maps/all_routes.js b/src/geo-networks/maps/all_routes.js index dca45367..272b47b3 100644 --- a/src/geo-networks/maps/all_routes.js +++ b/src/geo-networks/maps/all_routes.js @@ -144,7 +144,7 @@ var routeNodes = [ new L.LatLng(42.52069952914966, -70.048828125), new L.LatLng(40.896905775860006, -71.707763671875), new L.LatLng(26.745610382199022, -20.7421875), - new L.LatLng(32.48196313217176, -16.7431640625), + new L.LatLng(29.84064389983441, -17.358398437500004), new L.LatLng(15.749962572748768, -20.2587890625), new L.LatLng(12.254127737657381, -19.2041015625), new L.LatLng(36.659606226479696, -9.20654296875), @@ -1047,4 +1047,6 @@ var links = [ { start: 315, end: 317 }, { start: 317, end: 193 }, { start: 193, end: 318 }, + { start: 148, end: 69 }, + { start: 150, end: 69 }, ]; \ No newline at end of file diff --git a/src/geo-networks/maps/ao_routes.js b/src/geo-networks/maps/ao_routes.js index e17ce477..6c98b78a 100644 --- a/src/geo-networks/maps/ao_routes.js +++ b/src/geo-networks/maps/ao_routes.js @@ -26,7 +26,7 @@ var routeNodes = [ new L.LatLng(1.537901237431487, 3.8232421875000004), new L.LatLng(28.806173508854776, -88.76953125), new L.LatLng(3.0746950723696944, -1.2744140625000002), - new L.LatLng(37.38761749978395, -73.67431640625001), + new L.LatLng(36.56260003738548, -73.67431640625001), new L.LatLng(37.30027528134433, -65.83443968658294), new L.LatLng(23.120153621695614, -86.00097656250001), new L.LatLng(18.104087015773956, -84.28710937500001), @@ -36,6 +36,8 @@ var routeNodes = [ new L.LatLng(20.159098270646936, -69.71923828125001), new L.LatLng(19.02057711096681, -65.41259765625001), new L.LatLng(16.90968361555865, -60.73242187500001), + new L.LatLng(37.84015683604136, -74.09179687500001), + new L.LatLng(40.84706035607122, -71.67480468750001), ]; var links = [ { start: 6, end: 7 }, @@ -84,4 +86,8 @@ var links = [ { start: 20, end: 35 }, { start: 10, end: 36 }, { start: 10, end: 33 }, + { start: 37, end: 27 }, + { start: 27, end: 37 }, + { start: 27, end: 38 }, + { start: 38, end: 27 }, ]; \ No newline at end of file diff --git a/src/geo-networks/utils.py b/src/geo-networks/utils.py index 0878a951..ed78ae54 100644 --- a/src/geo-networks/utils.py +++ b/src/geo-networks/utils.py @@ -241,6 +241,14 @@ def getclosestneighbor(G,thisnode_id,comp_nodes_ids): closest_neighbor_distance,closest_neighbor_id=sorted_distances[0] return closest_neighbor_id,closest_neighbor_distance +def straightab(A,B,ab_id,result): + midx=(A[0]+B[0])/2 + midy=(A[1]+B[1])/2 + Control=(midx,midy) + result[ab_id]=[[[A, B], [Control, Control]]] + isstraight=True + return result,Control + def curvedab(A,B,C,prev_controlXY,smoothing=0.15): # print("curving-->",A,B,C,prev_controlXY) ## this function takes 4 xy points (the first [prev] or last [C] being nullable) @@ -248,6 +256,7 @@ def curvedab(A,B,C,prev_controlXY,smoothing=0.15): ## why this way? because splines that look forward and back not just to points ## but to control points are much, much smoother # print("curving",A,B,C,prev_controlXY) + overshoot_corrected=False if prev_controlXY is None: #first edge ControlX = B[0] + smoothing*(A[0]-C[0]) @@ -256,8 +265,10 @@ def curvedab(A,B,C,prev_controlXY,smoothing=0.15): nextControl=Control else: #last edge + lastedge=False if C is None: C=B + lastedge=True #all tother edges prev_ControlX,prev_ControlY=prev_controlXY ControlX = A[0]*2 - prev_ControlX @@ -266,7 +277,30 @@ def curvedab(A,B,C,prev_controlXY,smoothing=0.15): next_ControlY = B[1] + smoothing*(A[1]-C[1]) Control=[ControlX,ControlY] nextControl=[next_ControlX,next_ControlY] - return Control,nextControl + +# if lastedge: + #we're getting gross overshoots on our end nodes in some cases (like Annapolis and Madeira) + #can't quite pin down why + #so we're going to flatten those down + dist_A_to_Control=geteuclideandistance(A[1],A[0],Control[1],Control[0]) + dist_A_to_nextControl=geteuclideandistance(A[1],A[0],nextControl[1],nextControl[0]) + dist_A_to_B=geteuclideandistance(A[1],A[0],B[1],B[0]) + mid=[(A[0]+B[0])/2,(A[1]+B[1])/2] + dist_A_to_mid=geteuclideandistance(A[1],A[0],mid[1],mid[0]) + + if dist_A_to_B < max([dist_A_to_Control,dist_A_to_nextControl]): + overshoot_corrected=True + if dist_A_to_nextControl < dist_A_to_B: + Control=nextControl + elif dist_A_to_Control < dist_A_to_B: + nextControl=Control + else: + Control=mid + nextControl=mid + + + + return Control,nextControl,overshoot_corrected def straightab(A,B,ab_id,result): midx=(A[0]+B[0])/2 @@ -351,6 +385,8 @@ def weightedaverage_tuple(controlpoints): finalYb=numeratorYb/denominator return [[finalXa,finalYa],[finalXb,finalYb]] +overshoots_corrected=[] + def spline_curves(nodes,edges,paths,G): for path in paths: pathnodes=path['nodes'] @@ -367,7 +403,14 @@ def spline_curves(nodes,edges,paths,G): Axy=retrieve_nodeXY(A) Bxy=retrieve_nodeXY(B) Cxy=retrieve_nodeXY(C) - this_control,next_control=curvedab(Axy,Bxy,Cxy,prev_controlXY) + this_control,next_control,overshoot_corrected=curvedab(Axy,Bxy,Cxy,prev_controlXY) + if overshoot_corrected: + Aname=A['data'].get('name') + Bname=B['data'].get('name') + if Aname not in overshoots_corrected and Bname not in overshoots_corrected: + print('OVERSHOOT CORRECTED ON',Aname,Bname) + overshoots_corrected.append(Aname) + overshoots_corrected.append(Bname) edge_id=[A_id,B_id] edges=add_edge_topathdict(edges,edge_id,this_control,next_control,pathweight) prev_controlXY=next_control @@ -379,8 +422,17 @@ def spline_curves(nodes,edges,paths,G): Bxy=retrieve_nodeXY(B) A_id=str(A['id']) B_id=str(B['id']) - this_control,next_control=curvedab(Axy,Bxy,C,prev_controlXY) + this_control,next_control,overshoot_corrected=curvedab(Axy,Bxy,C,prev_controlXY) + if overshoot_corrected: + Aname=A['data'].get('name') + Bname=B['data'].get('name') + if Aname not in overshoots_corrected and Bname not in overshoots_corrected: + print('OVERSHOOT CORRECTED ON',Aname,Bname) + overshoots_corrected.append(Aname) + overshoots_corrected.append(Bname) + edge_id=[A_id,B_id] + edges=add_edge_topathdict(edges,edge_id,this_control,next_control,pathweight) elif len(pathnodes)==2: