JuliaGeo / LibGEOS.jl

Julia package for manipulation and analysis of planar geometric objects
MIT License
72 stars 23 forks source link

Add `LineString` constructors based on `Point`s and `LineString`s #104

Open mathieu17g opened 2 years ago

mathieu17g commented 2 years ago

@visr what about adding LineString constructors based on Points and LineStrings?

It could look like:

LineString(ls::LineString, pt::Point) = LineString([coordinates(ls); [coordinates(pt)]])
LineString(ls::LineString, pt1::Point, pt2::Point, pts::Vararg{Point}) = LineString(LineString(ls, pt1), pt2, pts...)
LineString(pt1::Point, pt2::Point) = LineString([coordinates(pt1), coordinates(pt2)])
LineString(pt1::Point, pt2::Point, pt3::Point, pts::Vararg{Point}) = LineString(LineString(pt1, pt2), pt3, pts...)

This may be extended to other geometry types

nxiangg commented 1 year ago

Hi,

Following up on this question, could we create a LineString out of say 2 points now? Thank you very much!

visr commented 1 year ago

Yes that works if you supply the points as a vector.

https://github.com/JuliaGeo/LibGEOS.jl/blob/v0.8.5/src/geos_types.jl#L107