Exemplo n.º 1
0
def generate_location(eclipse_path_data):
    points = eclipse_gis.load_stripped_data(
        open(eclipse_path_data).readlines())
    boundary, center = eclipse_gis.generate_polygon(points)
    eg = eclipse_gis.EclipseGIS(boundary, center)
    p = eg.get_random_point_in_polygon()
    return p
Exemplo n.º 2
0
    def __init__(self, datastore_client, storage_client):
        self.datastore = datastore_client
        self.storage = storage_client

        times, points = eclipse_gis.load_stripped_data(
            open("/app/data/eclipse_data.txt").readlines())
        boundary, center_line = eclipse_gis.generate_polygon(points)
        self.eclipse_gis = eclipse_gis.EclipseGIS(boundary, center_line)
Exemplo n.º 3
0
def generate_grid(eclipse_path_data,
                  us_map_polygon,
                  outside=False,
                  umbra_boundary_buffer_size=1.5,
                  x_count=75,
                  y_count=125):
    """Generate a grid of locations within or around the eclipse path.  If
    outside=False, the grid points are within the eclipse path.  If
    outside=True, the grid points are in a buffer region around the
    eclipse path.  umbra_boundary_buffer_size defines the buffer.
    x_count and y_count define the number of points in the grid (the
    full grid covers the bounding box of the United states).
    """
    times, points = eclipse_gis.load_stripped_data(
        open(eclipse_path_data).readlines())
    boundary, center = eclipse_gis.generate_polygon(points)
    eg = eclipse_gis.EclipseGIS(boundary, center)

    # TODO(dek) use shapely to compute the BB
    min_x = min([item[0] for item in us_map_polygon.exterior.coords])
    min_y = min([item[1] for item in us_map_polygon.exterior.coords])
    max_x = max([item[0] for item in us_map_polygon.exterior.coords])
    max_y = max([item[1] for item in us_map_polygon.exterior.coords])

    # Create a grid of candidate points covering the US
    x_range = np.linspace(min_x, max_x, x_count)
    y_range = np.linspace(min_y, max_y, y_count)
    cp = cartesian_product2([x_range, y_range])
    p = []

    # Create a buffer around the eclipse path bounding
    boundary_buffer = boundary.buffer(umbra_boundary_buffer_size)
    for point in cp:
        Po = Point(point)
        inside_umbra = eg.test_point_within_eclipse_boundary(Po)
        inside_us = us_map_polygon.contains(Po)
        inside_boundary_buffer = boundary_buffer.contains(Po)
        # Filter candidate points
        if not outside and inside_umbra:
            # User wants point inside the eclipse path and point is inside the
            # eclipse path
            p.append(Po)
        elif outside and not inside_umbra and inside_us and inside_boundary_buffer:
            # User wants point outside the eclipse path and point is not inside
            # the eclipse path, is inside the US map boundaries, and inside the boundary buffer
            p.append(Po)

    return p
Exemplo n.º 4
0
 def setUp(self):
     self.eg = eclipse_gis.EclipseGIS(test_boundary, test_center)
Exemplo n.º 5
0
def load_path(eclipse_path_data):
    times, points = eclipse_gis.load_stripped_data(open(eclipse_path_data).readlines())
    boundary, center = eclipse_gis.generate_polygon(points)
    eg = eclipse_gis.EclipseGIS(boundary, center)
    return eg
Exemplo n.º 6
0
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from eclipse_gis import eclipse_gis
times, points = eclipse_gis.load_stripped_data(
    open("src/eclipse_gis/data/eclipse_data.txt").readlines())
boundary, center = eclipse_gis.generate_polygon(points)
print center
eclipse_gis = eclipse_gis.EclipseGIS(boundary, center)
from shapely.geometry import Point
print eclipse_gis.find_nearest_point_on_line(Point(44.62, -117.13))
print eclipse_gis.interpolate_nearest_point_on_line(Point(44.62, -117.13))
print eclipse_gis.find_nearest_point_on_line(Point(37, -88))
print eclipse_gis.interpolate_nearest_point_on_line(Point(37, -88))