pub fn write_metadata(tr: &Transaction, metadata: Metadata) -> Result<(), Box<dyn std::error::Error>> {
    let mut insert_metadata = tr.prepare_cached("INSERT INTO metadata (name, value) VALUES (?1, ?2)")?;

    insert_metadata.execute(params!["name", metadata.name])?;

    if let FileFormat::Pbf(mvt_metadata) = &metadata.format {
        insert_metadata.execute(params!["json", serde_json::to_string(&mvt_metadata)?])?;
    }

    let format_str: String = metadata.format.into();
    insert_metadata.execute(params!["format", format_str])?;

    if let Some(bounds) = &metadata.bounds {
        let tl = bounds.top_left();
        let br = bounds.bottom_right();
        insert_metadata.execute(params![
            "bounds",
            format!("{},{},{},{}", tl.lon(), br.lat(), br.lon(), tl.lat())
        ])?;
    }

    if let Some(center) = &metadata.center {
        let (coord, zoom) = center;
        insert_metadata.execute(params!["center", format!("{},{},{}", coord.lon(), coord.lat(), zoom)])?;
    }

    if let Some(zoom_range) = &metadata.zoom_range {
        insert_metadata.execute(params!["minzoom", zoom_range.start()])?;
        insert_metadata.execute(params!["maxzoom", zoom_range.end()])?;
    }

    if let Some(attribution) = &metadata.attribution {
        insert_metadata.execute(params!["attribution", attribution])?;
    }

    if let Some(description) = &metadata.description {
        insert_metadata.execute(params!["description", description])?;
    }

    if let Some(r#type) = metadata.r#type {
        let type_str: &'static str = r#type.into();
        insert_metadata.execute(params!["type", type_str])?;
    }

    if let Some(version) = &metadata.version {
        insert_metadata.execute(params!["version", version])?;
    }

    Ok(())
}
/// Writes the given metadata into the database.
Writes the given metadata into the database.
Writes the given metadata into the database .
pub fn write_metadata(tr: &Transaction, metadata: Metadata) -> Result<(), Box<dyn std::error::Error>> {
    let mut insert_metadata = tr.prepare_cached("INSERT INTO metadata (name, value) VALUES (?1, ?2)")?;
    insert_metadata.execute(params!["name", metadata.name])?;
    if let FileFormat::Pbf(mvt_metadata) = &metadata.format {
        insert_metadata.execute(params!["json", serde_json::to_string(&mvt_metadata)?])?;
    }
    let format_str: String = metadata.format.into();
    insert_metadata.execute(params!["format", format_str])?;
    if let Some(bounds) = &metadata.bounds {
        let tl = bounds.top_left();
        let br = bounds.bottom_right();
        insert_metadata.execute(params![
            "bounds",
            format!("{},{},{},{}", tl.lon(), br.lat(), br.lon(), tl.lat())
        ])?;
    }
    if let Some(center) = &metadata.center {
        let (coord, zoom) = center;
        insert_metadata.execute(params!["center", format!("{},{},{}", coord.lon(), coord.lat(), zoom)])?;
    }
    if let Some(zoom_range) = &metadata.zoom_range {
        insert_metadata.execute(params!["minzoom", zoom_range.start()])?;
        insert_metadata.execute(params!["maxzoom", zoom_range.end()])?;
    }
    if let Some(attribution) = &metadata.attribution {
        insert_metadata.execute(params!["attribution", attribution])?;
    }
    if let Some(description) = &metadata.description {
        insert_metadata.execute(params!["description", description])?;
    }
    if let Some(r#type) = metadata.r#type {
        let type_str: &'static str = r#type.into();
        insert_metadata.execute(params!["type", type_str])?;
    }
    if let Some(version) = &metadata.version {
        insert_metadata.execute(params!["version", version])?;
    }
    Ok(())
}
pub fn write_metadata ( tr : & Transaction , metadata : Metadata ) -> Result < ( ) , Box < dyn std :: error :: Error > > { let mut insert_metadata = tr . prepare_cached ( " " ) ? ; insert_metadata . execute ( params ! [ " " metadata name ] ) ? ; if let FileFormat :: Pbf ( mvt_metadata ) = & metadata . format { insert_metadata . execute ( params ! [ " " serde_json to_string ( mvt_metadata ) ] ) ? ; } let format_str : String = metadata . format . into ( ) ; insert_metadata . execute ( params ! [ " " format_str ] ) ? ; if let Some ( bounds ) = & metadata . bounds { let tl = bounds . top_left ( ) ; let br = bounds . bottom_right ( ) ; insert_metadata . execute ( params ! [ " " format ( " " tl lon ( ) br lat ( ) br lon ( ) tl lat ( ) ) ] ) ? ; } if let Some ( center ) = & metadata . center { let ( coord , zoom ) = center ; insert_metadata . execute ( params ! [ " " format ( " " coord lon ( ) coord lat ( ) zoom ) ] ) ? ; } if let Some ( zoom_range ) = & metadata . zoom_range { insert_metadata . execute ( params ! [ " " zoom_range start ( ) ] ) ? ; insert_metadata . execute ( params ! [ " " zoom_range end ( ) ] ) ? ; } if let Some ( attribution ) = & metadata . attribution { insert_metadata . execute ( params ! [ " " attribution ] ) ? ; } if let Some ( description ) = & metadata . description { insert_metadata . execute ( params ! [ " " description ] ) ? ; } if let Some ( r#type ) = metadata . r#type { let type_str : & ' static str = r#type . into ( ) ; insert_metadata . execute ( params ! [ " " type_str ] ) ? ; } if let Some ( version ) = & metadata . version { insert_metadata . execute ( params ! [ " " version ] ) ? ; } Ok ( ( ) ) }
Writes the given metadata into the database.
Writes the given metadata into the database .
tr
&Transaction
metadata
Metadata