code: def compute_point_linestring_nearest_point_host(gs1, gs2):
      gpdf = gpd.GeoDataFrame({"lhs": gs1, "rhs": gs2})
      nearest_points = gpdf.apply(
          lambda row: shapely.ops.nearest_points(
              row["lhs"], row["rhs"]
          ),
          axis=1,
          result_type="expand",
      )
  
      # Compute point geometry id
      def point_idx_in_multipoint(row):
          point = row["nearest_points"]
          multipoint = row["points"]
          if not isinstance(multipoint, MultiPoint):
              return 0
  
          for i, g in enumerate(multipoint.geoms):
              if g.equals(point):
                  return i
          return -1
  
      points_gpdf = gpd.GeoDataFrame(
          {"nearest_points": nearest_points[0], "points": gs1}
      )
      point_geometry_id = points_gpdf.apply(
          point_idx_in_multipoint, axis=1
      )
  
      # compute linestring geometry id and segment id
      # shapely's predicate between point and linestring is too strict,
      # thus this resorts to a custom approxmated method via
      # `approximate_point_on_line`
      def point_idx_in_multilinestring(row):
          multilinestring = row["lines"]
          point = row["nearest_points"]
          for i, line in enumerate(multilinestring.geoms):
              for j, segment in enumerate(
                  zip(line.coords[:-1], line.coords[1:])
              ):
                  if LineString(segment).intersects(point.buffer(1e-8)):
                      return [i, j]
          return [-1, -1]
  
      lines_gpdf = gpd.GeoDataFrame(
          {"nearest_points": nearest_points[1], "lines": gs2}
      )
      line_geometry_id = lines_gpdf.apply(
          point_idx_in_multilinestring, axis=1, result_type="expand"
      )
  
      return gpd.GeoDataFrame(
          {
              "point_geometry_id": point_geometry_id,
              "linestring_geometry_id": line_geometry_id[0],
              "segment_id": line_geometry_id[1],
              "geometry": nearest_points[1],
          }
      )
  
file_path: cuspatial/python/cuspatial/cuspatial/tests/spatial/nearest_points/test_nearest_points.py
imports: import geopandas
  import pytest
  import shapely
  from geopandas.testing import assert_geodataframe_equal
  from shapely.geometry import LineString, MultiLineString, MultiPoint, Point
  import cuspatial
label_desc: Use image node_id 1 for calling a global function with example usage: compute_point_linestring_nearest_point_host(gs1, gs2) and returns: gpd, unknown, list, int, i, list