本文整理汇总了C++中LineString类的典型用法代码示例。如果您正苦于以下问题:C++ LineString类的具体用法?C++ LineString怎么用?C++ LineString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LineString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void ForceValidityVisitor::visit( LineString& g )
{
g.forceValidityFlag( valid_ );
for ( size_t i = 0; i < g.numPoints(); i++ ) {
visit( g.pointN( i ) );
}
}
示例2: geosIntersect
bool geosIntersect(const LineSegment& ls1, Meters buffer, const LineSegment& ls2,
LineSegment& result)
{
boost::shared_ptr<Geometry> g1(ls1.toGeometry(*GeometryFactory::getDefaultInstance())->clone());
boost::shared_ptr<Geometry> g2(ls2.toGeometry(*GeometryFactory::getDefaultInstance())->clone());
boost::shared_ptr<Geometry> g(g1->buffer(buffer, 40));
boost::shared_ptr<Geometry> i(g->intersection(g2.get()));
if (i->isEmpty())
{
result.p0 = Coordinate::getNull();
return false;
}
else if (i->getGeometryTypeId() == GEOS_POINT)
{
Point* p = dynamic_cast<Point*>(i.get());
result.p0 = *(p->getCoordinate());
}
else if (i->getGeometryTypeId() == GEOS_LINESTRING)
{
LineString* ls = dynamic_cast<LineString*>(i.get());
assert(ls->getNumPoints() == 2);
result.p0 = *ls->getPointN(0)->getCoordinate();
result.p1 = *ls->getPointN(1)->getCoordinate();
}
else
{
throw HootException();
}
return true;
}
示例3:
bool
SegmentIntersectionTester::hasIntersection(
const LineString &line, const LineString &testLine)
{
typedef std::size_t size_type;
const CoordinateSequence &seq0 = *(line.getCoordinatesRO());
size_type seq0size = seq0.getSize();
const CoordinateSequence &seq1 = *(testLine.getCoordinatesRO());
size_type seq1size = seq1.getSize();
for (size_type i = 1; i<seq0size && !hasIntersectionVar; ++i)
{
seq0.getAt(i - 1, pt00);
seq0.getAt(i, pt01);
for (size_type j = 1; j < seq1size && !hasIntersectionVar; ++j)
{
seq1.getAt(j-1, pt10);
seq1.getAt(j, pt11);
li.computeIntersection(pt00, pt01, pt10, pt11);
if (li.hasIntersection()) hasIntersectionVar = true;
}
}
return hasIntersectionVar;
}
示例4: minkowskiSum
void minkowskiSum( const LineString& gA, const Polygon_2& gB, Polygon_set_2& polygonSet )
{
if ( gA.isEmpty() ) {
return ;
}
int npt = gA.numPoints() ;
for ( int i = 0; i < npt - 1 ; i++ ) {
Polygon_2 P;
P.push_back( gA.pointN( i ).toPoint_2() );
P.push_back( gA.pointN( i+1 ).toPoint_2() );
//
// We want to compute the "minkowski sum" on each segment of the line string
// This is not very well defined. But it appears CGAL supports it.
// However we must use the explicit "full convolution" method for that particular case in CGAL >= 4.7
#if CGAL_VERSION_NR < 1040701000 // version 4.7
Polygon_with_holes_2 part = minkowski_sum_2( P, gB );
#else
Polygon_with_holes_2 part = minkowski_sum_by_full_convolution_2( P, gB );
#endif
// merge into a polygon set
if ( polygonSet.is_empty() ) {
polygonSet.insert( part );
}
else {
polygonSet.join( part );
}
}
}
示例5: compute
void compute()
{
//Tell the calculator about the new start/end points
_profileCalculator->setStartEnd( GeoPoint(_mapNode->getMapSRS(), _start.x(), _start.y(), 0),
GeoPoint(_mapNode->getMapSRS(), _end.x(), _end.y(), 0));
if (_featureNode.valid())
{
_root->removeChild( _featureNode.get() );
_featureNode = 0;
}
LineString* line = new LineString();
line->push_back( _start );
line->push_back( _end );
Feature* feature = new Feature(line, _mapNode->getMapSRS());
feature->geoInterp() = GEOINTERP_GREAT_CIRCLE;
//Define a style for the line
Style style;
LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>();
ls->stroke()->color() = Color::Yellow;
ls->stroke()->width() = 2.0f;
ls->tessellation() = 20;
style.getOrCreate<AltitudeSymbol>()->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN;
feature->style() = style;
_featureNode = new FeatureNode( _mapNode, feature );
//Disable lighting
_featureNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
_root->addChild( _featureNode.get() );
}
示例6: TEST
TEST(TileCover, DISABLED_FuzzLine) {
while(1)
{
std::srand (time(NULL));
std::size_t len = std::rand() % 10000 + 3;
MultiLineString<double> mls;
std::size_t num_lines = 1;
num_lines += std::rand() % 5;
while (num_lines > 0) {
LineString<double> line;
for (std::size_t i = 0; i < len; ++i) {
double x = std::rand() % 180;
double y = std::rand() % 90;
line.push_back({x,y});
}
mls.emplace_back(line);
--num_lines;
}
std::clog << ".";
util::TileCover tc(mls, 5);
while(tc.next()) {
};
}
}
示例7: Geometry
LineString::LineString( const LineString& other ):
Geometry()
{
for ( size_t i = 0; i < other.numPoints(); i++ ) {
_points.push_back( other.pointN( i ).clone() ) ;
}
}
示例8:
Handle<Value> LineStringPoints::count(const Arguments& args)
{
HandleScope scope;
Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
LineString *geom = ObjectWrap::Unwrap<LineString>(parent);
return scope.Close(Integer::New(geom->get()->getNumPoints()));
}
示例9: writeInner
void WktWriter::writeInner( const LineString & g )
{
_s << "(";
for ( size_t i = 0; i < g.numPoints(); i++ ){
if ( i != 0 )
_s << ",";
write( g.pointN(i).coordinates() );
}
_s << ")";
}
示例10: Undefined
Handle<Value> LineStringPoints::reverse(const Arguments& args)
{
HandleScope scope;
Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
LineString *geom = ObjectWrap::Unwrap<LineString>(parent);
geom->get()->reversePoints();
return Undefined();
}
示例11: LineString
Geometry*
Ring::cloneAs( const Geometry::Type& newType ) const
{
if ( newType == TYPE_LINESTRING )
{
LineString* line = new LineString( &this->asVector() );
if ( line->size() > 1 && line->front() != line->back() )
line->push_back( front() );
return line;
}
else return Geometry::cloneAs( newType );
}
示例12: writeByteOrder
void
WKBWriter::writeLineString(const LineString& g)
{
writeByteOrder();
writeGeometryType(WKBConstants::wkbLineString, g.getSRID());
writeSRID(g.getSRID());
const CoordinateSequence* cs = g.getCoordinatesRO();
assert(cs);
writeCoordinateSequence(*cs, true);
}
示例13: isClosed
bool MultiLineString::isClosed() const {
if (isEmpty()) {
return false;
}
for (size_t i = 0, n = geometries->size(); i < n; ++i) {
LineString *ls = dynamic_cast<LineString*>((*geometries)[i]);
if ( ! ls->isClosed() ) {
return false;
}
}
return true;
}
示例14:
std::unordered_map<std::string, std::vector<Feature>> Source::Impl::queryRenderedFeatures(const QueryParameters& parameters) const {
std::unordered_map<std::string, std::vector<Feature>> result;
if (renderTiles.empty() || parameters.geometry.empty()) {
return result;
}
LineString<double> queryGeometry;
for (const auto& p : parameters.geometry) {
queryGeometry.push_back(TileCoordinate::fromScreenCoordinate(
parameters.transformState, 0, { p.x, parameters.transformState.getSize().height - p.y }).p);
}
mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry);
auto sortRenderTiles = [](const RenderTile& a, const RenderTile& b) {
return a.id.canonical.z != b.id.canonical.z ? a.id.canonical.z < b.id.canonical.z :
a.id.canonical.y != b.id.canonical.y ? a.id.canonical.y < b.id.canonical.y :
a.id.wrap != b.id.wrap ? a.id.wrap < b.id.wrap : a.id.canonical.x < b.id.canonical.x;
};
std::vector<std::reference_wrapper<const RenderTile>> sortedTiles;
std::transform(renderTiles.cbegin(), renderTiles.cend(), std::back_inserter(sortedTiles),
[](const auto& pair) { return std::ref(pair.second); });
std::sort(sortedTiles.begin(), sortedTiles.end(), sortRenderTiles);
for (const auto& renderTileRef : sortedTiles) {
const RenderTile& renderTile = renderTileRef.get();
GeometryCoordinate tileSpaceBoundsMin = TileCoordinate::toGeometryCoordinate(renderTile.id, box.min);
if (tileSpaceBoundsMin.x >= util::EXTENT || tileSpaceBoundsMin.y >= util::EXTENT) {
continue;
}
GeometryCoordinate tileSpaceBoundsMax = TileCoordinate::toGeometryCoordinate(renderTile.id, box.max);
if (tileSpaceBoundsMax.x < 0 || tileSpaceBoundsMax.y < 0) {
continue;
}
GeometryCoordinates tileSpaceQueryGeometry;
tileSpaceQueryGeometry.reserve(queryGeometry.size());
for (const auto& c : queryGeometry) {
tileSpaceQueryGeometry.push_back(TileCoordinate::toGeometryCoordinate(renderTile.id, c));
}
renderTile.tile.queryRenderedFeatures(result,
tileSpaceQueryGeometry,
parameters.transformState,
parameters.layerIDs);
}
return result;
}
示例15: assert
MultiLineString*
MultiLineString::reverse() const
{
size_t nLines = geometries->size();
Geometry::NonConstVect *revLines = new Geometry::NonConstVect(nLines);
for (size_t i=0; i<nLines; ++i)
{
LineString *iLS = dynamic_cast<LineString*>((*geometries)[i]);
assert(iLS);
(*revLines)[nLines-1-i] = iLS->reverse();
}
return getFactory()->createMultiLineString(revLines);
}