コード例 #1
0
def getEndpoint(lat1, lon1, d1, d2):
    bearing = random.uniform(0, 360)
    dist = random.uniform(d1, d2)
    radius = (d2-d1)/2
    geod = Geodesic(Constants.WGS84_a, Constants.WGS84_f)
    d = geod.Direct(lat1, lon1, bearing, dist)
    return d['lon2'], d['lat2'], radius
コード例 #2
0
def get_endpoint(lat1, lon1, bearing, d):


    geod = Geodesic(Constants.WGS84_a, Constants.WGS84_f)
    d = geod.Direct(lat1, lon1, bearing, d)#* 1852.0)

    return d['lat2'], d['lon2']
コード例 #3
0
 def Direct(self, lat1, lon1, azi1, s12, *outmask):
     '''Return the C{Direct} result.
     '''
     d = _Geodesic.Direct(self, lat1, lon1, azi1, s12, *outmask)
     return _Adict(d)
コード例 #4
0
class geodesic(Distance):
    """
    Calculate the geodesic distance between two points.

    Set which ellipsoidal model of the earth to use by specifying an
    ``ellipsoid`` keyword argument. The default is 'WGS-84', which is the
    most globally accurate model.  If ``ellipsoid`` is a string, it is
    looked up in the `ELLIPSOIDS` dictionary to obtain the major and minor
    semiaxes and the flattening. Otherwise, it should be a tuple with those
    values.  See the comments above the `ELLIPSOIDS` dictionary for
    more information.

    Example::

        >>> from geopy.distance import geodesic
        >>> newport_ri = (41.49008, -71.312796)
        >>> cleveland_oh = (41.499498, -81.695391)
        >>> print(geodesic(newport_ri, cleveland_oh).miles)
        538.390445368


    .. versionadded:: 1.13.0
    """

    ellipsoid_key = None
    ELLIPSOID = None
    geod = None

    def __init__(self, *args, **kwargs):
        self.set_ellipsoid(kwargs.pop('ellipsoid', 'WGS-84'))
        if 'iterations' in kwargs:
            warnings.warn(
                'Ignoring unused `iterations` kwarg for geodesic '
                'distance.', UserWarning)
        kwargs.pop('iterations', 0)
        major, minor, f = self.ELLIPSOID
        super(geodesic, self).__init__(*args, **kwargs)

    def set_ellipsoid(self, ellipsoid):
        """
        Change the ellipsoid used in the calculation.
        """
        if not isinstance(ellipsoid, (list, tuple)):
            try:
                self.ELLIPSOID = ELLIPSOIDS[ellipsoid]
                self.ellipsoid_key = ellipsoid
            except KeyError:
                raise Exception(
                    "Invalid ellipsoid. See geopy.distance.ELLIPSOIDS")
        else:
            self.ELLIPSOID = ellipsoid
            self.ellipsoid_key = None
        return

    # Call geographiclib routines for measure and destination
    def measure(self, a, b):
        a, b = Point(a), Point(b)
        lat1, lon1 = a.latitude, a.longitude
        lat2, lon2 = b.latitude, b.longitude

        if not (isinstance(self.geod, Geodesic) and self.geod.a
                == self.ELLIPSOID[0] and self.geod.f == self.ELLIPSOID[2]):
            self.geod = Geodesic(self.ELLIPSOID[0], self.ELLIPSOID[2])

        s12 = self.geod.Inverse(lat1, lon1, lat2, lon2,
                                Geodesic.DISTANCE)['s12']

        return s12

    def destination(self, point, bearing, distance=None):
        """
        TODO docs.
        """
        point = Point(point)
        lat1 = point.latitude
        lon1 = point.longitude
        azi1 = bearing

        if distance is None:
            distance = self
        if isinstance(distance, Distance):
            distance = distance.kilometers

        if not (isinstance(self.geod, Geodesic) and self.geod.a
                == self.ELLIPSOID[0] and self.geod.f == self.ELLIPSOID[2]):
            self.geod = Geodesic(self.ELLIPSOID[0], self.ELLIPSOID[2])

        r = self.geod.Direct(lat1, lon1, azi1, distance,
                             Geodesic.LATITUDE | Geodesic.LONGITUDE)

        return Point(r['lat2'], r['lon2'])
コード例 #5
0
 def test_GeodSolve28(self):
     # Check for bad placement of assignment of r.a12 with |f| > 0.01 (bug in
     # Java implementation fixed on 2015-05-19).
     geod = Geodesic(6.4e6, 0.1)
     dir = geod.Direct(1, 2, 10, 5e6)
     self.assertAlmostEqual(dir["a12"], 48.55570690, delta=0.5e-8)
コード例 #6
0
 def test_GeodSolve15(self):
     # Initial implementation of Math::eatanhe was wrong for e^2 < 0.  This
     # checks that this is fixed.
     geod = Geodesic(6.4e6, -1 / 150.0)
     dir = geod.Direct(1, 2, 3, 4, Geodesic.AREA)
     self.assertAlmostEqual(dir["S12"], 23700, delta=0.5)
