@classmethod<EOL><INDENT>def to_instance(cls, ob, default=None, strict=False):<DEDENT>
if ob is None and default is not None:<EOL><INDENT>instance = default()<EOL><DEDENT>elif isinstance(ob, GeoJSON):<EOL><INDENT>instance = ob<EOL><DEDENT>else:<EOL><INDENT>mapping = to_mapping(ob)<EOL>d = {}<EOL>for k in mapping:<EOL><INDENT>d[k] = mapping[k]<EOL><DEDENT>try:<EOL><INDENT>type_ = d.pop("<STR_LIT:type>")<EOL>try:<EOL><INDENT>type_ = str(type_)<EOL><DEDENT>except UnicodeEncodeError:<EOL><INDENT>raise AttributeError(<EOL>"<STR_LIT>").format(type_)<EOL><DEDENT>geojson_factory = getattr(geojson.factory, type_)<EOL>instance = geojson_factory(**d)<EOL><DEDENT>except (AttributeError, KeyError) as invalid:<EOL><INDENT>if strict:<EOL><INDENT>msg = "<STR_LIT>"<EOL>msg %= (ob, invalid)<EOL>raise ValueError(msg)<EOL><DEDENT>instance = ob<EOL><DEDENT><DEDENT>return instance<EOL>
Encode a GeoJSON dict into an GeoJSON object.
        Assumes the caller knows that the dict should satisfy a GeoJSON type.

        :param cls: Dict containing the elements to be encoded into a GeoJSON
        object.
        :type cls: dict
        :param ob: GeoJSON object into which to encode the dict provided in
        `cls`.
        :type ob: GeoJSON
        :param default: A default instance to append the content of the dict
        to if none is provided.
        :type default: GeoJSON
        :param strict: Raise error if unable to coerce particular keys or
        attributes to a valid GeoJSON structure.
        :type strict: bool
        :return: A GeoJSON object with the dict's elements as its constituents.
        :rtype: GeoJSON
        :raises TypeError: If the input dict contains items that are not valid
        GeoJSON types.
        :raises UnicodeEncodeError: If the input dict contains items of a type
        that contain non-ASCII characters.
        :raises AttributeError: If the input dict contains items that are not
        valid GeoJSON types.