Hi, I wrote a patch for the python interface to support Python3. It seems to work both on python3.3 and 2.7.
Best, Amato
diff --git python/geographiclib/geodesic.py python/geographiclib/geodesic.py index 1b6509e..a6ad9c1 100644 --- python/geographiclib/geodesic.py +++ python/geographiclib/geodesic.py @@ -65,9 +65,9 @@ class Geodesic(object): nA3_ = GEOGRAPHICLIB_GEODESIC_ORDER nA3x_ = nA3_ nC3_ = GEOGRAPHICLIB_GEODESIC_ORDER - nC3x_ = (nC3_ * (nC3_ - 1)) / 2 + nC3x_ = (nC3_ * (nC3_ - 1)) // 2 nC4_ = GEOGRAPHICLIB_GEODESIC_ORDER - nC4x_ = (nC4_ * (nC4_ + 1)) / 2 + nC4x_ = (nC4_ * (nC4_ + 1)) // 2 maxit1_ = 20 maxit2_= maxit1_ + Math.digits + 10 @@ -270,9 +270,9 @@ class Geodesic(object): raise ValueError("Major radius is not positive") if not(Math.isfinite(self._b) and self._b > 0): raise ValueError("Minor radius is not positive") - self._A3x = range(Geodesic.nA3x_) - self._C3x = range(Geodesic.nC3x_) - self._C4x = range(Geodesic.nC4x_) + self._A3x = list(range(Geodesic.nA3x_)) + self._C3x = list(range(Geodesic.nC3x_)) + self._C4x = list(range(Geodesic.nC4x_)) self.A3coeff() self.C3coeff() self.C4coeff() @@ -683,9 +683,9 @@ class Geodesic(object): # real a12, sig12, calp1, salp1, calp2, salp2 # index zero elements of these arrays are unused - C1a = range(Geodesic.nC1_ + 1) - C2a = range(Geodesic.nC2_ + 1) - C3a = range(Geodesic.nC3_) + C1a = list(range(Geodesic.nC1_ + 1)) + C2a = list(range(Geodesic.nC2_ + 1)) + C3a = list(range(Geodesic.nC3_)) meridian = lat1 == -90 or slam12 == 0 @@ -857,7 +857,7 @@ class Geodesic(object): A4 = Math.sq(self._a) * calp0 * salp0 * self._e2 ssig1, csig1 = Geodesic.SinCosNorm(ssig1, csig1) ssig2, csig2 = Geodesic.SinCosNorm(ssig2, csig2) - C4a = range(Geodesic.nC4_) + C4a = list(range(Geodesic.nC4_)) self.C4f(eps, C4a) B41 = Geodesic.SinCosSeries(False, ssig1, csig1, C4a, Geodesic.nC4_) B42 = Geodesic.SinCosSeries(False, ssig2, csig2, C4a, Geodesic.nC4_) diff --git python/geographiclib/geodesicline.py python/geographiclib/geodesicline.py index 37cc345..662bc63 100644 --- python/geographiclib/geodesicline.py +++ python/geographiclib/geodesicline.py @@ -80,7 +80,7 @@ class GeodesicLine(object): if self._caps & Geodesic.CAP_C1: self._A1m1 = Geodesic.A1m1f(eps) - self._C1a = range(Geodesic.nC1_ + 1) + self._C1a = list(range(Geodesic.nC1_ + 1)) Geodesic.C1f(eps, self._C1a) self._B11 = Geodesic.SinCosSeries( True, self._ssig1, self._csig1, self._C1a, Geodesic.nC1_) @@ -92,25 +92,25 @@ class GeodesicLine(object): # _B11 = -SinCosSeries(true, _stau1, _ctau1, _C1pa, nC1p_) if self._caps & Geodesic.CAP_C1p: - self._C1pa = range(Geodesic.nC1p_ + 1) + self._C1pa = list(range(Geodesic.nC1p_ + 1)) Geodesic.C1pf(eps, self._C1pa) if self._caps & Geodesic.CAP_C2: self._A2m1 = Geodesic.A2m1f(eps) - self._C2a = range(Geodesic.nC2_ + 1) + self._C2a = list(range(Geodesic.nC2_ + 1)) Geodesic.C2f(eps, self._C2a) self._B21 = Geodesic.SinCosSeries( True, self._ssig1, self._csig1, self._C2a, Geodesic.nC2_) if self._caps & Geodesic.CAP_C3: - self._C3a = range(Geodesic.nC3_) + self._C3a = list(range(Geodesic.nC3_)) geod.C3f(eps, self._C3a) self._A3c = -self._f * self._salp0 * geod.A3f(eps) self._B31 = Geodesic.SinCosSeries( True, self._ssig1, self._csig1, self._C3a, Geodesic.nC3_-1) if self._caps & Geodesic.CAP_C4: - self._C4a = range(Geodesic.nC4_) + self._C4a = list(range(Geodesic.nC4_)) geod.C4f(eps, self._C4a) # Multiplier = a^2 * e^2 * cos(alpha0) * sin(alpha0) self._A4 = Math.sq(self._a) * self._calp0 * self._salp0 * geod._e2
Anonymous
You seem to have CSS turned off. Please don't fill out this field.
Thanks. I'll incorporate this patch into the next release of GeographicLib. --Charles
This fix is included in GeographicLib version 1.31.
Hi,
I wrote a patch for the python interface to support Python3.
It seems to work both on python3.3 and 2.7.
Best,
Amato
Thanks. I'll incorporate this patch into the next release
of GeographicLib.
--Charles
This fix is included in GeographicLib version 1.31.