<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_geoms_to_file(self, fp, geoms, names=None):
 """Write unioned geometries ``geoms`` to filepath ``fp``. Optionally use ``names`` in name field."""

        if fp[-5:] != '.gpkg':
            fp = fp + '.gpkg'
        if names is not None:
            assert len(geoms) == len(names), "Inconsistent length of geometries and names"
        else:
            names = ("Merged geometry {}".format(count) for count in itertools.count())
        meta = {
            'crs': {'no_defs': True, 'ellps': 'WGS84', 'datum': 'WGS84', 'proj': 'longlat'},
            'driver': 'GPKG',
            'schema': {'geometry': 'MultiPolygon', 'properties': {'name': 'str', 'id': 'int'}}
        }
        with fiona.drivers():
            with fiona.open(fp, 'w', **meta) as sink:
                for geom, name, count in zip(geoms, names, itertools.count(1)):
                    sink.write({
                        'geometry': _to_fiona(geom),
                        'properties': {'name': name, 'id': count}
                    })
        return fp