Giter VIP home page Giter VIP logo

Comments (2)

michaelkirk avatar michaelkirk commented on June 5, 2024

A MultiPolygon is implemented as a Vec of Polygons, so if you need an object of Polygon, you can take the Polygon from the inner Vec.

use geo::{MultiPolygon, Polygon, polygon};

let mut multi_polygon: MultiPolygon = MultiPolygon::new(vec![polygon![(x: 0.0, y: 0.0), (x: 2.0,  y: 0.0), (x: 1.0, y: 2.0)]]);
let polygon: Polygon = multi_polygon.0.remove(0);
println!("polygon: {:?}", polygon);

If that's not what you mean, could you please clarify by providing some example code that you'd like to be able to write, but currently cannot.

from geo.

JosiahParry avatar JosiahParry commented on June 5, 2024

Yeah, quite similar. I'd like some syntax like below, preferably. Where the Result panics if the inner vector is greater than length 1.

use geo::{MultiPolygon, Polygon, polygon};

let multi_polygon: MultiPolygon = MultiPolygon::new(vec![polygon![(x: 0.0, y: 0.0), (x: 2.0,  y: 0.0), (x: 1.0, y: 2.0)]]);

let inner_poly: Polygon = multi_polygon.try_from().unwrap();

from geo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.