コード例 #7
0
                           longg[i])['s12']

        if A1 < 0:
            Az1 = 360 + A1 + 23.2
            Az2 = Az1 + 66.8 + 66.8
            Az3 = Az2 + 23.2 + 23.2
            Az4 = Az3 + 66.8 + 66.8
        else:
            Az1 = 23.2 + A1
            Az2 = Az1 + 66.8 + 66.8
            Az3 = Az2 + 23.2 + 23.2
            Az4 = Az3 + 66.8 + 66.8

        # Calcular as latitudes e longitudes dos vértices das células ---------------------------------------------------------------

        la1 = geod.Direct(latii[i - 1], longg[i - 1], Az1,
                          d_meio_borda * 1000)['lat2']
        lo1 = geod.Direct(latii[i - 1], longg[i - 1], Az1,
                          d_meio_borda * 1000)['lon2'] + 360

        la2 = geod.Direct(latii[i - 1], longg[i - 1], Az2,
                          d_meio_borda * 1000)['lat2']
        lo2 = geod.Direct(latii[i - 1], longg[i - 1], Az2,
                          d_meio_borda * 1000)['lon2'] + 360

        la3 = geod.Direct(latii[i - 1], longg[i - 1], Az3,
                          d_meio_borda * 1000)['lat2']
        lo3 = geod.Direct(latii[i - 1], longg[i - 1], Az3,
                          d_meio_borda * 1000)['lon2'] + 360

        la4 = geod.Direct(latii[i - 1], longg[i - 1], Az4,
                          d_meio_borda * 1000)['lat2']
コード例 #8
0
            else:
                raise ValueError(
                    "Apparently neither an airplane or ship hauled this special magnetometer check your track_type"
                )

            if row["quality"] != "g":
                if row["track_type"] == 'ship': pcol = "lightgrey"
                elif row["track_type"] == 'aero': pcol = "plum"
                alpha, fill_alpha = .5, .2
            else:
                alpha, fill_alpha = 1., .5

            # Project amplitude onto map
            mlats, mlons, fill_lats = [], [], []
            for i in range(len(mag)):
                gdsc = geod.Direct(lat[i], lon[i], perp, mag[i] * scle)
                mlons.append(gdsc['lon2'])
                mlats.append(gdsc['lat2'])
                if mag[i] > 0: fill_lats.append(gdsc['lat2'])
                else: fill_lats.append(gdsc['lat1'])

            # Plot map elements
            geotrack = proj.transform_points(
                ccrs.PlateCarree(), np.array(utl.convert_to_0_360(lon)),
                np.array(lat))
            magtrack = proj.transform_points(
                ccrs.PlateCarree(), np.array(utl.convert_to_0_360(mlons)),
                np.array(mlats))
            filltrack = proj.transform_points(
                ccrs.PlateCarree(), np.array(utl.convert_to_0_360(mlons)),
                np.array(fill_lats))
コード例 #9
0
    def get_geopoints(self, address, query):

        # Get lat and long for input address
        geolocator = Nominatim(user_agent="a")
        location = geolocator.geocode(address)
        lat1 = location.latitude
        lon1 = location.longitude

        # Generate 13 x 13 endpoints, 169 total
        geod = Geodesic(Constants.WGS84_a, Constants.WGS84_f)
        lst = [(lat1, lon1)]
        for b in [0, 90, 180, 170]:

            for x in range(0, 6):

                d = geod.Direct(lat1, lon1, b, self.d)
                lst.append((d['lat2'], d['lon2']))
                lat1, lon1 = d['lat2'], d['lon2']
                lat2, lon2 = d['lat2'], d['lon2']

                for y in range(0, 6):

                    d = geod.Direct(lat2, lon2, b + 90, self.d)
                    lst.append((d['lat2'], d['lon2']))
                    lat2 = d['lat2']
                    lon2 = d['lon2']

        print(lst)

        # Input lat and long points
        self.driver.get(self.domain)

        for latlon in lst:

            WebDriverWait(self.driver, 30).until(
                EC.visibility_of_element_located(
                    (By.XPATH, "(//input[@class='tactile-searchbox-input'])[1]"
                     ))).send_keys(str(latlon))
            time.sleep(1)

            self.driver.find_element_by_xpath(
                "//div[@class='searchbox-searchbutton-container']/button"
            ).click()
            time.sleep(3)

            WebDriverWait(self.driver, 30).until(
                EC.visibility_of_element_located(
                    (By.XPATH, "(//input[@class='tactile-searchbox-input'])[1]"
                     ))).clear()
            time.sleep(1)

            # input query, click, zoom in 3x

            WebDriverWait(self.driver, 30).until(
                EC.visibility_of_element_located(
                    (By.XPATH, "(//input[@class='tactile-searchbox-input'])[1]"
                     ))).send_keys(query)
            time.sleep(1)

            self.driver.find_element_by_xpath(
                "//div[@class='searchbox-searchbutton-container']/button"
            ).click()
            time.sleep(3)

            # self.driver.find_element_by_xpath("//div[@jsaction='blur:zoom.onZoomInOrTooltipBlur']/button").click()
            # time.sleep(1)
            # self.driver.find_element_by_xpath("//div[@jsaction='blur:zoom.onZoomInOrTooltipBlur']/button").click()
            # time.sleep(1)
            # self.driver.find_element_by_xpath("//div[@jsaction='blur:zoom.onZoomInOrTooltipBlur']/button").click()
            # time.sleep(1)

            # # Search this area
            # self.driver.find_element_by_xpath("//div[@class='widget-search-this-area widget-search-this-area-visible']/button").click()
            # time.sleep(3)

            # WebDriverWait(self.driver,30).until(EC.visibility_of_element_located((By.XPATH, "(//input[@class='tactile-searchbox-input'])[1]"))).clear()
            # time.sleep(1)

            a = self.driver.find_element_by_xpath(
                "//div[@class='section-layout section-scrollbox scrollable-y scrollable-show section-layout-flex-vertical']/div"
            )
            vendors = a.find_elements_by_xpath(
                "//h3[@class='section-result-title']")
            for x, y in enumerate(vendors):
                print(x)
                print(y.text)
            time.sleep(10)
コード例 #10
0
def getEndpoint(lat1, lon1, brng, d):
    geod = Geodesic(Constants.WGS84_a, Constants.WGS84_f)
    d = geod.Direct(lat1, lon1, brng, d)
    return {'lat': d['lat2'], 'lng': d['lon2']}