Shumate.VectorReaderIter

g GObject.Object GObject.Object Shumate.VectorReaderIter Shumate.VectorReaderIter GObject.Object->Shumate.VectorReaderIter

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

feature_contains_point (x, y)

get_feature_geometry_type ()

get_feature_id ()

get_feature_keys ()

get_feature_point ()

get_feature_tag (key)

get_layer_count ()

get_layer_extent ()

get_layer_feature_count ()

get_layer_name ()

get_reader ()

next_feature ()

read_feature (index)

read_layer (index)

read_layer_by_name (name)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

reader

Shumate.VectorReader

r/w/co

reader

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Shumate.VectorReaderIter(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Shumate.VectorReaderIterClass

Reads the layers and features of a vector tile.

To create a new [class`VectorReaderIter`], use [method`VectorReader`.iterate].

A vector tile consists of named layers, which contain features. Each feature has an ID, a geometry, and a set of key/value tags. The meanings of the IDs and tags depends on the data source that the tile came from. The OpenMapTiles schema is a common schema for vector tiles.

To read all layers in a tile, use [method`VectorReaderIter`.get_layer_count] and [method`VectorReaderIter`.read_layer]. If you know the name of the layer you want, you can also use [method`VectorReaderIter`.read_layer_by_name]. Once the iterator is reading a layer, you can call [method`VectorReaderIter`.next_feature] in a loop to read all the features in the layer.

A [class`VectorReaderIter`] is not thread-safe, but iterators created from the same [class`VectorReader`] can be used in different threads.

See the Mapbox Vector Tile specification for more information about the vector tile format.

New in version 1.2.

feature_contains_point(x, y)
Parameters:
Returns:

True if the feature contains the point, False otherwise.

Return type:

bool

Determines whether the current feature contains the given point.

The point must be specified in tile space. See [method`VectorReaderIter`.get_layer_extent] to get the range of the coordinates.

Only polygon or multipolygon features can contain a point. For all other feature types, this function returns False.

If the point is on the border of the polygon, this function may return either True or False.

New in version 1.2.

get_feature_geometry_type()
Returns:

The geometry type of the current feature.

Return type:

Shumate.GeometryType

Gets the geometry type of the current feature.

New in version 1.2.

get_feature_id()
Returns:

The ID of the current feature.

Return type:

int

Gets the ID of the current feature.

New in version 1.2.

get_feature_keys()
Returns:

The keys of the tags of the current feature.

Return type:

[str]

Gets the keys of the tags of the current feature.

New in version 1.2.

get_feature_point()
Returns:

True if the feature is a point, False otherwise.

x:

The x coordinate of the point.

y:

The y coordinate of the point.

Return type:

(bool, x: float, y: float)

Gets the coordinates of the current feature in tile space, if the feature is a single point.

See [method`VectorReaderIter`.get_layer_extent] to get the range of the coordinates.

It is an error to call this function if the feature is not a single point. Use [method`VectorReaderIter`.get_feature_geometry_type] to check the feature’s geometry type.

New in version 1.2.

get_feature_tag(key)
Parameters:

key (str) – The key of the tag to get.

Returns:

True if the tag was found, False otherwise.

value:

The value of the tag.

Return type:

(bool, value: GObject.Value)

Gets the value of the tag with the given key.

New in version 1.2.

get_layer_count()
Returns:

The number of layers.

Return type:

int

Gets the number of layers in the vector tile.

New in version 1.2.

get_layer_extent()
Returns:

The layer’s extent

Return type:

int

Gets the extent for coordinates in the current layer.

0 represents the top and left edges of the tile, and this value represents the bottom and right edges. Feature geometries may extend outside of this range, since tiles often include some margin.

Tiles do not contain metadata about the location of the tile within the world, so it is up to the caller to know the tile’s coordinates and convert latitude/longitude to tile-space coordinates.

New in version 1.2.

get_layer_feature_count()
Returns:

The number of features in the current layer.

Return type:

int

Gets the number of features in the current layer.

You can loop over all features in the current layer by calling [method`VectorReaderIter`.read_feature] with each index from 0 to the feature count, but it might be easier to use [method`VectorReaderIter`.next_feature] instead.

New in version 1.2.

get_layer_name()
Returns:

The name of the current layer.

Return type:

str

Gets the name of the current layer.

New in version 1.2.

get_reader()
Returns:

The reader that the iterator is iterating over.

Return type:

Shumate.VectorReader

Gets the reader that the iterator is iterating over.

New in version 1.2.

next_feature()
Returns:

True if there is a next feature, False otherwise.

Return type:

bool

Advances the iterator to the next feature in the current layer.

New in version 1.2.

read_feature(index)
Parameters:

index (int) – The index of the feature to read.

Moves the iterator to the feature at the given index in the current layer.

You can get the number of features in the current layer with [method`VectorReaderIter`.get_layer_feature_count].

New in version 1.2.

read_layer(index)
Parameters:

index (int) – The index of the layer to read.

Sets the current layer of the reader to the layer at the given index.

New in version 1.2.

read_layer_by_name(name)
Parameters:

name (str) –

Returns:

True if the layer was found, False otherwise.

Return type:

bool

Moves the iterator to the layer with the given name, if present.

If the layer is not found, the current layer will be set to None and the function will return False. Layers are typically omitted if they are empty, so don’t assume that a layer in the schema will always be present.

The iterator’s current feature will be None after calling this function; use [method`VectorReaderIter`.next_feature] to advance to the first feature in the layer.

New in version 1.2.

Property Details

Shumate.VectorReaderIter.props.reader
Name:

reader

Type:

Shumate.VectorReader

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

reader