cartography 0.11.0

Cartography is a map rendering library for Geographic features expressed using [georust](https://georust.org/) libraries.
Documentation
use std::path::Path;

use image::{DynamicImage, ImageResult};

/// Open an image with the `image` crate
pub fn open_image<P>(path: P, rect: geo::Rect) -> ImageResult<GeoImage>
where
  P: AsRef<Path>,
{
  image::open(path).map(|img| GeoImage {
    dynamic_image: img,
    rect,
  })
}

/// Open an image with the `image` crate
pub fn load_image_from_memory(buffer: &[u8], rect: geo::Rect) -> ImageResult<GeoImage>
{
  image::load_from_memory(buffer).map(|img| GeoImage {
    dynamic_image: img,
    rect,
  })
}

/// GeoImage is an image with meta geo meta information
pub struct GeoImage
{
  dynamic_image: DynamicImage,
  rect: geo::Rect,
}

impl super::ImageData for GeoImage
{
  fn bounding_box(&self) -> geo::Rect
  {
    self.rect
  }
  fn pixel_size(&self) -> (u32, u32)
  {
    (self.dynamic_image.width(), self.dynamic_image.height())
  }
  fn rgba_data(&self) -> Vec<u8>
  {
    self.dynamic_image.to_rgba8().into_raw().to_vec()
  }
}