From 29a8aae078f881a6c78689d62b58e422e1bfc435 Mon Sep 17 00:00:00 2001 From: genthalili Date: Sun, 30 Oct 2022 15:25:25 +0100 Subject: [PATCH] v1.0.8 --- CHANGELOG.txt | 8 +- README.md | 17 + searoute/__pycache__/searoute.cpython-310.pyc | Bin 3623 -> 4046 bytes searoute/data/marnet_densified_old.json | 3606 ----------------- searoute/data/marnet_densified_old2.json | 1 - searoute/data/marnet_densified_v2.geojson | 2 +- searoute/data/marnet_densified_v2_old.geojson | 1 + searoute/searoute.py | 45 +- setup.py | 2 +- test.py | 4 +- 10 files changed, 69 insertions(+), 3617 deletions(-) delete mode 100644 searoute/data/marnet_densified_old.json delete mode 100644 searoute/data/marnet_densified_old2.json create mode 100644 searoute/data/marnet_densified_v2_old.geojson diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ac8377a..2e9c3a3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -27,4 +27,10 @@ Change Log 1.0.7 (13/10/2022) ------------------ - Imporved network connectivity -- Connection points were not adjusted \ No newline at end of file +- Connection points were not adjusted + +1.0.8 (25/10/2022) +------------------ +- Imporved network connectivity +- Added append_orig_dest parameter as input to append origin and destination points to the LineString +- Updated README.md \ No newline at end of file diff --git a/README.md b/README.md index 266bc27..3beb669 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,23 @@ routeMiles = sr.searoute(origin, destination, units="mi") ~~~ +## Parameters + +`origin` +Mandatory. An array of 2 floats representing longitude and latitude i.e : `[{lon}, {lat}]` + +`destination` +Mandatory. An array of 2 floats representing longitude and latitude i.e : `[{lon}, {lat}]` + +`units` +Optional. Default to `km` = kilometers, can be `m` = meters `mi` = miles `ft` = feets `in` = inches `deg` = degrees `cen` = centimeters `rad` = radians `naut` = nauticals `yd` = yards + +`speed_knot` +Optional. Speed of the boat, default 24 knots + +`append_orig_dest` +Optional. If the origin and destination should be appended to the LineString, default is `False` + ## Credits Based on Eurostat's [Searoute Java library](https://github.com/eurostat/searoute) and Dijkstra's algorithm implemented by [perliedman](https://www.liedman.net/geojson-path-finder/). \ No newline at end of file diff --git a/searoute/__pycache__/searoute.cpython-310.pyc b/searoute/__pycache__/searoute.cpython-310.pyc index 5403975530da8407b6d181c84e0e363128751942..32474f49274011969c42d80b2871b2e55f32a81e 100644 GIT binary patch delta 1370 zcmZ`(-)kI29G@TiV|H(E?{Xf!3k~fiwT%~rSlZY&wrJJH2a8rBv^|h;WH#yECA*io ziPbPm3dw80GWaH#dnmqIDn9#ML3}E@Ac$|Z{s$uQJJ&{};4br-na}q#^PTzb_q$(D z{CGUf%4HwH^JwSh@;68BhW8pT@CvW);&zjd@!BqGk8`|;TJ`%6uV7qxP$e~jr}PQy zgY7CtNFs@MaE>I|r$dzEtw5o!#ql`eWE?5nwK=_ruA|h$$h_P-QQBI|+DC}r)H@6i9`(o}Whr3{Np=Z!D$&{<~FIKhX?NN-Btt`%(sE5QIMU~B2 z1A)v}{%BbVdZugkxoLl-#@(_iD^FGU)A>lB+Z(4hCY8BrN%!sMkuC4awZ(Vm&zzq- zSFqJMTaTsqtkBvX;zG|kYugtfYJ=AR7-oc!CU$UueG*`XEokQTaTN!aVa&Kr&Af_z zN}gB^F$+rz(p!Jrgu%kH4S4ueVc{>SCk|GM0L&L!-7=u&#dPhN(UDS@xAq~E<>Qe__S@*d$~9pz!_0tp;QfXhRU z^NOMz!(F~pR0fLdV9-$&DtZ*<6=~8TR0I;D@+IZfJpxHE*7^CtZ|)x$$NC3vdZphH zo%N{G@5d=$%0#ld#N&aSk2;)3W}2i?C*_eLBS@BhmZWkJ0V{9C(bXi47o|wj)hJsT zF(TWP@hc!->1?jaC>cZxowY%%|MZfRlkm~SNdqqeyf3BzldA^@2amrsqg#*;;)L${ zk<&7wv-)#C!lAzJAHy^HCx0q_3FyK}(m^bwphiOs7izyPwGcOWSermr~e9O$IPfjg;^&~ z11#wI@YFE1G^YHZW z6p7HD7CSV};9D7;u{SC97!d8~aW1_gX%LlYrXA^x5KQs4-+v;Dr)OrI3rm@PIMhQO z;sZJP_uh|Bovq2OVQtIvZ}+@pn{lF^RLuvc3srN^ z-KZ^K>76qO0t6kRJ`F$s$8A3!@(}bHYoizMdGIOy$p_VGOzP3b=Jz5RHIDFqg=o0A zujB4~A!gPqZS#cGVV@>UgH;s~b?vg$L7pSav2Z5&9#7r1zHX>v0d-?_M+=k#729`p z#ww18+OEh9H?{C8U975*l2s zXqF(q0~pA3R180: + nowX = nowX+360 + ls.append((nowX, node['y'])) + previousX = nowX + + if append_orig_dest: + + if len(ls) == 1: + #to avoid strage connections remove, eventually non-ocean connections with one coord, remove it to add origin and dest + ls = [] + # add origin at fist position of the linestring + ls.insert(0, origin ) + # add destination at the last position of the linestring + nowX = destination[0] + if previousX: + if previousX-nowX<-180: + nowX = -180-(180-nowX) + elif previousX-nowX>180: + nowX = nowX+360 + ls.append((nowX, destination[1])) + lineString = LineString(ls) diff --git a/setup.py b/setup.py index d6f6bc6..ad63526 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name='searoute', - version='1.0.7', + version='1.0.8', description='A python package for generating the shortest sea route between two points on Earth.', long_description=open('README.md').read() + '\n\n' + open('CHANGELOG.txt').read(), diff --git a/test.py b/test.py index 3e66f72..385d916 100644 --- a/test.py +++ b/test.py @@ -5,7 +5,7 @@ destination = [-118.2629, 33.7276] -route = sr.searoute(origin, destination) +route = sr.searoute(origin, destination, append_orig_dest=True) # > Returns a GeoJSON LineString Feature # show route distance with unit print("{:.1f} {}".format(route.properties['length'], route.properties['units'])) @@ -15,4 +15,4 @@ # Optionally, define the units for the length calculation included in the properties object. # Defaults to km, can be can be 'm' = meters 'mi = miles 'ft' = feets 'in' = inches 'deg' = degrees # 'cen' = centimeters 'rad' = radians 'naut' = nauticals 'yd' = yards -routeMiles = sr.searoute(origin, destination, units="mi") +routeMiles = sr.searoute(origin, destination, units="mi") \ No newline at end of file