// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{ffi, GeometryType, VectorReader};
use glib::translate::*;

glib::wrapper! {
    #[doc(alias = "ShumateVectorReaderIter")]
    pub struct VectorReaderIter(Object<ffi::ShumateVectorReaderIter, ffi::ShumateVectorReaderIterClass>);

    match fn {
        type_ => || ffi::shumate_vector_reader_iter_get_type(),
    }
}

impl VectorReaderIter {
    #[doc(alias = "shumate_vector_reader_iter_feature_contains_point")]
    pub fn feature_contains_point(&self, x: f64, y: f64) -> bool {
        unsafe {
            from_glib(ffi::shumate_vector_reader_iter_feature_contains_point(
                self.to_glib_none().0,
                x,
                y,
            ))
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_feature_geometry_type")]
    #[doc(alias = "get_feature_geometry_type")]
    pub fn feature_geometry_type(&self) -> GeometryType {
        unsafe {
            from_glib(ffi::shumate_vector_reader_iter_get_feature_geometry_type(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_feature_id")]
    #[doc(alias = "get_feature_id")]
    pub fn feature_id(&self) -> u64 {
        unsafe { ffi::shumate_vector_reader_iter_get_feature_id(self.to_glib_none().0) }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_feature_keys")]
    #[doc(alias = "get_feature_keys")]
    pub fn feature_keys(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_container(
                ffi::shumate_vector_reader_iter_get_feature_keys(self.to_glib_none().0),
            )
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_feature_point")]
    #[doc(alias = "get_feature_point")]
    pub fn feature_point(&self) -> Option<(f64, f64)> {
        unsafe {
            let mut x = std::mem::MaybeUninit::uninit();
            let mut y = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::shumate_vector_reader_iter_get_feature_point(
                self.to_glib_none().0,
                x.as_mut_ptr(),
                y.as_mut_ptr(),
            ));
            if ret {
                Some((x.assume_init(), y.assume_init()))
            } else {
                None
            }
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_feature_tag")]
    #[doc(alias = "get_feature_tag")]
    pub fn feature_tag(&self, key: &str) -> Option<glib::Value> {
        unsafe {
            let mut value = glib::Value::uninitialized();
            let ret = from_glib(ffi::shumate_vector_reader_iter_get_feature_tag(
                self.to_glib_none().0,
                key.to_glib_none().0,
                value.to_glib_none_mut().0,
            ));
            if ret {
                Some(value)
            } else {
                None
            }
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_layer_count")]
    #[doc(alias = "get_layer_count")]
    pub fn layer_count(&self) -> u32 {
        unsafe { ffi::shumate_vector_reader_iter_get_layer_count(self.to_glib_none().0) }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_layer_extent")]
    #[doc(alias = "get_layer_extent")]
    pub fn layer_extent(&self) -> u32 {
        unsafe { ffi::shumate_vector_reader_iter_get_layer_extent(self.to_glib_none().0) }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_layer_feature_count")]
    #[doc(alias = "get_layer_feature_count")]
    pub fn layer_feature_count(&self) -> u32 {
        unsafe { ffi::shumate_vector_reader_iter_get_layer_feature_count(self.to_glib_none().0) }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_layer_name")]
    #[doc(alias = "get_layer_name")]
    pub fn layer_name(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::shumate_vector_reader_iter_get_layer_name(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_get_reader")]
    #[doc(alias = "get_reader")]
    pub fn reader(&self) -> Option<VectorReader> {
        unsafe {
            from_glib_none(ffi::shumate_vector_reader_iter_get_reader(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_next_feature")]
    pub fn next_feature(&self) -> bool {
        unsafe {
            from_glib(ffi::shumate_vector_reader_iter_next_feature(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_read_feature")]
    pub fn read_feature(&self, index: i32) {
        unsafe {
            ffi::shumate_vector_reader_iter_read_feature(self.to_glib_none().0, index);
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_read_layer")]
    pub fn read_layer(&self, index: i32) {
        unsafe {
            ffi::shumate_vector_reader_iter_read_layer(self.to_glib_none().0, index);
        }
    }

    #[doc(alias = "shumate_vector_reader_iter_read_layer_by_name")]
    pub fn read_layer_by_name(&self, name: &str) -> bool {
        unsafe {
            from_glib(ffi::shumate_vector_reader_iter_read_layer_by_name(
                self.to_glib_none().0,
                name.to_glib_none().0,
            ))
        }
    }
}
