mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-13 12:32:09 +00:00
Merge branch 'develop' of https://github.com/boostorg/geometry into feature/disjoint
This commit is contained in:
@@ -8,6 +8,23 @@
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================/]
|
||||
|
||||
[heading The WKT Format]
|
||||
WKT is a general markup format in ASCII.
|
||||
It is described in detail on [@http://en.wikipedia.org/wiki/Well-known_text Wikipedia]
|
||||
|
||||
Boost Geometry supports the common formats (POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON). Because Boost.Geometry
|
||||
also supports Box and Segment geometries, which are not standard OGC geometries, there are some extensions:
|
||||
|
||||
* a Box can be read from WKT by specifying either a polygon (with 4 points) or a specific BOX string (non OGC)
|
||||
* a Segment can be read from WKT by specifying either a linestring (with 2 points) or a specific SEGMENT string (non OGC)
|
||||
* a Ring can be read from WKT by specifying a polygon (with no holes)
|
||||
|
||||
[heading Conformance]
|
||||
Other libraries refer to this functionality as [*ST_GeomFromText] or [*STGeomFromText].
|
||||
That is not done here because Boost.Geometry support more text formats. The name GeomFromText
|
||||
is reserved for future usage, which will then have an indication of the used text format.
|
||||
|
||||
|
||||
[heading Example]
|
||||
[read_wkt]
|
||||
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================/]
|
||||
|
||||
[def __this_function__ wkt]
|
||||
|
||||
[heading_conformance_ogc __this_function__..AsText]
|
||||
[note __this_function__ is not named "AsText" or "as_text" because Boost.Geometry
|
||||
also supports other textformats (svg, dsv)]
|
||||
|
||||
[heading Example]
|
||||
[wkt]
|
||||
[wkt_output]
|
||||
|
||||
@@ -10,25 +10,26 @@
|
||||
//[read_wkt
|
||||
//` Shows the usage of read_wkt
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
#include <boost/geometry/geometries/polygon.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Specify the basic type
|
||||
typedef boost::geometry::model::d2::point_xy<double> point_type;
|
||||
|
||||
// Declare some geometries and set their values
|
||||
point_type a;
|
||||
boost::geometry::model::polygon<point_type> b;
|
||||
boost::geometry::model::linestring<point_type> b;
|
||||
boost::geometry::model::polygon<point_type> c;
|
||||
boost::geometry::model::box<point_type> d;
|
||||
boost::geometry::model::segment<point_type> e;
|
||||
|
||||
boost::geometry::read_wkt("POINT(1 2)", a);
|
||||
boost::geometry::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", b);
|
||||
|
||||
boost::geometry::read_wkt("LINESTRING(0 0,2 2,3 1)", b);
|
||||
boost::geometry::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", c);
|
||||
boost::geometry::read_wkt("BOX(0 0,3 3)", d);
|
||||
boost::geometry::read_wkt("SEGMENT(1 0,3 4)", e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
//` Shows the usage of wkt
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
@@ -19,14 +18,19 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
// Specify the basic type
|
||||
typedef boost::geometry::model::d2::point_xy<double> point_type;
|
||||
namespace geom = boost::geometry;
|
||||
typedef geom::model::d2::point_xy<double> point_type;
|
||||
|
||||
// Declare some geometries and set their values
|
||||
point_type a;
|
||||
boost::geometry::assign_values(a, 3, 6);
|
||||
point_type point = geom::make<point_type>(3, 6);
|
||||
geom::model::polygon<point_type> polygon;
|
||||
geom::append(geom::exterior_ring(polygon), geom::make<point_type>(0, 0));
|
||||
geom::append(geom::exterior_ring(polygon), geom::make<point_type>(0, 4));
|
||||
geom::append(geom::exterior_ring(polygon), geom::make<point_type>(4, 4));
|
||||
geom::append(geom::exterior_ring(polygon), geom::make<point_type>(4, 0));
|
||||
geom::append(geom::exterior_ring(polygon), geom::make<point_type>(0, 0));
|
||||
|
||||
std::cout << boost::geometry::wkt(a) << std::endl;
|
||||
std::cout << boost::geometry::wkt(point) << std::endl;
|
||||
std::cout << boost::geometry::wkt(polygon) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -37,7 +41,11 @@ int main()
|
||||
//[wkt_output
|
||||
/*`
|
||||
Output:
|
||||
point(3 6)
|
||||
[pre
|
||||
POINT(3 6)
|
||||
POLYGON((0 0,0 4,4 4,4 0,0 0))
|
||||
]
|
||||
|
||||
|
||||
*/
|
||||
//]
|
||||
|
||||
@@ -172,7 +172,7 @@ struct buffered_piece_collection
|
||||
// To check clustered locations we keep track of segments being opposite somewhere
|
||||
std::set<segment_identifier> m_in_opposite_segments;
|
||||
|
||||
RobustPolicy const& m_rescale_policy;
|
||||
RobustPolicy const& m_robust_policy;
|
||||
|
||||
struct buffer_occupation_info : public occupation_info<angle_info<point_type, coordinate_type> >
|
||||
{
|
||||
@@ -195,7 +195,7 @@ struct buffered_piece_collection
|
||||
};
|
||||
|
||||
buffered_piece_collection(RobustPolicy const& robust_policy)
|
||||
: m_rescale_policy(robust_policy)
|
||||
: m_robust_policy(robust_policy)
|
||||
{}
|
||||
|
||||
|
||||
@@ -291,7 +291,8 @@ struct buffered_piece_collection
|
||||
|
||||
turn_policy::apply(*prev1, *it1, *next1,
|
||||
*prev2, *it2, *next2,
|
||||
the_model, m_rescale_policy, std::back_inserter(m_turns));
|
||||
false, false, false, false,
|
||||
the_model, m_robust_policy, std::back_inserter(m_turns));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,7 +389,7 @@ struct buffered_piece_collection
|
||||
int const side_wrt_circle = side_on_convex_range<side_strategy>(turn.point,
|
||||
boost::begin(ring) + seg_id.segment_index,
|
||||
boost::begin(ring) + pc.last_segment_index,
|
||||
seg_id, on_segment_seg_id, m_rescale_policy);
|
||||
seg_id, on_segment_seg_id, m_robust_policy);
|
||||
switch (side_wrt_circle)
|
||||
{
|
||||
case 0 : turn.count_on_offsetted++; break;
|
||||
@@ -397,7 +398,7 @@ struct buffered_piece_collection
|
||||
return;
|
||||
}
|
||||
|
||||
int side_helper = side_on_convex_range<side_strategy>(turn.point, pc.helper_segments, m_rescale_policy);
|
||||
int side_helper = side_on_convex_range<side_strategy>(turn.point, pc.helper_segments, m_robust_policy);
|
||||
if (side_helper == 1)
|
||||
{
|
||||
// Left or outside
|
||||
@@ -407,7 +408,7 @@ struct buffered_piece_collection
|
||||
int const side_offsetted = side_on_convex_range<side_strategy>(turn.point,
|
||||
boost::begin(ring) + seg_id.segment_index,
|
||||
boost::begin(ring) + pc.last_segment_index,
|
||||
seg_id, on_segment_seg_id, m_rescale_policy);
|
||||
seg_id, on_segment_seg_id, m_robust_policy);
|
||||
if (side_offsetted == 1)
|
||||
{
|
||||
return;
|
||||
@@ -424,8 +425,8 @@ struct buffered_piece_collection
|
||||
}
|
||||
if (side_helper == 0)
|
||||
{
|
||||
if (detail::overlay::points_equal_or_close(turn.point, pc.helper_segments.back(), m_rescale_policy)
|
||||
|| detail::overlay::points_equal_or_close(turn.point, pc.helper_segments.front(), m_rescale_policy))
|
||||
if (detail::overlay::points_equal_or_close(turn.point, pc.helper_segments.back(), m_robust_policy)
|
||||
|| detail::overlay::points_equal_or_close(turn.point, pc.helper_segments.front(), m_robust_policy))
|
||||
{
|
||||
turn.count_on_corner++;
|
||||
}
|
||||
@@ -664,12 +665,12 @@ struct buffered_piece_collection
|
||||
>::type robust_point_type;
|
||||
|
||||
robust_point_type p1_rob, p2_rob, prev1_rob, prev2_rob, cur1_rob, cur2_rob;
|
||||
geometry::recalculate(p1_rob, select_for_side(prev1, it1, which), m_rescale_policy);
|
||||
geometry::recalculate(p2_rob, select_for_side(prev2, it2, which), m_rescale_policy);
|
||||
geometry::recalculate(prev1_rob, *prev1, m_rescale_policy);
|
||||
geometry::recalculate(prev2_rob, *prev2, m_rescale_policy);
|
||||
geometry::recalculate(cur1_rob, *it1, m_rescale_policy);
|
||||
geometry::recalculate(cur2_rob, *it2, m_rescale_policy);
|
||||
geometry::recalculate(p1_rob, select_for_side(prev1, it1, which), m_robust_policy);
|
||||
geometry::recalculate(p2_rob, select_for_side(prev2, it2, which), m_robust_policy);
|
||||
geometry::recalculate(prev1_rob, *prev1, m_robust_policy);
|
||||
geometry::recalculate(prev2_rob, *prev2, m_robust_policy);
|
||||
geometry::recalculate(cur1_rob, *it1, m_robust_policy);
|
||||
geometry::recalculate(cur2_rob, *it2, m_robust_policy);
|
||||
|
||||
int const code1 = side_strategy::apply(p1_rob, prev2_rob, cur2_rob);
|
||||
int const code2 = side_strategy::apply(p2_rob, prev1_rob, cur1_rob);
|
||||
@@ -743,7 +744,7 @@ struct buffered_piece_collection
|
||||
return true;
|
||||
}
|
||||
|
||||
if (detail::overlay::points_equal_or_close(a.point, b.point, m_rescale_policy))
|
||||
if (detail::overlay::points_equal_or_close(a.point, b.point, m_robust_policy))
|
||||
{
|
||||
std::cout << "=";
|
||||
return true;
|
||||
@@ -1165,7 +1166,7 @@ struct buffered_piece_collection
|
||||
enrich_intersection_points<false, false>(m_turns,
|
||||
detail::overlay::operation_union,
|
||||
offsetted_rings, offsetted_rings,
|
||||
m_rescale_policy, side_strategy_type());
|
||||
m_robust_policy, side_strategy_type());
|
||||
}
|
||||
|
||||
// Discards all rings which do have not-OK intersection points only.
|
||||
@@ -1222,7 +1223,7 @@ struct buffered_piece_collection
|
||||
traversed_rings.clear();
|
||||
traverser::apply(offsetted_rings, offsetted_rings,
|
||||
detail::overlay::operation_union,
|
||||
m_rescale_policy, m_turns, traversed_rings);
|
||||
m_robust_policy, m_turns, traversed_rings);
|
||||
}
|
||||
|
||||
template <typename GeometryOutput, typename OutputIterator>
|
||||
|
||||
@@ -250,13 +250,7 @@ struct within
|
||||
static inline bool apply(Point const& point,
|
||||
MultiGeometry const& multi, Strategy const& strategy)
|
||||
{
|
||||
return detail::within::geometry_multi_within_code
|
||||
<
|
||||
Point,
|
||||
MultiGeometry,
|
||||
Strategy,
|
||||
point_in_buffered_ring
|
||||
>::apply(point, multi, strategy) == 1;
|
||||
return detail::within::point_in_geometry(point, multi, strategy) == 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ static inline void init_rescale_policy(Geometry const& geometry,
|
||||
num_type const diff = boost::numeric_cast<num_type>(detail::get_max_size(env));
|
||||
num_type const range = 10000000.0; // Define a large range to get precise integer coordinates
|
||||
num_type const half = 0.5;
|
||||
factor = boost::numeric_cast<num_type>(
|
||||
factor = math::equals(diff, num_type()) ? 1
|
||||
: boost::numeric_cast<num_type>(
|
||||
boost::numeric_cast<boost::long_long_type>(half + range / diff));
|
||||
|
||||
// Assign input/output minimal points
|
||||
@@ -90,7 +91,8 @@ static inline void init_rescale_policy(Geometry1 const& geometry1,
|
||||
num_type const diff = boost::numeric_cast<num_type>(detail::get_max_size(env));
|
||||
num_type const range = 10000000.0; // Define a large range to get precise integer coordinates
|
||||
num_type const half = 0.5;
|
||||
factor = boost::numeric_cast<num_type>(
|
||||
factor = math::equals(diff, num_type()) ? 1
|
||||
: boost::numeric_cast<num_type>(
|
||||
boost::numeric_cast<boost::long_long_type>(half + range / diff));
|
||||
|
||||
// Assign input/output minimal points
|
||||
|
||||
Reference in New Issue
Block a user