def test_points_intersects_point(gp_points, gp_point): # Get scalar Point sg_point = gp_point[0] if len(gp_points) > 0: # Add gp_point to gp_points so we know something will intersect gp_points = pd.concat([pd.Series(gp_points), pd.Series(gp_point)]).array # Compute expected intersection expected = gp_points.intersects(sg_point) # Create spatialpandas PointArray point = Point.from_shapely(sg_point) points = PointArray.from_geopandas(gp_points) points_series = GeoSeries(points, index=np.arange(10, 10 + len(points))) # Test Point.intersects result = np.array([ point_el.intersects(point) for point_el in points ]) np.testing.assert_equal(result, expected) # Test PointArray.intersect result = points.intersects(point) np.testing.assert_equal(result, expected) # Test PointArray.intersects with inds inds = np.flipud(np.arange(0, len(points))) result = points.intersects(point, inds) np.testing.assert_equal(result, np.flipud(expected)) # Test GeoSeries.intersects pd.testing.assert_series_equal( points_series.intersects(point), pd.Series(expected, index=points_series.index) )
def test_points_intersects_point_offset(gp_points, offset, gp_point): # Get scalar Point sg_point = gp_point[0] if len(gp_points) > 0: # Add gp_point to gp_points so we know something will intersect gp_points = pd.concat([pd.Series(gp_points), pd.Series(gp_point)]).array # Compute expected intersection expected = gp_points.intersects(sg_point)[offset:] # Create spatialpandas PointArray point = Point.from_shapely(sg_point) points = PointArray.from_geopandas(gp_points)[offset:] # Test PointArray.intersect result = points.intersects(point) np.testing.assert_equal(result, expected) # Test PointArray.intersects with inds inds = np.flipud(np.arange(0, len(points))) result = points.intersects(point, inds) np.testing.assert_equal(result, np.flipud(expected))
def test_point(): point = Point([1, 2]) assert point.length == 0.0 assert point.area == 0.0