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DBcF|B_k@j@sM?y@UwCy@oCkAgB_AaAiAu@aBk@uDWoG`AyBEs@QcEqAcViK_\oJchAkZmDyAe@o@w@eBiE}PY{ETqG|@iJnQyhARcD?{Es@oFaCoHsDwNGiA_A{CgDuFyCmFy@m@kAIiAJc@FWZkAc@kGmAuIiCY|A{Bq@" poly = decode_polyline(polyline_str) splits = poly.split_at_angle() splits_sum = sum(a.distance for a in splits) self.assertAlmostEqual(splits_sum, poly.distance) self.assertEqual(poly, Polyline.concat_multiple(splits))
def __snap(self, point, encoded_polyline, options, result): polyline = google_polyline.decode_polyline(encoded_polyline) #self.assertFalse(polyline.bounds.contains(point)) snap = polyline.snap_point(point, options) if result: self.assertNotEqual(snap, None) else: self.assertEqual(snap, None) return snap
import unittest import random from shapely.geometry import Point from gcs.tools.flattener import InterpolatedFlattener from math import fabs from gcs import LatLng from gcs.encoders import google_polyline poly_str = 'szkyEbma_NTWVSVSVGNAVAv@LrEnAh@F\?PETI^SRSJOHQHUH_@Dm@Ds@BkCCqBGkFIoHDsHDkGPcJB}DZqSgIIKfIMdN?XHXJRNPj@h@XZNLPXB^AxAQrIg@bOK|@iCxHu@fCk@dAsC`F' poly1 = google_polyline.decode_polyline(poly_str) MAX_DIFFERENCE = 100.0 class FlattenTestCase(unittest.TestCase): def _test_points(self, a, b): geo_d = a[0].distance_to(b[0]) cart_d = a[1].distance(b[1]) difference = ((geo_d - cart_d) * 100000) difference = round(difference, 4) if fabs(difference) > MAX_DIFFERENCE: print '%s -> %s' % (a[0], b[0]) print 'Correct Distance: %fkm' % geo_d print 'Interpolated Distance: %fkm' % cart_d print 'Difference: %.4fcm' % difference self.assertTrue(fabs(difference) <= MAX_DIFFERENCE)
import unittest import random from shapely.geometry import Point from gcs.tools.flattener import InterpolatedFlattener from math import fabs from gcs import LatLng from gcs.encoders import google_polyline poly_str = 'szkyEbma_NTWVSVSVGNAVAv@LrEnAh@F\?PETI^SRSJOHQHUH_@Dm@Ds@BkCCqBGkFIoHDsHDkGPcJB}DZqSgIIKfIMdN?XHXJRNPj@h@XZNLPXB^AxAQrIg@bOK|@iCxHu@fCk@dAsC`F' poly1 = google_polyline.decode_polyline(poly_str) MAX_DIFFERENCE = 100.0 class FlattenTestCase(unittest.TestCase): def _test_points(self, a, b): geo_d = a[0].distance_to(b[0]) cart_d = a[1].distance(b[1]) difference = ((geo_d - cart_d) * 100000) difference = round(difference, 4) if fabs(difference) > MAX_DIFFERENCE: print '%s -> %s' % (a[0], b[0]) print 'Correct Distance: %fkm' % geo_d print 'Interpolated Distance: %fkm' % cart_d print 'Difference: %.4fcm' % difference