from typing import OrderedDict
import json


def get_selection_dict(obj):
    """Return the selection as a feature collection dictionary."""
    geom_collection = obj.original_selection
    if not geom_collection:
        return None
    feature_collection = OrderedDict()
    feature_collection["type"] = "FeatureCollection"
    feature_collection["features"] = []
    for geom in geom_collection:
        geojson_geom = json.loads(geom.geojson)
        feature = OrderedDict()
        feature["type"] = "Feature"
        feature["geometry"] = geojson_geom
        feature_collection["features"].append(feature)
    return feature_collection