diff --git a/src/pybind11_geobuf/_core/__init__.pyi b/src/pybind11_geobuf/_core/__init__.pyi index 8d644d8..45e2943 100644 --- a/src/pybind11_geobuf/_core/__init__.pyi +++ b/src/pybind11_geobuf/_core/__init__.pyi @@ -4,129 +4,164 @@ import pybind11_stubgen.typing_ext import typing from . import geojson from . import tf -__all__ = ['Decoder', 'Encoder', 'GeobufIndex', 'NodeItem', 'PackedRTree', 'Planet', 'geojson', 'is_subset_of', 'normalize_json', 'pbf_decode', 'rapidjson', 'str2geojson2str', 'str2json2str', 'tf'] + +__all__ = [ + "Decoder", + "Encoder", + "GeobufIndex", + "NodeItem", + "PackedRTree", + "Planet", + "geojson", + "is_subset_of", + "normalize_json", + "pbf_decode", + "rapidjson", + "str2geojson2str", + "str2json2str", + "tf", +] + class Decoder: def __init__(self) -> None: """ - Initialize a Decoder object. + Initialize a Decoder object. """ @typing.overload - def decode(self, geobuf: str, *, indent: bool = False, sort_keys: bool = False) -> str: + def decode( + self, geobuf: str, *, indent: bool = False, sort_keys: bool = False + ) -> str: """ - Decode Protocol Buffer (PBF) bytes to GeoJSON string. + Decode Protocol Buffer (PBF) bytes to GeoJSON string. - Args: - geobuf (str): Input PBF bytes. - indent (bool, optional): Whether to indent the output JSON. Defaults to False. - sort_keys (bool, optional): Whether to sort object keys. Defaults to False. + Args: + geobuf (str): Input PBF bytes. + indent (bool, optional): Whether to indent the output JSON. Defaults to False. + sort_keys (bool, optional): Whether to sort object keys. Defaults to False. - Returns: - str: Decoded GeoJSON as a string. + Returns: + str: Decoded GeoJSON as a string. """ @typing.overload - def decode(self, *, geobuf: str, geojson: str, indent: bool = False, sort_keys: bool = False) -> bool: + def decode( + self, + *, + geobuf: str, + geojson: str, + indent: bool = False, + sort_keys: bool = False, + ) -> bool: """ - Decode Protocol Buffer (PBF) file to GeoJSON file. + Decode Protocol Buffer (PBF) file to GeoJSON file. - Args: - geobuf (str): Path to input PBF file. - geojson (str): Path to output GeoJSON file. - indent (bool, optional): Whether to indent the output JSON. Defaults to False. - sort_keys (bool, optional): Whether to sort object keys. Defaults to False. + Args: + geobuf (str): Path to input PBF file. + geojson (str): Path to output GeoJSON file. + indent (bool, optional): Whether to indent the output JSON. Defaults to False. + sort_keys (bool, optional): Whether to sort object keys. Defaults to False. - Returns: - None + Returns: + None """ - def decode_feature(self, bytes: str, only_geometry: bool = False, only_properties: bool = False) -> ... | None: + def decode_feature( + self, bytes: str, only_geometry: bool = False, only_properties: bool = False + ) -> geojson.Feature | None: """ - Decode Protocol Buffer (PBF) feature. + Decode Protocol Buffer (PBF) feature. - Args: - bytes (str): Input PBF bytes. - only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. - only_properties (bool, optional): Whether to decode only properties. Defaults to False. + Args: + bytes (str): Input PBF bytes. + only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. + only_properties (bool, optional): Whether to decode only properties. Defaults to False. - Returns: - mapbox::geojson::feature: Decoded GeoJSON feature. + Returns: + mapbox::geojson::feature: Decoded GeoJSON feature. """ def decode_header(self, bytes: str) -> None: """ - Decode Protocol Buffer (PBF) header. + Decode Protocol Buffer (PBF) header. - Args: - bytes (str): Input PBF bytes. + Args: + bytes (str): Input PBF bytes. - Returns: - dict: Decoded header information. + Returns: + dict: Decoded header information. """ - def decode_non_features(self, arg0: str) -> ...: + def decode_non_features(self, arg0: str) -> geojson.value: """ - Decode non-feature elements from Protocol Buffer (PBF) bytes. + Decode non-feature elements from Protocol Buffer (PBF) bytes. - Args: - bytes (str): Input PBF bytes. + Args: + bytes (str): Input PBF bytes. - Returns: - dict: Decoded non-feature elements. + Returns: + dict: Decoded non-feature elements. """ - def decode_to_geojson(self, geobuf: str) -> ...: + def decode_to_geojson(self, geobuf: str) -> geojson.GeoJSON: """ - Decode Protocol Buffer (PBF) bytes to mapbox::geojson::geojson object. + Decode Protocol Buffer (PBF) bytes to mapbox::geojson::geojson object. - Args: - geobuf (str): Input PBF bytes. + Args: + geobuf (str): Input PBF bytes. - Returns: - mapbox::geojson::geojson: Decoded GeoJSON object. + Returns: + mapbox::geojson::geojson: Decoded GeoJSON object. """ - def decode_to_rapidjson(self, geobuf: str, *, sort_keys: bool = False) -> ...: + def decode_to_rapidjson(self, geobuf: str, *, sort_keys: bool = False) -> rapidjson: """ - Decode Protocol Buffer (PBF) bytes to RapidjsonValue GeoJSON. + Decode Protocol Buffer (PBF) bytes to RapidjsonValue GeoJSON. - Args: - geobuf (str): Input PBF bytes. - sort_keys (bool, optional): Whether to sort object keys. Defaults to False. + Args: + geobuf (str): Input PBF bytes. + sort_keys (bool, optional): Whether to sort object keys. Defaults to False. - Returns: - RapidjsonValue: Decoded GeoJSON as a RapidjsonValue object. + Returns: + RapidjsonValue: Decoded GeoJSON as a RapidjsonValue object. """ def dim(self) -> int: """ - Get the dimension of the coordinates in the decoded data. + Get the dimension of the coordinates in the decoded data. - Returns: - int: The dimension value (2 for 2D, 3 for 3D). + Returns: + int: The dimension value (2 for 2D, 3 for 3D). """ def keys(self) -> list[str]: """ - Get the keys of the decoded Protocol Buffer (PBF) data. + Get the keys of the decoded Protocol Buffer (PBF) data. - Returns: - list: A list of strings representing the keys in the decoded PBF data. + Returns: + list: A list of strings representing the keys in the decoded PBF data. """ def offsets(self) -> list[int]: """ - Get the offsets of features in the Protocol Buffer (PBF) file. + Get the offsets of features in the Protocol Buffer (PBF) file. - Returns: - list: A list of integer offsets representing the starting positions of features in the PBF file. + Returns: + list: A list of integer offsets representing the starting positions of features in the PBF file. """ def precision(self) -> int: """ - Get the precision used in the decoding process. + Get the precision used in the decoding process. - Returns: - int: The precision value. + Returns: + int: The precision value. """ + class Encoder: - def __init__(self, *, max_precision: int = 1000000, only_xy: bool = False, round_z: int | None = None) -> None: + def __init__( + self, + *, + max_precision: int = 1000000, + only_xy: bool = False, + round_z: int | None = None, + ) -> None: """ - Initialize an Encoder object. + Initialize an Encoder object. - Args: - max_precision (int): Maximum precision for coordinate encoding. Default is 10^8. - only_xy (bool): If True, only encode X and Y coordinates. Default is False. - round_z (Optional[int]): Number of decimal places to round Z coordinates. Default is None. + Args: + max_precision (int): Maximum precision for coordinate encoding. Default is 10^8. + only_xy (bool): If True, only encode X and Y coordinates. Default is False. + round_z (Optional[int]): Number of decimal places to round Z coordinates. Default is None. """ def dim(self) -> int: """ @@ -137,95 +172,86 @@ class Encoder: Get the encoding factor used for coordinate precision. """ @typing.overload - def encode(self, geojson: ..., std: ..., mapbox: ..., mapbox: ..., std: ...) -> bytes: + def encode(self, geojson: geojson.GeoJSON) -> bytes: """ - Encode GeoJSON to Protocol Buffer (PBF) bytes. + Encode GeoJSON to Protocol Buffer (PBF) bytes. - Args: - geojson (mapbox::geojson::geojson): Input GeoJSON object. + Args: + geojson (mapbox::geojson::geojson): Input GeoJSON object. - Returns: - bytes: Encoded PBF bytes. + Returns: + bytes: Encoded PBF bytes. """ @typing.overload - def encode(self, features: ..., std: ...) -> bytes: + def encode(self, features: geojson.FeatureCollection) -> bytes: """ - Encode GeoJSON FeatureCollection to Protocol Buffer (PBF) bytes. + Encode GeoJSON FeatureCollection to Protocol Buffer (PBF) bytes. - Args: - features (mapbox::geojson::feature_collection): Input GeoJSON FeatureCollection. + Args: + features (mapbox::geojson::feature_collection): Input GeoJSON FeatureCollection. - Returns: - bytes: Encoded PBF bytes. + Returns: + bytes: Encoded PBF bytes. """ @typing.overload - def encode(self, feature: ...) -> bytes: + def encode(self, feature: geojson.Feature) -> bytes: """ - Encode GeoJSON Feature to Protocol Buffer (PBF) bytes. + Encode GeoJSON Feature to Protocol Buffer (PBF) bytes. - Args: - feature (mapbox::geojson::feature): Input GeoJSON Feature. + Args: + feature (mapbox::geojson::feature): Input GeoJSON Feature. - Returns: - bytes: Encoded PBF bytes. + Returns: + bytes: Encoded PBF bytes. """ @typing.overload - def encode(self, geometry: ..., std: ...) -> bytes: + def encode(self, geometry: geojson.Geometry) -> bytes: """ - Encode GeoJSON Geometry to Protocol Buffer (PBF) bytes. + Encode GeoJSON Geometry to Protocol Buffer (PBF) bytes. - Args: - geometry (mapbox::geojson::geometry): Input GeoJSON Geometry. + Args: + geometry (mapbox::geojson::geometry): Input GeoJSON Geometry. - Returns: - bytes: Encoded PBF bytes. + Returns: + bytes: Encoded PBF bytes. """ @typing.overload - def encode(self, geojson: ..., rapidjson: ...) -> bytes: + def encode(self, geojson: rapidjson) -> bytes: """ - Encode RapidjsonValue GeoJSON to Protocol Buffer (PBF) bytes. + Encode RapidjsonValue GeoJSON to Protocol Buffer (PBF) bytes. - Args: - geojson (RapidjsonValue): Input RapidjsonValue GeoJSON object. + Args: + geojson (RapidjsonValue): Input RapidjsonValue GeoJSON object. - Returns: - bytes: Encoded PBF bytes. + Returns: + bytes: Encoded PBF bytes. """ @typing.overload def encode(self, geojson: typing.Any) -> bytes: """ - Encode Python object GeoJSON to Protocol Buffer (PBF) bytes. + Encode Python object GeoJSON to Protocol Buffer (PBF) bytes. - Args: - geojson (object): Input Python object representing GeoJSON. + Args: + geojson (object): Input Python object representing GeoJSON. - Returns: - bytes: Encoded PBF bytes. + Returns: + bytes: Encoded PBF bytes. """ @typing.overload def encode(self, *, geojson: str, geobuf: str) -> bool: """ - Encode GeoJSON file to Protocol Buffer (PBF) file. + Encode GeoJSON file to Protocol Buffer (PBF) file. - Args: - geojson (str): Path to input GeoJSON file. - geobuf (str): Path to output PBF file. + Args: + geojson (str): Path to input GeoJSON file. + geobuf (str): Path to output PBF file. - Returns: - Bool: succ or not. - """ - @typing.overload - def keys(self) -> dict[str, int]: + Returns: + Bool: succ or not. """ - Get the list of keys used in the encoded data. - """ - @typing.overload def keys(self) -> dict[str, int]: """ - Get the list of keys used in the encoding process. - - Returns: - list: A list of strings representing the keys used during encoding. + Get keys used in the encoded data. """ def max_precision(self) -> int: """ @@ -239,189 +265,213 @@ class Encoder: """ Get the number of decimal places used for rounding Z coordinates. """ + class GeobufIndex: @staticmethod - def indexing(input_geobuf_path: str, output_index_path: str, *, feature_id: str | None = '@', packed_rtree: str | None = '@') -> bool: + def indexing( + input_geobuf_path: str, + output_index_path: str, + *, + feature_id: str | None = "@", + packed_rtree: str | None = "@", + ) -> bool: """ - Create an index for a Geobuf file. + Create an index for a Geobuf file. - Args: - input_geobuf_path (str): Path to the input Geobuf file. - output_index_path (str): Path to save the output index file. - feature_id (str, optional): Feature ID field. Defaults to "@". - packed_rtree (str, optional): Packed R-tree option. Defaults to "@". + Args: + input_geobuf_path (str): Path to the input Geobuf file. + output_index_path (str): Path to save the output index file. + feature_id (str, optional): Feature ID field. Defaults to "@". + packed_rtree (str, optional): Packed R-tree option. Defaults to "@". - Returns: - None + Returns: + None """ def __init__(self) -> None: """ - Default constructor for GeobufIndex. + Default constructor for GeobufIndex. """ @typing.overload - def decode_feature(self, index: int, *, only_geometry: bool = False, only_properties: bool = False) -> geojson.Feature | None: + def decode_feature( + self, index: int, *, only_geometry: bool = False, only_properties: bool = False + ) -> geojson.Feature | None: """ - Decode a feature from the Geobuf file. + Decode a feature from the Geobuf file. - Args: - index (int): Index of the feature to decode. - only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. - only_properties (bool, optional): Whether to decode only properties. Defaults to False. + Args: + index (int): Index of the feature to decode. + only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. + only_properties (bool, optional): Whether to decode only properties. Defaults to False. - Returns: - mapbox::geojson::feature: Decoded feature. + Returns: + mapbox::geojson::feature: Decoded feature. """ @typing.overload - def decode_feature(self, bytes: str, *, only_geometry: bool = False, only_properties: bool = False) -> geojson.Feature | None: + def decode_feature( + self, bytes: str, *, only_geometry: bool = False, only_properties: bool = False + ) -> geojson.Feature | None: """ - Decode a feature from bytes. + Decode a feature from bytes. - Args: - bytes (str): Bytes containing the feature data. - only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. - only_properties (bool, optional): Whether to decode only properties. Defaults to False. + Args: + bytes (str): Bytes containing the feature data. + only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. + only_properties (bool, optional): Whether to decode only properties. Defaults to False. - Returns: - mapbox::geojson::feature: Decoded feature. + Returns: + mapbox::geojson::feature: Decoded feature. """ - def decode_feature_of_id(self, id: str, *, only_geometry: bool = False, only_properties: bool = False) -> geojson.Feature | None: + def decode_feature_of_id( + self, id: str, *, only_geometry: bool = False, only_properties: bool = False + ) -> geojson.Feature | None: """ - Decode a feature by its ID. + Decode a feature by its ID. - Args: - id (str): ID of the feature to decode. - only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. - only_properties (bool, optional): Whether to decode only properties. Defaults to False. + Args: + id (str): ID of the feature to decode. + only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. + only_properties (bool, optional): Whether to decode only properties. Defaults to False. - Returns: - mapbox::geojson::feature: Decoded feature. + Returns: + mapbox::geojson::feature: Decoded feature. """ - def decode_features(self, index: list[int], *, only_geometry: bool = False, only_properties: bool = False) -> geojson.FeatureCollection: + def decode_features( + self, + index: list[int], + *, + only_geometry: bool = False, + only_properties: bool = False, + ) -> geojson.FeatureCollection: """ - Decode multiple features from the Geobuf file. + Decode multiple features from the Geobuf file. - Args: - index (List[int]): List of indices of the features to decode. - only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. - only_properties (bool, optional): Whether to decode only properties. Defaults to False. + Args: + index (List[int]): List of indices of the features to decode. + only_geometry (bool, optional): Whether to decode only geometry. Defaults to False. + only_properties (bool, optional): Whether to decode only properties. Defaults to False. - Returns: - List[mapbox::geojson::feature]: List of decoded features. + Returns: + List[mapbox::geojson::feature]: List of decoded features. """ @typing.overload def decode_non_features(self, bytes: str) -> geojson.value: """ - Decode non-feature data from bytes. + Decode non-feature data from bytes. - Args: - bytes (str): Bytes containing the non-feature data. + Args: + bytes (str): Bytes containing the non-feature data. - Returns: - Dict: Decoded non-feature data. + Returns: + Dict: Decoded non-feature data. """ @typing.overload def decode_non_features(self) -> geojson.value: """ - Decode non-feature data from the Geobuf file. + Decode non-feature data from the Geobuf file. - Returns: - Dict: Decoded non-feature data. + Returns: + Dict: Decoded non-feature data. """ def init(self, index_bytes: str) -> bool: """ - Initialize the GeobufIndex from index bytes. + Initialize the GeobufIndex from index bytes. - Args: - index_bytes (str): Bytes containing the index information. + Args: + index_bytes (str): Bytes containing the index information. - Returns: - None + Returns: + None """ def mmap_bytes(self, offset: int, length: int) -> bytes | None: """ - Read bytes from the memory-mapped file. + Read bytes from the memory-mapped file. - Args: - offset (int): Offset in the file. - length (int): Number of bytes to read. + Args: + offset (int): Offset in the file. + length (int): Number of bytes to read. - Returns: - Optional[bytes]: Read bytes, or None if reading failed. + Returns: + Optional[bytes]: Read bytes, or None if reading failed. """ @typing.overload def mmap_init(self, index_path: str, geobuf_path: str) -> bool: """ - Initialize the GeobufIndex using memory-mapped files. + Initialize the GeobufIndex using memory-mapped files. - Args: - index_path (str): Path to the index file. - geobuf_path (str): Path to the Geobuf file. + Args: + index_path (str): Path to the index file. + geobuf_path (str): Path to the Geobuf file. - Returns: - None + Returns: + None """ @typing.overload def mmap_init(self, geobuf_path: str) -> bool: """ - Initialize the GeobufIndex using a memory-mapped Geobuf file. + Initialize the GeobufIndex using a memory-mapped Geobuf file. - Args: - geobuf_path (str): Path to the Geobuf file. + Args: + geobuf_path (str): Path to the Geobuf file. - Returns: - None + Returns: + None """ - def query(self, arg0: numpy.ndarray[numpy.float64[2, 1]], arg1: numpy.ndarray[numpy.float64[2, 1]]) -> set[int]: + def query( + self, + arg0: numpy.ndarray[numpy.float64[2, 1]], + arg1: numpy.ndarray[numpy.float64[2, 1]], + ) -> set[int]: """ - Query features within a bounding box. + Query features within a bounding box. - Args: - min_corner (Eigen::Vector2d): Minimum corner of the bounding box. - max_corner (Eigen::Vector2d): Maximum corner of the bounding box. + Args: + min_corner (Eigen::Vector2d): Minimum corner of the bounding box. + max_corner (Eigen::Vector2d): Maximum corner of the bounding box. - Returns: - List[int]: List of indices of features within the bounding box. + Returns: + List[int]: List of indices of features within the bounding box. """ @property def header_size(self) -> int: """ - Get the size of the header in bytes. + Get the size of the header in bytes. - Returns: - int: The size of the header in bytes. + Returns: + int: The size of the header in bytes. """ @property def ids(self) -> dict[str, int] | None: """ - Get the IDs of features in the index. + Get the IDs of features in the index. - Returns: - list: A list of feature IDs. + Returns: + list: A list of feature IDs. """ @property def num_features(self) -> int: """ - Get the number of features in the index. + Get the number of features in the index. - Returns: - int: The number of features. + Returns: + int: The number of features. """ @property def offsets(self) -> list[int]: """ - Get the offsets of features in the Geobuf file. + Get the offsets of features in the Geobuf file. - Returns: - list: A list of offsets for each feature. + Returns: + list: A list of offsets for each feature. """ @property def packed_rtree(self) -> PackedRTree: """ - Get the packed R-tree of the index. + Get the packed R-tree of the index. - Returns: - FlatGeobuf.PackedRTree: The packed R-tree of the index, or None if not available. + Returns: + FlatGeobuf.PackedRTree: The packed R-tree of the index, or None if not available. """ + class NodeItem: __hash__: typing.ClassVar[None] = None def __eq__(self, arg0: NodeItem) -> bool: @@ -479,114 +529,125 @@ class NodeItem: """ Get the width of the node's bounding box """ + class PackedRTree: - def search(self, min_x: float, min_y: float, max_x: float, max_y: float) -> list[int]: + def search( + self, min_x: float, min_y: float, max_x: float, max_y: float + ) -> list[int]: """ - Search for items within the given bounding box. + Search for items within the given bounding box. - Args: - min_x (float): Minimum X coordinate of the bounding box. - min_y (float): Minimum Y coordinate of the bounding box. - max_x (float): Maximum X coordinate of the bounding box. - max_y (float): Maximum Y coordinate of the bounding box. + Args: + min_x (float): Minimum X coordinate of the bounding box. + min_y (float): Minimum Y coordinate of the bounding box. + max_x (float): Maximum X coordinate of the bounding box. + max_y (float): Maximum Y coordinate of the bounding box. - Returns: - list: List of offsets of items within the bounding box. + Returns: + list: List of offsets of items within the bounding box. """ @property - def extent(self) -> numpy.ndarray[numpy.float64[4, 1]]: - ... + def extent(self) -> numpy.ndarray[numpy.float64[4, 1]]: ... @property - def node_size(self) -> int: - ... + def node_size(self) -> int: ... @property - def num_items(self) -> int: - ... + def num_items(self) -> int: ... @property - def num_nodes(self) -> int: - ... + def num_nodes(self) -> int: ... @property - def size(self) -> int: - ... + def size(self) -> int: ... + class Planet: @typing.overload def __init__(self) -> None: """ - Initialize an empty Planet object. + Initialize an empty Planet object. """ @typing.overload def __init__(self, arg0: geojson.FeatureCollection) -> None: """ - Initialize a Planet object with a feature collection. + Initialize a Planet object with a feature collection. - Args: - feature_collection (mapbox::geojson::feature_collection): The feature collection to initialize with. + Args: + feature_collection (mapbox::geojson::feature_collection): The feature collection to initialize with. """ def build(self, *, per_line_segment: bool = False, force: bool = False) -> None: """ - Build the spatial index for the features. + Build the spatial index for the features. - Args: - per_line_segment (bool, optional): Whether to index each line segment separately. Defaults to False. - force (bool, optional): Whether to force rebuilding the index. Defaults to False. + Args: + per_line_segment (bool, optional): Whether to index each line segment separately. Defaults to False. + force (bool, optional): Whether to force rebuilding the index. Defaults to False. - Returns: - None + Returns: + None """ def copy(self, arg0: numpy.ndarray[numpy.int32[m, 1]]) -> geojson.FeatureCollection: """ - Create a deep copy of the Planet object. + Create a deep copy of the Planet object. - Returns: - Planet: A new Planet object that is a deep copy of the current one. + Returns: + Planet: A new Planet object that is a deep copy of the current one. """ - def crop(self, polygon: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous], *, clipping_mode: str = 'longest', strip_properties: bool = False, is_wgs84: bool = True) -> geojson.FeatureCollection: + def crop( + self, + polygon: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous], + *, + clipping_mode: str = "longest", + strip_properties: bool = False, + is_wgs84: bool = True, + ) -> geojson.FeatureCollection: """ - Crop features using a polygon. + Crop features using a polygon. - Args: - polygon (mapbox::geojson::polygon): Polygon to crop with. - clipping_mode (str, optional): Clipping mode. Defaults to "longest". - strip_properties (bool, optional): Whether to strip properties from cropped features. Defaults to False. - is_wgs84 (bool, optional): Whether the coordinates are in WGS84. Defaults to True. + Args: + polygon (mapbox::geojson::polygon): Polygon to crop with. + clipping_mode (str, optional): Clipping mode. Defaults to "longest". + strip_properties (bool, optional): Whether to strip properties from cropped features. Defaults to False. + is_wgs84 (bool, optional): Whether the coordinates are in WGS84. Defaults to True. - Returns: - Planet: New Planet object with cropped features. + Returns: + Planet: New Planet object with cropped features. """ @typing.overload def features(self) -> geojson.FeatureCollection: """ - Get the features of the Planet object. + Get the features of the Planet object. - Returns: - mapbox::geojson::feature_collection: The features of the Planet object. + Returns: + mapbox::geojson::feature_collection: The features of the Planet object. """ @typing.overload def features(self, arg0: geojson.FeatureCollection) -> Planet: """ - Set the features of the Planet object. + Set the features of the Planet object. - Args: - feature_collection (mapbox::geojson::feature_collection): The new feature collection to set. + Args: + feature_collection (mapbox::geojson::feature_collection): The new feature collection to set. """ def packed_rtree(self) -> PackedRTree: """ - Get the packed R-tree of the Planet object. + Get the packed R-tree of the Planet object. - Returns: - FlatGeobuf::PackedRTree: The packed R-tree of the Planet object. + Returns: + FlatGeobuf::PackedRTree: The packed R-tree of the Planet object. """ - def query(self, min: numpy.ndarray[numpy.float64[2, 1]], max: numpy.ndarray[numpy.float64[2, 1]]) -> numpy.ndarray[numpy.int32[m, 1]]: + def query( + self, + min: numpy.ndarray[numpy.float64[2, 1]], + max: numpy.ndarray[numpy.float64[2, 1]], + ) -> numpy.ndarray[numpy.int32[m, 1]]: """ - Query features within the given bounding box. + Query features within the given bounding box. - Args: - min (array-like): Minimum coordinates of the bounding box. - max (array-like): Maximum coordinates of the bounding box. + Args: + min (array-like): Minimum coordinates of the bounding box. + max (array-like): Maximum coordinates of the bounding box. - Returns: - list: List of features within the bounding box. + Returns: + list: List of features within the bounding box. """ + class rapidjson: class type: """ @@ -606,7 +667,10 @@ class rapidjson: kNumberType : Number type """ - __members__: typing.ClassVar[dict[str, rapidjson.type]] # value = {'kNullType': , 'kFalseType': , 'kTrueType': , 'kObjectType': , 'kArrayType': , 'kStringType': , 'kNumberType': } + + __members__: typing.ClassVar[ + dict[str, rapidjson.type] + ] # value = {'kNullType': , 'kFalseType': , 'kTrueType': , 'kObjectType': , 'kArrayType': , 'kStringType': , 'kNumberType': } kArrayType: typing.ClassVar[rapidjson.type] # value = kFalseType: typing.ClassVar[rapidjson.type] # value = kNullType: typing.ClassVar[rapidjson.type] # value = @@ -614,32 +678,21 @@ class rapidjson: kObjectType: typing.ClassVar[rapidjson.type] # value = kStringType: typing.ClassVar[rapidjson.type] # value = kTrueType: typing.ClassVar[rapidjson.type] # value = - def __eq__(self, other: typing.Any) -> bool: - ... - def __getstate__(self) -> int: - ... - def __hash__(self) -> int: - ... - def __index__(self) -> int: - ... - def __init__(self, value: int) -> None: - ... - def __int__(self) -> int: - ... - def __ne__(self, other: typing.Any) -> bool: - ... - def __repr__(self) -> str: - ... - def __setstate__(self, state: int) -> None: - ... - def __str__(self) -> str: - ... + def __eq__(self, other: typing.Any) -> bool: ... + def __getstate__(self) -> int: ... + def __hash__(self) -> int: ... + def __index__(self) -> int: ... + def __init__(self, value: int) -> None: ... + def __int__(self) -> int: ... + def __ne__(self, other: typing.Any) -> bool: ... + def __repr__(self) -> str: ... + def __setstate__(self, state: int) -> None: ... + def __str__(self) -> str: ... @property - def name(self) -> str: - ... + def name(self) -> str: ... @property - def value(self) -> int: - ... + def value(self) -> int: ... + __hash__: typing.ClassVar[None] = None kArrayType: typing.ClassVar[rapidjson.type] # value = kFalseType: typing.ClassVar[rapidjson.type] # value = @@ -852,8 +905,7 @@ class rapidjson: """ Get an array element by index """ - def __getstate__(self) -> typing.Any: - ... + def __getstate__(self) -> typing.Any: ... @typing.overload def __init__(self) -> None: """ @@ -934,7 +986,18 @@ class rapidjson: """ Locate NaN or Inf values in the JSON """ - def normalize(self, *, sort_keys: bool = True, strip_geometry_z_0: bool = True, round_geojson_non_geometry: int | None = 3, round_geojson_geometry: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] | None = [8, 8, 3], denoise_double_0: bool = True) -> rapidjson: + def normalize( + self, + *, + sort_keys: bool = True, + strip_geometry_z_0: bool = True, + round_geojson_non_geometry: int | None = 3, + round_geojson_geometry: typing.Annotated[ + list[int], pybind11_stubgen.typing_ext.FixedSize(3) + ] + | None = [8, 8, 3], + denoise_double_0: bool = True, + ) -> rapidjson: """ Normalize JSON by applying multiple transformations """ @@ -946,11 +1009,19 @@ class rapidjson: """ Append value to array """ - def round(self, *, precision: float = 3, depth: int = 32, skip_keys: list[str] = []) -> rapidjson: + def round( + self, *, precision: float = 3, depth: int = 32, skip_keys: list[str] = [] + ) -> rapidjson: """ Round numeric values in the JSON """ - def round_geojson_geometry(self, *, precision: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] = [8, 8, 3]) -> rapidjson: + def round_geojson_geometry( + self, + *, + precision: typing.Annotated[ + list[int], pybind11_stubgen.typing_ext.FixedSize(3) + ] = [8, 8, 3], + ) -> rapidjson: """ Round geometry coordinates in GeoJSON """ @@ -980,86 +1051,123 @@ class rapidjson: """ Get a list of values for an object """ + def is_subset_of(path1: str, path2: str) -> bool: """ - Check if the JSON at path1 is a subset of the JSON at path2. + Check if the JSON at path1 is a subset of the JSON at path2. - Args: - path1 (str): Path to the first JSON file. - path2 (str): Path to the second JSON file. + Args: + path1 (str): Path to the first JSON file. + path2 (str): Path to the second JSON file. - Returns: - bool: True if the first JSON is a subset of the second, False otherwise. + Returns: + bool: True if the first JSON is a subset of the second, False otherwise. """ + @typing.overload -def normalize_json(input_path: str, output_path: str, *, indent: bool = True, sort_keys: bool = True, denoise_double_0: bool = True, strip_geometry_z_0: bool = True, round_non_geojson: int | None = 3, round_geojson_non_geometry: int | None = 3, round_geojson_geometry: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] | None = [8, 8, 3]) -> bool: +def normalize_json( + input_path: str, + output_path: str, + *, + indent: bool = True, + sort_keys: bool = True, + denoise_double_0: bool = True, + strip_geometry_z_0: bool = True, + round_non_geojson: int | None = 3, + round_geojson_non_geometry: int | None = 3, + round_geojson_geometry: typing.Annotated[ + list[int], pybind11_stubgen.typing_ext.FixedSize(3) + ] + | None = [8, 8, 3], +) -> bool: """ - Normalize JSON file. - - Args: - input_path (str): Path to input JSON file. - output_path (str): Path to output normalized JSON file. - indent (bool, optional): Whether to indent the output JSON. Defaults to True. - sort_keys (bool, optional): Whether to sort object keys. Defaults to True. - denoise_double_0 (bool, optional): Whether to remove trailing zeros from doubles. Defaults to True. - strip_geometry_z_0 (bool, optional): Whether to strip Z coordinate if it's 0. Defaults to True. - round_non_geojson (int, optional): Number of decimal places to round non-GeoJSON numbers. Defaults to 3. - round_geojson_non_geometry (int, optional): Number of decimal places to round GeoJSON non-geometry numbers. Defaults to 3. - round_geojson_geometry (array of 3 ints, optional): Number of decimal places to round GeoJSON geometry coordinates. Defaults to [8, 8, 3]. - - Returns: - None + Normalize JSON file. + + Args: + input_path (str): Path to input JSON file. + output_path (str): Path to output normalized JSON file. + indent (bool, optional): Whether to indent the output JSON. Defaults to True. + sort_keys (bool, optional): Whether to sort object keys. Defaults to True. + denoise_double_0 (bool, optional): Whether to remove trailing zeros from doubles. Defaults to True. + strip_geometry_z_0 (bool, optional): Whether to strip Z coordinate if it's 0. Defaults to True. + round_non_geojson (int, optional): Number of decimal places to round non-GeoJSON numbers. Defaults to 3. + round_geojson_non_geometry (int, optional): Number of decimal places to round GeoJSON non-geometry numbers. Defaults to 3. + round_geojson_geometry (array of 3 ints, optional): Number of decimal places to round GeoJSON geometry coordinates. Defaults to [8, 8, 3]. + + Returns: + None """ + @typing.overload -def normalize_json(json: ..., rapidjson: ..., *, sort_keys: bool = True, denoise_double_0: bool = True, strip_geometry_z_0: bool = True, round_non_geojson: int | None = 3, round_geojson_non_geometry: int | None = 3, round_geojson_geometry: typing.Annotated[list[int], pybind11_stubgen.typing_ext.FixedSize(3)] | None = [8, 8, 3]) -> ...: +def normalize_json( + json: rapidjson, + *, + sort_keys: bool = True, + denoise_double_0: bool = True, + strip_geometry_z_0: bool = True, + round_non_geojson: int | None = 3, + round_geojson_non_geometry: int | None = 3, + round_geojson_geometry: typing.Annotated[ + list[int], pybind11_stubgen.typing_ext.FixedSize(3) + ] + | None = [8, 8, 3], +) -> rapidjson: """ - Normalize JSON object in-place. - - Args: - json (RapidjsonValue): JSON object to normalize. - sort_keys (bool, optional): Whether to sort object keys. Defaults to True. - denoise_double_0 (bool, optional): Whether to remove trailing zeros from doubles. Defaults to True. - strip_geometry_z_0 (bool, optional): Whether to strip Z coordinate if it's 0. Defaults to True. - round_non_geojson (int, optional): Number of decimal places to round non-GeoJSON numbers. Defaults to 3. - round_geojson_non_geometry (int, optional): Number of decimal places to round GeoJSON non-geometry numbers. Defaults to 3. - round_geojson_geometry (array of 3 ints, optional): Number of decimal places to round GeoJSON geometry coordinates. Defaults to [8, 8, 3]. - - Returns: - RapidjsonValue: Reference to the normalized JSON object. + Normalize JSON object in-place. + + Args: + json (RapidjsonValue): JSON object to normalize. + sort_keys (bool, optional): Whether to sort object keys. Defaults to True. + denoise_double_0 (bool, optional): Whether to remove trailing zeros from doubles. Defaults to True. + strip_geometry_z_0 (bool, optional): Whether to strip Z coordinate if it's 0. Defaults to True. + round_non_geojson (int, optional): Number of decimal places to round non-GeoJSON numbers. Defaults to 3. + round_geojson_non_geometry (int, optional): Number of decimal places to round GeoJSON non-geometry numbers. Defaults to 3. + round_geojson_geometry (array of 3 ints, optional): Number of decimal places to round GeoJSON geometry coordinates. Defaults to [8, 8, 3]. + + Returns: + RapidjsonValue: Reference to the normalized JSON object. """ -def pbf_decode(pbf_bytes: str, *, indent: str = '') -> str: + +def pbf_decode(pbf_bytes: str, *, indent: str = "") -> str: """ - Decode Protocol Buffer (PBF) bytes to a printable string. + Decode Protocol Buffer (PBF) bytes to a printable string. - Args: - pbf_bytes (str): Input PBF bytes. - indent (str, optional): Indentation string. Defaults to "". + Args: + pbf_bytes (str): Input PBF bytes. + indent (str, optional): Indentation string. Defaults to "". - Returns: - str: Decoded and formatted PBF content as a string. + Returns: + str: Decoded and formatted PBF content as a string. """ -def str2geojson2str(json_string: str, *, indent: bool = False, sort_keys: bool = False) -> str | None: + +def str2geojson2str( + json_string: str, *, indent: bool = False, sort_keys: bool = False +) -> str | None: """ - Convert JSON string to GeoJSON object and back to JSON string. + Convert JSON string to GeoJSON object and back to JSON string. - Args: - json_string (str): Input JSON string. - indent (bool, optional): Whether to indent the output JSON. Defaults to False. - sort_keys (bool, optional): Whether to sort object keys. Defaults to False. + Args: + json_string (str): Input JSON string. + indent (bool, optional): Whether to indent the output JSON. Defaults to False. + sort_keys (bool, optional): Whether to sort object keys. Defaults to False. - Returns: - Optional[str]: Converted GeoJSON string, or None if input is invalid. + Returns: + Optional[str]: Converted GeoJSON string, or None if input is invalid. """ -def str2json2str(json_string: str, *, indent: bool = False, sort_keys: bool = False) -> str | None: + +def str2json2str( + json_string: str, *, indent: bool = False, sort_keys: bool = False +) -> str | None: """ - Convert JSON string to JSON object and back to string. + Convert JSON string to JSON object and back to string. - Args: - json_string (str): Input JSON string. - indent (bool, optional): Whether to indent the output JSON. Defaults to False. - sort_keys (bool, optional): Whether to sort object keys. Defaults to False. + Args: + json_string (str): Input JSON string. + indent (bool, optional): Whether to indent the output JSON. Defaults to False. + sort_keys (bool, optional): Whether to sort object keys. Defaults to False. - Returns: - Optional[str]: Converted JSON string, or None if input is invalid. + Returns: + Optional[str]: Converted JSON string, or None if input is invalid. """ -__version__: str = '0.2.2' + +__version__: str = "0.2.2" diff --git a/src/pybind11_geobuf/_core/geojson.pyi b/src/pybind11_geobuf/_core/geojson.pyi index 017bd72..3b3ba8c 100644 --- a/src/pybind11_geobuf/_core/geojson.pyi +++ b/src/pybind11_geobuf/_core/geojson.pyi @@ -1,5 +1,6 @@ from __future__ import annotations import numpy +import pybind11_geobuf._core import typing __all__ = ['Feature', 'FeatureCollection', 'FeatureList', 'GeoJSON', 'Geometry', 'GeometryBase', 'GeometryCollection', 'GeometryList', 'LineString', 'LineStringList', 'LinearRing', 'LinearRingList', 'MultiLineString', 'MultiPoint', 'MultiPolygon', 'Point', 'Polygon', 'PolygonList', 'coordinates', 'value'] class Feature: @@ -39,7 +40,7 @@ class Feature: Copy constructor for GeoJSON Feature """ @typing.overload - def __init__(self, arg0: ..., rapidjson: ...) -> None: + def __init__(self, arg0: pybind11_geobuf._core.rapidjson) -> None: """ Construct a GeoJSON Feature from a RapidJSON value """ @@ -91,7 +92,7 @@ class Feature: Initialize the feature from Geobuf bytes """ @typing.overload - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> Feature: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> Feature: """ Initialize the feature from a RapidJSON value """ @@ -196,7 +197,7 @@ class Feature: """ Convert the feature geometry to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the feature to a RapidJSON value """ @@ -295,7 +296,7 @@ class FeatureCollection(FeatureList): """ Load the FeatureCollection from Geobuf bytes """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> FeatureCollection: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> FeatureCollection: """ Load the FeatureCollection from a RapidJSON value """ @@ -323,7 +324,7 @@ class FeatureCollection(FeatureList): """ Convert the FeatureCollection to Geobuf bytes """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the FeatureCollection to a RapidJSON value """ @@ -502,7 +503,7 @@ class GeoJSON: """ Decode a Geobuf byte string into a GeoJSON object """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> GeoJSON: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> GeoJSON: """ Convert a RapidJSON value to a GeoJSON object """ @@ -530,7 +531,7 @@ class GeoJSON: """ Encode the GeoJSON object to a Geobuf byte string """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the GeoJSON object to a RapidJSON value """ @@ -613,7 +614,7 @@ class Geometry(GeometryBase): Initialize from a GeometryCollection """ @typing.overload - def __init__(self, arg0: ..., rapidjson: ...) -> None: + def __init__(self, arg0: pybind11_geobuf._core.rapidjson) -> None: """ Initialize from a RapidJSON value """ @@ -708,7 +709,7 @@ class Geometry(GeometryBase): """ Set geometry coordinates from a numpy array """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> Geometry: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> Geometry: """ Convert a RapidJSON value to a geometry """ @@ -810,7 +811,7 @@ class Geometry(GeometryBase): """ Convert geometry coordinates to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the geometry to a RapidJSON value """ @@ -910,7 +911,7 @@ class GeometryCollection(GeometryList): """ Remove duplicate consecutive points based on their XYZ coordinates """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> GeometryCollection: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> GeometryCollection: """ Set the GeometryCollection from a RapidJSON value """ @@ -966,7 +967,7 @@ class GeometryCollection(GeometryList): """ Round the coordinates of all geometries in the GeometryCollection """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the GeometryCollection to a RapidJSON value """ @@ -1160,7 +1161,7 @@ class LineString(coordinates): """ Set the geometry points from a numpy array """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> LineString: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> LineString: """ Initialize from a RapidJSON value """ @@ -1190,7 +1191,7 @@ class LineString(coordinates): """ Convert the geometry points to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert to a RapidJSON value """ @@ -1565,7 +1566,7 @@ class MultiLineString(LineStringList): """ Set the geometry from a numpy array of points """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> MultiLineString: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> MultiLineString: """ Initialize the geometry from a RapidJSON value """ @@ -1591,7 +1592,7 @@ class MultiLineString(LineStringList): """ Convert the geometry to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the geometry to a RapidJSON value """ @@ -1684,7 +1685,7 @@ class MultiPoint(coordinates): """ Set the geometry points from a numpy array """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> MultiPoint: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> MultiPoint: """ Initialize from a RapidJSON value """ @@ -1714,7 +1715,7 @@ class MultiPoint(coordinates): """ Convert the geometry points to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert to a RapidJSON value """ @@ -1813,7 +1814,7 @@ class MultiPolygon(PolygonList): """ Set MultiPolygon coordinates from a numpy array """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> MultiPolygon: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> MultiPolygon: """ Set the MultiPolygon from a RapidJSON value """ @@ -1839,7 +1840,7 @@ class MultiPolygon(PolygonList): """ Convert MultiPolygon to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the MultiPolygon to a RapidJSON value """ @@ -1931,7 +1932,7 @@ class Point: """ Set point coordinates from a numpy array """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> Point: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> Point: """ Create a Point from a RapidJSON value """ @@ -1943,7 +1944,7 @@ class Point: """ Convert point coordinates to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the Point to a RapidJSON value """ @@ -2064,7 +2065,7 @@ class Polygon(LinearRingList): """ Set the geometry from a numpy array of points """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> Polygon: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> Polygon: """ Initialize the geometry from a RapidJSON value """ @@ -2090,7 +2091,7 @@ class Polygon(LinearRingList): """ Convert the geometry to a numpy array """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the geometry to a RapidJSON value """ @@ -2426,7 +2427,7 @@ class value: """ Extend the list by appending all the items in the given list """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> value.array_type: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> value.array_type: """ Set the GeoJSON array from a RapidJSON value """ @@ -2448,7 +2449,7 @@ class value: """ Remove the first item from the list whose value is x. It is an error if there is no such item. """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the GeoJSON array to a RapidJSON value """ @@ -2500,7 +2501,7 @@ class value: """ Clear the GeoJSON object """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> value.object_type: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> value.object_type: """ Convert a RapidJSON value to a GeoJSON object """ @@ -2520,7 +2521,7 @@ class value: """ Get an iterator over the keys of the GeoJSON object """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the GeoJSON object to a RapidJSON value """ @@ -2624,7 +2625,7 @@ class value: """ Clear the GeoJSON value """ - def from_rapidjson(self, arg0: ..., rapidjson: ...) -> value: + def from_rapidjson(self, arg0: pybind11_geobuf._core.rapidjson) -> value: """ Set the GeoJSON value from a RapidJSON value """ @@ -2660,7 +2661,7 @@ class value: """ Set the GeoJSON value from a Python object """ - def to_rapidjson(self) -> ...: + def to_rapidjson(self) -> pybind11_geobuf._core.rapidjson: """ Convert the GeoJSON value to a RapidJSON value """