def _get_geom_value(self, col, doc):
        # TODO: This is information model dependent. Could extract somewhere
        res = None
        try:
            if col == "geom":  # Resource center point (POINT type)
                if "geospatial_point_center" in doc:
                    lat, lon = doc["geospatial_point_center"].get("lat", 0), doc["geospatial_point_center"].get("lon", 0)
                    if lat != lon != 0:
                        res = "POINT(%s %s)" % (lon, lat)   # x,y

            elif col == "geom_loc":  # Resource bounding box (POLYGON shape, 2D)
                geoc = None
                if "geospatial_bounds" in doc:
                    geoc = doc["geospatial_bounds"]
                elif "constraint_list" in doc:
                    # Find the first one - alternatively could expand a bbox
                    for cons in doc["constraint_list"]:
                        if isinstance(cons, dict) and cons.get("type_", None) == "GeospatialBounds":
                            geoc = cons
                            break
                if geoc:
                    try:
                        geovals = dict(x1=float(geoc["geospatial_longitude_limit_west"]),
                                       y1=float(geoc["geospatial_latitude_limit_south"]),
                                       x2=float(geoc["geospatial_longitude_limit_east"]),
                                       y2=float(geoc["geospatial_latitude_limit_north"]))
                        if any((geovals["x1"], geovals["x2"], geovals["y1"], geovals["y2"])):
                            res = ("POLYGON((%(x1)s %(y1)s, %(x2)s %(y1)s, %(x2)s %(y2)s, %(x1)s %(y2)s, %(x1)s %(y1)s))") % geovals
                    except ValueError as ve:
                        log.warn("GeospatialBounds location values not parseable %s: %s", geoc, ve)

            if res:
                log.debug("Geospatial column %s value: %s", col, res)
        except Exception as ex:
            log.warn("Could not compute value for geospatial column %s: %s", col, ex)
        return res
For a given geospatial column name, return the appropriate representation given a document
dataset/ETHPy150Open ooici/pyon/pyon/datastore/postgresql/base_store.py/PostgresDataStore._get_geom_value